/* ============================================================
   3D Solar System — UI overlay styles
   Dark glassmorphic HUD layered over the WebGL canvas
   ============================================================ */

:root {
  --bg:            #04060f;
  --panel-bg:      rgba(10, 14, 28, 0.72);
  --panel-border:  rgba(120, 160, 255, 0.18);
  --text:          #e6ecff;
  --text-dim:      #8b98c4;
  --accent:        #4da3ff;
  --accent-2:      #ffb84d;
  --radius:        14px;
  --blur:          blur(14px) saturate(140%);
  --shadow:        0 8px 32px rgba(0, 0, 0, 0.55);
  --font:          "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

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

#scene-container { position: fixed; inset: 0; }
#scene-container canvas { display: block; }

/* ---------- Loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; background: var(--bg); color: var(--text-dim);
  transition: opacity .6s ease, visibility .6s ease;
  font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
}
#loader.hidden { opacity: 0; visibility: hidden; }
.loader-ring {
  width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid rgba(120,160,255,.15);
  border-top-color: var(--accent);
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Panel ---------- */
.panel {
  position: fixed; top: 18px; left: 18px; z-index: 20;
  width: 268px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .35s cubic-bezier(.4,0,.2,1);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(77,163,255,.10), transparent);
}
.panel-head h1 {
  font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
}
#panel-toggle {
  width: 24px; height: 24px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--panel-border); background: rgba(255,255,255,.04);
  color: var(--text-dim); font-size: 15px; line-height: 1;
  transition: all .2s ease;
}
#panel-toggle:hover { color: var(--text); background: rgba(255,255,255,.10); }

.panel-body { padding: 16px; display: flex; flex-direction: column; gap: 20px; max-height: 74vh; overflow-y: auto; }
.panel.collapsed .panel-body { display: none; }

/* Scrollbar styling */
/* Safari / Chrome / Edge — webkit only (do not add scrollbar-color here) */
.panel-body::-webkit-scrollbar {
  width: 8px;
}
.panel-body::-webkit-scrollbar-track {
  background: transparent;
}
.panel-body::-webkit-scrollbar-thumb {
  background: rgba(77,163,255,.35);
  border-radius: 4px;
  border: 1px solid rgba(77,163,255,.10);
}
.panel-body::-webkit-scrollbar-thumb:hover {
  background: rgba(77,163,255,.55);
  border: 1px solid rgba(77,163,255,.25);
}
/* Firefox only — @supports detects lack of webkit support */
@supports not selector(::-webkit-scrollbar) {
  .panel-body {
    scrollbar-color: rgba(77,163,255,.35) transparent;
    scrollbar-width: thin;
  }
}

.ctrl-group { display: flex; flex-direction: column; gap: 9px; }
.ctrl-label {
  font-size: 10px; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--text-dim);
}
.row { display: flex; align-items: center; gap: 10px; }
.hint { font-size: 10.5px; color: var(--text-dim); opacity: .75; line-height: 1.5; }

/* Select */
select {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 13px;
  color: var(--text); background: rgba(255,255,255,.05);
  border: 1px solid var(--panel-border); border-radius: 9px;
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%238b98c4' stroke-width='1.6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
}
select:focus { outline: none; border-color: var(--accent); }
select option { background: #0b1022; color: var(--text); }

/* Buttons */
.btn {
  flex: 1; padding: 9px 12px; font: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--text); background: rgba(255,255,255,.05);
  border: 1px solid var(--panel-border); border-radius: 9px;
  cursor: pointer; transition: all .18s ease; white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.11); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { border-color: rgba(77,163,255,.45); color: #bcdcff; background: rgba(77,163,255,.12); }
.btn-primary:hover { background: rgba(77,163,255,.22); }

.badge {
  min-width: 52px; text-align: center; padding: 5px 9px;
  font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--accent-2); background: rgba(255,184,77,.10);
  border: 1px solid rgba(255,184,77,.25); border-radius: 7px;
}

/* Range slider */
input[type="range"] {
  width: 100%; height: 4px; appearance: none; border-radius: 2px; cursor: pointer;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--fill,10%), rgba(255,255,255,.12) var(--fill,10%));
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 0 10px rgba(77,163,255,.7); cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; background: #fff;
  border: 3px solid var(--accent); cursor: grab;
}
.range-legend {
  display: flex; justify-content: space-between;
  font-size: 9.5px; color: var(--text-dim); opacity: .6;
}

/* Quick-select time-rate chips: faster and more precise than dragging the
   slider onto an exact hour/day/month value. */
.chip-row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chip {
  padding: 5px 9px; font: inherit; font-size: 11px; font-weight: 500;
  color: var(--text-dim); background: rgba(255,255,255,.04);
  border: 1px solid var(--panel-border); border-radius: 20px;
  cursor: pointer; transition: all .15s ease;
}
.chip:hover { color: var(--text); background: rgba(255,255,255,.10); }
.chip.active {
  color: #bcdcff; background: rgba(77,163,255,.16);
  border-color: rgba(77,163,255,.5);
}

/* Switches */
.switch {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--text); cursor: pointer; user-select: none;
}
.switch input { display: none; }
.switch span {
  position: relative; flex: 0 0 34px; height: 18px; border-radius: 9px;
  background: rgba(255,255,255,.12); transition: background .22s ease;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }

/* ---------- Info card ---------- */
.info-card {
  position: fixed; top: 18px; right: 18px; z-index: 20;
  width: 290px; padding: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  transition: opacity .3s ease, transform .3s cubic-bezier(.4,0,.2,1);
}
.info-card.hidden { opacity: 0; transform: translateX(24px); pointer-events: none; }

.info-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.swatch {
  width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto;
  box-shadow: 0 0 12px currentColor; background: currentColor;
}
.info-head h2 { flex: 1; font-size: 16px; font-weight: 600; letter-spacing: .02em; }
#info-close {
  width: 22px; height: 22px; border: none; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--text-dim); font-size: 19px; line-height: 1;
}
#info-close:hover { color: var(--text); background: rgba(255,255,255,.08); }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 12px; }
.info-grid dt {
  font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 3px;
}
.info-grid dd { font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums; }

.fact {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--panel-border);
  font-size: 11.5px; line-height: 1.65; color: var(--text-dim); font-style: italic;
}

/* ---------- Labels ---------- */
#label-layer { position: fixed; inset: 0; z-index: 10; pointer-events: none; overflow: hidden; }
.planet-label {
  position: absolute; transform: translate(-50%, -50%);
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
  font-size: 10.5px; font-weight: 500; letter-spacing: .06em;
  color: var(--text); background: rgba(8,12,26,.55);
  border: 1px solid rgba(120,160,255,.20);
  backdrop-filter: blur(4px);
  transition: opacity .2s ease;
}
#label-layer.hidden { display: none; }

/* ---------- Stats ---------- */
.stats {
  position: fixed; bottom: 14px; left: 18px; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-dim); opacity: .55; font-variant-numeric: tabular-nums;
}
.stats b { font-weight: 600; color: var(--text); }
.stats .sep { opacity: .4; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .panel { width: calc(100% - 24px); left: 12px; top: 12px; }
  .panel-body { max-height: 46vh; }
  .info-card {
    top: auto; bottom: 12px; right: 12px; left: 12px; width: auto;
  }
  .stats { display: none; }
}
