/* /try/story/: one made-up employee through all six flows.
   Without scroll-driven animation support, or with reduced motion, every map shows
   its finished state and the page reads top to bottom like any other. */

.hero .crumb { margin-bottom: var(--space-3); }
.toc { list-style: none; margin: var(--space-6) 0 0; padding: 0; border-top: 1px solid var(--color-divider); }
.toc li { border-bottom: 1px solid var(--color-divider); }
.toc a { display: block; padding: 10px 0; font-weight: 600; text-decoration: none; }
.toc a:hover { text-decoration: underline; }
.toc span { display: inline-block; min-width: 9.5em; font-weight: 400; color: var(--color-neutral-500); }

.chapter { margin-top: calc(var(--space-8) * 2); }
.when { margin: 0 0 var(--space-2); font-size: 16px; font-weight: 600; color: var(--color-accent); }
.when .num { color: var(--color-neutral-500); font-weight: 400; margin-right: 6px; }
.chapter h2 { font-size: 34px; line-height: 1.1; margin: 0 0 var(--space-4); }
.ch-text p { max-width: 36em; color: var(--color-neutral-300); margin: 0 0 var(--space-3); }
.whatif { max-width: 36em; margin: var(--space-4) 0 0; padding-left: var(--space-3); border-left: 3px solid var(--color-warn); color: var(--color-neutral-300); }
.ch-links { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); margin: var(--space-5) 0 0; }
.coda { margin-top: calc(var(--space-8) * 2.5); padding-top: var(--space-6); border-top: 1px solid var(--color-divider); }
.coda h2 { font-size: 30px; margin: 0 0 var(--space-3); }
.coda p { max-width: 36em; }

/* --on goes from 0 to 1 as a step lights; it stays 1 when nothing animates */
@property --on { syntax: '<number>'; inherits: true; initial-value: 1; }

/* — the small map: five steps joined by a line — */
.smap { list-style: none; margin: var(--space-5) 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 22px; }
.sn {
  position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 8px 10px; min-height: 76px; border-radius: var(--radius-md); overflow-wrap: anywhere;
  border: 1.5px solid var(--color-accent); background: var(--color-accent-900);
}
.sn + .sn::before {
  content: ""; position: absolute; left: -23px; top: 50%; width: 22px; height: 2px;
  background: var(--color-accent);
}
.sn-label { font-family: var(--font-heading); font-weight: 600; font-size: 17px; line-height: 1.15;
  color: color-mix(in srgb, var(--color-neutral-100) calc(var(--on) * 100%), var(--color-neutral-500)); }
.sn-label::before { content: "\2713\00a0"; color: var(--color-accent); opacity: var(--on); }
.sn-sub { font-size: 14px; line-height: 1.25; color: var(--color-neutral-400); }
.sn-subs { display: grid; }
.sn-subs > * { grid-area: 1 / 1; }
.sn-bad { visibility: hidden; color: var(--color-warn); font-weight: 650; }

/* a step that stopped and was fixed: finished, with the stop still marked */
.sn-stop { box-shadow: inset 4px 0 0 var(--color-warn); padding-left: 14px; }
.sn-stop .sn-label::before { content: none; }
/* a step that raised a flag */
.sn-flag { border-color: var(--color-warn); background: var(--color-warn-tint); }
.sn-flag .sn-label, .sn-flag .sn-sub { color: var(--color-warn); }
.sn-flag .sn-label::before { content: "!\00a0"; color: var(--color-warn); }

@media (max-width: 860px) {
  .smap { grid-template-columns: 1fr; gap: 10px; }
  .sn { min-height: 0; flex-direction: row; align-items: baseline; flex-wrap: wrap; column-gap: 8px; padding: 7px 10px; }
  .sn-stop { padding-left: 14px; }
  .sn + .sn::before { left: 22px; top: -11px; width: 2px; height: 10px; }
}
@media (max-width: 480px) {
  .ch-links .btn { width: 100%; text-align: center; }
}
@media (max-width: 700px) {
  .chapter h2 { font-size: 28px; }
  .smap { grid-template-columns: 1fr; gap: 10px; }
  .sn { min-height: 0; flex-direction: row; align-items: baseline; flex-wrap: wrap; column-gap: 8px; padding: 7px 10px; }
  .sn-stop { padding-left: 14px; }
  .sn + .sn::before { left: 22px; top: -11px; width: 2px; height: 10px; }
  .toc span { display: block; min-width: 0; font-size: 15px; }
  .coda h2 { font-size: 28px; }
  .crumb a, .ch-links a:not(.btn) { display: inline-block; padding-block: 11px; }
}

