/* Combination scroll story, 2026. Everything is scoped to .story. Re-theme with the custom properties below,
   on :root or on the story element; the defaults use :where() so any site rule wins. See INTEGRATION.md. */
@font-face { font-family: Manrope; src: url(fonts/manrope-latin-wght-normal.woff2) format('woff2'); font-weight: 200 800; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url(fonts/jetbrains-mono-latin-wght-normal.woff2) format('woff2'); font-weight: 100 800; font-display: swap; }

:where(:root) {
  /* colour */
  --story-paper: #f2f1ed;        /* background of beats 01-04: the desk */
  --story-sheet: #ffffff;        /* the drawing sheet */
  --story-ink: #0b0b0c;          /* text and lines on light */
  --story-muted: #5d5d5a;        /* the sentence on light */
  --story-dark: #09090a;         /* background of beats 05-08: the studio */
  --story-on-dark: #f4f4f1;      /* text on dark */
  --story-muted-dark: #a6a6a2;   /* the sentence on dark */
  --story-bench: #e6e5e1;        /* background of beats 09-11: the bench */
  --story-line: #ecece9;         /* lines drawn on dark */
  --story-rule: rgba(11, 11, 12, .14);      /* hairlines on light */
  --story-rule-dark: rgba(244, 244, 241, .2); /* hairlines on dark */
  --story-accent: #ff5a1f;       /* the one highlighter colour, on light; --story-accent-dark (unset) overrides it on dark */
  /* type */
  --story-font-sans: Manrope, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --story-font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --story-title-size: clamp(26px, 3.1vw, 46px);
  --story-title-weight: 600;
  --story-title-tracking: -0.025em;
  --story-text-size: clamp(15px, 1.35vw, 19px);
  --story-mono-size: 11px;
  --story-mono-tracking: .08em;
  /* layout and motion */
  --story-gutter: clamp(20px, 5vw, 72px);
  --story-top: 0px;              /* height of a fixed site header over the stage */
  --story-len: 12;               /* length of the story in screen heights */
  --story-ease: cubic-bezier(.2, .7, .2, 1);
}

