/* Scroll prototype: the page scrolls, everything else stays fixed and is driven by the scroll position. */
html, body { height: auto; overflow-x: hidden; overflow-y: auto; }
html { scroll-snap-type: y proximity; }
.track { position: relative; pointer-events: none; }
.track .snap { position: absolute; left: 0; width: 1px; height: 1px; scroll-snap-align: start; }
.universe { cursor: default; }

/* cards: no inner scroll, so the wheel always moves the journey */
.card-host, body.is-side .card-host { overflow: visible; max-height: none; overscroll-behavior: auto; }
.card { padding-bottom: 0; }
.card > * { will-change: opacity, transform; }
.card-host:empty { display: none; }

.proto-chip { padding: 6px 12px; border-radius: 999px; border: 1px dashed var(--line); color: var(--muted); font-size: .75rem; white-space: nowrap; }

/* scroll cue on the first screen */
.cue { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: .9375rem; }
.cue i { position: relative; width: 22px; height: 34px; border: 1.5px solid var(--ink-2); border-radius: 12px; }
.cue i::after { content: ""; position: absolute; left: 50%; top: 7px; width: 3px; height: 7px; margin-left: -1.5px; border-radius: 2px; background: var(--accent); animation: cue 1.8s var(--ease) infinite; }
@keyframes cue { 0% { transform: translateY(0); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(12px); opacity: 0; } }

/* Eagle's timeline */
.when { font-family: var(--mono); font-size: .8125rem; color: var(--accent); letter-spacing: .02em; }
.phases { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 30em; }
.phases span { position: relative; padding-top: 12px; font-size: .75rem; color: var(--muted); transition: color .3s; }
.phases span::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .16); }
.phases span::after { content: ""; position: absolute; inset-inline-start: 0; top: 0; height: 2px; border-radius: 2px; background: var(--ink); width: calc(var(--k, 0) * 100%); }
.phases span.on { color: var(--ink); }
.coords { font-family: var(--mono); font-size: .9375rem; color: var(--ink-2); }

/* the dust gauge */
.gauge { display: grid; gap: 8px; max-width: 30em; }
.gauge-bar { position: relative; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .14); }
.gauge-fill { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 6px; background: linear-gradient(90deg, var(--ink), var(--accent)); width: calc(var(--k, 0) * 100%); }
.gauge-tick { position: absolute; top: -5px; width: 1.5px; height: 16px; background: var(--ink-2); }
.gauge-ticks { position: relative; height: 1.4em; font-size: .6875rem; color: var(--muted); }
.gauge-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
[dir="rtl"] .gauge-ticks span { transform: translateX(50%); }
.gauge-note { font-size: .75rem; color: var(--muted); }
.sun-state { font-weight: 600; }
.sun-state.is-low { color: var(--accent); }
.dust-veil { position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: 0;
  background: radial-gradient(ellipse at 60% 40%, rgba(150, 85, 40, .35), rgba(45, 22, 8, .85)); }

/* progress rail */
.rail { position: fixed; z-index: 20; inset-inline-end: var(--pad); top: 50%; transform: translateY(-50%); display: grid; gap: 22px; padding: 4px 0; }
.rail::before, .rail::after { content: ""; position: absolute; inset-inline-end: 4px; top: 0; width: 1px; height: 100%; background: rgba(255, 255, 255, .16); }
.rail::after { background: var(--ink); height: calc(var(--k, 0) * 100%); }
.rail a { position: relative; z-index: 1; display: flex; align-items: center; justify-content: flex-end; gap: 10px; color: var(--muted); font-size: .75rem; text-decoration: none; }
.rail a i { width: 9px; height: 9px; border-radius: 50%; background: #000; border: 1.5px solid rgba(255, 255, 255, .4); transition: background .3s, border-color .3s, transform .3s var(--ease); }
.rail a span { opacity: 0; transform: translateX(6px); transition: opacity .3s, transform .3s var(--ease); }
.rail:hover a span, .rail a.is-here span { opacity: 1; transform: none; }
.rail a.is-past i { background: var(--ink); border-color: var(--ink); }
.rail a.is-here i { background: var(--accent); border-color: var(--accent); transform: scale(1.35); }
.rail a.is-here { color: var(--ink); }
.rail, .rail-where { transition: opacity .4s; }
.card-right .rail, .card-right .rail-where { opacity: 0; pointer-events: none; }

.gauge-ticks span:last-child { transform: translateX(-100%); }
[dir="rtl"] .gauge-ticks span:last-child { transform: translateX(100%); }
.card .hint { display: none; }             /* "press Next" belonged to the old step-by-step journey */

@media (max-width: 760px) {
  /* phones: the rail becomes a row of dots under the top bar, clear of the card */
  .rail { top: calc(env(safe-area-inset-top, 0px) + 64px); transform: none; grid-auto-flow: column; gap: 12px; }
  .rail::before { inset-inline-end: 0; top: 4px; width: 100%; height: 1px; }
  .rail::after { inset-inline-end: auto; inset-inline-start: 0; top: 4px; width: calc(var(--k, 0) * 100%); height: 1px; }
  .rail a span { display: none; }
  .proto-chip { display: none; }
  .card-host, body.is-side .card-host, body.is-wide .card-host { max-height: none; overflow: visible; }
}
@media (prefers-reduced-motion: reduce) { .cue i::after { animation: none; opacity: 1; } }

/* ---- cinematic pass ---- */
/* titles rise word by word out of a mask */
.card h1 .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .1em; margin-bottom: -.1em; }
.card h1 .w > span { display: inline-block; will-change: transform; }