/* — scroll-driven version — */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .progress {
      position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 10;
      background: var(--color-accent); transform-origin: 0 50%;
      animation: grow linear both; animation-timeline: scroll(root);
    }
    @keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

    .sn, .sn::before, .sn-stop .sn-bad, .sn-stop .sn-ok { animation-fill-mode: both; animation-timing-function: linear; }
    .sn { animation-name: lit; }
    .sn::before { animation-name: line; }
    .sn-stop { animation-name: stop; }
    .sn-flag { animation-name: flag; }
    .sn-stop .sn-bad { animation-name: show-bad; animation-timing-function: step-end; }
    .sn-stop .sn-ok { animation-name: hide-ok; animation-timing-function: step-end; }

    @keyframes lit { from { --on: 0; border-color: var(--color-neutral-600); background: var(--color-bg); border-style: dashed; } }
    @keyframes line { from { background: var(--color-neutral-600); } }
    /* a stop: lights red, holds while the fix happens, then resumes */
    @keyframes stop {
      0% { --on: 0; border-color: var(--color-neutral-700); background: var(--color-bg); border-style: dashed; box-shadow: none; }
      11.9% { --on: 0; }
      12%, 78% { border-color: var(--color-warn); background: var(--color-warn-tint); border-style: solid; box-shadow: inset 4px 0 0 var(--color-warn), 0 0 0 4px var(--color-warn-tint); }
    }
    @keyframes flag { 0% { --on: 0; border-color: var(--color-neutral-700); background: var(--color-bg); border-style: dashed; } }
    @keyframes show-bad { 0% { visibility: hidden; } 12% { visibility: visible; } 78% { visibility: hidden; } }
    @keyframes hide-ok { 0% { visibility: hidden; } 12% { visibility: hidden; } 78% { visibility: visible; } }

    /* wide screens: each chapter pins while its map plays through */
    @media (min-width: 701px) and (min-height: 700px) {
      .chapter { height: 190vh; margin-top: 0; }
      .stage { position: sticky; top: 0; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: var(--space-6) 0; }
      .chapter:nth-of-type(1) { view-timeline-name: --ch1; }
      .chapter:nth-of-type(2) { view-timeline-name: --ch2; }
      .chapter:nth-of-type(3) { view-timeline-name: --ch3; }
      .chapter:nth-of-type(4) { view-timeline-name: --ch4; }
      .chapter:nth-of-type(5) { view-timeline-name: --ch5; }
      .chapter:nth-of-type(6) { view-timeline-name: --ch6; }
      .chapter:nth-of-type(1) :is(.sn, .sn-sub) { animation-timeline: --ch1; }
      .chapter:nth-of-type(2) :is(.sn, .sn-sub) { animation-timeline: --ch2; }
      .chapter:nth-of-type(3) :is(.sn, .sn-sub) { animation-timeline: --ch3; }
      .chapter:nth-of-type(4) :is(.sn, .sn-sub) { animation-timeline: --ch4; }
      .chapter:nth-of-type(5) :is(.sn, .sn-sub) { animation-timeline: --ch5; }
      .chapter:nth-of-type(6) :is(.sn, .sn-sub) { animation-timeline: --ch6; }
      .chapter:nth-of-type(1) .sn::before { animation-timeline: --ch1; }
      .chapter:nth-of-type(2) .sn::before { animation-timeline: --ch2; }
      .chapter:nth-of-type(3) .sn::before { animation-timeline: --ch3; }
      .chapter:nth-of-type(4) .sn::before { animation-timeline: --ch4; }
      .chapter:nth-of-type(5) .sn::before { animation-timeline: --ch5; }
      .chapter:nth-of-type(6) .sn::before { animation-timeline: --ch6; }
      .sn, .sn::before { animation-range: contain calc(6% + var(--i) * 12%) contain calc(12% + var(--i) * 12%); }
      .sn-stop, .sn-stop .sn-sub { animation-range: contain calc(6% + var(--i) * 12%) contain calc(40% + var(--i) * 12%); }
      .sn-stop ~ .sn, .sn-stop ~ .sn::before { animation-range: contain calc(36% + var(--i) * 12%) contain calc(42% + var(--i) * 12%); }
    }
    /* phones and short screens: no pinning, each step lights as it scrolls into view */
    @media (max-width: 700px), (max-height: 699px) {
      .sn, .sn::before, .sn-sub { animation-timeline: view(); }
      .sn::before { animation-timeline: auto; animation-name: none; }
      .sn { animation-range: entry 100% cover 45%; }
      .sn-stop, .sn-stop .sn-sub { animation-range: entry 100% cover 62%; }
      .sn-stop ~ .sn { animation-range: cover 60% cover 78%; }
    }
  }
}
