/* ISS Live Tracker — HUD styling.
   Design system: 8px spacing unit; type scale 20/16/13/11; accent #4cc2ff;
   dark grays #0b0e14 / #121826 (never pure black), softened text #dbe4ee. */
:root {
  --bg: #0b0e14;
  --panel: rgba(16, 21, 32, 0.82);
  --panel-solid: #121826;
  --line: rgba(120, 150, 190, 0.18);
  --text: #dbe4ee;
  --muted: #8fa1b8;
  --accent: #4cc2ff;
  --ok: #3ddc97;
  --warn: #ffb347;
  --err: #ff6b6b;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

/* ---- top bar ---- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 48px; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(8,11,18,.85), rgba(8,11,18,0));
}
.brand { font-size: 16px; font-weight: 700; letter-spacing: .06em; }
.brand .ver { color: var(--accent); font-weight: 600; }
.brand .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); margin-right: 8px; box-shadow: 0 0 8px var(--ok);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .brand .dot { animation: none; } }
.top-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.badge {
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); font-size: 12px;
}
.badge.live { color: var(--ok); border-color: rgba(61,220,151,.4); }
.badge.stale { color: var(--warn); border-color: rgba(255,179,71,.4); }
.badge.err { color: var(--err); border-color: rgba(255,107,107,.4); }

/* ---- telemetry panel ---- */
#telemetry {
  position: absolute; top: 64px; left: 16px; width: 264px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; backdrop-filter: blur(10px);
}
#telemetry h2, #hud-passes h3 {
  margin: 0 0 10px; font-size: 11px; letter-spacing: .14em; color: var(--muted); font-weight: 600;
}
#telemetry dl { margin: 0; }
#telemetry dl > div {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; border-bottom: 1px solid rgba(120,150,190,.08);
}
#telemetry dt { font-size: 12px; color: var(--muted); }
#telemetry dd { margin: 0; font-size: 14px; }
#hud-daynight.day { color: var(--warn); }
#hud-daynight.night { color: var(--accent); }
#hud-daynight.twilight { color: #c792ea; }
#hud-passes { margin-top: 14px; }
#hud-passes .hint { color: var(--accent); letter-spacing: 0; text-transform: none; }
#pass-list { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
#pass-list li {
  display: flex; justify-content: space-between; padding: 4px 0;
  border-bottom: 1px solid rgba(120,150,190,.08); font-family: var(--mono);
}
#pass-list li .max { color: var(--muted); }

/* ---- bottom dock (modes + time in one cohesive panel) ---- */
#dock {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
#modes { display: flex; gap: 6px; }
#modes button {
  font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
  padding: 8px 16px; border: 1px solid transparent; border-radius: 9px;
  background: transparent; transition: background .15s ease-out, border-color .15s ease-out;
  min-height: 40px;
}
#modes button:hover { background: rgba(76,194,255,.10); }
#modes button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#modes button.active {
  background: rgba(76,194,255,.16); border-color: rgba(76,194,255,.5); color: #fff;
}
#modes button.ghost { color: var(--muted); }

/* ---- time row ---- */
#timerow {
  display: flex; align-items: center; gap: 4px; padding: 4px 6px;
  font-size: 12px;
}
button.ghost {
  font: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 5px 9px; min-height: 32px; transition: color .15s, background .15s;
}
button.ghost:hover { color: var(--text); background: rgba(120,150,190,.12); }
button.ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.ghost.active { color: var(--accent); background: rgba(76,194,255,.12); }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.chk { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; cursor: pointer; }
.chk input { accent-color: var(--accent); }

/* ---- hints & toasts ---- */
#ground-hint {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px; font-size: 13px;
  background: var(--panel); border: 1px solid var(--line); color: var(--warn);
  backdrop-filter: blur(10px);
}
#toast {
  position: absolute; bottom: 116px; left: 50%; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 8px; font-size: 13px;
  background: var(--panel-solid); border: 1px solid var(--line);
}
#fatal {
  position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 10;
}
#fatal > div { max-width: 420px; text-align: center; padding: 24px; }
#fatal h1 { font-size: 20px; color: var(--err); }

/* ---- dialog ---- */
#observer-dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-solid);
  color: var(--text); padding: 24px; width: min(320px, 90vw);
}
#observer-dialog::backdrop { background: rgba(4,6,10,.6); }
#observer-dialog h2 { margin: 0 0 16px; font-size: 16px; }
#observer-dialog label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
#observer-dialog input {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-family: var(--mono);
  color: var(--text); background: #0d1220; border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 12px;
}
#observer-dialog input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
#observer-dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 8px 0 0; padding: 0; }
#observer-dialog menu button {
  font: inherit; padding: 8px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--text); min-height: 40px;
}
#observer-dialog menu .primary { background: var(--accent); color: #04121e; border-color: var(--accent); font-weight: 600; }

/* ---- responsive ---- */
@media (max-width: 760px) {
  #btn-telemetry { display: inline-block; }
  #topbar { height: auto; flex-wrap: wrap; gap: 4px; padding: 8px 12px; }
  .brand { font-size: 14px; }
  #tle-source { font-size: 11px; padding: 2px 8px; }
  /* Telemetry as a slide-down drawer from the header; never collides the dock.
     The header stays above it (z-index) so the toggle can close it again. */
  #telemetry {
    top: 0; left: 0; right: 0; width: auto; border-radius: 0 0 var(--radius) var(--radius);
    max-height: 52vh; overflow-y: auto; padding-top: 64px;
    transform: translateY(-105%); transition: transform .22s ease-out;
    margin-top: 0;
  }
  #telemetry.open { transform: translateY(0); }
  #hud-passes { display: none; }
  #dock { width: calc(100% - 16px); left: 8px; right: 8px; transform: none; bottom: 8px; }
  #modes { width: 100%; justify-content: center; flex-wrap: wrap; }
  #modes button { padding: 10px 12px; min-height: 44px; }
  #timerow { flex-wrap: wrap; justify-content: center; width: 100%; }
  .top-right #sim-clock { display: none; }
  #ground-hint { top: auto; bottom: 168px; }
}}
