/* ============================================================
   Solar System Simulator — UI styles
   Dark "deep space" theme with glassmorphism panels.
   ============================================================ */

:root {
  --bg: #03040a;
  --panel-bg: rgba(12, 16, 30, 0.72);
  --panel-border: rgba(120, 160, 255, 0.18);
  --panel-glow: rgba(80, 130, 255, 0.25);
  --text: #e7ecff;
  --text-dim: #9aa6c8;
  --text-faint: #6b779b;
  --accent: #6ea8ff;
  --accent-2: #ffcf6e;
  --good: #74e0a3;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  cursor: default;
}

#scene-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

/* The CSS2D label layer sits above the canvas but must not eat pointer events
   except on the labels themselves. */
#label-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

/* ---------------- Body labels (CSS2D) ---------------- */
.body-label {
  pointer-events: auto;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 1);
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
  transform: translateY(-50%);
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.body-label::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dot, var(--accent));
  box-shadow: 0 0 8px var(--dot, var(--accent));
  flex: none;
}
.body-label:hover {
  color: #fff;
  background: rgba(80, 130, 255, 0.12);
}
.body-label.is-selected {
  color: #fff;
  background: rgba(110, 168, 255, 0.18);
}
.body-label.is-minor {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0.02em;
}

/* ---------------- Top title / brand ---------------- */
#brand {
  position: fixed;
  top: 22px;
  left: 26px;
  z-index: 20;
  user-select: none;
  pointer-events: none;
}
#brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  background: linear-gradient(90deg, #cfe0ff, #8ab0ff 60%, #ffcf8a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#brand p {
  margin: 3px 0 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ---------------- Control dock (bottom) ---------------- */
#controls {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  max-width: calc(100vw - 32px);
  flex-wrap: wrap;
  justify-content: center;
}

.ctl-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ctl-sep {
  width: 1px;
  height: 26px;
  background: var(--panel-border);
}

button.icon-btn,
button.text-btn {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button.icon-btn {
  width: 38px;
  height: 38px;
  font-size: 16px;
}
button.text-btn {
  height: 34px;
  padding: 0 13px;
  font-size: 12px;
  letter-spacing: 0.04em;
  gap: 7px;
}
button.icon-btn:hover,
button.text-btn:hover {
  background: rgba(110, 168, 255, 0.16);
  border-color: var(--panel-border);
}
button.icon-btn:active,
button.text-btn:active { transform: scale(0.94); }
button.is-active {
  background: rgba(110, 168, 255, 0.22);
  border-color: rgba(110, 168, 255, 0.5);
  color: #fff;
}
button.is-active .dot-on { opacity: 1; }

.ctl-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  user-select: none;
}

/* Speed slider */
.speed-wrap { display: flex; align-items: center; gap: 9px; }
#speed-value {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  min-width: 52px;
  text-align: right;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 130px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #2a3a66);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #dce8ff;
  border: 2px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(110, 168, 255, 0.6);
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: #dce8ff; border: 2px solid var(--accent); cursor: pointer;
}

/* ---------------- Jump-to menu ---------------- */
#jump-wrap { position: relative; }
#jump-menu {
  position: absolute;
  bottom: 46px;
  left: 0;
  min-width: 180px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  max-height: 50vh;
  overflow-y: auto;
}
#jump-menu.open { display: flex; }
.jump-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  transition: background 0.12s ease, color 0.12s ease;
}
.jump-item:hover { background: rgba(110, 168, 255, 0.14); color: #fff; }
.jump-item .swatch {
  width: 11px; height: 11px; border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
  flex: none;
}
.jump-item .jtype {
  margin-left: auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

/* ---------------- Info panel (right) ---------------- */
#info-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  width: 380px;
  max-width: 92vw;
  height: 100%;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: -18px 0 60px rgba(0, 0, 0, 0.55);
  transform: translateX(105%);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#info-panel.open { transform: translateX(0); }

.panel-hero {
  position: relative;
  height: 190px;
  flex: none;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid var(--panel-border);
}
.panel-hero canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.panel-hero .hero-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(3, 4, 10, 0) 40%, rgba(8, 11, 22, 0.9) 100%);
  pointer-events: none;
}
.panel-hero .hero-text {
  position: relative;
  padding: 18px 22px;
  z-index: 2;
}
.panel-hero .hero-type {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.panel-hero h2 {
  margin: 4px 0 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

#panel-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(8, 11, 22, 0.6);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
#panel-close:hover { background: rgba(255, 90, 90, 0.25); }
#panel-close:active { transform: scale(0.9); }

.panel-body {
  padding: 20px 22px 30px;
  overflow-y: auto;
  flex: 1;
}
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb {
  background: rgba(110, 168, 255, 0.25);
  border-radius: 8px;
}

.panel-desc {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-dim);
  margin: 0 0 22px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 11px;
  padding: 11px 13px;
}
.stat .k {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: block;
  margin-bottom: 5px;
}
.stat .v {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
}
.stat .v small { color: var(--text-dim); font-size: 11px; }

.section-title {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--panel-border);
}

.facts {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.facts li {
  position: relative;
  padding-left: 22px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
}
.facts li::before {
  content: "✦";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent-2);
  font-size: 12px;
}

.panel-actions {
  margin-top: 22px;
  display: flex;
  gap: 10px;
}
.panel-actions button {
  flex: 1;
  height: 40px;
  font-size: 12px;
  letter-spacing: 0.05em;
}

/* ---------------- Hover tooltip ---------------- */
#hover-tip {
  position: fixed;
  z-index: 25;
  padding: 5px 10px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(8, 11, 22, 0.85);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  pointer-events: none;
  transform: translate(-50%, -150%);
  opacity: 0;
  transition: opacity 0.12s ease;
  white-space: nowrap;
}
#hover-tip.show { opacity: 1; }

/* ---------------- Help / hint (top right) ---------------- */
#hint {
  position: fixed;
  top: 22px;
  right: 26px;
  z-index: 20;
  text-align: right;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  pointer-events: none;
  transition: opacity 0.4s ease;
  line-height: 1.7;
}
#hint b { color: var(--text-dim); font-weight: 600; }

/* ---------------- Loading screen ---------------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(circle at 50% 40%, #0a1024, #03040a 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  transition: opacity 0.8s ease;
}
#loader.hidden { opacity: 0; pointer-events: none; }
.loader-orbit {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 2px solid rgba(110, 168, 255, 0.15);
  position: relative;
  animation: spin 2.4s linear infinite;
}
.loader-orbit::after {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
}
.loader-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff4d0, #ffb347);
  box-shadow: 0 0 30px #ffb347;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }
#loader .l-text {
  font-size: 12px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-dim);
}
#loader .l-sub {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-top: -16px;
  font-family: var(--mono);
}

@media (max-width: 640px) {
  #brand { top: 14px; left: 16px; }
  #hint { display: none; }
  #controls { gap: 8px; padding: 8px 10px; bottom: 14px; }
  input[type="range"] { width: 90px; }
  .ctl-label { display: none; }
  #info-panel { width: 100%; }
}
