/* =====================================================================
   STARBOOK · atlas.css
   The Atlas console. A starship instrument laid over the WWT engine:
   huge negative space, mono telemetry, the amber/blue temperature system.
   Builds on the shared tokens in starbook.css.
   ===================================================================== */

.atlas-body {
  height: 100vh; height: 100svh;
  overflow: hidden;
  background: var(--bg);
}
.mono { font-family: var(--font-mono); font-size: var(--fs-mono); letter-spacing: .14em; }

/* ---- The engine stage ---- */
.atlas-stage { position: fixed; inset: 0; z-index: 0; background: #000; }
.atlas-stage canvas { display: block; width: 100% !important; height: 100% !important; }

/* ---- Overview-Effect wash (masks each render-mode switch) ---- */
#overview-wash {
  position: fixed; inset: 0; z-index: 30;
  pointer-events: none; opacity: 0;
  transition: opacity 420ms var(--ease-io);
}
#overview-wash.is-on { opacity: 1; }
#overview-wash[data-tint="amber"] {
  background:
    radial-gradient(120% 100% at 50% 64%, rgba(255,158,44,.42), rgba(255,158,44,.10) 42%, rgba(5,7,10,.92) 78%);
}
#overview-wash[data-tint="cool"] {
  background:
    radial-gradient(120% 100% at 50% 40%, rgba(91,138,181,.34), rgba(44,74,117,.18) 44%, rgba(5,7,10,.94) 80%);
}

/* fine instrument vignette + cinematic nebula glow at the edges (real-sky palette) */
.atlas-edge {
  position: fixed; inset: 0; z-index: 20; pointer-events: none;
  box-shadow: inset 0 0 220px 40px rgba(0,0,0,.62);
  background:
    radial-gradient(75% 55% at 100% 0%, var(--neb-glow), transparent 55%),          /* violet, top-right */
    radial-gradient(70% 55% at 0% 100%, rgba(59,107,255,.18), transparent 55%),       /* electric blue, bottom-left */
    radial-gradient(60% 50% at 100% 100%, rgba(232,90,168,.12), transparent 60%),     /* nebula pink, bottom-right */
    radial-gradient(140% 100% at 50% -10%, transparent 60%, rgba(0,0,0,.42)),
    radial-gradient(120% 100% at 50% 115%, rgba(0,0,0,.5), transparent 55%);
}

/* ---- Loading ---- */
/* Cinematic black fade-in — sits above everything, then clears to reveal a framed Earth */
#atlas-fade { position: fixed; inset: 0; z-index: 70; background: #000; opacity: 1; pointer-events: none; transition: opacity 1.6s ease; }
#atlas-fade.is-clear { opacity: 0; }

#atlas-loading {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-content: center; justify-items: center; gap: 16px;
  background: radial-gradient(120% 100% at 50% 30%, #0a1018, var(--bg) 70%);
  text-align: center; padding: var(--gut);
  transition: opacity 700ms var(--ease), visibility 700ms;
}
#atlas-loading.is-gone { opacity: 0; visibility: hidden; }
.loading__beacon {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--accent-bright), var(--accent) 45%, transparent 72%);
  box-shadow: 0 0 26px 4px var(--accent-glow);
  animation: beaconPulse 2.4s var(--ease-io) infinite;
}
.loading__title { font-family: var(--font-display); font-size: clamp(1.4rem, 1rem + 2vw, 2.4rem); font-weight: 500; letter-spacing: -.02em; }
.loading__status { color: var(--accent); }
.loading__hint { color: var(--muted); }

/* ---- HUD shell: all overlays sit above the stage, click-through by default ---- */
.atlas-top, #tier-rail, .atlas-readout, .atlas-descend, .atlas-legal, .sound-toggle { z-index: 40; }