/* the huge outlined year behind the lander */
.bigtype { position: fixed; z-index: 2; inset-inline-end: 5vw; top: 15vh; margin: 0; pointer-events: none;
  font-size: clamp(7rem, 24vw, 22rem); font-weight: 600; line-height: .9; letter-spacing: -.06em; font-variant-numeric: tabular-nums;
  color: transparent; -webkit-text-stroke: 1.5px rgba(242, 239, 232, .28); }

/* the last call: one sentence in the middle of the dark */
body.is-center .card-host { inset: 0; width: auto; height: 100dvh; display: grid; place-items: center; padding-inline: var(--pad); transform: none; }
.card-center { max-width: 22em; justify-items: center; text-align: center; }
.card-center h1 { font-size: clamp(2rem, 4.6vw, 4rem); }
.card-center .lead { color: var(--muted); }

/* milestone lines on the long flight */
.flight-mile { margin-top: 14px; font-size: .9375rem; color: var(--ink-2); max-width: 24em; animation: mile .9s var(--ease) both; }
@keyframes mile { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 760px) {
  .bigtype { inset-inline-end: auto; inset-inline-start: 12px; top: 16vh; font-size: 38vw; }
  body.is-center .card-host { bottom: 0; max-height: none; }
}
@media (prefers-reduced-motion: reduce) { .flight-mile { animation: none; } }
.flight-clock { white-space: nowrap; }
@media (max-width: 760px) { .flight-clock { font-size: clamp(2rem, 11vw, 2.6rem); } }

/* sound */
.start-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; }
.btn-sound-on { gap: 10px; }
body.is-quaking .space { animation-duration: .09s; }
@media (prefers-reduced-motion: reduce) { body.is-quaking .space { animation: none; } }

/* captions for the real Apollo 11 voices */
.caption { position: fixed; z-index: 16; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 84px); transform: translateX(-50%); margin: 0;
  width: max-content; max-width: min(36em, calc(100vw - 32px)); padding: 7px 14px; border-radius: 8px; background: rgba(0, 0, 0, .62);
  font-size: .9375rem; line-height: 1.4; text-align: center; color: var(--ink); animation: mile .4s var(--ease) both; }
.caption-who { font-family: var(--mono); font-size: .6875rem; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
@media (max-width: 760px) { .caption { top: calc(env(safe-area-inset-top, 0px) + 92px); font-size: .875rem; } }

/* ---- full journey ---- */
/* a story, photo or the sources sheet is open: the journey behind it holds still */
html:has(body.layer-open) { overflow: hidden; }
/* seventeen resting places on the rail */
.rail { gap: 13px; }
.rail a i { width: 8px; height: 8px; }
@media (max-width: 760px) {
  .rail { gap: 7px; inset-inline-end: 12px; }
  .rail a i { width: 6px; height: 6px; border-width: 1px; }
}
@media (max-height: 560px) { .rail { display: none; } }

/* tap a machine to see its real photo */
body.over-machine { cursor: pointer; }
.pick-hint { position: fixed; z-index: 30; left: 0; top: 0; margin: 0; padding: 4px 10px; border-radius: 999px; pointer-events: none;
  background: rgba(0, 0, 0, .7); border: 1px solid var(--line); font-size: .75rem; color: var(--ink); white-space: nowrap; }

/* ---- the loading screen: real progress, opens only when everything is ready ---- */
.boot-full { gap: 14px; }
.boot-title { font-size: clamp(2rem, 6vw, 3.4rem); font-weight: 600; letter-spacing: -.04em; color: var(--ink); margin: 6px 0 0; }
.boot-full .boot-text { min-height: 1.4em; text-align: center; padding-inline: 16px; }
.boot-bar { width: min(320px, 70vw); height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.boot-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--ink), var(--accent)); transform-origin: left; transform: scaleX(0); transition: transform .25s linear; }
[dir="rtl"] .boot-bar i { transform-origin: right; }
.boot-meta { display: flex; gap: 12px; font-family: var(--mono); font-size: .75rem; color: var(--muted); }

