/* Scroll story (story.js): a sticky stage that follows the text. Every rule below applies only after the script has
   switched a story on (.is-on); without the script, or without this file, the markup is an ordinary sequence.
   Colours and type are the site's tokens (site/DESIGN.md). A page without them gets neutral fallbacks and sets
   --story-top and --story-ground (its background) on .story. */
.story{
  --story-top:calc(65px + env(safe-area-inset-top,0px));   /* the page's sticky top bar; set 0px where there is none */
  --story-accent:var(--teal,#17888C); --story-accent-text:var(--teal-hi,#48B0B4);
  --story-ground:var(--bg,Canvas); --story-rule:var(--line-2,color-mix(in srgb,currentColor 18%,transparent));
  --story-track:var(--grey-2,color-mix(in srgb,currentColor 22%,transparent)); --story-done:var(--grey,color-mix(in srgb,currentColor 45%,transparent));
  --story-ink:var(--text,currentColor); --story-ink-3:var(--text-3,color-mix(in srgb,currentColor 60%,transparent));
  --story-label:var(--label,var(--mono,ui-monospace,SFMono-Regular,Menlo,Consolas,monospace));
}
.story-progress,.story-note,.story-kicker,.story-frames:empty{display:none}

/* steps: one rail down the text column, the active step's part of it in the accent */
.story.is-on .story-step{margin:0;padding:0 0 24vh 20px;border-left:2px solid var(--story-rule);opacity:.6;transition:opacity .2s,border-color .2s}
.story.is-on .story-step.is-active{opacity:1;border-left-color:var(--story-accent)}
.story.is-on .story-step:last-child{padding-bottom:14vh}
.story.is-on .story-step>:first-child,.story.is-on .story-intro>:first-child{margin-top:0}
.story.is-on .story-step>:last-child{margin-bottom:0}
.story.is-on .story-step:focus-visible{outline-offset:6px}
.story.is-on .story-label{cursor:pointer}
.story.is-on .story-kicker{display:block;margin:0 0 10px;font:500 12px/1.2 var(--story-label);color:var(--story-ink-3)}
.story.is-on .story-step.is-active .story-kicker{color:var(--story-accent-text)}

/* the stage's own parts */
.story.is-on .story-progress{display:flex;align-items:center;gap:12px;margin:0 0 8px}
.story.is-on .story-ticks{display:flex;flex:1;gap:3px;min-width:0}
.story.is-on .story-ticks button{flex:1;min-width:0;height:20px;padding:0;border:0;background:none;cursor:pointer;position:relative;-webkit-appearance:none;appearance:none}
.story.is-on .story-ticks button::before{content:"";position:absolute;left:0;right:0;top:9px;height:2px;border-radius:1px;background:var(--story-track)}
.story.is-on .story-ticks button.is-done::before{background:var(--story-done)}
.story.is-on .story-ticks button:hover::before{background:var(--story-ink-3)}
.story.is-on .story-ticks button[aria-current]::before{top:8px;height:4px;border-radius:2px;background:var(--story-accent)}
.story.is-on .story-count{font:500 12px/1 var(--story-label);color:var(--story-ink-3);font-variant-numeric:tabular-nums;white-space:nowrap}
.story.is-on .story-note{display:block;margin:10px 0 0;font-family:var(--sans,inherit);font-weight:500;font-size:14.5px;line-height:1.45;color:var(--story-ink);text-align:left}
.story.is-on .story-frames{margin:16px 0 0}
.story.is-on .story-frames>.story-frame{display:none;margin:0}
.story.is-on .story-frames>.story-frame.is-on{display:block;animation:story-in .2s ease-out both}
@keyframes story-in{from{opacity:0}}

/* wide window: text on the left, the stage sticks on the right */
.story.is-on[data-layout="side"]{
  --story-w:min(1300px,100vw - 64px);
  width:var(--story-w);max-width:none;margin:56px 0 0 calc(50% - var(--story-w)/2);
  display:grid;grid-template-columns:minmax(360px,32%) minmax(0,860px);justify-content:center;column-gap:44px;align-items:start;
}
.story.is-on[data-layout="side"]>.story-intro{grid-column:1 / -1}
.story.is-on[data-layout="side"]>.story-steps{grid-column:1;grid-row:2;min-width:0}
.story.is-on[data-layout="side"]>.story-stage{grid-column:2;grid-row:2;min-width:0;margin:0;position:sticky;top:calc(var(--story-top) + 20px);
  max-height:calc(100vh - var(--story-top) - 36px);overflow:hidden auto;scrollbar-width:thin;display:flex;flex-direction:column}
/* order in the stage: progress, the figure, the step's note, the figure's caption, the step's frames */
.story.is-on[data-layout="side"]>.story-stage>*{flex:none;order:1}
.story.is-on[data-layout="side"]>.story-stage>.story-progress{order:0}
.story.is-on[data-layout="side"]>.story-stage>.story-note{order:2}
.story.is-on[data-layout="side"]>.story-stage>figcaption{order:3}
.story.is-on[data-layout="side"]>.story-stage>.story-frames{order:4}
.story.is-on[data-layout="side"] .story-note:empty{display:none}
/* the stage stays until the last step has reached the reading line */
.story.is-on[data-layout="side"] .story-step:last-child{min-height:50vh;padding-bottom:18vh}

/* narrow window: the stage is pinned under the top bar, the steps scroll below it */
/* its ground runs to both edges of the window, so wider figures in the steps pass under it and not beside it */
.story.is-on[data-layout="top"]>.story-stage{position:sticky;top:var(--story-top);z-index:5;margin:0;padding:8px 0 10px;
  background:var(--story-ground);border-bottom:1px solid var(--story-rule);
  box-shadow:0 0 0 100vmax var(--story-ground);clip-path:inset(0 -100vmax)}
.story.is-on[data-layout="top"] .story-progress{margin-bottom:6px}
.story.is-on[data-layout="top"] .story-note{min-height:2.9em;margin-top:8px;font-size:13.5px}
.story.is-on[data-notes="0"] .story-note{display:none}
.story.is-on[data-layout="top"]>.story-caption{margin:10px 0 0}
.story.is-on[data-layout="top"]>.story-steps{margin-top:22px}
.story.is-on[data-layout="top"] .story-step{padding:0 0 12vh 14px}

@media (prefers-reduced-motion:reduce){
  .story.is-on .story-step{transition:none}
  .story.is-on .story-frames>.story-frame.is-on{animation:none}
}
@media print{
  .story.is-on[data-layout]{display:block;width:auto;margin:0}
  .story.is-on[data-layout]>.story-stage{position:static;max-height:none;overflow:visible}
  .story.is-on .story-step{opacity:1;border:0;padding:0 0 1em}
  .story.is-on .story-frames>.story-frame{display:block}
  .story.is-on .story-progress,.story.is-on .story-note{display:none}
}
/* brief steps: the takeaway, and the text folded under it */
.story-take{margin:0 0 10px;font-family:var(--sans,inherit);font-weight:600;font-size:1.18em;line-height:1.4;color:var(--story-ink);letter-spacing:-.01em;text-wrap:balance}
.story-more{margin:0}
.story-more>summary{display:inline-block;cursor:pointer;list-style:none;font:500 12px/1.2 var(--story-label);color:var(--story-ink-3);padding:4px 0}
.story-more>summary::-webkit-details-marker{display:none}
.story-more>summary::before{content:"+ "}
.story-more[open]>summary::before{content:"– "}
.story-more>summary:hover{color:var(--story-ink)}
.story-more[open]>summary{margin-bottom:8px}
.story-all{display:none}
.story.is-on .story-all{display:inline-block;all:unset;cursor:pointer;margin-left:12px;font:500 12px/1 var(--story-label);color:var(--story-ink-3);border:1px solid var(--story-rule);border-radius:99px;padding:5px 10px;white-space:nowrap}
.story.is-on .story-all:hover,.story.is-on .story-all[aria-pressed="true"]{color:var(--story-ink);border-color:var(--story-ink-3)}
.story.is-on .story-all:focus-visible{outline:2px solid var(--story-ink);outline-offset:2px}
.story.is-on[data-story-brief] .story-note{display:none}
.story.is-on[data-story-brief][data-layout="side"] .story-step{padding-bottom:16vh}
