/* Sound Journey: one dark, cinematic world. A fixed particle field sits behind pinned chapter "stages";
   text and photographs reveal over it as you scroll. Ultramarine and gold carry over from the main site. */
:root {
  --bg: #070a14;
  --fg: #e9ebf2;
  --muted: #8e97ad;
  --dim: #5b6479;
  --rule: rgba(233, 235, 242, .1);
  --ultramarine: #5d7cff;
  --gold: #e8b74a;
  --display: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 2px; }

/* Layers behind the story */
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: calc(1 - var(--focus, 0) * .65);
  background: radial-gradient(120% 90% at 50% 50%, transparent 40%, rgba(7, 10, 20, .75) 100%);
}
/* darkens the text column only while the story sits to the left (driven by --side from the script) */
.vignette::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(7, 10, 20, .82) 0%, rgba(7, 10, 20, .62) 40%, transparent 64%);
  opacity: var(--side, 0);
}
.grain {
  position: fixed; inset: -8%; z-index: 60; pointer-events: none; opacity: .035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

/* HUD */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) clamp(16px, 4vw, 40px) 18px;
  font-size: .85rem;
}
.mark { font-family: var(--display); font-size: 1.25rem; font-weight: 600; text-decoration: none; letter-spacing: .01em; }
.where { font-family: var(--mono); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); text-align: center; }
.hud-r { display: flex; justify-content: flex-end; align-items: center; gap: 18px; }
.hud-r a { color: var(--muted); text-decoration: none; }
.hud-r a:hover { color: var(--fg); }
.sound {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: 500 .78rem var(--mono); letter-spacing: .04em; color: var(--fg);
  background: rgba(233, 235, 242, .06); border: 1px solid var(--rule); border-radius: 999px; padding: 7px 12px 7px 10px;
}
.sound:hover { border-color: rgba(233, 235, 242, .3); }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.bars i { width: 2px; height: 3px; background: var(--muted); border-radius: 1px; }
.sound[aria-pressed="true"] .bars i { background: var(--gold); animation: eq 1s ease-in-out infinite; }
/* sound is on but waiting for the visitor's first click or tap: gold, but still */
.sound.pending .bars i { animation: none !important; opacity: .55; }
.sound[aria-pressed="true"] .bars i:nth-child(2) { animation-delay: -.3s; }
.sound[aria-pressed="true"] .bars i:nth-child(3) { animation-delay: -.6s; }
.sound[aria-pressed="true"] .bars i:nth-child(4) { animation-delay: -.15s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }

/* Chapters: each is a tall track with a pinned stage. In motion mode they overlap by one viewport,
   so the next stage is already pinned when the previous one lets go. */
#story { position: relative; z-index: 2; }
.ch { position: relative; height: calc(var(--len) * 1svh); }
.motion .ch + .ch { margin-top: -100svh; }
.stage {
  position: sticky; top: 0; height: 100svh; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr); align-items: center;
  padding: 96px clamp(16px, 6vw, 96px) 64px;
  transition: opacity .45s ease;
}
/* a leap through the page (the Home key, the scrollbar dragged fast) dips the words out until it lands */
.leap .stage { opacity: 0; transition-duration: .1s; }
/* overlapping chapters must not swallow clicks meant for the one underneath */
.motion .ch { pointer-events: none; }
.motion .ch a, .motion .ch button { pointer-events: auto; }
.center { text-align: center; max-width: 46rem; margin: 0 auto; }
.text { max-width: 31rem; position: relative; z-index: 3; }

/* Before the script is ready, keep the opening words hidden so they don't flash */
@media (prefers-reduced-motion: no-preference) and (min-height: 561px) {
  .js:not(.story-ready) .ch-silence .line { opacity: 0; }
}