/* ---- the tour ---- */
.btn-tour { gap: 6px; }
html.touring { scroll-snap-type: none; }
.tour-stop { position: fixed; z-index: 40; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%); background: rgba(0, 0, 0, .7); }

/* ---- no 3D: the journey as a plain page of cards ---- */
body.no-3d .space, body.no-3d .vignette, body.no-3d .rail, body.no-3d #sound-btn, body.no-3d .flight, body.no-3d .dust-veil { display: none; }
body.no-3d .card-host { position: static; width: auto; max-height: none; transform: none; }
.text-journey { display: grid; gap: 72px; max-width: 640px; margin: 0 auto; padding: 110px 16px 80px; }
.text-journey .card { opacity: 1; }
.tj-stop { scroll-margin-top: 90px; padding-top: 24px; border-top: 1px solid var(--line); }

/* ---- the science it made possible, and where it is today ---- */
.learned { position: relative; padding: 10px 14px; border-radius: 10px; background: rgba(255, 255, 255, .07); border-inline-start: 3px solid var(--accent);
  font-size: .9375rem; line-height: 1.45; color: var(--ink); max-width: 34em; text-shadow: none; }
.learned-k { display: block; margin-bottom: 2px; font-family: var(--mono); font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.now-far { font-size: .8125rem; color: var(--muted); max-width: 34em; }
.thumb-now img { filter: grayscale(.2); }
.photo-tabs { justify-self: center; margin-bottom: 4px; }
.lightbox img.wide { width: min(1100px, 92vw); max-height: none; }

/* ---- sound button: a speaker with the word, so nobody mistakes it for "more" ---- */
.sound-tool { gap: 7px; }
.spk { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.spk-body { fill: currentColor; stroke: none; }
.sound-tool[aria-pressed="true"] .spk-off, .sound-tool[aria-pressed="false"] .spk-on { display: none; }
.sound-tool[aria-pressed="false"] { color: var(--muted); }

/* ---- where you are, in words, next to the rail ---- */
.rail-where { position: fixed; z-index: 20; inset-inline-end: var(--pad); top: calc(50% - 196px); margin: 0; transform: translateY(-100%);
  font-family: var(--mono); font-size: .6875rem; letter-spacing: .04em; color: var(--ink-2); white-space: nowrap; }
@media (max-width: 760px) { .rail-where { top: calc(env(safe-area-inset-top, 0px) + 78px); inset-inline-end: 12px; transform: none; } }
body.no-3d .rail-where { display: none; }

/* ---- the loading screen's hook ---- */
.boot-hook { max-width: 30em; margin: 0; padding-inline: 16px; text-align: center; font-size: .9375rem; line-height: 1.45; color: var(--ink-2); min-height: 1.4em; }

/* ---- phones: shorter machine cards, so the machine stays in view above them ---- */
@media (max-width: 760px) {
  .card-machine .voice-line { display: none; }        /* the quote is still read aloud by Listen */
  .card-machine { gap: 10px; }
  .card-machine h1 { font-size: 2.1rem; }
  .card-machine .now { font-size: .8125rem; }
  .learned { padding: 8px 12px; font-size: .875rem; }
  .card-machine .info { display: none; }              /* model notes stay in the full story and on desktop */
}

/* status and the live sky share one quiet line on machine cards */
.status-line .now { margin-inline-start: 10px; font-size: .8125rem; color: var(--muted); }
.status-line .now::before { top: .5em; }
.card-machine .info summary { opacity: .7; }

/* the caption on a hop across one world: where to, how far, which way */
.flight .hop-name { font-family: inherit; font-size: clamp(1.6rem, 3vw, 2.4rem); font-weight: 600; letter-spacing: -.02em; white-space: normal; }
@media (max-width: 760px) { .flight .hop-name { font-size: 1.6rem; } }

/* "Can you spot it?" */
.photo-frame { position: relative; width: fit-content; margin: 0 auto; }
.photo-frame img { display: block; }
.photo-frame.is-spot img { height: min(70vh, calc(92vw / var(--ar, 1))); width: auto; max-height: none; cursor: crosshair; }
.photo-frame.is-spot.is-shown img { cursor: default; }
.spot-mark { position: absolute; pointer-events: none; border-radius: 50%; transform: translate(-50%, -50%); }
.spot-ring { width: 54px; height: 54px; border: 2px solid var(--accent); box-shadow: 0 0 0 2px rgba(0, 0, 0, .5); animation: spot-ring 1s var(--ease) both; }
.spot-tap { width: 12px; height: 12px; background: #fff; border: 2px solid #000; }
@keyframes spot-ring { from { opacity: 0; width: 220px; height: 220px; } }
@media (prefers-reduced-motion: reduce) { .spot-ring { animation: none; } }
.linkish { background: none; border: 0; padding: 0; color: var(--ink); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.thumb.is-spot { position: relative; }
.thumb.is-spot::after { content: "?"; position: absolute; top: 3px; inset-inline-end: 3px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #000; font: 700 .6875rem/1 var(--mono, monospace); box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .6); z-index: 1; }

/* place markers on the journey: a glowing dot, a short leader line, the name (no pill) */
.label.pin i { width: 8px; height: 8px; margin: 3px; border: 0; background: var(--ink); box-shadow: 0 0 0 4px rgba(255, 255, 255, .14), 0 0 14px rgba(255, 255, 255, .55); animation: pin-glow 2.4s ease-in-out infinite; }
.label.pin.status-still-working i { background: var(--accent); box-shadow: 0 0 0 4px rgba(255, 106, 61, .22), 0 0 14px var(--accent); }
.label.pin span { position: relative; padding: 0 0 0 24px; border: 0; border-radius: 0; background: none; font-size: .8125rem; font-weight: 600; color: var(--ink); text-shadow: 0 1px 8px #000, 0 0 3px #000; }
.label.pin span::before { content: ""; position: absolute; left: 2px; top: 50%; width: 16px; height: 1px; background: rgba(255, 255, 255, .55); }
.label.pin.flip span { padding: 0 24px 0 0; }
.label.pin.flip span::before { left: auto; right: 2px; }
button.label.pin:hover span { background: none; color: var(--accent); }
@keyframes pin-glow { 50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, .06), 0 0 18px rgba(255, 255, 255, .7); } }
@media (prefers-reduced-motion: reduce) { .label.pin i { animation: none; } }

/* desktop: the flight clock sits on the card's side, so the world you fly toward stays clear */
@media (min-width: 761px) {
  .flight { left: auto; inset-inline-start: var(--pad); transform: translateY(-50%); justify-items: start; text-align: start; }
}

/* "turn on sound" at the moments that need it (only while sound is off) */
.sound-hint { position: fixed; z-index: 25; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: inline-flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: 999px; border: 1px solid var(--accent); background: rgba(10, 10, 10, .82); backdrop-filter: blur(8px); color: var(--ink); font: 600 .875rem/1.2 inherit; cursor: pointer; white-space: nowrap; animation: hint-in .5s var(--ease) both, hint-glow 2.4s ease-in-out .5s infinite; }
.sound-hint:hover { background: var(--accent); color: #000; }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes hint-glow { 50% { box-shadow: 0 0 0 6px rgba(255, 106, 51, .15); } }
@media (max-width: 760px) { .sound-hint { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 96px); font-size: .8125rem; max-width: calc(100vw - 32px); white-space: normal; text-align: center; } }
@media (prefers-reduced-motion: reduce) { .sound-hint { animation: none; } }

/* Arabic: English lines inside the page (names, and text not yet translated) read left to right in the right order,
   while still sitting on the right like the Arabic around them */
[dir="rtl"] :is(.card, .flight, .lightbox, .caption, .sound-hint) :is(h2, p, figcaption, li, .lbl),
[dir="rtl"] .label span { unicode-bidi: plaintext; text-align: right; }
[dir="rtl"] .card-center :is(h2, p) { text-align: center; }
[dir="rtl"] .card h1 { text-align: right; }
[dir="rtl"] .card-center h1 { text-align: center; }

/* phones: no room in the top bar; the Sources page is linked from the last card */
@media (max-width: 760px) { .tool-sources { display: none; } }
