/* ===========================================================================
   Orbital — n-body gravity sandbox
   Dark, luminous, deep-space HUD aesthetic. System fonts only, no webfonts.
   =========================================================================== */

:root {
  --void-0: #05060a;
  --void-1: #0a0d18;
  --nebula: #10162e;

  --glass: rgba(14, 18, 32, 0.66);
  --glass-edge: rgba(255, 255, 255, 0.08);
  --glass-edge-strong: rgba(255, 255, 255, 0.14);

  --accent-cyan: #54e0ff;
  --accent-violet: #a98bff;

  --text: #e8ecf6;
  --muted: #9aa3bd;
  --faint: #5b6480;

  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 8px;

  --sys-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sys-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--void-0);
  color: var(--text);
  font-family: var(--sys-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#sky {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--nebula) 0%, transparent 55%),
    linear-gradient(180deg, var(--void-1) 0%, var(--void-0) 70%);
}

/* ----------------------------------------------------------------- HUD ---- */
.hud {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 270px;
  max-width: calc(100vw - 32px);
  padding: 14px 16px 16px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  z-index: 10;
  user-select: none;
}

.hud__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hud__brand { display: flex; align-items: center; gap: 9px; }

.hud__dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6cf, #ff9f3d 60%, #ff6a2c 100%);
  box-shadow: 0 0 14px 2px rgba(255, 150, 60, 0.7);
}

.hud__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hud__lede {
  margin: 12px 0 14px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.hud__body {
  overflow: hidden;
  transition: max-height 0.32s ease, opacity 0.28s ease, margin 0.28s ease;
  max-height: 640px;
  opacity: 1;
}

.hud.is-collapsed .hud__body {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------- buttons ---- */
.btnrow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.btn__ico { font-size: 13px; line-height: 1; opacity: 0.95; }
.btn:hover {
  transform: translateY(-1px);
  border-color: var(--glass-edge-strong);
  box-shadow: 0 0 0 1px rgba(84, 224, 255, 0.15), 0 8px 22px rgba(0,0,0,0.45);
}
.btn:active { transform: translateY(0); }
.btn:focus-visible {
  outline: none;
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--void-1), 0 0 0 4px var(--accent-cyan);
}
.btn--ghost { color: var(--muted); }
.btn[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(84,224,255,0.22), rgba(169,139,255,0.16));
  border-color: rgba(84,224,255,0.5);
  color: #f2faff;
}

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.iconbtn__glyph { font-size: 18px; line-height: 1; }
.iconbtn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.iconbtn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--void-1), 0 0 0 4px var(--accent-cyan);
}

/* ------------------------------------------------------------- sliders ---- */
.ctrl { margin-bottom: 14px; }

.ctrl__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.ctrl__val {
  font-family: var(--sys-mono);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--accent-cyan);
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--accent-cyan), var(--accent-violet)) no-repeat,
    rgba(255,255,255,0.08);
  background-size: var(--fill, 40%) 100%, 100% 100%;
  cursor: pointer;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent-cyan);
  box-shadow: 0 0 10px 1px rgba(84,224,255,0.7);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.12); }
.slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent-cyan);
  box-shadow: 0 0 10px 1px rgba(84,224,255,0.7);
  cursor: pointer;
}
.slider:focus-visible {
  box-shadow: 0 0 0 2px var(--void-1), 0 0 0 4px var(--accent-cyan);
}

/* ------------------------------------------------------------ toggles ----- */
.toggles {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
}

.chk {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.chk input { position: absolute; opacity: 0; width: 0; height: 0; }
.chk__box {
  width: 16px; height: 16px;
  border-radius: 5px;
  border: 1px solid var(--glass-edge-strong);
  background: rgba(255,255,255,0.04);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.chk input:checked + .chk__box {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  border-color: transparent;
}
.chk input:checked + .chk__box::after {
  content: "";
  position: absolute;
  left: 5px; top: 2px;
  width: 4px; height: 8px;
  border: solid #06121a;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.chk input:focus-visible + .chk__box {
  box-shadow: 0 0 0 2px var(--void-1), 0 0 0 4px var(--accent-cyan);
}
.chk:hover .chk__lbl { color: var(--text); }

/* -------------------------------------------------------------- stats ----- */
.stats {
  display: flex;
  gap: 10px;
  margin: 4px 0 14px;
}
.stat {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-edge);
}
.stat__k {
  display: block;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.stat__v {
  display: block;
  margin-top: 2px;
  font-family: var(--sys-mono);
  font-size: 16px;
  color: var(--text);
}

/* --------------------------------------------------------------- help ----- */
.link {
  display: inline-block;
  padding: 2px 0;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--accent-violet);
  background: none;
  border: none;
  cursor: pointer;
}
.link:hover { color: var(--accent-cyan); }
.link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--void-1), 0 0 0 4px var(--accent-cyan);
  border-radius: 4px;
}

.help {
  list-style: none;
  margin: 10px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--glass-edge);
  display: grid;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
}
.help[hidden] { display: none; }
.help li { display: flex; align-items: center; gap: 9px; }
kbd {
  display: inline-block;
  min-width: 34px;
  text-align: center;
  padding: 2px 6px;
  font-family: var(--sys-mono);
  font-size: 10.5px;
  color: var(--text);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-edge-strong);
  border-radius: 5px;
}

/* ------------------------------------------------------------- footer ----- */
.footer {
  position: fixed;
  right: 14px;
  bottom: 12px;
  z-index: 10;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--faint);
  text-decoration: none;
  transition: color 0.18s ease;
}
.footer:hover { color: var(--muted); }
.footer:focus-visible {
  outline: none;
  color: var(--accent-cyan);
  border-radius: 4px;
  box-shadow: 0 0 0 2px var(--void-1), 0 0 0 4px var(--accent-cyan);
}

/* -------------------------------------------------------- responsive ------ */
@media (max-width: 560px) {
  .hud {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
  }
  .footer {
    right: 10px;
    bottom: 8px;
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