/* top bar */
.atlas-top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: clamp(14px, 2.2vw, 22px) clamp(16px, 3vw, 34px);
  pointer-events: none;
  background: linear-gradient(180deg, rgba(5,7,10,.7), transparent);
}
.atlas-back {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 500; color: var(--ink);
  padding: 6px 4px;
}
.atlas-back svg { width: 18px; height: 18px; color: var(--muted); transition: color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.atlas-back:hover svg { color: var(--accent); transform: translateX(-3px); }
.atlas-back__text { font-size: 1.05rem; letter-spacing: .01em; }
.atlas-back__text i { color: var(--muted); font-style: normal; margin-left: 4px; font-weight: 400; }
.atlas-clock { color: var(--ink-soft); white-space: nowrap; }

/* descent spine (left) */
#tier-rail {
  position: fixed; left: clamp(16px, 3vw, 34px); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
  transition: transform var(--t-med) var(--ease), opacity var(--t-med) var(--ease);
}
#tier-rail.is-tucked { transform: translate(-160%, -50%); opacity: 0; pointer-events: none; }
.rail__head { color: var(--faint); margin-bottom: 8px; display: flex; }
.rail__head svg { width: 18px; height: 18px; color: var(--accent-line); }
.rail__tier {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: 0; padding: 8px 6px;
  font-family: var(--font-mono); font-size: .76rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); text-align: left;
  transition: color var(--t-fast) var(--ease);
}
.rail__dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  border: 1px solid var(--line); background: transparent;
  transition: all var(--t-med) var(--ease);
}
.rail__tier:hover { color: var(--ink); }
.rail__tier:hover .rail__dot { border-color: var(--accent-line); }
.rail__tier.is-active { color: var(--ink); }
.rail__tier.is-active .rail__dot {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 14px 2px var(--accent-glow);
}
/* connecting spine line */
#tier-rail::before {
  content: ""; position: absolute; left: calc(6px + 4px); top: 38px; bottom: 14px;
  width: 1px; background: linear-gradient(var(--cool-far), var(--accent-line));
  z-index: -1; opacity: .5;
}

/* telemetry readout (bottom) */
.atlas-readout {
  position: fixed; left: 0; right: 0; bottom: clamp(64px, 10vh, 92px);
  display: flex; flex-wrap: wrap; gap: 6px 26px; justify-content: center;
  padding-inline: clamp(16px, 4vw, 60px);
  pointer-events: none; text-transform: uppercase;
}
.ro { color: var(--muted); }
.ro--scale { color: var(--accent); }
.ro--stat { color: var(--ink-soft); }
.ro--source { color: var(--cool-bright); }

/* descend button */
.atlas-descend {
  position: fixed; left: 50%; bottom: clamp(14px, 3vh, 26px); transform: translateX(-50%);
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: .7em;
  padding: .8em 1.5em; border-radius: 100px;
  border: 1px solid var(--accent-line);
  background: linear-gradient(180deg, var(--accent-wash), transparent);
  color: var(--ink);
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .16em; text-transform: uppercase;
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.atlas-descend:hover {
  border-color: var(--accent); transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 10px 40px -16px var(--accent-glow);
}
.atlas-descend svg { width: 16px; height: 16px; color: var(--accent); }
.atlas-descend__glyph { opacity: .9; }                                   /* leading scale glyph — steady */
.atlas-descend__chev { animation: nudge 2.4s var(--ease-io) infinite; }  /* only the chevron nudges */
.atlas-descend[hidden] { display: none; }   /* class-set display must not beat [hidden] */

/* legal / illustrative note */
.atlas-legal {
  position: fixed; right: clamp(16px, 3vw, 30px); bottom: clamp(58px, 11vh, 96px);
  max-width: 30ch; text-align: right; color: var(--faint); line-height: 1.6;
  pointer-events: none; letter-spacing: .06em;
}

/* sound toggle reposition for the console */
.sound-toggle--atlas { bottom: clamp(14px, 3vh, 26px); right: clamp(16px, 3vw, 30px); }

/* noscript */
.noscript-note { position: fixed; inset: 0; display: none; place-content: center; text-align: center; padding: var(--gut); z-index: 70; background: var(--bg); }
.noscript-note a { color: var(--accent); text-decoration: underline; }

/* ---- Witness — the live frontier moment ---- */
.witness-callout {
  position: fixed; z-index: 40;
  top: clamp(78px, 11vh, 110px); left: 50%; transform: translateX(-50%);
  max-width: min(88vw, 540px); text-align: center; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.witness-callout[hidden] { display: none; }
.witness__live { display: inline-flex; align-items: center; gap: 9px; color: var(--accent); letter-spacing: .26em; text-transform: uppercase; }
.witness__label {
  font-family: var(--font-display); font-weight: 500; letter-spacing: -.01em;
  font-size: clamp(1.05rem, .9rem + 1vw, 1.7rem); line-height: 1.16; color: var(--ink);
  text-shadow: 0 0 calc(8px + var(--flare, 0) * 26px) rgba(255, 158, 44, calc(.12 + var(--flare, 0) * .55));
  transition: text-shadow 320ms var(--ease);
}
.witness__meta { color: var(--muted); letter-spacing: .12em; }
.witness__meta span { color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---- Signals — a message crossing the dark at light speed ---- */
.signal-cue {
  position: fixed; z-index: 40;
  left: clamp(16px, 3vw, 34px); bottom: clamp(118px, 17vh, 178px);
  width: min(32vw, 290px);
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.signal-cue[hidden] { display: none; }
.signal-cue__head { color: var(--ink-soft); letter-spacing: .12em; }
.signal-cue__head b { color: var(--accent); font-weight: 500; }
.signal-cue__track { position: relative; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--cool-far), var(--accent-line)); }
.signal-cue__fill { position: absolute; inset: 0 auto 0 0; width: 0%; border-radius: 2px; background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); transition: width 150ms linear; }
.signal-cue__pulse { position: absolute; top: 50%; left: 0; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--accent-bright); box-shadow: 0 0 10px 2px var(--accent-glow); transition: left 150ms linear; }
.signal-cue__meta { color: var(--muted); letter-spacing: .1em; }

