/* The scroll page: a pinned canvas and text that scrolls past it. Phone first: the graphic holds the top of the screen
   and the text runs in the band below it; each step's card sticks at the top of the band while its step plays, then
   slides up under the graphic as the next one arrives, so a card never covers the picture. From 820px wide: text
   column on the left, graphic pinned on the right. --trig is where a step starts, a fraction of the viewport height
   from the top, the line the cards stick to; scroll.js reads it, and the anchors (#step-2) land a step's top on it.
   A book sets its colours and fonts in its own <style> (:root { --accent: … }); scroll.js draws with the same ones.
   --grain-img: a paper texture laid over the paper scenes (url(../img/paper.webp)), none by default. */
@import url("fonts.css");
:root {
  --paper: #f3ede0; --ink: #2b2520; --soft: #6a6258; --accent: #c4321f; --night: #04060a;
  --font-key: "Oswald", "Arial Narrow", sans-serif; --font-text: "EB Garamond", Georgia, serif;
  --grain-img: none; --graphic-h: 60svh; --trig: .62;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--paper); }
html, body { overflow-x: clip; }
a:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 19px/1.5 var(--font-text); }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: .15em; }
b { font-weight: 500; }
.accent { color: var(--accent); }

.progress { position: fixed; inset: 0 0 auto; height: 3px; z-index: 5; pointer-events: none; }
.progress i { display: block; height: 100%; background: var(--accent); transform-origin: 0 0; transform: scaleX(0); }

/* the way back to the shelf: one quiet line above the story, out of its flow */
.shelf { position: absolute; top: 12px; left: max(16px, env(safe-area-inset-left)); font-size: 17px; }
.shelf a { display: inline-block; padding: 10px 0; color: var(--soft); text-decoration: none; }
.shelf a:hover { color: var(--ink); }
.hero { min-height: 92svh; padding: 18svh 16px 8svh; max-width: 40rem; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; }
.kicker { font: 500 17px/1.2 var(--font-key); color: var(--accent); margin: -8px 0 20px; }
h1 { font: 600 clamp(48px, 13vw, 112px)/.95 var(--font-key); text-transform: uppercase; letter-spacing: .02em; margin: 0 0 20px; }
.dek { font-size: 23px; line-height: 1.35; margin: 0 0 16px; }
.more { color: var(--soft); font-size: 17px; margin: 0; }
.cue { font: 500 28px var(--font-key); color: var(--accent); margin: 6svh 0 0; }

.scrolly { position: relative; }
.graphic { position: sticky; top: 0; height: var(--graphic-h); margin: 0; z-index: 2; background: var(--night); }
.graphic::after { /* the band's top edge: text slides under a soft rule, not a hard cut */
  content: ""; position: absolute; inset: auto 0 -14px; height: 14px; background: linear-gradient(var(--paper), transparent); }
.graphic canvas { display: block; width: 100%; height: 100%; }
/* the vignette (and --grain-img) over the canvas; scroll.js sets its opacity to how much paper is on screen (paperTop) */
.graphic .grain { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(closest-corner at 50% 50%, rgba(26, 18, 8, 0) 50%, rgba(26, 18, 8, .4) 100%); mix-blend-mode: multiply; }
.graphic .grain::before { content: ""; position: absolute; inset: 0; background: var(--grain-img) center / 100% 100%; opacity: .4; }
.steps { position: relative; z-index: 1; padding: 2svh 0 50svh; }
.step { min-height: 100svh; max-width: 34rem; margin: 0 auto; scroll-margin-top: calc(var(--trig) * 100svh); }
.card { position: sticky; top: calc(var(--trig) * 100svh); padding: 4px 20px 0; }
.step p { margin: 0 0 .7em; }
.step blockquote { margin: 0 0 .7em; padding-left: 14px; border-left: 3px solid var(--accent); font-style: italic; }
.step .src { font-size: 15px; color: var(--soft); }

.credits { max-width: 40rem; margin: 0 auto; padding: 12svh 16px 20svh; font-size: 16px; color: var(--soft); }
.credits h2 { font: 500 15px/1.2 var(--font-key); letter-spacing: .04em; text-transform: uppercase; color: var(--ink); }
.credits li { margin-bottom: .4em; }
.credits code { font-size: .9em; }

@media (max-width: 819px) and (max-height: 720px) {   /* a short phone: a smaller graphic and type, so a card fits the band */
  :root { --graphic-h: 52svh; --trig: .54; }
  body { font-size: 17px; }
}
@media (min-width: 820px) {
  :root { --trig: .3; }
  .scrolly { display: grid; grid-template-columns: minmax(320px, 36fr) 64fr; }
  .graphic { grid-column: 2; grid-row: 1; height: 100vh; }
  .graphic::after { display: none; }
  .steps { grid-column: 1; grid-row: 1; padding: 30vh 0 60vh; }
  .step { min-height: 110vh; padding: 0 max(28px, 3vw); scroll-margin-top: calc(var(--trig) * 100vh); }
  .card { top: calc(var(--trig) * 100vh); padding: 0; }
  body { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
