/* Pale Blue Echo: a scroll journey. Direction "colour chapters" (taste-skill seed 1532448286), adapted:
   the journey chapters are transparent over the live Earth (fixed canvas); the closing chapters are
   tone steps of the same night, lit by the swarm's blue (after the vgpu reference). */
:root {
  --ground: #02030a;
  --ink: #eef2f8;
  --muted: #9aa6b8;
  --accent: #a896ff;
  --accent-ink: #0b0718;
  --dark: #0b0718;
  --surface: #070b18;
  --surface-2: #0d1428;
  --deep: #5a45d6;
  --mid: #7f6af0;
  --pale: #d6ceff;
  --font-display: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-text: "Inter", "Helvetica Neue", Arial, sans-serif;
  --step-display: clamp(40px, 4.6vw, 80px);
  --step-year: clamp(40px, 4.2vw, 70px);
  --step-head: clamp(30px, 3.2vw, 56px);
  --step-chapter: clamp(22px, 2vw, 34px);
  --step-lead: clamp(16px, 1.15vw, 19px);
  --step-body: clamp(15px, 1vw, 16px);
  --step-small: 14px;
  --m: max(20px, env(safe-area-inset-left, 0px));
  --bar-ink: var(--ink);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--ground); }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font-text); font-size: var(--step-body); line-height: 1.5; -webkit-font-smoothing: antialiased; }
img, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.06em; line-height: 0.98; margin: 0; }
h1 span, h2 span { display: block; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
/* The film fades in once its first craft is ready, so the opening never shows a half-formed swarm. */
.js #scene { opacity: 0; transition: opacity 1.2s ease; }
.js.film-ready #scene { opacity: 1; }
main, .field, .numbers, .foot { position: relative; z-index: 1; }

/* Header: wordmark, three links, the sound switch. It takes the ink of the chapter under it. */
.bar { background: rgba(2, 3, 10, .86); position: fixed; z-index: 5; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 22px var(--m); color: var(--bar-ink); transition: color .3s ease; }
.wordmark { font-weight: 500; font-size: 18px; letter-spacing: -0.08em; text-decoration: none; }
.bar nav { display: flex; gap: 28px; align-items: center; }
.bar nav a, #sound { font: 400 var(--step-small)/1 var(--font-text); text-decoration: none; color: inherit; background: none; border: 0; padding: 6px 0; cursor: pointer; transition: opacity .2s ease; }
.bar nav a:hover, #sound:hover { opacity: .7; }
#sound[aria-pressed="false"] { opacity: .6; }

.button { display: inline-flex; align-items: center; min-height: 56px; padding: 0 28px; background: var(--accent); color: var(--accent-ink); font: 500 15px/1 var(--font-text); text-decoration: none; border: 0; cursor: pointer; transition: background-color .2s ease, transform .15s ease; }
.button:hover { background: var(--pale); }
.button:active { transform: translateY(1px) scale(.99); }
/* The quiet action: a step of tone above the ground, no line; the arrow drifts down the way the page goes. */
.button.quiet { background: var(--surface-2); color: var(--ink); gap: 12px; }
.button.quiet:hover { background: #1d2140; }
.button.quiet .drift { display: inline-block; color: var(--accent); animation: drift 1.8s cubic-bezier(.4, 0, .2, 1) infinite; }
@keyframes drift { 0%, 100% { transform: translateY(-2px); opacity: .7; } 50% { transform: translateY(3px); opacity: 1; } }
.button.dark { background: var(--accent); color: var(--accent-ink); }
.button.dark:hover { background: var(--pale); }

/* Hero: the headline across the top, Explorer 1 standing on the horizon, the action at the foot. */
/* The opening frame: the title centred over the close-up nose of the first rocket; the scroll pulls
   back until the whole rocket stands in frame. */
.hero { min-height: 100svh; position: relative; }
.hero-inner { position: sticky; top: 0; height: 100svh; padding: 15svh var(--m) 0; display: flex; flex-direction: column; justify-content: flex-start; align-items: center; text-align: center; gap: 24px; }
.hero h1 { font-size: clamp(56px, 7.6vw, 136px); line-height: 0.95; }
.lede { font-size: var(--step-lead); line-height: 1.55; font-weight: 300; max-width: 36ch; }
.hero .lede { max-width: 44ch; }
.fact b { color: var(--ink); font-weight: 500; }

/* Journey chapters: the craft holds the centre; when and what on the left, the story on the right.
   The two sides pin while the craft holds, and leave as the swarm carries it to the next era. */
.chapter { min-height: 140svh; display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; padding: 0 var(--m); position: relative; }
.side { position: sticky; top: 0; height: 100svh; align-self: start; display: flex; flex-direction: column; gap: 20px; }
.side.l { grid-column: 1 / 5; padding-top: 12svh; }
.side.r { grid-column: 9 / 13; padding-top: 36svh; }
.year { font-weight: 500; font-size: var(--step-year); line-height: 0.9; letter-spacing: -0.06em; color: var(--accent); font-variant-numeric: tabular-nums; }
.chapter h2 { font-size: var(--step-chapter); line-height: 1.1; }
.story { max-width: 34ch; font-size: var(--step-lead); line-height: 1.55; font-weight: 300; color: var(--ink); }
.fact { color: var(--muted); }
.plate { margin: 8px 0 0; width: min(100%, 300px); }
.plate figcaption { margin-top: 10px; color: var(--muted); font-size: var(--step-small); }
.plate img { aspect-ratio: 4 / 5; object-fit: cover; width: 100%; max-height: 32svh; }
.plate.film video { aspect-ratio: 16 / 9; object-fit: cover; width: 100%; background: #1a1d22; }

/* The beat caption: one plain line over the timeline, naming the shot on screen. */
.caption { margin: 0 0 6px; text-align: center; font-size: var(--step-small); color: var(--muted); transition: opacity .3s ease; }
.caption.dim { opacity: 0.35; }

/* The timeline: fixed along the bottom through the journey, the page's scroll is its playhead. */
.timeline { position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; padding: 0 var(--m) max(14px, env(safe-area-inset-bottom, 0px)); transition: opacity .4s ease, transform .4s ease; }
.timeline.away { opacity: 0; transform: translateY(24px); pointer-events: none; }
.scrub { position: relative; width: 100%; height: 66px; cursor: grab; touch-action: none; outline: none; }
.scrub:active { cursor: grabbing; }
.scrub:focus-visible .scrub-head { outline: 2px solid var(--ink); outline-offset: 3px; }
.scrub-track { position: absolute; left: 0; right: 0; top: 0; height: 44px; }
.tick { position: absolute; bottom: 0; width: 2px; transform: translateX(-1px); background: var(--muted); opacity: calc(0.3 + var(--g, 0) * 0.7); height: calc(6px + var(--g, 0) * 24px); transition: height .14s ease-out; }
.tick.stop { background: var(--ink); height: calc(14px + var(--g, 0) * 24px); }
.scrub-head { position: absolute; bottom: -2px; width: 3px; height: 46px; transform: translateX(-1.5px); background: var(--accent); }
.scrub-labels { position: absolute; left: 0; right: 0; top: 50px; height: 16px; font: 400 13px/1 var(--font-text); color: var(--muted); font-variant-numeric: tabular-nums; }
.scrub-labels span { position: absolute; transform: translateX(-50%); }
.scrub-labels span:first-child { transform: none; }
.scrub-labels span:last-child { transform: translateX(-100%); }

/* Scenes: a picture held while the page scrolls past it. --p runs 0 to 1 over the hold. */
.scene { position: relative; z-index: 2; height: 300svh; }
.scene-stage { position: sticky; top: 0; height: 100svh; overflow: hidden; background: var(--ground); }
.scene-pic { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scene-words { position: absolute; left: var(--m); top: 104px; max-width: min(620px, 46vw); display: grid; gap: 22px; }
.scene-words h2 { font-size: var(--step-head); }
.scene-words p { max-width: 40ch; }
.rise-scene .scene-pic { object-position: 50% 58%; }
.rise-scene.is-live .scene-pic { clip-path: inset(calc((1 - var(--e, 1)) * 16%) calc((1 - var(--e, 1)) * 5%) calc((1 - var(--e, 1)) * 16%) calc((1 - var(--e, 1)) * 48%)); transform: scale(calc(1.12 - var(--e, 1) * 0.12)); }
.rise-scene .scene-words { top: 30svh; }
.dot-scene .scene-pic { object-position: 59.5% 51.8%; transform-origin: 59.5% 51.8%; }
.dot-scene.is-live .scene-pic { transform: scale(calc(1 + var(--e, 0) * 4)); }
.dot-ring { position: absolute; left: 59.5%; top: 51.8%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; border: 2px solid var(--accent); }
.dot-scene.is-live .dot-ring { transform: scale(calc(2.2 - var(--e, 0) * 1.2)); opacity: calc(var(--e, 0) * 1.4); }


/* Closing fields. */
.field { min-height: 100svh; padding: 120px var(--m) 40px; }
.moon { background: var(--surface); }
.atmosphere { background: var(--surface-2); }
.paper { background: var(--surface); }

.gallery { display: grid; place-items: start center; padding-top: 18svh; overflow: hidden; position: relative; z-index: 1; }
.gallery h2 { font-size: var(--step-display); text-align: center; }
.print { position: absolute; margin: 0; transition: transform .25s ease; z-index: 2; }
.print img { width: 100%; object-fit: cover; }
.print:hover { transform: rotate(0deg) scale(1.02); z-index: 3; }
.p1 { width: 22vw; left: 20vw; top: 46svh; transform: rotate(-8deg); }
.p1 img { aspect-ratio: 1; }
.p2 { width: 28vw; left: 50vw; top: 52svh; transform: rotate(6deg); }
.p2 img { aspect-ratio: 16 / 10; }
.p3 { width: 17vw; right: var(--m); bottom: -6svh; transform: rotate(-3deg); }
.p3 img { aspect-ratio: 3 / 2; }
.gallery-note { position: absolute; left: var(--m); right: var(--m); bottom: 28px; max-width: 46ch; }

.numbers { min-height: 100svh; background: var(--ground); padding: 160px var(--m) 160px; display: grid; grid-template-columns: repeat(12, 1fr); grid-template-rows: 14svh 12svh auto; column-gap: 8px; }
.numbers h2 { grid-column: 6 / 13; grid-row: 1; align-self: end; font-size: var(--step-head); line-height: 1.05; padding-bottom: 20px; }
.tile { display: flex; flex-direction: column; justify-content: space-between; padding: 28px; gap: 24px; }
.tile .figure { font-family: var(--font-display); font-weight: 500; font-size: clamp(40px, 4.4vw, 76px); line-height: 0.95; letter-spacing: -0.06em; }
.tile p:not(.figure) { max-width: 30ch; }
.t1 { grid-column: 1 / 6; grid-row: 1 / 4; min-height: 70svh; background: var(--accent); color: var(--dark); }
.t2 { grid-column: 6 / 10; grid-row: 2 / 4; min-height: 44svh; align-self: start; background: var(--surface-2); }
.t3 { grid-column: 10 / 13; grid-row: 3; margin-top: 0; min-height: 34svh; align-self: start; background: var(--deep); }
.t3 { margin-top: 0; }

.your-year { display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; row-gap: 48px; align-content: center; }
.your-year h2 { grid-column: 1 / 13; font-size: var(--step-head); text-align: center; }
.year-form { grid-column: 1 / 6; display: grid; gap: 14px; align-content: start; }
.year-form label { font-weight: 500; }
.year-row { display: flex; gap: 8px; }
#born { width: 5.2ch; font: 500 var(--step-head)/1 var(--font-display); letter-spacing: -0.06em; color: var(--ink); background: var(--surface); border: 0; padding: 10px 14px; min-width: 0; }
#born::placeholder { color: #5f5c7d; }
#born:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.year-row .button { min-height: auto; }
.help { font-size: var(--step-small); }
.year-answer { grid-column: 7 / 13; display: grid; gap: 18px; align-content: start; }
.answer-big { font-size: var(--step-lead); font-weight: 500; line-height: 1.4; max-width: 28ch; }
.year-answer a { font-weight: 500; }
.year-answer p { max-width: 52ch; }

.close { display: grid; grid-template-rows: 1fr auto; min-height: 100svh; }
.close h2 { font-size: var(--step-display); align-self: center; text-align: center; }
.close-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; flex-wrap: wrap; }
.close-foot p { font-size: var(--step-lead); line-height: 1.35; max-width: 34ch; }

.foot { background: var(--ground); padding: 120px var(--m) 40px; }
.mark { display: flex; align-items: flex-end; gap: 4px; height: 34svh; margin: 0 0 56px; }
.mark span { flex: 1; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 0.08em; font: 500 var(--step-head)/1 var(--font-display); letter-spacing: -0.06em; color: var(--dark); background: var(--accent); height: 100%; }
.mark i { width: 2.4vw; }
.mark span:nth-child(3n) { background: var(--mid); height: 78%; }
.mark span:nth-child(3n+1) { height: 92%; }
.mark span:nth-child(4n) { background: var(--deep); height: 64%; }
.mark span:nth-child(5n) { background: var(--pale); height: 86%; }
.foot-cols { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 32px; font-size: var(--step-small); color: var(--muted); }
.foot-cols p { max-width: 70ch; }

/* Entrances: each part rises once as its section arrives. Content shows without the script. */
.js [data-rise] { opacity: 0; transform: translateY(28px); transition: opacity .9s cubic-bezier(.2,.7,.1,1), transform .9s cubic-bezier(.2,.7,.1,1); transition-delay: calc(var(--d, 0) * 80ms); }
.js [data-rise].in { opacity: 1; transform: none; }

/* Phones and portrait tablets: the craft holds the top half, the words pass under it on a flat scrim. */
@media (max-width: 1023px) {
  .chapter { display: block; min-height: 0; padding: 50svh var(--m) 24svh; }
  .side { position: relative; height: auto; padding: 0 20px; margin: 0 -20px; background: rgba(5, 6, 8, .82); gap: 14px; }
  .side.l { padding-top: 22px; }
  .side.r { padding-top: 14px; padding-bottom: 22px; }
  .story { max-width: 40ch; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .chapter { display: grid; grid-template-columns: 1fr 1fr; column-gap: 0; align-content: start; }
  .side.l { grid-column: 1; padding-bottom: 22px; }
  .side.r { grid-column: 2; padding-top: 22px; margin-left: 0; }
  .bar { background: var(--bar-bg, rgba(5, 6, 8, .82)); padding-block: 16px; }
  .plate { width: min(56%, 280px); }
}
@media (max-width: 1100px) and (min-width: 768px) {

}
@media (max-width: 767px) {
  :root { --step-display: clamp(30px, 8.6vw, 52px); --step-year: clamp(34px, 9vw, 48px); --step-head: clamp(24px, 6.4vw, 34px); --step-chapter: clamp(17px, 4.6vw, 20px); }
  .bar nav a:not([href="#your-year"]) { display: none; }
  .hero-inner { gap: 20px; }
  .timeline { padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
  .scrub-labels span:nth-child(2), .scrub-labels span:nth-child(4) { display: none; }
  .scene { height: 240svh; }
  .scene-words, .rise-scene .scene-words { right: var(--m); max-width: none; top: 84px; }
  .p1 { width: 52vw; left: 6vw; top: 20svh; }
  .p2 { width: 60vw; left: 34vw; top: 46svh; }
  .p3 { display: none; }
  .numbers { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto; row-gap: 28px; column-gap: 6px; padding: 120px var(--m); }
  .numbers h2 { grid-column: 1 / 3; grid-row: auto; font-size: 26px; }
  .t1 { grid-column: 1 / 3; grid-row: auto; min-height: 56vw; }
  .t2 { grid-column: 1 / 3; grid-row: auto; min-height: 0; margin-left: 18vw; }
  .t3 { grid-column: 1 / 3; grid-row: auto; min-height: 0; margin-right: 18vw; }
  .gallery h2 { font-size: var(--step-head); }
  .tile { padding: 18px; }
  .your-year h2, .close h2 { font-size: var(--step-head); }
  .year-form, .year-answer { grid-column: 1 / 13; }
  .mark { height: 18svh; }
  .mark span { font-size: 7vw; }
  .foot-cols { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .js #scene { transition: none; }
  .js [data-rise] { opacity: 1; transform: none; transition: none; }
  .print, .button, .bar { transition: none; }
  .button.quiet .drift { animation: none; }
  .scene { height: auto; }
  .scene-stage { position: relative; }
}