.story { position: relative; display: block; background: var(--story-paper); color: var(--story-ink); font-family: var(--story-font-sans); }
.story:empty { min-height: 100vh; } /* holds the place until the script has built the story */
.story *, .story *::before, .story *::after { box-sizing: border-box; }
.story :focus-visible { outline: 2px solid var(--story-accent); outline-offset: 3px; }
.story__heading { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.story__end { display: block; height: 0; outline: 0; }
.story__skip { font: 500 calc(var(--story-mono-size) + 1px)/1 var(--story-font-mono); letter-spacing: var(--story-mono-tracking); text-transform: uppercase; color: inherit; text-underline-offset: 4px; padding: 14px 0; white-space: nowrap; }
.story__skip::after { content: ' \2193'; }
.story__note { font: 400 10.5px/1.2 var(--story-font-mono); letter-spacing: .02em; text-transform: none; opacity: .62; white-space: nowrap; }

/* ---------- static: a calm vertical sequence (reduced motion, no WebGL) ---------- */
.story__beats { list-style: none; margin: 0 auto; padding: 40px var(--story-gutter) 56px; max-width: 1100px; }
.story__beat { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(20px, 5vw, 72px); align-items: center; padding: 36px 0; border-top: 1px solid var(--story-rule); }
.story__beat:first-child { border-top: 0; }
.story__still, .story__sketch { display: block; width: 100%; height: auto; border-radius: 2px; background: var(--story-paper); }
.story__num { font: 500 var(--story-mono-size)/1.2 var(--story-font-mono); letter-spacing: var(--story-mono-tracking); text-transform: uppercase; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.story__num::before { content: ''; width: 18px; height: 2px; background: var(--story-accent); flex: none; }
.story__num span { opacity: .6; }
.story__title { font: var(--story-title-weight) clamp(26px, 3vw, 42px)/1.06 var(--story-font-sans); letter-spacing: var(--story-title-tracking); margin: 0 0 12px; text-wrap: balance; }
.story__text { margin: 0; font-size: 17px; line-height: 1.5; color: var(--story-muted); max-width: 34ch; text-wrap: pretty; }
.story .sk { fill: none; stroke: var(--story-ink); stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.story .sk--faint { stroke-width: .8; opacity: .55; }
.story .sk--hl { stroke: var(--story-accent); stroke-width: 9; stroke-linecap: butt; opacity: .5; mix-blend-mode: multiply; }
.story .napkin__sheet { fill: var(--story-sheet); }
.story--static .story__skip { position: relative; display: block; width: max-content; margin: 24px auto 0; max-width: 1100px; padding-left: 0; }
.story--static .story__stage { display: flex; flex-direction: column; }
.story--static .story__rail { order: 3; max-width: 1100px; width: 100%; margin: 0 auto; padding: 0 var(--story-gutter) 48px; }
.story--static .story__count, .story--static .story__phases { display: none; }
@media (max-width: 760px) { .story__beat { grid-template-columns: 1fr; gap: 18px; } .story__text { font-size: 15px; } }

/* ---------- live: one pinned stage driven by scroll ---------- */
.story--live { height: calc(var(--story-len) * 100vh); }
.story--live .story__end { position: absolute; left: 0; bottom: 0; } /* the skip link lands just past the story */
.story--live .story__stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; background: var(--story-paper); transition: color .3s linear; } /* the background colour is set by the script, in step with the scene */
.story--live .story__stage[data-theme='dark'] { background: var(--story-dark); color: var(--story-on-dark); --story-muted: var(--story-muted-dark); --story-rule: var(--story-rule-dark); }
.story--live .story__stage[data-theme='bench'] { background: var(--story-bench); }
.story--live .story__visual { position: absolute; inset: 0; }
/* a band behind the stage line in the stage colour, so nothing in the picture runs under the text */
.story--live .story__visual::after { content: ''; position: absolute; z-index: 2; left: 0; right: 0; top: 0; height: calc(var(--rt, 150px) + 26px); background: linear-gradient(var(--scrim, var(--story-paper)) calc(100% - 38px), transparent); pointer-events: none; }
/* and a solid one behind the rail, with a taller fade above it */
.story--live .story__visual::before { content: ''; position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; height: calc(var(--rb, 66px) + 40px); background: linear-gradient(transparent, var(--scrim, var(--story-paper)) 40px); pointer-events: none; }
.story--live .story__stage[data-theme='dark'] .story__visual { --scrim: var(--story-dark); }
.story--live .story__stage[data-theme='bench'] .story__visual { --scrim: var(--story-bench); }
.story__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .45s linear; }
.story__canvas.is-ready { opacity: 1; }
.story--live .story__beats { position: static; margin: 0; padding: 0; max-width: none; }
.story--live .story__beat { display: block; padding: 0; border: 0; }
.story--live .story__still { display: none; }
.story--live .story__sketch { position: absolute; z-index: 1; left: 0; top: 0; width: 320px; height: 300px; max-width: none; transform-origin: 0 0; border-radius: 0; background: none; pointer-events: none;
  transform: translate(50vw, 55vh) scale(2) translate(-150px, -150px); } /* until the script places it */

/* the stage line: stage name and one sentence, centred at the top; only the current beat's is visible */
.story--live .story__caption { position: absolute; z-index: 3; left: var(--story-gutter); right: var(--story-gutter); top: calc(var(--story-top) + clamp(20px, 4.6vh, 44px)); text-align: center; opacity: 0; transform: translateY(10px); transition: opacity .16s linear, transform .2s ease-in; pointer-events: none; }
.story--live .story__beat.is-past .story__caption { transform: translateY(-10px); }
.story--live .story__beat.is-on .story__caption { opacity: 1; transform: none; transition: opacity .26s linear .1s, transform .42s var(--story-ease) .1s; }
.story--live .story__num { display: none; }
.story--live .story__title { font-size: var(--story-title-size); line-height: 1.06; margin: 0 auto 10px; transition: color .3s linear; }
.story--live .story__text { font-size: var(--story-text-size); line-height: 1.4; margin: 0 auto; max-width: 62ch; text-wrap: balance; transition: color .3s linear; }

/* the rail: step counter, the five phases with a tick per stage, the illustration note, skip */
.story--live .story__skip { position: absolute; z-index: 5; right: var(--story-gutter); bottom: 10px; padding: 16px 0; }
.story__rail { display: flex; align-items: flex-end; gap: 24px; font: 500 var(--story-mono-size)/1 var(--story-font-mono); letter-spacing: var(--story-mono-tracking); text-transform: uppercase; }
.story--live .story__rail { position: absolute; z-index: 4; left: var(--story-gutter); right: calc(var(--story-gutter) + var(--skip-w, 140px) + 24px); bottom: 26px; }
.story__count { flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; opacity: .75; }
.story__count b { font-weight: 600; opacity: 1; }
.story__phases { flex: 1; display: flex; justify-content: center; gap: clamp(16px, 2.6vw, 40px); }
/* on wide screens the phases sit on the stage's centre line, under the stage name */
.story--live .story__rail { min-height: 33px; }
.story--live .story__phases { position: absolute; left: calc(var(--sw, 100vw) / 2 - var(--story-gutter)); bottom: 0; translate: -50% 0; flex: none; }
.story__phase { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.story__phase-name { opacity: .64; white-space: nowrap; transition: opacity .3s; }
.story__phase.is-on .story__phase-name { opacity: 1; font-weight: 600; }
.story__ticks { display: flex; gap: 8px; align-items: flex-end; height: 14px; }
.story__ticks i { display: block; width: 2px; height: 9px; background: currentColor; opacity: .32; transition: height .25s var(--story-ease), opacity .25s, background-color .25s; }
.story__ticks i.is-past { opacity: 1; }
.story__ticks i.is-on { width: 3px; height: 14px; opacity: 1; background: var(--story-accent); }
.story--live .story__stage[data-theme='dark'] .story__ticks i.is-on { background: var(--story-accent-dark, var(--story-accent)); }
/* the illustration note: only on the first and the last stage, just above the skip link */
.story--live .story__note { position: absolute; right: calc(-1 * (var(--skip-w, 140px) + 24px)); bottom: 40px; margin: 0; opacity: 0; transition: opacity .3s; text-shadow: 0 0 6px var(--scrim, var(--story-paper)), 0 0 2px var(--scrim, var(--story-paper)); }
.story--live .story__rail.is-note .story__note { opacity: .7; }

/* in-picture labels, placed by the script on the projected parts */
.story__tags { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; visibility: hidden; }
.story__tag, .story__balloon { position: absolute; left: 0; top: 0; opacity: 0; visibility: hidden; white-space: nowrap; font: 500 var(--story-mono-size)/1 var(--story-font-mono); letter-spacing: var(--story-mono-tracking); text-transform: uppercase; }
.story__tags--parts .story__tag { translate: -50% -100%; padding-bottom: 15px; }
.story__tags--parts .story__tag::after { content: ''; position: absolute; left: 50%; bottom: 0; width: 2px; height: 10px; margin-left: -1px; background: var(--story-accent); }
.story__tags--parts .story__tag.is-down { translate: -50% 0; padding: 15px 0 0; }
.story__tags--parts .story__tag.is-down::after { top: 0; bottom: auto; }
.story__balloon { --br: 13px; display: grid; place-items: center; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 1.25px solid currentColor; border-radius: 50%; font-weight: 600; letter-spacing: 0; background: var(--story-bench); transition: background-color .2s, color .2s, border-color .2s; }
/* the leader: from the balloon's edge to its part, at any angle (--lead length, --ang direction, --lo opacity) */
.story__balloon::before { content: ''; position: absolute; left: 50%; top: 50%; width: max(0px, calc(var(--lead, 30px) - var(--br))); height: 1px; margin-top: -.5px; background: currentColor; opacity: calc(.7 * var(--lo, 1)); transform-origin: 0 50%; transform: rotate(var(--ang, 180deg)) translateX(var(--br)); }
.story__balloon::after { content: ''; position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px; border-radius: 50%; background: currentColor; opacity: var(--lo, 1); transform: rotate(var(--ang, 180deg)) translateX(var(--lead, 30px)); }
.story__balloon.is-done { background: var(--story-accent); border-color: var(--story-accent); color: var(--story-on-accent, var(--story-ink)); }
/* the test fixture's result */
.story__tags--fix .story__tag { translate: -50% -100%; margin-top: -8px; padding: 6px 9px 5px; border-radius: 2px; background: var(--story-accent); color: var(--story-on-accent, var(--story-ink)); font-weight: 600; }
.story__tags--fix .story__tag::before { content: '\2713\00a0'; }
.story__tags--builds .story__tag { translate: -100% -50%; padding-right: 20px; font-weight: 600; font-size: calc(var(--story-mono-size) + 1px); }
.story__tags--builds .story__tag::after { content: ''; position: absolute; right: 0; top: 50%; width: 12px; height: 2px; margin-top: -1px; background: var(--story-accent); }

/* functional validation: the test panel beside the prototype */
.story__tests { position: absolute; z-index: 2; left: 54%; top: var(--ry, 50%); width: min(340px, 36vw); translate: 0 -50%; font: 500 12px/1 var(--story-font-mono); color: var(--story-on-dark); opacity: 0; visibility: hidden; pointer-events: none; }
.story__trace { display: block; width: 100%; height: 44px; margin: 0 0 14px; overflow: visible; }
.story__trace path { fill: none; stroke: var(--story-accent-dark, var(--story-accent)); stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.story__tests ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--story-rule-dark); }
.story__tests li { display: grid; grid-template-columns: 2.6em 1fr auto; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--story-rule-dark); color: var(--story-muted-dark); letter-spacing: var(--story-mono-tracking); text-transform: uppercase; transition: color .2s; }
.story__tests li span { opacity: .7; }
.story__tests li b { font-weight: 500; }
.story__tests li em { font-style: normal; display: flex; align-items: center; gap: 7px; }
.story__tests li.is-run, .story__tests li.is-pass { color: var(--story-on-dark); }
.story__tests li.is-run em::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.story__tests li.is-pass em { color: var(--story-accent-dark, var(--story-accent)); }
.story__tests li.is-pass em::before { content: '\2713'; font-size: 13px; }
.story__tests code { display: block; margin-top: 14px; min-height: 1.2em; font: inherit; color: var(--story-muted-dark); white-space: pre; overflow: hidden; text-overflow: ellipsis; }

