/* ===================================================================
 * Orrery · Universe Simulator
 * Modern HUD design — mission-control meets editorial dark UI.
 * Uses system font stack (no external font requests).
 * =================================================================== */

:root {
  --bg: #03050a;
  --bg-deep: #01020a;
  --panel-bg: rgba(8, 12, 22, 0.62);
  --panel-bg-strong: rgba(10, 16, 28, 0.86);
  --panel-border: rgba(255, 255, 255, 0.07);
  --panel-border-strong: rgba(255, 255, 255, 0.13);
  --text: #f0f4ff;
  --text-mute: rgba(240, 244, 255, 0.62);
  --text-faint: rgba(240, 244, 255, 0.38);
  --accent: #6dd5ff;
  --accent-warm: #ffb86b;
  --accent-soft: rgba(109, 213, 255, 0.18);
  --accent-line: rgba(109, 213, 255, 0.42);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  --radius: 14px;
  --radius-sm: 9px;
  --gutter: 18px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "IBM Plex Mono", Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  /* Subtle nebular backdrop, just in case the WebGL context fails. */
  background:
    radial-gradient(circle at 20% 80%, rgba(80, 30, 140, 0.18), transparent 55%),
    radial-gradient(circle at 78% 18%, rgba(20, 70, 160, 0.20), transparent 50%),
    var(--bg-deep);
}

#viewport {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  touch-action: none;
}

/* ---------- HUD framework ---------- */

.hud {
  position: fixed;
  z-index: 10;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
}

.hud::before {
  /* Hairline highlight */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), transparent 45%);
  -webkit-mask: linear-gradient(#000, #000) content-box, linear-gradient(#000, #000);
  mask: linear-gradient(#000, #000) content-box, linear-gradient(#000, #000);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.hud--topleft    { top: var(--gutter); left: var(--gutter); min-width: 248px; }
.hud--topright   { top: var(--gutter); right: var(--gutter); min-width: 192px; display: grid; gap: 10px; }
.hud--right      { top: 50%; right: var(--gutter); transform: translateY(-50%); width: 138px; padding: 14px 12px; }
.hud--bottomleft { bottom: var(--gutter); left: var(--gutter); display: grid; gap: 14px; }
.hud--bottomright{ bottom: var(--gutter); right: var(--gutter); width: 360px; padding: 0; overflow: hidden; }

/* ---------- Brand block ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}
.brand__mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, #fff7d4, #ffcf6b 45%, #c97a18 70%, #6b3403 100%);
  box-shadow:
    0 0 18px rgba(255, 196, 102, 0.55),
    0 0 0 1px rgba(255, 196, 102, 0.25);
  position: relative;
}
.brand__mark::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(255, 196, 102, 0.30);
  opacity: 0.7;
}
.brand__text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.brand__title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
}
.brand__sub {
  font-size: 10.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.brand__chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(109, 213, 255, 0.10);
  color: var(--accent);
  border: 1px solid rgba(109, 213, 255, 0.22);
}

/* ---------- Metric lines ---------- */

.metric {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
}
.metric + .metric {
  border-top: 1px dashed rgba(255, 255, 255, 0.06);
  margin-top: 6px;
  padding-top: 12px;
}
.metric__label {
  font-size: 10.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.metric__value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.metric--row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
.metric--row .metric__label { color: var(--text-mute); }
.metric--row + .metric--row { border-top: none; padding-top: 0; margin-top: 0; }

/* ---------- Status indicator ---------- */

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--panel-border);
}
.status__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #6effb8;
  box-shadow: 0 0 10px rgba(110, 255, 184, 0.7);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.status__dot[data-state="paused"] {
  background: var(--accent-warm);
  box-shadow: 0 0 10px rgba(255, 184, 107, 0.65);
}
.status__dot[data-state="paused"]::after {
  /* Pulses slowly when paused */
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--accent-warm);
  opacity: 0.6;
  animation: pulse 1.6s ease-in-out infinite;
}
.status__label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
}

@keyframes pulse {
  0%, 100% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.25); opacity: 0.0; }
}

/* ---------- Body list nav ---------- */

