/* =========================================================================
   VOYAGER — Solar System Experience
   Global UI styling. The 3D scene lives on <canvas.webgl>; everything here
   is the overlay HUD that floats above it. Design goals: cinematic, dark,
   minimal, typographic. No layout frameworks — just custom properties.
   ========================================================================= */

:root {
  --bg:           #04060d;
  --ink:          #eef2ff;
  --ink-dim:      rgba(238, 242, 255, 0.62);
  --ink-faint:    rgba(238, 242, 255, 0.34);
  --line:         rgba(238, 242, 255, 0.14);
  --accent:       #8ab4ff;
  --accent-warm:  #ffcaa0;
  --ease:         cubic-bezier(0.22, 1, 0.36, 1);
  /* Display = geometric & modern; HUD/labels = Orbitron for that sci-fi feel. */
  --serif:        "Space Grotesk", system-ui, sans-serif;
  --mono:         "Orbitron", ui-monospace, monospace;
  --pad:          clamp(20px, 4vw, 64px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  overflow: hidden;            /* scroll is virtual — captured, not native */
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

.webgl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* Left scrim — keeps left-aligned UI readable over bright scene content. */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg,
      rgba(4, 6, 13, 0.92) 0%,
      rgba(4, 6, 13, 0.78) 22%,
      rgba(4, 6, 13, 0.42) 42%,
      rgba(4, 6, 13, 0.0) 60%),
    linear-gradient(270deg,
      rgba(4, 6, 13, 0.86) 0%,
      rgba(4, 6, 13, 0.52) 16%,
      rgba(4, 6, 13, 0.0) 34%),
    linear-gradient(0deg,
      rgba(4, 6, 13, 0.6) 0%,
      rgba(4, 6, 13, 0.0) 32%);
}

/* Overlay layer — pointer-events pass through except on interactive bits */
.ui {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.ui button { pointer-events: auto; }

/* ----------------------------------------------------------- Loader veil */
.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 120% at 50% 40%, #0a1024 0%, #04060d 70%);
  transition: opacity 1.1s var(--ease), visibility 1.1s var(--ease);
}
.loader.is-hidden { opacity: 0; visibility: hidden; }
.loader__inner { text-align: center; width: min(320px, 70vw); }
.loader__mark {
  font-family: var(--mono); /* Orbitron */
  font-weight: 600;
  letter-spacing: 0.42em;
  font-size: 14px;
  padding-left: 0.42em;
  color: var(--ink-dim);
  margin-bottom: 22px;
}
.loader__bar {
  height: 1px;
  width: 100%;
  background: var(--line);
  overflow: hidden;
}
.loader__bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  transition: width 0.4s var(--ease);
}
.loader__hint {
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ------------------------------------------------------------------- HUD */
.hud {
  position: fixed;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--pad);
  z-index: 10;
}
.hud--top { top: 0; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-warm);
  box-shadow: 0 0 14px 2px var(--accent-warm);
  animation: pulse 3.6s var(--ease) infinite;
}
@keyframes pulse { 0%,100%{opacity:.5} 50%{opacity:1} }
.brand__name {
  font-family: var(--mono);   /* Orbitron — logotype reads as a HUD mark */
  font-weight: 600;
  letter-spacing: 0.34em;
  font-size: 13px;
  padding-left: 0.34em;
}
.hud__right { display: flex; align-items: center; gap: 14px; }

/* mode + sound toggles */
.mode-toggle, .sound-toggle, .lang-toggle {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-radius: 100px;
  cursor: pointer;
  transition: color .4s var(--ease), border-color .4s var(--ease), background .4s var(--ease);
  backdrop-filter: blur(8px);
}
.mode-toggle { padding: 9px 18px; }
.lang-toggle { padding: 9px 14px; min-width: 46px; }
.mode-toggle:hover, .sound-toggle:hover, .lang-toggle:hover { color: var(--ink); border-color: rgba(255,255,255,0.32); }
.mode-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.sound-toggle { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; }
.sound-toggle__icon {
  width: 14px; height: 14px;
  background:
    linear-gradient(var(--ink-dim),var(--ink-dim)) left center/3px 6px no-repeat,
    linear-gradient(var(--ink-dim),var(--ink-dim)) center/3px 11px no-repeat,
    linear-gradient(var(--ink-dim),var(--ink-dim)) right center/3px 8px no-repeat;
  opacity: .4;
  transition: opacity .4s var(--ease);
}
.sound-toggle[aria-pressed="true"] .sound-toggle__icon { opacity: 1; animation: eq 1.1s steps(3) infinite alternate; }
@keyframes eq { to { transform: scaleY(0.5); } }