/* iteration: the version number */
.story__ver { position: absolute; z-index: 2; right: calc(var(--story-gutter) + 2vw); top: calc(var(--rt, 160px) + 24px); display: grid; grid-template-columns: repeat(4, 14px); gap: 6px; align-items: end; color: var(--story-on-dark); opacity: 0; visibility: hidden; pointer-events: none; }
.story__ver b { grid-column: 1 / -1; font: 500 60px/1 var(--story-font-mono); letter-spacing: -.04em; }
.story__ver span { grid-column: 1 / -1; font: 500 var(--story-mono-size)/1 var(--story-font-mono); letter-spacing: var(--story-mono-tracking); text-transform: uppercase; color: var(--story-muted-dark); margin: 4px 0 8px; }
.story__ver i { height: 3px; background: #4a4a4c; }
.story__ver i.is-on { background: var(--story-accent-dark, var(--story-accent)); }

/* low-power: the pinned stage with each beat's still in place of the canvas */
.story--lite .story__beat.is-on .story__still { display: block; position: absolute; z-index: 1; left: 50%; top: var(--ry, 55%); width: auto; height: var(--rh, 70%); max-width: 94%; object-fit: contain; translate: -50% -50%; background: none;
  -webkit-mask-image: radial-gradient(closest-side, #000 80%, transparent); mask-image: radial-gradient(closest-side, #000 80%, transparent); }

/* phones and tall windows: the stage line on top, the object under it */
@media (max-width: 819px), (max-aspect-ratio: 9/10) {
  .story--live .story__caption { top: calc(var(--story-top) + 18px); left: 20px; right: 20px; }
  .story--live .story__title { font-size: clamp(25px, 7vw, 32px); margin-bottom: 8px; }
  .story--live .story__text { font-size: 15px; max-width: 32ch; }
  .story--live .story__rail { left: 20px; right: calc(20px + var(--skip-w, 110px) + 14px); bottom: 18px; gap: 14px; }
  .story--live .story__skip { right: 20px; bottom: 4px; }
  .story__phases, .story--live .story__phases { position: static; translate: none; flex: 1; justify-content: flex-start; gap: 12px; }
  .story__phase { position: relative; }
  .story__phase-name { position: absolute; left: 0; bottom: 22px; opacity: 0; }

  .story__phase:nth-child(n+4) .story__phase-name { left: auto; right: 0; }
  .story__ticks { gap: 6px; }
  .story--live .story__note { right: calc(-1 * (var(--skip-w, 110px) + 14px)); bottom: 48px; font-size: 10px; }
  .story__tests { left: 20px; right: 20px; width: auto; top: auto; bottom: calc(var(--rb, 70px) + 6px); translate: none; font-size: 11px; } /* under the device, the trace inside the panel */
  .story__trace { height: 26px; margin-bottom: 10px; }
  .story__tests li { padding: 8px 0; }
  .story__tests code { margin-top: 10px; }
  .story__ver { right: 20px; top: calc(var(--rt, 150px) + 4px); grid-template-columns: repeat(4, 10px); gap: 4px; }
  .story__ver b { font-size: 34px; }
  .story__balloon { --br: 11px; width: 22px; height: 22px; margin: -11px 0 0 -11px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { .story *, .story { transition: none !important; animation: none !important; } }
