/* Planet Orbits — dark space theme, one amber accent. */

:root {
  --bg: #050810;
  --bg-soft: #0a0f1a;
  --panel: rgba(13, 18, 28, 0.88);
  --line: rgba(178, 200, 235, 0.14);
  --line-soft: rgba(178, 200, 235, 0.08);
  --ink: #e8edf4;
  --mut: #93a2b5;
  --mut-2: #6b7a90;
  --accent: #f0b35c;
  --accent-dim: rgba(240, 179, 92, 0.16);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html.smooth-scroll { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }

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

/* ---------- top bar ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(5, 8, 16, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.brand b { font-weight: 600; }
.brand-mark { width: 24px; height: 24px; flex: none; }

.topnav { display: flex; gap: 4px; }
.topnav a {
  color: var(--mut);
  text-decoration: none;
  font-size: 13.5px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.topnav a:hover { color: var(--ink); background: var(--line-soft); }

/* ---------- stage ---------- */

.stage {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#space {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#space:active { cursor: grabbing; }

.hud { position: absolute; z-index: 10; }

/* view controls — top right */

.hud-view {
  top: calc(var(--topbar-h) + 14px);
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.seg {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 3px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--mut);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  min-height: 34px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.on { background: var(--accent-dim); color: var(--accent); }

.scale-note {
  max-width: 230px;
  text-align: right;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--mut-2);
  padding-right: 2px;
}

.hud-btns { display: flex; gap: 8px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  color: var(--mut);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: color 0.15s, border-color 0.15s, transform 0.1s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { color: var(--ink); border-color: rgba(178, 200, 235, 0.32); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.small { width: 34px; height: 34px; border-radius: 9px; }
.icon-btn.small svg { width: 15px; height: 15px; }

.settings {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 210px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.settings label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  font-size: 13px;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
}
.settings label:hover { background: var(--line-soft); }
.settings input { accent-color: var(--accent); width: 16px; height: 16px; }

/* follow chip */

.hud-follow {
  top: calc(var(--topbar-h) + 14px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 14px;
  font-size: 12.5px;
  color: var(--mut);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.hud-follow b { color: var(--accent); font-weight: 600; }
.hud-follow button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border: 0; border-radius: 50%;
  background: var(--line-soft);
  color: var(--mut);
}
.hud-follow button:hover { color: var(--ink); background: var(--line); }
.hud-follow button svg { width: 11px; height: 11px; }

/* first-visit hint + toast */

.hint {
  position: absolute;
  z-index: 10;
  left: 16px;
  bottom: 92px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  padding: 11px 10px 11px 16px;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.hint p { color: var(--mut); }
.hint button {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border: 0; border-radius: 7px;
  background: var(--line-soft);
  color: var(--mut);
}
.hint button:hover { color: var(--ink); }
.hint button svg { width: 12px; height: 12px; }

.toast {
  position: absolute;
  z-index: 11;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 48px));
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--ink);
  text-align: center;
  background: rgba(20, 26, 38, 0.95);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* time controls — bottom centre */

.hud-time {
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 15px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.icon-btn.play {
  width: 44px; height: 44px;
  color: var(--accent);
  border-color: rgba(240, 179, 92, 0.35);
  background: var(--accent-dim);
}
.icon-btn.play .ic-play { display: none; }
.icon-btn.play.paused .ic-play { display: block; }
.icon-btn.play.paused .ic-pause { display: none; }

.speeds {
  display: flex;
  background: rgba(5, 8, 16, 0.5);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 3px;
}
.speeds button {
  border: 0;
  background: transparent;
  color: var(--mut);
  font: 500 12px var(--mono);
  padding: 7px 11px;
  min-height: 34px;
  border-radius: 7px;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.speeds button:hover { color: var(--ink); }
.speeds button.on { background: var(--line); color: var(--ink); }

.date {
  font: 500 13px var(--mono);
  color: var(--ink);
  padding: 0 12px 0 4px;
  min-width: 96px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* scroll cue */

.cue {
  position: absolute;
  z-index: 10;
  right: 16px;
  bottom: 26px;
  color: var(--mut-2);
  text-decoration: none;
  font-size: 12.5px;
  padding: 10px 4px;
  transition: color 0.15s;
}
.cue:hover { color: var(--accent); }

/* ---------- planet panel ---------- */

.panel {
  position: fixed;
  z-index: 20;
  top: calc(var(--topbar-h) + 14px);
  right: 16px;
  bottom: 96px;
  width: 330px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transform: translateX(calc(100% + 24px));
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.25, 1);
  overflow-y: auto;
}
.panel.open { transform: translateX(0); }

.panel-grip { display: none; }

.panel-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
}
.panel-dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 10px 1px currentColor;
}
.panel-head h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
  flex: 1;
}

.stats { margin: 0 0 14px; display: grid; gap: 2px; }
.stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.stat dt { color: var(--mut); font-size: 12.5px; }
.stat dd {
  margin: 0;
  font: 500 12.5px var(--mono);
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.fact {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink);
  padding: 12px 14px;
  background: rgba(240, 179, 92, 0.07);
  border: 1px solid rgba(240, 179, 92, 0.18);
  border-radius: 11px;
  margin-bottom: 16px;
}

.panel-actions { margin-top: auto; }
.btn {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(240, 179, 92, 0.4);
  border-radius: 11px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: rgba(240, 179, 92, 0.26); }
.btn:active { transform: scale(0.98); }
.btn[aria-pressed="true"] { background: var(--accent); color: #1a1206; }

/* ---------- content sections ---------- */

.page-sec { padding: 96px 20px 40px; }
.wrap { max-width: 1160px; margin: 0 auto; }

.kicker {
  font: 500 12px var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.page-sec h2 {
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 14px;
}

.lede {
  max-width: 640px;
  font-size: 16px;
  line-height: 1.65;
  color: var(--mut);
  margin-bottom: 40px;
}

.law-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.law-card {
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
}

.law-card h3 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.law-num {
  font: 500 12px var(--mono);
  color: var(--accent);
  border: 1px solid rgba(240, 179, 92, 0.35);
  border-radius: 7px;
  padding: 2px 7px;
}

.law-card > p {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--mut);
  margin-bottom: 16px;
}

.lab-canvas {
  width: 100%;
  height: 270px;
  display: block;
  background: rgba(5, 8, 16, 0.6);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.law-controls { margin-top: 14px; }

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--mut);
  margin-bottom: 6px;
}
.slider-label output { font: 500 12.5px var(--mono); color: var(--accent); }

input[type="range"] {
  width: 100%;
  height: 28px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #0a0f1a;
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #0a0f1a;
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.chips button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--mut);
  font: 500 11px var(--mono);
  padding: 6px 11px;
  min-height: 30px;
  transition: color 0.15s, border-color 0.15s;
}
.chips button:hover { color: var(--ink); border-color: rgba(178, 200, 235, 0.4); }

.readout {
  font: 400 11.5px/1.5 var(--mono);
  color: var(--mut);
  min-height: 18px;
}

.chart-wrap { position: relative; }
.chart-tip {
  position: absolute;
  z-index: 5;
  padding: 8px 11px;
  font: 400 11px/1.6 var(--mono);
  color: var(--ink);
  background: rgba(20, 26, 38, 0.96);
  border: 1px solid var(--line);
  border-radius: 9px;
  pointer-events: none;
  white-space: nowrap;
}
.chart-tip b { color: var(--accent); }

/* table */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--bg-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  white-space: nowrap;
}
th, td { padding: 12px 16px; text-align: left; }
thead th {
  font: 500 11px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mut-2);
  border-bottom: 1px solid var(--line-soft);
}
tbody tr { border-bottom: 1px solid var(--line-soft); }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: rgba(178, 200, 235, 0.04); }
td:nth-child(n+2):nth-child(-n+5) { font: 400 12.5px var(--mono); color: var(--ink); }