/* ---- Free-flight hint ---- */
.flight-hint {
  position: fixed; z-index: 40; left: 50%; bottom: clamp(120px, 15vh, 150px); transform: translateX(-50%);
  color: var(--faint); letter-spacing: .16em; text-transform: uppercase; pointer-events: none;
  white-space: nowrap; opacity: .85;
}
@media (max-width: 720px) { .flight-hint { display: none; } }

/* ---- Launches feed (next real launch + countdown) ---- */
.launch-feed {
  position: fixed; z-index: 40; left: clamp(16px, 3vw, 34px); top: clamp(80px, 12vh, 116px);
  display: flex; flex-direction: column; gap: 3px; max-width: 250px; pointer-events: none;
}
.launch-feed[hidden] { display: none; }
.launch-feed__tag { color: var(--accent); letter-spacing: .22em; }
.launch-feed__name { color: var(--ink); font-size: .8rem; letter-spacing: .02em; line-height: 1.22; }
.launch-feed__meta { color: var(--muted); font-size: .68rem; letter-spacing: .06em; }
.launch-feed__meta b { color: var(--accent); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---- Destinations (free-roam: fly to / follow any world) ---- */
.destinations {
  position: fixed; z-index: 40; right: clamp(16px, 3vw, 34px); top: 50%; transform: translate(0, -50%);
  width: min(44vw, 196px); display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  /* smooth, gentle slide — eased in AND out (no knee-jerk), transform + opacity in lockstep */
  transition: transform 720ms var(--ease-io), opacity 720ms var(--ease-io);
}
/* tucked into the right margin after a destination is chosen; hover the edge to bring it back */
.destinations.is-tucked { transform: translate(140%, -50%); opacity: 0; pointer-events: none; }

/* ---- Persistent edge peek handles (menus can collapse but never get lost) ---- */
.edge-peek {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 41;
  display: grid; place-items: center; width: 34px; height: 54px; padding: 0;
  background: color-mix(in srgb, var(--base) 62%, transparent);
  border: 1px solid var(--line); color: var(--muted); cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.edge-peek svg { width: 20px; height: 20px; }
.edge-peek:hover { color: var(--ink); border-color: var(--accent-line); background: color-mix(in srgb, var(--base) 80%, transparent); }
.edge-peek--scale { left: 0; border-left: 0; border-radius: 0 10px 10px 0; }
.edge-peek--dest  { right: 0; border-right: 0; border-radius: 10px 0 0 10px; }

/* ---- Always-on body labels: clickable name chips projected onto the live 3D view ---- */
#atlas-blabels { position: fixed; inset: 0; z-index: 33; pointer-events: none; }  /* gaps pass clicks through */
.atlas-blabel {
  position: absolute; top: 0; left: 0; will-change: transform; white-space: nowrap;
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 100px;
  font-family: var(--font-mono); font-size: .76rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--base) 48%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-line) 45%, transparent);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  text-shadow: 0 0 8px rgba(0, 0, 0, 1), 0 1px 3px rgba(0, 0, 0, .95);
  pointer-events: auto; cursor: pointer;     /* a real, generous tap target */
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.atlas-blabel:hover { color: var(--ink); border-color: var(--accent); background: color-mix(in srgb, var(--base) 80%, transparent); }
/* the body you're parked on: brighter name, sitting on it */
.atlas-blabel.is-centered { color: var(--accent-bright); border-color: var(--accent); }
.dest__toggle { background: transparent; border: 0; color: var(--faint); letter-spacing: .26em; padding: 4px 0; cursor: pointer; }
.dest__toggle:hover { color: var(--ink-soft); }
.dest__list { display: flex; flex-direction: column; gap: 3px; width: 100%; }
.dest__list[hidden] { display: none; }
.dest {
  font-family: var(--font-mono); font-size: .76rem; letter-spacing: .06em; text-align: right;
  color: var(--muted); background: transparent; border: 0; border-right: 1px solid var(--line);
  padding: 5px 11px 5px 0; cursor: pointer; transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), padding var(--t-fast) var(--ease);
}
.dest:hover { color: var(--ink); border-color: var(--accent-line); padding-right: 15px; }
.dest.is-active { color: var(--accent); border-color: var(--accent); }

