/* Scroll stories: one figure assembles and opens as the page scrolls. The steps scroll on the left (5 of 12 columns),
   the figure is sticky on the right (7 columns); on a phone the figure is sticky on top and the steps run below it.
   story.js maps the scroll onto the figure's scrub (kernel header, "Scrub"). */
.doc { max-width: var(--page); margin: 0 auto; padding: 72px max(var(--gutter), 56px) 120px; }
.nav a[aria-current] { color: var(--ink); }
.head { max-width: 56ch; }
h1 { font-weight: 500; font-size: 44px; line-height: 1.08; letter-spacing: -0.035em; }
.lede { margin-top: 16px; font-size: 16px; line-height: 1.55; color: var(--soft); }

.story { margin-top: 24px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--col-gap); }
ol.beats { grid-column: 1 / 6; grid-row: 1; list-style: none; counter-reset: beat; }
ol.beats > li { min-height: 90svh; display: flex; align-items: center; counter-increment: beat; }
ol.beats > li:first-child { min-height: 70svh; align-items: flex-start; padding-top: 18svh; }
ol.beats .txt { opacity: .35; transition: opacity .4s cubic-bezier(.4, 0, .2, 1); max-width: 34ch; }
ol.beats > li.on .txt { opacity: 1; }
ol.beats .n { display: block; font: 400 11px/1 var(--mono); letter-spacing: .08em; color: var(--faint); margin-bottom: 12px; }
ol.beats .n::before { content: counter(beat, decimal-leading-zero); }
ol.beats strong { display: block; font-weight: 500; font-size: 22px; line-height: 1.2; letter-spacing: -0.02em; }
ol.beats p { margin-top: 10px; color: var(--soft); font-size: 15px; line-height: 1.55; }

.fig { grid-column: 6 / 13; grid-row: 1; align-self: start; position: sticky; top: max(72px, calc(50svh - 0.4 * min(56vw, 720px)));
  aspect-ratio: 5 / 4; background: var(--bg); }
.fig iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; pointer-events: none;
  opacity: 0; transition: opacity .4s cubic-bezier(.4, 0, .2, 1); background: transparent; }
.fig iframe.on { opacity: 1; }

.end { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--rule); display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 14px; }
.end a { color: var(--soft); display: inline-flex; align-items: center; gap: 6px; }
.end a:hover { color: var(--ink); }

@media (max-width: 900px) {
  .doc { padding: 40px 24px 88px; }
  h1 { font-size: 32px; }
  .story { display: block; margin-top: 16px; }
  .fig { position: sticky; top: 0; z-index: 1; height: 44svh; aspect-ratio: auto; margin-inline: -24px;
    border-bottom: 1px solid var(--rule); }
  ol.beats > li { min-height: 62svh; }
  ol.beats > li:first-child { min-height: 50svh; padding-top: 8svh; }
  ol.beats strong { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  ol.beats .txt, .fig iframe { transition: opacity .2s linear; }
}

/* a barely-there dot grid, pinned to the viewport. The figure's canvas paints a solid plate that hides it, so the same
   grid is laid over the figure (multiplied in light, screened in dark, letting the pointer through) and runs on unbroken. */
:root { --dots: radial-gradient(circle, rgb(0 0 0 / 9%) 1px, transparent 1.25px) center / 20px 20px fixed; --dots-blend: multiply; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --dots: radial-gradient(circle, rgb(255 255 255 / 9%) 1px, transparent 1.25px) center / 20px 20px fixed; --dots-blend: screen; }
}
:root[data-theme="dark"] { --dots: radial-gradient(circle, rgb(255 255 255 / 9%) 1px, transparent 1.25px) center / 20px 20px fixed; --dots-blend: screen; }
body { background: var(--dots), var(--bg); }
.fig::after { content: ''; position: absolute; inset: 0; background: var(--dots); mix-blend-mode: var(--dots-blend); pointer-events: none; z-index: 1; }