.tdot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 9px;
  vertical-align: 1px;
}

.locate {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--mut);
  font: 500 11px var(--mono);
  padding: 6px 12px;
  min-height: 30px;
  transition: color 0.15s, border-color 0.15s;
}
.locate:hover { color: var(--accent); border-color: rgba(240, 179, 92, 0.5); }

/* footer */

.foot {
  padding: 40px 20px 56px;
  border-top: 1px solid var(--line-soft);
}
.foot p {
  max-width: 720px;
  margin: 0 auto 10px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--mut-2);
  text-align: center;
}
.foot .muted { color: #48556a; }

/* ---------- mobile ---------- */

@media (max-width: 900px) {
  .law-grid { grid-template-columns: 1fr; }
  .law-card { max-width: 560px; }
}

@media (max-width: 720px) {
  .topbar { padding: 0 14px; }
  .brand span { font-size: 14px; }
  .topnav a { padding: 8px 8px; font-size: 12.5px; }

  .hud-view { right: 10px; }
  .scale-note { max-width: 190px; }

  .hud-time {
    left: 10px;
    right: 10px;
    transform: none;
    bottom: 14px;
    justify-content: space-between;
    gap: 6px;
  }
  .speeds { flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .speeds::-webkit-scrollbar { display: none; }
  .speeds button { padding: 7px 9px; font-size: 11px; }
  .date { min-width: 0; font-size: 12px; padding-right: 4px; white-space: nowrap; }

  .hud-follow { left: 10px; transform: none; }

  .hint { left: 10px; right: 10px; bottom: 84px; max-width: none; }
  .cue { display: none; }

  /* panel becomes a bottom sheet */
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    max-height: 62dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    padding: 8px 20px 24px;
    transform: translateY(calc(100% + 24px));
  }
  .panel.open { transform: translateY(0); }
  .panel-grip {
    display: block;
    width: 38px; height: 4px;
    margin: 6px auto 14px;
    padding: 10px 0;
    border-radius: 2px;
    background: var(--line);
    background-clip: content-box;
    cursor: grab;
    touch-action: none;
  }
}

@media (max-width: 420px) {
  .topnav a[href="#numbers"] { display: none; }
  .seg-btn { padding: 7px 10px; font-size: 12px; }
}

/* reduced motion: kill UI transitions; the simulation itself is content */
@media (prefers-reduced-motion: reduce) {
  html.smooth-scroll { scroll-behavior: auto; }
  .panel, .icon-btn, .btn, .topnav a, .seg-btn, .speeds button { transition: none; }
}