/* ---- Time-rate dial ---- */
.timedial {
  position: fixed; z-index: 40; left: clamp(16px, 3vw, 34px); bottom: clamp(14px, 3vh, 26px);
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 100px;
  background: rgba(5,7,10,.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.timedial__label { color: var(--faint); letter-spacing: .2em; margin-right: 4px; }
.timedial__btn { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .05em; color: var(--muted); background: transparent; border: 0; padding: 4px 8px; border-radius: 100px; cursor: pointer; transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.timedial__btn:hover { color: var(--ink); }
.timedial__btn.is-active { color: #120d04; background: var(--accent); }

@keyframes nudge { 0%,100% { transform: translateY(0); } 50% { transform: translateY(3px); } }

/* ---- Responsive: compact bottom-stacked console on narrow screens ---- */
@media (max-width: 720px) {
  .atlas-clock { display: none; }
  .atlas-top { padding: 12px 16px; background: linear-gradient(180deg, rgba(5,7,10,.82), transparent); }
  .atlas-back__text { font-size: .95rem; }

  /* the rail becomes a horizontal pill row, just above the readout */
  #tier-rail {
    top: auto; bottom: 124px; left: 0; right: 0; transform: none;
    flex-direction: row; justify-content: center; align-items: center;
    flex-wrap: wrap; gap: 6px; padding-inline: 10px;
  }
  #tier-rail::before { display: none; }
  .rail__head { display: none; }
  .rail__tier {
    border: 1px solid var(--line); border-radius: 100px; padding: 6px 10px;
    font-size: .62rem; letter-spacing: .08em; gap: 8px;
    background: rgba(5,7,10,.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  }
  .rail__dot { width: 7px; height: 7px; }
  .rail__tier.is-active { border-color: var(--accent-line); }

  /* readout: keep only the signal that matters, tidy centred lines */
  .atlas-readout {
    bottom: 46px; gap: 4px 16px; justify-content: center; text-align: center;
    font-size: .56rem; padding-inline: 14px;
  }
  .ro--coord, .ro--lag { display: none; }

  /* the rail is the navigation on mobile — the big button is redundant */
  .atlas-descend { display: none; }
  .atlas-descend[hidden] { display: none; }

  /* one tiny disclaimer line, full width at the very bottom */
  .atlas-legal {
    left: 14px; right: 14px; bottom: 12px; max-width: none; text-align: center;
    font-size: .52rem; line-height: 1.5; color: var(--muted);
  }

  /* move ambient to the top-right where the clock was, to free the bottom */
  .sound-toggle--atlas { top: 12px; right: 14px; bottom: auto; padding: 7px 10px; }
  .sound-toggle--atlas .sound-toggle__label { display: none; }

  /* Witness stays (compact); the secondary Signal cue is desktop-only here */
  .witness-callout { top: 62px; max-width: 90vw; gap: 5px; }
  .witness__live { font-size: .56rem; }
  .signal-cue { display: none; }

  /* Time dial + launch feed are desktop-only; destinations collapses to a popover */
  .timedial { display: none; }
  .launch-feed { display: none; }
  .destinations { top: auto; bottom: 170px; right: 14px; transform: none; width: auto; }
  .destinations.is-tucked { transform: translateX(140%); opacity: 0; }
  .destinations .dest__list {
    position: absolute; bottom: 30px; right: 0; min-width: 150px;
    background: rgba(5,7,10,.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
    max-height: 46vh; overflow-y: auto;
  }
  .dest { border-right: 0; padding: 7px 2px; }
}

@media (max-width: 380px) {
  .atlas-readout .ro--source { display: none; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  #overview-wash { transition: none; }
  .loading__beacon, .atlas-descend svg { animation: none; }
  #atlas-loading, #atlas-fade { transition: opacity 1ms; }
}