/* ----------------------------------------------------------------- Intro */
.intro {
  position: fixed;
  left: var(--pad); bottom: clamp(64px, 14vh, 140px);
  max-width: 520px;
  z-index: 8;
  transition: opacity 0.45s var(--ease), transform 0.8s var(--ease);
}
.intro__eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}
.intro__title {
  /* Same face as the eyebrow (Orbitron) — the whole intro reads as one HUD.
     Orbitron is wide, so the size is dialled down vs the old serif title. */
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(32px, 4.6vw, 66px);
  line-height: 1.08;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.intro__sub {
  margin-top: 22px;
  font-family: var(--mono);
  font-weight: 400;
  font-size: clamp(12px, 1.3vw, 15px);
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  max-width: 40ch;
}
.scroll-cue {
  margin-top: 40px;
  display: flex; align-items: center; gap: 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.scroll-cue__line {
  position: relative;
  width: 60px; height: 1px;
  background: var(--line);
  overflow: hidden;
}
.scroll-cue__line::after {
  content: "";
  position: absolute; inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent));
  animation: cue 2.4s var(--ease) infinite;
}
@keyframes cue { 0%{transform:translateX(-100%)} 100%{transform:translateX(250%)} }

/* ------------------------------------------------------- Planet panel */
.panel {
  position: fixed;
  right: var(--pad);
  top: 50%;
  transform: translateY(-46%);
  width: min(400px, 40vw);
  z-index: 8;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s var(--ease);
}
.panel.is-active { opacity: 1; }

.panel__index {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 14px;
}
.panel__index i { color: var(--ink-faint); font-style: normal; margin-left: 6px; }

.panel__title {
  font-weight: 300;
  font-size: clamp(40px, 5vw, 68px);
  line-height: 1;
  letter-spacing: -0.01em;
}
.panel__tagline {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-warm);
}
.panel__desc {
  margin-top: 22px;
  font-weight: 300;
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-dim);
}

/* stat chips */
.stats {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.stat {
  background: rgba(8, 11, 22, 0.72);
  backdrop-filter: blur(8px);
  padding: 16px 18px;
}
.stat__label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.stat__value {
  margin-top: 7px;
  font-weight: 300;
  font-size: 19px;
  color: var(--ink);
}
.stat__value small { font-size: 12px; color: var(--ink-dim); margin-left: 3px; }

/* story blocks */
.story { margin-top: 26px; display: flex; flex-direction: column; gap: 16px; }
.story__block {
  border-left: 1px solid var(--line);
  padding-left: 16px;
  opacity: 0;
  transform: translateX(8px);
}
.story__block h4 {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.story__block p { font-weight: 300; font-size: 14px; line-height: 1.6; color: var(--ink-dim); }

/* progressive-reveal helper: children animate in sequence */
.reveal-up { opacity: 0; transform: translateY(14px); }

/* ----------------------------------------------------------------- Outro */
.outro {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s var(--ease);
}
.outro.is-active { opacity: 1; pointer-events: auto; }
.outro__title {
  font-weight: 300;
  font-size: clamp(34px, 6vw, 86px);
  line-height: 1.04;
  letter-spacing: -0.01em;
}
.outro__sub { color: var(--ink-dim); font-weight: 300; font-size: clamp(15px,1.6vw,18px); }
.outro__restart {
  margin: 28px auto 0;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 14px 28px;
  border-radius: 100px;
  cursor: pointer;
  transition: border-color .4s var(--ease), background .4s var(--ease);
}
.outro__restart:hover { border-color: var(--accent); background: rgba(138,180,255,0.08); }

/* -------------------------------------------------------------- Timeline */
.timeline {
  position: fixed;
  left: var(--pad);
  top: 50%;
  transform: translateY(-50%);
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 18px;
  opacity: 0;
  transition: opacity 0.8s var(--ease);
}
.timeline.is-active { opacity: 1; }
.timeline__node {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: none; border: none;
  cursor: pointer;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color .4s var(--ease);
}
.timeline__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-faint);
  transition: transform .4s var(--ease), background .4s var(--ease), box-shadow .4s var(--ease);
}
.timeline__label { opacity: 0; transform: translateX(-6px); transition: opacity .4s var(--ease), transform .4s var(--ease); }
.timeline__node:hover .timeline__label { opacity: 1; transform: translateX(0); }
.timeline__node:hover { color: var(--ink-dim); }
.timeline__node.is-current { color: var(--ink); }
.timeline__node.is-current .timeline__dot {
  background: var(--accent-warm);
  transform: scale(1.7);
  box-shadow: 0 0 12px 1px var(--accent-warm);
}
.timeline__node.is-current .timeline__label { opacity: 1; transform: translateX(0); }

/* ------------------------------------------------------------ Orbit hint */
.orbit-hint {
  position: fixed;
  left: 50%; bottom: clamp(40px, 8vh, 80px);
  transform: translateX(-50%);
  z-index: 8;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  opacity: 0;
  transition: opacity 0.6s var(--ease);
}
.orbit-hint.is-active { opacity: 1; }

