/* Glassmorphism dark HUD — Interactive Solar System Viewer */

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

html, body {
  width: 100%;
  height: 100%;
  width: 100dvw;
  height: 100dvh;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e8ecf4;
  background: #020408;
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

/* ── Viewport orientation gizmo ───────────────────────────────── */
#orientation-gizmo {
  position: absolute;
  top: 72px;
  right: 16px;
  width: 108px;
  height: 108px;
  z-index: 25;
  cursor: pointer;
  border-radius: 50%;
  background: rgba(20, 24, 34, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  touch-action: none;
  transition: background 0.18s ease, border-color 0.18s ease;
}

#orientation-gizmo:hover {
  background: rgba(30, 36, 52, 0.70);
  border-color: rgba(255, 255, 255, 0.28);
}

#orientation-gizmo canvas {
  display: block;
  width: 108px;
  height: 108px;
  border-radius: 50%;
}

@media (max-width: 900px) {
  #orientation-gizmo {
    right: 15px;
  }
}

@media (max-width: 600px) {
  #orientation-gizmo {
    transform: scale(0.82);
    transform-origin: top right;
    top: 60px;
    right: 10px;
  }
}

/* ── Glass panel base ─────────────────────────────────────────── */
.glass-panel {
  position: fixed;
  z-index: 10;
  background: rgba(12, 18, 32, 0.55);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

/* ── Top bar ──────────────────────────────────────────────────── */
#top-bar {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
  white-space: nowrap;
}

#top-bar h1 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #c8d8f0;
}

.top-controls {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  padding: 6px 14px;
  font-size: 0.78rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #b0c0d8;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.toggle-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.toggle-btn.active { background: rgba(60, 120, 220, 0.35); border-color: rgba(100, 160, 255, 0.4); color: #fff; }
.toggle-btn.true-scale { background: rgba(180, 100, 40, 0.35); border-color: rgba(255, 160, 80, 0.4); }

/* ── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
  top: 72px;
  left: 12px;
  width: 240px;
  max-height: calc(100vh - 160px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease, opacity 0.25s;
}

#sidebar.collapsed {
  width: 44px;
  overflow: hidden;
}

#sidebar.collapsed #hierarchy-tree,
#sidebar.collapsed h2 { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header h2 {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8899b0;
}

#sidebar-toggle {
  background: none;
  border: none;
  color: #8899b0;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px;
}

#hierarchy-tree {
  overflow-y: auto;
  padding: 8px 0;
  flex: 1;
}

.tree-item { user-select: none; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px 5px 8px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.15s;
}

.tree-row:hover { background: rgba(255, 255, 255, 0.06); }
.tree-row.selected { background: rgba(60, 120, 220, 0.25); color: #fff; }

.tree-toggle, .tree-spacer {
  width: 14px;
  font-size: 0.7rem;
  color: #667;
  flex-shrink: 0;
}

.tree-children { padding-left: 12px; }
.tree-children.collapsed { display: none; }

.depth-0 > .tree-row .tree-label { font-weight: 600; }

/* ── Telemetry card ───────────────────────────────────────────── */
#telemetry-card {
  top: 196px;
  right: 12px;
  width: 260px;
  padding: 16px 18px;
}

#telemetry-card.hidden { display: none; }

#telemetry-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: #d0e0ff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 0.78rem;
}

.telemetry-grid dt {
  color: #7888a0;
  font-weight: 500;
}

.telemetry-grid dd {
  text-align: right;
  color: #e0e8f8;
  font-variant-numeric: tabular-nums;
}

/* ── Bottom bar ───────────────────────────────────────────────── */
#bottom-bar {
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
}

.transport-controls {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #c0d0e8;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.2s;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.icon-btn.active { background: rgba(200, 80, 80, 0.3); border-color: rgba(255, 100, 100, 0.4); }

.timeline-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

#timeline-slider {
  width: 100%;
  accent-color: #5090e0;
  cursor: pointer;
}

#time-label {
  font-size: 0.72rem;
  color: #8899b0;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.speed-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.speed-label {
  font-size: 0.72rem;
  color: #667;
  margin-right: 4px;
}

.speed-btn {
  padding: 4px 8px;
  font-size: 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: #a0b0c8;
  cursor: pointer;
  transition: background 0.15s;
}

.speed-btn:hover { background: rgba(255, 255, 255, 0.12); }
.speed-btn.active { background: rgba(60, 120, 220, 0.35); color: #fff; border-color: rgba(100, 160, 255, 0.35); }

/* ── HUD notice ───────────────────────────────────────────────── */
#hud-notice {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 20;
  padding: 8px 18px;
  background: rgba(200, 120, 40, 0.85);
  border-radius: 8px;
  font-size: 0.78rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

#hud-notice.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Loading overlay ──────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #020408;
  gap: 16px;
  transition: opacity 0.5s;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  display: none;
}

#loading-overlay p {
  font-size: 0.85rem;
  color: #667;
}

.loader-ring {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: #5090e0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Responsive: phones only. Laptops stay on the desktop HUD. ── */
#tex-credit {
  position: fixed;
  left: 14px;
  bottom: 78px;
  z-index: 8;
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.02em;
  color: rgba(200, 210, 230, 0.42);
  pointer-events: none;
  max-width: 42vw;
}

@media (max-width: 640px) {
  #top-bar {
    left: 12px;
    right: 12px;
    transform: none;
    white-space: normal;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
  }

  #top-bar h1 {
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
  }

  .top-controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .toggle-btn {
    padding: 6px 10px;
    font-size: 0.72rem;
  }

  #orientation-gizmo {
    top: 108px;
    right: 10px;
    width: 72px;
    height: 72px;
    transform: none;
  }

  #orientation-gizmo canvas {
    width: 72px;
    height: 72px;
  }

  #sidebar {
    top: 118px;
    width: 200px;
  }

  #telemetry-card {
    width: calc(100% - 24px);
    right: 12px;
    top: auto;
    bottom: 90px;
  }

  #hud-notice {
    top: auto;
    bottom: 88px;
  }

  #bottom-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
  }

  .speed-controls { flex-wrap: wrap; }

  #tex-credit { display: none; }
}
