/* Late Light — the planetarium's late-night show */

:root {
  --bg: #06070f;
  --ink: #efe7d6;
  --mute: rgba(239, 231, 214, 0.62);
  --faint: rgba(239, 231, 214, 0.38);
  --line: rgba(239, 231, 214, 0.14);
  --gold: #f3c27a;
  --red: #ff6a45;
  --shift: 0;
  --accent: var(--gold);
  --accent: color-mix(in oklab, var(--gold), var(--red) calc(var(--shift) * 100%));
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body: "Instrument Sans", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --gutter: clamp(20px, 5vw, 72px);
  --size: min(56vw, 400px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--ink);
  scroll-behavior: smooth;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}
html[data-motion="off"] { scroll-behavior: auto; }

body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  overflow-x: clip;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: block;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.055;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .7 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

/* ---------- chrome ---------- */

.skip {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 50;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  font-size: 14px;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip:focus-visible { transform: none; outline: 2px solid var(--accent); outline-offset: 2px; }

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px var(--gutter);
  pointer-events: none;
}
.top > * { pointer-events: auto; }

.wordmark {
  font-family: var(--display);
  font-variation-settings: "opsz" 24, "wght" 500;
  font-size: 20px;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}

.motion {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(6, 7, 15, 0.55);
  color: var(--mute);
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.motion:hover { color: var(--ink); border-color: var(--faint); }
.motion:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.motion-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
html[data-motion="off"] .motion-dot { background: var(--faint); box-shadow: none; }

.rail {
  position: fixed;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rail a {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
}
.rail a::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--faint);
  transition: background 0.3s, transform 0.3s, box-shadow 0.3s;
}
.rail a span {
  position: absolute;
  right: 26px;
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  white-space: nowrap;
  font: 400 12px/1 var(--mono);
  letter-spacing: 0.04em;
  color: var(--mute);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.rail a:hover span, .rail a:focus-visible span, .rail a.active span { opacity: 1; transform: translateY(-50%); }
.rail a.active::before { background: var(--accent); transform: scale(1.4); box-shadow: 0 0 12px var(--accent); }
.rail a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hud {
  position: fixed;
  left: var(--gutter);
  bottom: 22px;
  z-index: 20;
  width: min(352px, calc(100vw - 2 * var(--gutter)));
  padding: 14px 16px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(6, 7, 15, 0.6);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  font-family: var(--mono);
  font-size: 12px;
  transition: opacity 0.4s;
}
.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 3px 0;
}
.hud-k { color: var(--faint); letter-spacing: 0.06em; text-transform: uppercase; font-size: 10px; white-space: nowrap; }
.hud-v { color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
#hud-dist { color: var(--accent); }
.hud-bar {
  position: relative;
  height: 2px;
  margin-top: 10px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.hud-bar i {
  position: absolute;
  inset: 0;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
}

/* ---------- chapters ---------- */

main { position: relative; z-index: 2; }

.chapter {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: clamp(24px, 6vw, 96px);
  padding: clamp(80px, 12vh, 140px) var(--gutter);
  max-width: 1240px;
  margin: 0 auto;
}
.chapter:nth-of-type(odd) .object { order: 2; }

.object {
  margin: 0;
  display: grid;
  place-items: center;
  min-height: min(60vw, 460px);
  will-change: transform;
}

.copy { max-width: 520px; }

.eyebrow {
  margin: 0 0 18px;
  font: 400 12px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}
.idx { color: var(--accent); margin-right: 10px; }

h1, h2 {
  margin: 0 0 22px;
  font-family: var(--display);
  font-weight: 300;
  font-variation-settings: "opsz" 144, "wght" 300;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
h1 { font-size: clamp(72px, 15vw, 190px); line-height: 0.9; }
h2 { font-size: clamp(42px, 6.2vw, 84px); line-height: 0.98; }
h1 em, h2 em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "wght" 300;
  color: var(--accent);
}

.copy p, .lede { color: var(--mute); margin: 0; font-size: clamp(16px, 1.3vw, 19px); }

.copy > *, .hero-copy > * {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}
.chapter.is-in .copy > *, .chapter.is-in .hero-copy > * { opacity: 1; transform: none; }
.chapter.is-in .copy > :nth-child(2), .chapter.is-in .hero-copy > :nth-child(2) { transition-delay: 0.08s; }
.chapter.is-in .copy > :nth-child(3), .chapter.is-in .hero-copy > :nth-child(3) { transition-delay: 0.16s; }
.chapter.is-in .copy > :nth-child(4), .chapter.is-in .hero-copy > :nth-child(4) { transition-delay: 0.24s; }
.chapter.is-in .copy > :nth-child(5) { transition-delay: 0.32s; }

.object > * {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 1.2s var(--ease), transform 1.4s var(--ease);
}
.chapter.is-in .object > * { opacity: 1; transform: none; }

/* ---------- hero ---------- */

.hero {
  grid-template-columns: 1fr;
  align-items: start;
  overflow: hidden;
  max-width: none;
  padding-top: clamp(110px, 18vh, 180px);
  padding-bottom: 36vh;
}
.hero-copy { max-width: 760px; margin: 0 auto; width: 100%; }
.hero .lede { max-width: 560px; }

.hint {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 40px;
  color: var(--mute);
  text-decoration: none;
  font: 400 12px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.hint:hover { color: var(--ink); }
.hint svg { animation: nod 2.2s var(--ease) infinite; }
@keyframes nod { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

.earth {
  position: absolute;
  left: 50%;
  bottom: calc(-180vmax + 26vh);
  width: 180vmax;
  height: 180vmax;
  margin-left: -90vmax;
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 2%, #9fd0ff 0, #4f93ec 10%, #1d5bc0 24%, #0f357f 40%, #071a44 55%, #040b22 70%);
  box-shadow:
    0 0 50px 14px rgba(140, 190, 255, 0.45),
    0 0 160px 60px rgba(90, 140, 255, 0.22),
    0 0 360px 120px rgba(60, 100, 230, 0.12);
  will-change: transform;
}
.earth > div { position: absolute; inset: 0; border-radius: 50%; }
.earth-land {
  background:
    radial-gradient(ellipse 9% 5% at 36% 4%, rgba(118, 168, 92, 0.85) 0 60%, transparent 70%),
    radial-gradient(ellipse 7% 9% at 50% 8%, rgba(132, 160, 96, 0.8) 0 60%, transparent 70%),
    radial-gradient(ellipse 12% 5% at 60% 3%, rgba(150, 170, 110, 0.7) 0 60%, transparent 70%),
    radial-gradient(ellipse 5% 7% at 28% 10%, rgba(120, 150, 90, 0.7) 0 60%, transparent 70%),
    radial-gradient(ellipse 6% 4% at 68% 9%, rgba(190, 180, 120, 0.6) 0 60%, transparent 70%);
  opacity: 0.9;
}
.earth-cloud {
  background:
    radial-gradient(ellipse 14% 3% at 30% 6%, rgba(255, 255, 255, 0.55) 0 50%, transparent 70%),
    radial-gradient(ellipse 10% 2.5% at 56% 5%, rgba(255, 255, 255, 0.5) 0 50%, transparent 70%),
    radial-gradient(ellipse 18% 2% at 46% 11%, rgba(255, 255, 255, 0.35) 0 50%, transparent 70%),
    radial-gradient(ellipse 8% 2% at 70% 7%, rgba(255, 255, 255, 0.45) 0 50%, transparent 70%);
  filter: blur(6px);
}
.earth-night {
  background: linear-gradient(100deg, transparent 52%, rgba(2, 4, 12, 0.55) 68%, rgba(2, 4, 12, 0.95) 80%);
}

/* ---------- objects ---------- */

.moon {
  width: var(--size);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 34%, rgba(0,0,0,0.16) 0 4.5%, rgba(255,255,255,0.1) 5% 5.8%, transparent 7%),
    radial-gradient(circle at 58% 62%, rgba(0,0,0,0.17) 0 6%, rgba(255,255,255,0.08) 6.5% 7.3%, transparent 8.5%),
    radial-gradient(circle at 46% 22%, rgba(0,0,0,0.14) 0 2.5%, rgba(255,255,255,0.1) 3% 3.8%, transparent 5%),
    radial-gradient(circle at 24% 62%, rgba(0,0,0,0.15) 0 3.2%, rgba(255,255,255,0.08) 3.7% 4.5%, transparent 5.5%),
    radial-gradient(circle at 70% 36%, rgba(0,0,0,0.13) 0 2%, rgba(255,255,255,0.1) 2.5% 3.3%, transparent 4.5%),
    radial-gradient(circle at 38% 78%, rgba(0,0,0,0.12) 0 1.6%, rgba(255,255,255,0.08) 2% 2.8%, transparent 3.8%),
    radial-gradient(circle at 76% 58%, rgba(0,0,0,0.12) 0 1.4%, rgba(255,255,255,0.08) 1.8% 2.5%, transparent 3.5%),
    radial-gradient(circle at 52% 44%, rgba(0,0,0,0.1) 0 1.2%, rgba(255,255,255,0.08) 1.6% 2.2%, transparent 3.2%),
    radial-gradient(circle at 20% 40%, rgba(0,0,0,0.1) 0 1.2%, rgba(255,255,255,0.08) 1.6% 2.2%, transparent 3.2%),
    radial-gradient(circle at 64% 18%, rgba(0,0,0,0.1) 0 1%, rgba(255,255,255,0.08) 1.4% 2%, transparent 3%),
    radial-gradient(ellipse 26% 18% at 40% 48%, rgba(0,0,0,0.16) 0 40%, transparent 100%),
    radial-gradient(ellipse 16% 22% at 62% 30%, rgba(0,0,0,0.13) 0 40%, transparent 100%),
    radial-gradient(ellipse 14% 10% at 30% 24%, rgba(0,0,0,0.1) 0 40%, transparent 100%),
    radial-gradient(circle at 36% 30%, #ddd9d0 0, #a8a59e 40%, #5c5b5b 72%, #1d1e23 100%);
  box-shadow:
    inset -36px -24px 70px rgba(0, 0, 0, 0.85),
    inset 10px 8px 30px rgba(255, 255, 255, 0.08),
    0 0 60px rgba(230, 225, 210, 0.08);
}

.mars {
  width: calc(var(--size) * 0.82);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 22% 7% at 50% 3%, rgba(255, 250, 240, 0.85) 0 30%, transparent 100%),
    radial-gradient(ellipse 14% 5% at 48% 98%, rgba(255, 250, 240, 0.4) 0 30%, transparent 100%),
    radial-gradient(ellipse 28% 14% at 34% 52%, rgba(80, 30, 16, 0.4) 0 60%, transparent 100%),
    radial-gradient(ellipse 20% 10% at 66% 40%, rgba(80, 30, 16, 0.35) 0 60%, transparent 100%),
    radial-gradient(ellipse 12% 6% at 58% 66%, rgba(90, 36, 20, 0.35) 0 60%, transparent 100%),
    radial-gradient(circle at 36% 32%, #f0a070 0, #c85a30 42%, #7a2d16 74%, #220b05 100%);
  box-shadow:
    inset -30px -20px 60px rgba(10, 0, 0, 0.85),
    0 0 70px rgba(230, 120, 70, 0.14);
}

.saturn, .voyager, .dome {
  width: min(84vw, 560px);
  height: auto;
  overflow: visible;
}
.saturn { filter: drop-shadow(0 0 40px rgba(240, 210, 150, 0.14)); }

.proxima {
  position: relative;
  width: calc(var(--size) * 0.42);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 36%, #ffd9b0 0, #ff8a4a 28%, #c8381b 62%, #5a1208 100%);
  box-shadow:
    0 0 40px 10px rgba(255, 110, 60, 0.55),
    0 0 140px 50px rgba(255, 80, 40, 0.25),
    0 0 300px 120px rgba(255, 60, 30, 0.1);
}
.proxima i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 260%;
  height: 1px;
  transform: translate(-50%, -50%);
  background: linear-gradient(90deg, transparent, rgba(255, 180, 140, 0.55), transparent);
}
.proxima i:last-child { transform: translate(-50%, -50%) rotate(90deg); }

.nebula {
  position: relative;
  width: var(--size);
  aspect-ratio: 1;
}
.nebula b {
  position: absolute;
  border-radius: 50%;
  filter: blur(26px);
  mix-blend-mode: screen;
}
.nebula .n1 { inset: 12% 10% 20% 14%; background: radial-gradient(circle at 50% 50%, rgba(255, 86, 150, 0.85), rgba(255, 86, 150, 0) 70%); }
.nebula .n2 { inset: 28% 28% 6% 2%; background: radial-gradient(circle at 50% 50%, rgba(80, 200, 220, 0.75), rgba(80, 200, 220, 0) 70%); }
.nebula .n3 { inset: 4% 4% 44% 42%; background: radial-gradient(circle at 50% 50%, rgba(180, 90, 255, 0.7), rgba(180, 90, 255, 0) 70%); }
.nebula .n4 { inset: 40% 12% 10% 40%; background: radial-gradient(circle at 50% 50%, rgba(255, 170, 90, 0.6), rgba(255, 170, 90, 0) 70%); }
.nebula s {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 14px 4px rgba(255, 255, 255, 0.8), 0 0 40px 10px rgba(180, 220, 255, 0.4);
}
.nebula s:nth-child(5) { left: 42%; top: 44%; }
.nebula s:nth-child(6) { left: 48%; top: 40%; width: 4px; height: 4px; }
.nebula s:nth-child(7) { left: 46%; top: 50%; width: 4px; height: 4px; }
.nebula s:nth-child(8) { left: 62%; top: 30%; width: 3px; height: 3px; }

.galaxy {
  position: relative;
  width: var(--size);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.galaxy::before, .galaxy::after, .galaxy i {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-32deg) scaleY(0.36);
}
.galaxy::before {
  width: 110%;
  height: 110%;
  background: radial-gradient(circle, rgba(255, 236, 200, 0.95) 0, rgba(255, 210, 150, 0.6) 10%, rgba(140, 150, 255, 0.28) 34%, rgba(120, 130, 255, 0.08) 56%, rgba(120, 130, 255, 0) 72%);
  filter: blur(4px);
}
.galaxy::after {
  width: 92%;
  height: 92%;
  background:
    radial-gradient(circle, transparent 0 32%, rgba(6, 7, 15, 0.55) 35% 38%, transparent 42%),
    radial-gradient(circle, transparent 0 52%, rgba(6, 7, 15, 0.45) 54% 57%, transparent 61%);
  filter: blur(5px);
}
.galaxy i {
  width: 36%;
  height: 36%;
  background: radial-gradient(circle, #fff6e6 0, rgba(255, 230, 190, 0.8) 22%, rgba(255, 220, 170, 0) 70%);
  filter: blur(2px);
  box-shadow: 0 0 90px 30px rgba(255, 220, 170, 0.12);
}

/* ---------- arrival ---------- */

.facts {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.facts li {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 15px;
}
.facts span {
  font: 400 11px/1.7 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 500 15px/1 var(--body);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, color 0.25s, transform 0.25s var(--ease);
}
.btn:hover { border-color: var(--faint); transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #130a05; }
.btn.primary:hover { filter: brightness(1.06); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.foot {
  position: relative;
  z-index: 2;
  padding: 40px var(--gutter) 140px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
}
.foot p { margin: 0 auto; max-width: 520px; }

@media (min-width: 761px) {
  .chapter:not(.hero) { padding-right: calc(var(--gutter) + 56px); }
}

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  :root { --size: min(64vw, 300px); }
  .chapter {
    grid-template-columns: 1fr;
    gap: 20px;
    padding-top: 96px;
    padding-bottom: 150px;
    align-content: center;
  }
  .chapter:nth-of-type(odd) .object { order: 0; }
  .object { min-height: min(72vw, 320px); }
  .saturn, .voyager, .dome { width: min(88vw, 420px); }
  .rail { display: none; }
  .hud { left: 16px; right: 16px; bottom: 14px; width: auto; padding: 10px 14px 10px; }
  .hud-row { padding: 2px 0; }
  .hud-k { font-size: 9px; }
  .hud-v { font-size: 11px; }
  .hero { padding-bottom: 42vh; }
  h1 { font-size: clamp(64px, 20vw, 120px); }
  .facts li { grid-template-columns: 64px 1fr; }
  .foot { padding-bottom: 150px; }
}

/* ---------- motion off ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
html[data-motion="off"] .hint svg { animation: none; }
html[data-motion="off"] .copy > *,
html[data-motion="off"] .hero-copy > *,
html[data-motion="off"] .object > * {
  opacity: 1;
  transform: none;
  transition: none;
}
html[data-motion="off"] .rail a::before,
html[data-motion="off"] .rail a span,
html[data-motion="off"] .btn,
html[data-motion="off"] .hud { transition: none; }
html[data-motion="off"] .btn:hover { transform: none; }
html[data-motion="off"] .object,
html[data-motion="off"] .earth { transform: none !important; }