/* ------------------------------------------------ Tracked annotations */
/* The boxed panel is replaced by data anchored to the planet. */
.panel { display: none !important; }

.anno { position: fixed; inset: 0; z-index: 7; pointer-events: none; }

.anno__lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.anno-line {
  stroke: rgba(238, 242, 255, 0.07);   /* almost invisible hairlines */
  stroke-width: 1;
  opacity: 0;
  transition: opacity 0.5s var(--ease);
  display: none;                        /* leader "sticks" hidden for now */
}
.anno__lines.is-on .anno-line { opacity: 1; }
.anno-dot { fill: rgba(255, 202, 160, 0.4); opacity: 0; transition: opacity 0.5s var(--ease); }
.anno__lines.is-on .anno-dot { opacity: 1; }

.anno__layer { position: absolute; inset: 0; }
.anno-item {
  position: absolute;
  opacity: 0;
  transition: opacity 0.55s var(--ease);
  transition-delay: calc(var(--i) * 0.07s);
  text-shadow: 0 1px 12px rgba(2, 4, 10, 0.85);
  will-change: left, top, transform, opacity;
}
.anno__layer.is-on .anno-item { opacity: 1; }

/* MOON — tiny readout tracked to each moon: name + up to two facts */
.moon { position: absolute; white-space: nowrap; }
.moon__name {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}
.moon__facts { display: block; margin-top: 2px; }
.moon__f { display: block; font-family: var(--mono); font-size: 9px; letter-spacing: 0.06em; line-height: 1.5; }
.moon__l { font-style: normal; text-transform: uppercase; color: var(--ink-faint); margin-right: 6px; }
.moon__v { font-weight: 400; color: var(--ink-dim); }

/* RIGHT: name + tagline + description, stacked, no leader line */
.anno-block { width: clamp(230px, 24vw, 340px); }
.anno-block__idx { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; color: var(--accent); }
.anno-block__idx i { color: var(--ink-faint); font-style: normal; }
.anno-block__name {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(34px, 4.2vw, 62px);
  line-height: 1;
  letter-spacing: -0.01em;
  margin-top: 6px;
}
.anno-block__tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-warm);
  margin-top: 10px;
}
.anno-block__desc {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 14px;
  line-height: 1.62;
  color: var(--ink-dim);
  margin-top: 16px;
}

/* LEFT: data facts, right-aligned toward the planet */
.cap { white-space: nowrap; text-align: right; }
.cap__label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.cap__value {
  display: block;
  font-family: var(--serif);
  font-weight: 300;
  font-size: 22px;
  color: var(--ink);
  margin-top: 3px;
}
.cap__value i { font-style: normal; font-size: 12px; color: var(--ink-dim); margin-left: 3px; }

/* --------------------------------------------------------- Responsive */
@media (max-width: 760px) {
  .panel { right: var(--pad); left: var(--pad); width: auto; top: auto; bottom: clamp(80px,18vh,140px); transform: none; }
  .panel.is-active { opacity: 1; }
  .stats { grid-template-columns: 1fr 1fr; }
  .timeline { display: none; }
  .intro { right: var(--pad); bottom: clamp(96px, 18vh, 170px); }
  .intro__title { font-size: clamp(24px, 7.4vw, 40px); }
  .intro__sub { font-size: 12px; }

  .hud { padding: 16px 20px; }

  /* Floating per-fact caps and moon readouts don't fit a phone screen —
     their data lives inside the bottom sheet instead (Annotations.js). */
  .cap, .moon { display: none !important; }

  /* The planet readout becomes a bottom sheet pinned above the orbit hint.
     !important guards against stale inline left/top from desktop frames. */
  .anno-block {
    position: fixed !important;
    left: var(--pad) !important;
    right: var(--pad);
    top: auto !important;
    bottom: clamp(64px, 12vh, 120px) !important;
    transform: none !important;
    width: auto;
    max-width: none;
  }
  .anno-block__name { font-size: clamp(28px, 8.5vw, 40px); }
  .anno-block__desc {
    font-size: 13px;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 3;          /* keep the sheet compact */
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .anno-block__facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    margin-top: 14px;
  }
  .anno-block__facts .af i {
    display: block;
    font-style: normal;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }
  .anno-block__facts .af b {
    font-family: var(--serif);
    font-weight: 300;
    font-size: 16px;
    color: var(--ink);
  }

  .orbit-hint { bottom: 18px; font-size: 10px; }
  .outro__title { font-size: clamp(28px, 8vw, 48px); }
}

/* Mobile browsers: dynamic viewport height (URL bar collapse) + no browser
   touch gestures fighting the virtual scroll. */
html, body { touch-action: none; }
.ui button { touch-action: auto; }
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: 0.001ms !important; }
}