h1, h2 { font-family: var(--display); font-weight: 400; margin: 0 0 22px; text-wrap: balance; letter-spacing: -.005em; }
h1 { font-size: clamp(2.8rem, 7vw, 5.6rem); line-height: 1.02; }
h2 { font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1.08; }
h1 em, h2 em, .big em, .lesson em { font-style: italic; color: var(--ultramarine); }
.text code { font-family: var(--mono); font-size: .9em; color: var(--gold); }
.text p { margin: 0 0 16px; color: #c8cddb; }
.text b { color: var(--fg); font-weight: 500; }
.eyebrow { font-family: var(--mono); font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 0 0 22px; }
.sub { color: var(--muted); margin: 0; font-size: 1.05rem; }
/* the opening: begin with sound, or read quietly */
.begin { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 12px 24px; }
.quiet { font: inherit; font-size: .92rem; color: var(--muted); background: none; border: 0; padding: 6px 2px; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(233, 235, 242, .25); text-underline-offset: 5px; }
.quiet:hover { color: var(--fg); }
.cue { margin-top: 64px; font-family: var(--mono); font-size: .68rem; letter-spacing: .3em; text-transform: uppercase; color: var(--dim); }
.cue::after { content: ""; display: block; width: 1px; height: 48px; margin: 12px auto 0; background: linear-gradient(var(--dim), transparent); }
.num { font-family: var(--mono); font-size: .72rem; letter-spacing: .2em; color: var(--gold); margin: 0 0 18px !important; }
.lesson { font-family: var(--display); font-size: clamp(1.45rem, 2.4vw, 1.9rem); line-height: 1.3; color: var(--fg) !important; margin-top: 28px !important; }
.big { font-family: var(--display); font-size: clamp(1.6rem, 2.8vw, 2.2rem); line-height: 1.2; color: var(--fg) !important; margin-top: 26px !important; }

/* Keyboard focus always shows the line it lands in, whatever the scroll timeline says */
.line:has(:focus-visible) { opacity: 1 !important; transform: none !important; filter: none !important; }
/* panels hidden from the pointer when faded (the two roads, the project cards) stay reachable from the keyboard,
   and a course reached that way shows itself and its roads at once */
.kbd .roads-scroll, .kbd .detail, .kbd .card { visibility: visible !important; }
.roads:has(:focus-visible) { --draw: 1 !important; }

/* Photographs: three frames of one life (2009, 2020, today). Each is feathered softly at its edges but bright at
   heart, and held by four thin gold corner marks, like a viewfinder, that close in as the photo comes into focus. */
.photo { position: absolute; margin: 0; z-index: 2; opacity: .96; --lock: 1; }
.photo img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  --fx: linear-gradient(90deg, transparent, rgba(0, 0, 0, .22) 8%, rgba(0, 0, 0, .62) 17%, #000 30%, #000 70%, rgba(0, 0, 0, .62) 83%, rgba(0, 0, 0, .22) 92%, transparent);
  --fy: linear-gradient(180deg, transparent, rgba(0, 0, 0, .22) 7%, rgba(0, 0, 0, .62) 14%, #000 25%, #000 75%, rgba(0, 0, 0, .62) 86%, rgba(0, 0, 0, .22) 93%, transparent);
  -webkit-mask-image: var(--fx), var(--fy);
  -webkit-mask-composite: source-in;
  mask-image: var(--fx), var(--fy);
  mask-composite: intersect;
  filter: saturate(.94) brightness(1.03);
}
.photo::after {
  --c: rgba(232, 183, 74, .62);
  content: ""; position: absolute; inset: -12px; pointer-events: none;
  background:
    linear-gradient(var(--c), var(--c)) left top / 24px 1px, linear-gradient(var(--c), var(--c)) left top / 1px 24px,
    linear-gradient(var(--c), var(--c)) right top / 24px 1px, linear-gradient(var(--c), var(--c)) right top / 1px 24px,
    linear-gradient(var(--c), var(--c)) left bottom / 24px 1px, linear-gradient(var(--c), var(--c)) left bottom / 1px 24px,
    linear-gradient(var(--c), var(--c)) right bottom / 24px 1px, linear-gradient(var(--c), var(--c)) right bottom / 1px 24px;
  background-repeat: no-repeat;
  opacity: var(--lock);
  transform: scale(calc(1.08 - .08 * var(--lock)));
}
.photo figcaption {
  position: absolute; left: 50%; top: calc(100% + 22px); transform: translateX(-50%);
  font-family: var(--mono); font-size: .66rem; letter-spacing: .3em; color: var(--muted); white-space: nowrap;
}
.photo figcaption::before { content: ""; display: inline-block; width: 18px; height: 1px; margin-right: 12px; vertical-align: middle; background: var(--gold); opacity: .75; }
/* each sits right of the text, above the light at the bottom of its chapter */
.p-right { right: clamp(24px, 9vw, 170px); top: 46%; height: min(40svh, 380px); aspect-ratio: 4 / 3; max-width: 36vw; transform: translateY(-50%); }
.p-school { aspect-ratio: 770 / 800; top: 45%; height: min(39svh, 360px); }

/* Chapter 2: no player. Lost arrives on its own when sound is on; otherwise one quiet invitation. */
.listen { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.listen .hear { order: 0; } .listen .now { order: 1; } .listen .spotify { order: 2; }
.listen .hint { order: 3; flex-basis: 100%; }
.ch-note .text { max-width: 34rem; }
.ch-note .big { font-size: clamp(1.5rem, 2.4vw, 1.95rem); margin-top: 20px !important; }
.spotify { font-family: var(--mono); font-size: .72rem; letter-spacing: .06em; color: var(--muted); text-underline-offset: 4px; }
.spotify:hover { color: var(--gold); }
.hear {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  font: 500 .92rem var(--body); color: var(--bg); background: var(--gold); border: 0; border-radius: 999px; padding: 12px 20px 12px 16px;
}
.hear:hover { filter: brightness(1.08); }
.hear .bars i { background: currentColor; height: 6px; }
.hear .bars i:nth-child(2) { height: 10px; } .hear .bars i:nth-child(3) { height: 4px; } .hear .bars i:nth-child(4) { height: 8px; }
/* only the invitations to turn sound on step aside once it is on (not the other buttons in this style) */
.sound-on .turn-on { display: none; }
.text .now, .text .hint { display: none; margin: 0; }
.text .now {
  align-items: center; gap: 10px;
  font-family: var(--mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold);
}
.now .bars i { background: var(--gold); }
.is-playing .now .bars i { animation: eq 1s ease-in-out infinite; }
.is-playing .now .bars i:nth-child(2) { animation-delay: -.3s; }
.is-playing .now .bars i:nth-child(3) { animation-delay: -.6s; }
.is-playing .now .bars i:nth-child(4) { animation-delay: -.15s; }
.sound-on .ch-note.is-playing .now { display: flex; }
.ch-note.is-playing .hint { display: block; font-size: .88rem; color: var(--muted); }
.back { color: var(--fg); text-underline-offset: 4px; }
/* Chapter 4: the gate, then the two roads on a dark glass panel (two beats in one stage) */
.text .gate-hint { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; color: var(--muted); margin-top: 22px; }
.gate-hint .by-touch { display: none; }
@media (hover: none) { .gate-hint .by-mouse { display: none; } .gate-hint .by-touch { display: inline; } }
.sound-link { font: inherit; letter-spacing: inherit; color: var(--gold); background: none; border: 0; padding: 0; margin-left: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.sound-on .sound-link, .no-gl .gate-hint { display: none; }
.beat { grid-area: 1 / 1; }
.roads-panel { justify-self: center; width: min(1240px, 100%); position: relative; z-index: 3; }
.roads-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 28px; flex-wrap: wrap; margin-bottom: 12px; }
.roads-head h3 { font-family: var(--display); font-weight: 400; font-size: clamp(1.6rem, 2.6vw, 2.1rem); margin: 0; }
.roads-head p { margin: 0; color: var(--muted); font-size: .84rem; max-width: 42em; }
.glass { background: rgba(10, 14, 26, .78); border: 1px solid var(--rule); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.roads-scroll { overflow-x: auto; overflow-y: hidden; border: 1px solid var(--rule); background: rgba(10, 14, 26, .8); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
/* The two roads draw themselves with the scroll (--draw runs from 0 to 1); each stop and its course arrive when the
   road reaches them (--at), then the stretch they share, then where it leads */
.roads { --draw: 1; position: relative; height: 360px; min-width: 880px; }
.roads-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.road { fill: none; stroke-width: 2; stroke-linecap: round; stroke-dasharray: var(--len) var(--len); }
.road-product, .road-ai { stroke-dashoffset: calc(var(--len) * (1 - min(1, var(--draw) / .8))); }
.road-product { stroke: var(--gold); }
.road-ai { stroke: var(--ultramarine); }
.road-meet { stroke: var(--fg); stroke-width: 3; stroke-dashoffset: calc(var(--len) * (1 - clamp(0, (var(--draw) - .8) / .1, 1))); }
.stop { stroke: #0a0e1a; stroke-width: 2; opacity: clamp(0, (var(--draw) - var(--at)) * 14, 1); }
.stop-product { fill: var(--gold); }
.stop-ai { fill: var(--ultramarine); }
.roads .end { fill: var(--gold); opacity: clamp(0, (var(--draw) - .88) * 10, 1); filter: drop-shadow(0 0 7px rgba(232, 183, 74, .85)); }
.road-name { position: absolute; transform: translate(calc(-100% - 12px), -50%); font: .62rem var(--mono); letter-spacing: .14em; text-transform: uppercase; opacity: clamp(0, var(--draw) * 12, 1); }
.road-name-product { color: var(--gold); }
.road-name-ai { color: #8fa5ff; }
.chip {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap; cursor: pointer;
  font: 500 .76rem/1 var(--body); color: var(--fg); background: rgba(10, 14, 26, .92); border: 1px solid; border-radius: 999px; padding: 6px 10px;
  opacity: clamp(0, (var(--draw) - var(--at)) * 14, 1);
}
.chip::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: var(--stem, 8px); background: currentColor; opacity: .3; }
.chip-ai { transform: translate(-50%, 0); }
.chip-ai::after { top: auto; bottom: 100%; }
.chip-product { border-color: rgba(232, 183, 74, .5); }
.chip-ai { border-color: rgba(93, 124, 255, .65); }
.chip:hover { border-color: var(--fg); }
.chip-product[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #1b1404; }
.chip-ai[aria-pressed="true"] { background: var(--ultramarine); border-color: var(--ultramarine); color: #fff; }
.roads .dest {
  position: absolute; transform: translateY(-50%); white-space: nowrap;
  font-family: var(--display); font-style: italic; font-size: 1.5rem; line-height: 1.1; color: var(--fg);
  opacity: clamp(0, (var(--draw) - .9) * 10, 1);
}
.roads .dest small { display: block; font-family: var(--mono); font-style: normal; font-size: .64rem; letter-spacing: .1em; color: var(--muted); margin-top: 6px; }
.detail { border: 1px solid var(--rule); border-top: 0; background: rgba(10, 14, 26, .8); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); padding: 14px 18px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 24px; min-height: 112px; }
.detail h3 { font-family: var(--display); font-weight: 500; font-size: 1.4rem; margin: 0; line-height: 1.15; }
.detail .grade { font-family: var(--mono); font-size: 1.05rem; color: var(--gold); text-align: right; font-variant-numeric: tabular-nums; }
.detail .sub { color: var(--muted); font-size: .82rem; }
.detail .skills { grid-column: 1 / -1; color: #c8cddb; font-size: .88rem; }
.detail ul { grid-column: 1 / -1; margin: 2px 0 0; padding-left: 18px; display: flex; flex-wrap: wrap; gap: 2px 22px; font-size: .86rem; }
.detail li a { color: var(--fg); text-decoration-color: var(--rule); text-underline-offset: 3px; }
.detail li a:hover { color: var(--gold); }

/* Chapter 5: projects as cards over the landscape */
.build { display: grid; grid-template-columns: minmax(0, 25rem) minmax(0, 1fr); gap: clamp(24px, 4vw, 72px); align-items: center; width: 100%; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; position: relative; z-index: 3; width: min(100%, 760px); justify-self: end; }
.card { background: rgba(10, 14, 26, .76); border: 1px solid var(--rule); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); padding: 14px 16px 14px; display: flex; flex-direction: column; gap: 7px; }
.card .k { font-family: var(--mono); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.card h3 { font-family: var(--display); font-weight: 500; font-size: 1.3rem; line-height: 1.15; margin: 0; }
.card h3 a { text-decoration: none; }
.card h3 a:hover { color: var(--gold); }
.text .card p, .card p { margin: 0; color: #c8cddb; font-size: .85rem; line-height: 1.5; }
.mini { margin: 4px 0 0; }
.mini svg { display: block; width: 100%; height: auto; overflow: visible; }
.mini .ax, .mini .tk line { stroke: rgba(233, 235, 242, .2); stroke-width: 1; }
.mini .tl text { font: 9px var(--mono); fill: var(--muted); text-anchor: middle; }
.mini .tl-l text { text-anchor: end; }
.mini .tl-v text { text-anchor: start; fill: var(--fg); }
.mini .dots-u circle { fill: var(--ultramarine); fill-opacity: .8; }
.mini .dot-g { fill: var(--gold); }
.mini .lb { font: 10px var(--body); fill: var(--muted); text-anchor: middle; }
.mini .lb-g { fill: var(--fg); }
.mini .bar { fill: var(--ultramarine); fill-opacity: .8; }
.mini .bar-g { fill: var(--gold); fill-opacity: 1; }
.flow { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; font: .7rem/1.4 var(--mono); color: var(--fg); }
.flow li::after { content: "→"; margin-left: 6px; color: var(--muted); }
.flow li.end { color: var(--gold); }
.flow li.end::after { content: none; }
.card .fig { font-family: var(--mono); font-size: .7rem; color: var(--gold); margin-top: auto; padding-top: 8px; border-top: 1px solid var(--rule); }
.more-link { color: var(--muted); text-underline-offset: 4px; font-size: .92rem; }
/* the GitHub mark beside links that open a repository */
.gh { width: .8em; height: .8em; margin-left: .4em; vertical-align: -.06em; fill: currentColor; opacity: .55; transition: opacity .2s; }
a:hover .gh, a:focus-visible .gh { opacity: 1; }
.more-link .gh { margin: 0 .45em 0 0; }
.more-link:hover { color: var(--fg); }

/* Chapter 6: the microphone */
.hello { margin-top: 4px; }
.text .hello .fine { margin: 12px 0 0; font-size: .8rem; color: var(--muted); }
.hear[aria-pressed="true"] { background: transparent; color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.hear[aria-pressed="true"] .bars i { animation: eq 1s ease-in-out infinite; }
.hear[aria-pressed="true"] .bars i:nth-child(2) { animation-delay: -.3s; }
.hear[aria-pressed="true"] .bars i:nth-child(3) { animation-delay: -.6s; }

/* Chapter 7: contact */
.mailrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 22px 0 6px; }
.mailtext { font-family: var(--mono); font-size: .95rem; color: var(--fg); user-select: all; margin-right: 6px; overflow-wrap: anywhere; }
a.hear { text-decoration: none; }
.hear.ghost { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 1px rgba(233, 235, 242, .3); }
.hear.ghost:hover { box-shadow: inset 0 0 0 1px var(--fg); filter: none; }
.text .quick { display: flex; gap: 20px; margin-top: 10px; }
.quick a { color: var(--muted); text-underline-offset: 4px; }
.quick a:hover { color: var(--fg); }
.p-portrait { aspect-ratio: .76; top: 44%; height: min(48svh, 460px); }
/* scrollable panels take touch and wheel input even inside the overlapping chapters */
.motion .ch .roads-scroll, .motion .ch .cards { pointer-events: auto; }

/* words that point at the animation are left out when there is none */
html:not(.motion) .motion-only { display: none; }

.js .line { will-change: transform, opacity; }

@media (max-height: 900px) and (min-width: 821px) {
  .roads-head p, .detail .skills { display: none; }
  .detail { min-height: 96px; padding: 10px 18px; }
}
@media (max-height: 780px) and (min-width: 821px) {
  .roads-panel { transform: scale(.85); transform-origin: 50% 0; }
  .detail .skills { display: none; }
}
@media (max-height: 720px) and (min-width: 821px) {
  h1 { font-size: clamp(2.4rem, 5.4vw, 4.2rem); }
  h2 { font-size: clamp(1.7rem, 3vw, 2.4rem); }
  .text p { margin-bottom: 10px; }
  .stage { padding-top: 76px; padding-bottom: 40px; }
}

@media (max-width: 820px) {
  body { font-size: 16px; }
  .hud { grid-template-columns: 1fr auto; }
  .where { display: none; }
  .hud-r a:first-of-type { display: none; }
  .stage {
    align-items: start;
    padding: calc(76px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .text { max-width: none; }
  .p-right {
    position: relative; right: auto; left: auto; top: auto; bottom: auto; transform: none;
    display: block; width: auto; max-width: none; height: min(24svh, 200px); justify-self: end; grid-area: 2 / 1; margin-top: 18px;
  }
  .photo::after { inset: -8px; }
  .photo figcaption { top: calc(100% + 12px); }
  /* a chapter whose words would fill a phone's screen turns a page there (the script splits it); the second page
     holds the rest of the words with the photo below them */
  .beat-photo { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; }
  /* projects: one row of cards to swipe through */
  .build { grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
  .cards { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; width: 100%; justify-self: stretch; padding-bottom: 4px; }
  .card { flex: 0 0 84%; scroll-snap-align: start; }
  .roads-head p { display: none; }
  .roads { height: 340px; }
  .detail { min-height: 0; padding: 10px 14px; }
  .detail .skills { display: none; }
  /* a course's projects in one line to swipe along, so the panel fits a short phone */
  .detail ul { flex-wrap: nowrap; overflow-x: auto; list-style: none; padding: 0 0 2px; gap: 2px 18px; scrollbar-width: none; }
  .detail li { flex: none; white-space: nowrap; }
  .vignette { background: linear-gradient(180deg, rgba(7, 10, 20, .8), rgba(7, 10, 20, .55) 62%, rgba(7, 10, 20, .15) 80%); }
  .vignette::after { display: none; }
}
/* short phones: a little tighter, so the longest chapter still fits on one screen */
@media (max-width: 820px) and (max-height: 700px) {
  body { font-size: 15px; }
  .text p { margin-bottom: 12px; line-height: 1.55; }
  h2 { font-size: 1.85rem; margin-bottom: 16px; }
  .lesson { font-size: 1.3rem; margin-top: 20px !important; }
}
@media (max-width: 820px), (pointer: coarse) {
  .grain { display: none; }
}

/* Static, readable version: reduced motion, or a viewport too short for pinned stages */
@media (prefers-reduced-motion: reduce), (max-height: 560px) {
  .grain { animation: none; }
  .sound[aria-pressed="true"] .bars i { animation: none; height: 8px; }
  .now .bars i { animation: none !important; }
  .ch { height: auto; }
  .stage { position: relative; height: auto; min-height: 100svh; overflow: visible; }
  .beat { grid-area: auto; }
  .roads-panel { margin-top: 40px; }
  /* the field still glows behind the words here, so they get a soft dark ground of their own */
  .text, .center { background: rgba(7, 10, 20, .8); box-shadow: 0 0 36px 28px rgba(7, 10, 20, .8); }
}
