/* SkyRef — VARØ Industries house style.
   Palette, type and radius are fixed by the house system; the dome bezel is
   where this app carries its own identity. */

:root {
  --bg: #080810;
  --bg-card: #0e0e1c;
  --bg-card2: #111125;
  --bg-hover: #14142a;
  --border: #1e1e3a;
  --border-bright: #2e2e54;
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, .12);
  --accent-glow: rgba(0, 212, 170, .25);
  --accent2: #7c6aff;
  --text: #e8e8f0;
  --text-muted: #7878a0;
  --text-dim: #4a4a6a;
  --red: #ff4d6a;
  --yellow: #ffd166;
  --green: #06d6a0;

  --font-mono: 'JetBrains Mono', ui-monospace, 'Courier New', monospace;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: .18s cubic-bezier(.4, 0, .2, 1);

  --rail-left: 236px;
  --rail-right: 300px;
}

[data-theme="light"] {
  --bg: #f4f4f8;
  --bg-card: #ffffff;
  --bg-card2: #f8f8fc;
  --bg-hover: #f0f0f8;
  --border: #e0e0ec;
  --border-bright: #c8c8e0;
  --accent: #00a882;
  --accent-dim: rgba(0, 168, 130, .1);
  --accent-glow: rgba(0, 168, 130, .2);
  --text: #1a1a2e;
  --text-muted: #5a5a7a;
  --text-dim: #9090b0;
}

/* Night vision. Everything collapses into the red channel so the page does not
   destroy the dark adaptation of someone standing in a field at 2am. */
[data-theme="night"] {
  --bg: #0a0000;
  --bg-card: #150202;
  --bg-card2: #1a0303;
  --bg-hover: #240404;
  --border: #3a0a0a;
  --border-bright: #521010;
  --accent: #ff3b3b;
  --accent-dim: rgba(255, 59, 59, .12);
  --accent-glow: rgba(255, 59, 59, .25);
  --accent2: #ff6b6b;
  --text: #ff6b6b;
  --text-muted: #b83c3c;
  --text-dim: #7a2020;
  --yellow: #ff5c3b;
  --green: #ff4d4d;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100dvh;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Status bar ─────────────────────────────────────────────────────────── */

#status-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  height: 34px;
  flex-shrink: 0;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background var(--transition);
}
.status-dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.loading { background: var(--yellow); animation: pulse 1s infinite; }
.status-dot.error { background: var(--red); }

@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

#status-meta { display: flex; gap: 16px; margin-left: auto; color: var(--text-dim); }
#status-meta span { white-space: nowrap; }
.brand { color: var(--accent); font-weight: 700; letter-spacing: .06em; }

.theme-switch { display: flex; gap: 2px; }
.theme-switch button {
  background: none; border: 1px solid transparent;
  color: var(--text-dim); font-size: 11px;
  padding: 2px 7px; border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  transition: var(--transition);
}
.theme-switch button:hover { color: var(--text); background: var(--bg-hover); }
.theme-switch button[aria-pressed="true"] {
  color: var(--accent); border-color: var(--border-bright); background: var(--accent-dim);
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

#app {
  display: grid;
  grid-template-columns: var(--rail-left) 1fr var(--rail-right);
  grid-template-rows: 34px 1fr auto;
  grid-template-areas:
    "status status status"
    "left   sky    right"
    "time   time   time";
  height: 100dvh;
}

#status-bar { grid-area: status; }
#rail-left  { grid-area: left; border-right: 1px solid var(--border); }
#rail-right { grid-area: right; border-left: 1px solid var(--border); }
#sky        { grid-area: sky; }
#timebar    { grid-area: time; }

.rail {
  background: var(--bg-card);
  overflow-y: auto;
  padding: 16px 14px;
}

.rail h2 {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 20px 0 9px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.rail h2:first-child { margin-top: 0; }

/* ── Layer toggles ──────────────────────────────────────────────────────── */

.toggle {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13px;
}
.toggle:hover { background: var(--bg-hover); }
.toggle input { accent-color: var(--accent); cursor: pointer; width: 14px; height: 14px; }
.toggle .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.rail-note {
  font-size: 11px; color: var(--text-dim); line-height: 1.5;
  padding: 4px 7px 0; margin-top: 2px;
}

.slider-row { padding: 9px 7px 4px; }
.slider-row label {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-muted); margin-bottom: 7px;
}
.slider-row output { color: var(--accent); }
input[type="range"] {
  width: 100%; accent-color: var(--accent);
  background: transparent; cursor: pointer;
}
.scale-marks {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 9px;
  color: var(--text-dim); margin-top: 3px;
}

/* ── Sky ────────────────────────────────────────────────────────────────── */

#sky {
  position: relative; background: var(--bg); overflow: hidden;
  cursor: grab; touch-action: none;
}
#sky:active { cursor: grabbing; }

#zoom-controls {
  position: absolute; z-index: 4; top: 14px; right: 14px;
  /* #sky sets touch-action:none for panning; the controls must keep normal
     tap behaviour or touch users cannot press them either. */
  touch-action: auto; cursor: default;
  display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px;
}
#zoom-controls button {
  background: none; border: 1px solid transparent; border-radius: 5px;
  color: var(--text-muted); font-family: var(--font-mono); font-size: 13px;
  width: 30px; height: 26px; line-height: 1; transition: var(--transition);
}
#zoom-controls button:hover:not(:disabled) {
  background: var(--bg-hover); color: var(--accent); border-color: var(--border-bright);
}
#zoom-controls button:disabled { opacity: .32; cursor: default; }
#zoom-controls #btn-zoom-reset { font-size: 10px; }
#zoom-level {
  font-family: var(--font-mono); font-size: 10px; color: var(--accent);
  text-align: center; padding: 1px 0;
}