.nav-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--panel-border);
}
.nav-title__label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.nav-title__hint {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.body-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.body-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  position: relative;
}
.body-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--panel-border);
}
.body-item.is-active {
  background: rgba(109, 213, 255, 0.10);
  border-color: rgba(109, 213, 255, 0.34);
}
.body-item.is-active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-line);
}
.body-item__chip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0 6px rgba(0, 0, 0, 0.6);
}
.body-item__name {
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.02em;
}
.body-item__type {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-faint);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------- Bottom-left controls ---------- */

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctl {
  --size: 40px;
  width: var(--size);
  height: var(--size);
  border-radius: 11px;
  background: rgba(109, 213, 255, 0.12);
  border: 1px solid rgba(109, 213, 255, 0.30);
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
}
.ctl:hover {
  background: rgba(109, 213, 255, 0.22);
  border-color: rgba(109, 213, 255, 0.55);
}
.ctl:active { transform: scale(0.96); }
.ctl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ctl--ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--panel-border);
  color: var(--text-mute);
}
.ctl--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--panel-border-strong);
  color: var(--text);
}

.ctl__icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.ctl[data-state="paused"] .ctl__icon[data-icon="pause"] { display: none; }
.ctl[data-state="running"] .ctl__icon[data-icon="play"]  { display: none; }

.ctl[data-state="reverse"] {
  background: rgba(255, 184, 107, 0.14);
  border-color: rgba(255, 184, 107, 0.36);
  color: var(--accent-warm);
}

.speed-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.speed {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  color: var(--text-mute);
  cursor: pointer;
  transition: all 0.15s ease;
  font-variant-numeric: tabular-nums;
  min-width: 46px;
}
.speed:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}
.speed.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(109, 213, 255, 0.18), 0 0 14px rgba(109, 213, 255, 0.18);
}

.shortcut-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
}
.kbd {
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  font-size: 10px;
  color: var(--text-mute);
}
.shortcut-hint { margin-right: 8px; letter-spacing: 0.04em; }

/* ---------- Info card ---------- */

.info-card {
  display: block;
  position: relative;
}
.info-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(109, 213, 255, 0.07), transparent 80%);
}
.info-card__swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0 12px rgba(0, 0, 0, 0.5);
  transition: background 0.3s ease;
}
.info-card__title { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.info-card__name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}
.info-card__type {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.info-card__symbol {
  font-family: var(--font-mono);
  font-size: 22px;
  color: var(--accent);
  opacity: 0.65;
  line-height: 1;
}

.info-card__lede {
  margin: 0;
  padding: 14px 18px 4px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-mute);
}

.info-grid {
  margin: 0;
  padding: 10px 18px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}
.info-stat { display: flex; flex-direction: column; gap: 2px; }
.info-stat dt {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.info-stat dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.info-card__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-top: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.18);
}
.live-tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(110, 255, 184, 0.12);
  color: #6effb8;
  border: 1px solid rgba(110, 255, 184, 0.28);
}
.live-label {
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

/* ---------- Vignette + boot ---------- */

.vignette {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.45) 100%);
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease;
}
.boot.is-hidden { opacity: 0; pointer-events: none; }
.boot__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.boot__ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(109, 213, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 1.1s linear infinite;
}
.boot__text {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-faint);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Cursor states ---------- */
#viewport { cursor: grab; }
#viewport.is-grabbing { cursor: grabbing; }
#viewport.is-pointing { cursor: pointer; }

/* ---------- Smaller screens ---------- */

@media (max-width: 1080px) {
  .hud--right { width: 116px; }
  .hud--bottomright { width: 320px; }
}

@media (max-width: 860px) {
  .hud--right { display: none; }
  .hud--bottomright {
    width: calc(100vw - 2 * var(--gutter));
    left: var(--gutter);
    bottom: 200px;
  }
  .hud--bottomleft { bottom: var(--gutter); }
}

@media (max-width: 640px) {
  .hud--topleft { min-width: 0; }
  .hud--topright { display: none; }
  .hud--bottomright { display: none; }
  .hud--bottomleft { left: 50%; transform: translateX(-50%); }
}