#zoom-hint {
  position: absolute; z-index: 4; bottom: 12px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 10px; color: var(--text-dim);
  pointer-events: none; opacity: .8;
}
@media (max-width: 900px) { #zoom-hint { display: none; } }
#sky canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

#dome-canvas { z-index: 1; }
#overlay-canvas { z-index: 2; }

#sky.booting #dome-canvas,
#sky.booting #overlay-canvas { opacity: 0; }
#dome-canvas, #overlay-canvas { transition: opacity .6s ease-out; opacity: 1; }

/* ── Object card ────────────────────────────────────────────────────────── */

#object-card {
  position: absolute; z-index: 3;
  background: var(--bg-card2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 13px 15px;
  min-width: 210px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
  font-size: 13px;
  pointer-events: auto;
}
#object-card[hidden] { display: none; }
#object-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
#object-card .sub {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .1em; margin-bottom: 10px;
}
#object-card dl {
  display: grid; grid-template-columns: auto 1fr;
  gap: 4px 14px; font-family: var(--font-mono); font-size: 11px;
}
#object-card dt { color: var(--text-dim); }
#object-card dd { color: var(--text); text-align: right; }
#object-card .close {
  position: absolute; top: 8px; right: 9px;
  background: none; border: none; color: var(--text-dim);
  font-size: 15px; line-height: 1; padding: 3px;
}
#object-card .close:hover { color: var(--text); }

/* ── Tonight rail ───────────────────────────────────────────────────────── */

.stat {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.stat:last-child { border-bottom: none; }
.stat .k { color: var(--text-muted); }
.stat .v { font-family: var(--font-mono); font-size: 12px; color: var(--text); }

.pending {
  font-size: 12px; color: var(--text-dim);
  padding: 10px 0; line-height: 1.5;
}

.shower {
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.shower:last-child { border-bottom: none; }
.shower-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.shower-name { font-size: 13px; color: var(--text); }
.shower.peak .shower-name { color: #ff9f43; font-weight: 600; }
.shower-alt { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.shower-verdict { font-size: 11.5px; color: var(--text-muted); line-height: 1.45; margin-top: 2px; }

.varo-strip {
  margin-top: 22px; padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 7px;
  font-size: 12px;
}
.varo-strip .label {
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 3px;
}
.varo-strip a { color: var(--text-muted); transition: color var(--transition); }
.varo-strip a:hover { color: var(--accent); text-decoration: none; }
.varo-strip a::after { content: ' ↗'; font-size: 9px; color: var(--text-dim); }

.site-footer {
  margin-top: 18px; padding-top: 13px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim);
  font-family: var(--font-mono); line-height: 1.9;
}
.site-footer a { color: var(--text-dim); }
.site-footer a:hover { color: var(--accent); text-decoration: none; }
.site-footer .legal { letter-spacing: .02em; }

/* ── Time bar ───────────────────────────────────────────────────────────── */

#timebar {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 11px 18px;
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}

.transport { display: flex; gap: 5px; }
.transport button, .speed button, .jump button {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted);
  transition: var(--transition);
}
.transport button:hover, .speed button:hover, .jump button:hover {
  border-color: var(--border-bright); color: var(--text); background: var(--bg-hover);
}
.speed button[aria-pressed="true"] {
  background: var(--accent-dim); border-color: var(--accent); color: var(--accent);
}

#clock-readout {
  font-family: var(--font-mono); font-size: 13px;
  color: var(--text); min-width: 232px; letter-spacing: .02em;
}
#clock-readout .live { color: var(--accent); font-weight: 600; }
#clock-readout .scrubbed { color: var(--yellow); font-weight: 600; }

#time-slider { flex: 1; min-width: 160px; }

.speed, .jump { display: flex; gap: 5px; margin-left: auto; }

/* ── Location control ───────────────────────────────────────────────────── */

.loc-search { display: flex; gap: 6px; margin-bottom: 10px; }
.loc-search input {
  flex: 1; min-width: 0;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text); font-family: var(--font-sans); font-size: 13px;
}
.loc-search input:focus { outline: none; border-color: var(--accent); }
.loc-search button {
  background: var(--accent-dim); border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm); padding: 7px 11px;
  font-family: var(--font-mono); font-size: 11px; color: var(--accent);
  transition: var(--transition);
}
.loc-search button:hover { background: var(--accent-glow); }

#loc-results { list-style: none; font-size: 13px; }
#loc-results li {
  padding: 7px 9px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--transition);
}
#loc-results li:hover { background: var(--bg-hover); }
#loc-results .coord {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-dim);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 34px 1fr auto auto;
    grid-template-areas:
      "status"
      "sky"
      "time"
      "left";
  }
  #rail-right { display: none; }
  #rail-left {
    border-right: none; border-top: 1px solid var(--border);
    max-height: 34dvh;
  }
  #status-meta { gap: 10px; }
  #status-meta .hide-sm { display: none; }
  .speed, .jump { margin-left: 0; }
  #clock-readout { min-width: 0; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
