/* Cosmos — Interactive 3D Solar System & Stars. Deep-space HUD styling, all original. */

:root {
  --ink: #e6ecff;
  --dim: #8d99c4;
  --accent: #ffd166;
  --accent2: #7db4ff;
  : rgba(7, 11, 26, 0.92);
  --line: rgba(140, 165, 255, 0.22);
  --col-bg: #04061a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #01020a; color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---------- three-column layout ----------
   LEFT data · CENTER stage · RIGHT switcher/options.
   The side columns are real layout (not overlays), so the canvas
   fills the centre column only and the system sits dead-centre. */
.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 340px;
  height: 100vh;
  height: 100dvh;
}
.col-left, .col-right {
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px; min-height: 0; overflow: hidden;
  background: var(--col-bg);
}
.col-left { border-right: 1px solid var(--line); }
.col-right { border-left: 1px solid var(--line); }
.col-center { position: relative; min-width: 0; overflow: hidden; }

#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- loading & failure ---------- */
#loading {
  position: fixed; inset: 0; z-index: 60;
  background: radial-gradient(ellipse at 50% 40%, #0a1030 0%, #01020a 70%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.9s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
.load-inner { text-align: center; color: var(--dim); letter-spacing: 0.01em; font-size: 0.75rem; }
.load-glyph { font-size: 2.4rem; color: var(--accent); animation: twinkle 1.6s ease-in-out infinite; }
@keyframes twinkle { 0%,100% { opacity: 0.3; transform: scale(0.9) rotate(0deg);} 50% { opacity: 1; transform: scale(1.15) rotate(45deg);} }

#webgl-fail { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: #01020a; }
#webgl-fail[hidden] { display: none; }
.fail-card { max-width: 420px; padding: 2rem; border: 1px solid var(--line); border-radius: 14px; background: var(--glass); text-align: center; }
.fail-card a { color: var(--accent); }

/* ---------- header card (left column) ---------- */
.hud.top {
  flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 18px; 
  box-shadow: 0 24px 70px rgba(0,0,0,0.6);
}

.back {
  color: var(--dim); text-decoration: none; font-size: 0.85rem; letter-spacing: 0.08em;
  border: 1px solid var(--line); padding: 7px 13px; border-radius: 999px; background: var(--glass);
   white-space: nowrap;
}
.back:hover { color: var(--accent); border-color: var(--accent); }

.title-block { text-align: left; }
.title-block h1 {
  margin: 0; font-size: clamp(1.8rem, 2.6vw, 2.4rem); font-weight: 200; letter-spacing: 0.01em;
   text-indent: 0.05em;
  background: linear-gradient(180deg, #fff8e6, #ffd166 60%, #c77f2a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.subtitle { margin: 4px 0 0; color: var(--dim); font-size: 0.78rem; letter-spacing: 0.01em; }

.scale-note {
  text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px;
  background:rgba(0,0,10,.92); 
}
.sn-label { display: block; font-size: 0.6rem; letter-spacing: 0.3em; color: var(--dim); }
.sn-value { font-size: 0.72rem; color: var(--accent); line-height: 1.35; display: block; margin-top: 2px; }

/* ---------- labels & tooltip ---------- */
#labels { position: fixed; inset: 0; z-index: 10; pointer-events: none; overflow: hidden; }
.body-label {
  position: absolute; transform: translate(-50%, -150%); white-space: nowrap;
  font-size: 0.66rem; letter-spacing: 0.01em;  color: #cfd9ff;
  text-shadow: 0 1px 8px #000;
}
#tooltip {
  position: fixed; z-index: 30; pointer-events: none; padding: 6px 11px; border-radius: 8px;
  background: var(--glass); border: 1px solid var(--line); font-size: 0.8rem; color: var(--ink);
}
#tooltip[hidden] { display: none; }

/* ---------- explorer (right column switcher) ---------- */
.explorer {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; 
  box-shadow: 0 24px 70px rgba(0,0,0,0.6);
}
.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex: none; }
.tab {
  flex: 1; cursor: pointer; color: var(--dim); background: rgba(125,180,255,0.06);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; font-size: 0.78rem; letter-spacing: 0.03em;
}
.tab.active { color: #0a0f22; background: var(--accent); border-color: var(--accent); font-weight: 600; }
#search {
  flex: none; width: 100%; padding: 8px 11px; margin-bottom: 10px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(0,0,10,0.5); color: var(--ink); font-size: 0.85rem;
}
#search::placeholder { color: var(--dim); }
.list { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 2px; flex: 1; min-height: 0; }
.list[hidden] { display: none; }
.list::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-thumb { background: rgba(140,165,255,0.3); border-radius: 3px; }
.item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; cursor: pointer;
  color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 10px;
  padding: 7px 9px; font-size: 0.86rem;
}
.item:hover { border-color: var(--line); background: rgba(125,180,255,0.07); }
.item.active { border-color: var(--accent); background: rgba(255,209,102,0.1); }
.item .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: 0 0 8px rgba(255,255,255,0.25) inset; }
.item .meta { margin-left: auto; color: var(--dim); font-size: 0.7rem; letter-spacing: 0.04em; white-space: nowrap; }
.item .sub { display: block; color: var(--dim); font-size: 0.68rem; margin-top: 1px; }
.wide-btn {
  margin-top: 10px; width: 100%; cursor: pointer; color: var(--accent);
  background: rgba(255,209,102,0.08); border: 1px solid rgba(255,209,102,0.45);
  border-radius: 10px; padding: 9px 12px; font-size: 0.82rem; flex: none;
}
.wide-btn[hidden] { display: none; }
.wide-btn:hover { background: rgba(255,209,102,0.16); }

/* ---------- info panel (left column, under header) ---------- */
.panel {
  position: relative; flex: 1; min-height: 0; overflow-y: auto;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 24px 20px; 
  box-shadow: 0 24px 70px rgba(0,0,0,0.65);
  animation: rise 0.45s cubic-bezier(.2,.9,.25,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px);} to { opacity: 1; transform: none;} }
.panel[hidden] { display: none; }
.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: rgba(140,165,255,0.3); border-radius: 3px; }
.panel-close { position: absolute; top: 10px; right: 14px; background: none; border: none; color: var(--dim); font-size: 1.5rem; cursor: pointer; line-height: 1; }
.panel-close:hover { color: var(--accent); }
.panel-kicker { margin: 0 0 6px; font-size: 0.66rem; letter-spacing: 0.01em; color: var(--accent); }
.panel h2 { margin: 0; font-size: 1.65rem; font-weight: 300; }
.p-tag { margin: 6px 0 14px; color: #c3cff2; font-size: 0.95rem; line-height: 1.45; }
.p-stats { margin: 0 0 14px; display: grid; gap: 9px; }
.p-stats div { border-left: 2px solid var(--line); padding-left: 10px; }
.p-stats dt { font-size: 0.62rem; letter-spacing: 0.01em; color: var(--dim); }
.p-stats dd { margin: 2px 0 0; font-size: 0.88rem; line-height: 1.4; }
.p-desc { font-size: 0.92rem; line-height: 1.6; color: #cdd7f5; margin: 0 0 12px; }
.p-fact { font-size: 0.88rem; line-height: 1.6; color: #a8d8b8; margin: 0; border-top: 1px dashed var(--line); padding-top: 12px; }
.panel .wide-btn { margin-top: 14px; }

/* ---------- controls (right column, under the list) ---------- */
.hud.bottom {
  flex: none; display: flex; flex-direction: column; gap: 10px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; 
  box-shadow: 0 24px 70px rgba(0,0,0,0.6);
}
.controls-left, .controls-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ctl {
  cursor: pointer; color: var(--ink); background:rgba(0,0,10,.92);
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 15px; font-size: 0.82rem;
   transition: border-color .2s, color .2s;
}
.ctl:hover { border-color: var(--accent); }
.ctl.active { background: rgba(255,209,102,0.14); border-color: var(--accent); }
.slider-wrap {
  display: flex; align-items: center; gap: 9px; color: var(--dim); font-size: 0.78rem; letter-spacing: 0.08em;
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; background:rgba(0,0,10,.92); 
  flex: 1;
}
input[type="range"] { accent-color: var(--accent); width: 110px; flex: 1; }
.segmented { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background:rgba(0,0,10,.92); flex: 1; }
.seg { cursor: pointer; border: none; background: transparent; color: var(--dim); padding: 9px 13px; font-size: 0.8rem; flex: 1; white-space: nowrap; }
.seg.active { background: rgba(255,209,102,0.16); color: #ffe9ad; }

.hint {
  position: absolute; bottom: 10px; left: 0; right: 0; z-index: 15; text-align: center;
  color: rgba(141,153,196,0.85); font-size: 0.72rem; letter-spacing: 0.01em; 
  pointer-events: none; padding: 0 12px;
}

/* ---------- tablet ---------- */
@media (max-width: 1023px) {
  .layout { grid-template-columns: 272px minmax(0, 1fr) 272px; }
  .col-left, .col-right { padding: 14px; gap: 12px; }
  .scale-note { display: none; }
  .title-block h1 { font-size: clamp(1.5rem, 2.2vw, 2rem); }
  .panel { padding: 16px 18px; }
}

/* ---------- mobile: single scrolling column ----------
   header → stage block (56vh, unobstructed) → explorer → info → controls.
   The side columns dissolve (display:contents) so their cards join
   this single flow in the established order. */
@media (max-width: 640px) {
  html, body { height: auto; overflow-y: auto; overflow-x: hidden; }
  .layout { display: flex; flex-direction: column; height: auto; min-height: 100vh; }
  .col-left, .col-right { display: contents; }
  .hud.top {
    order: 1; margin: 12px 12px 0; padding: 12px 14px; gap: 8px;
  }
  .title-block h1 { font-size: 1.35rem; letter-spacing: 0.24em; text-indent: 0.24em; }
  .subtitle { display: none; }
  .scale-note { display: none; }
  .col-center { order: 2; flex: none; width: 100%; height: 56vh; margin-top: 12px; }
  .explorer {
    order: 3; flex: none; margin: 12px 12px 0;
  }
  .explorer .list { flex: none; max-height: 30vh; }
  .panel {
    order: 4; flex: none; margin: 12px 12px 0; padding: 16px 18px;
  }
  .hud.bottom {
    order: 5; margin: 12px 12px 0; padding: 12px;
  }
  .controls-left, .controls-right {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%;
  }
  .controls-left .slider-wrap { grid-column: 1 / -1; justify-content: space-between; }
  .controls-left .ctl, .controls-right .ctl { width: 100%; text-align: center; }
  .segmented { grid-column: 1 / -1; }
  .segmented .seg { flex: 1; }
  input[type="range"] { flex: 1; }
  .hint { display: none; }
}

/* ================= PREMIUM UI SYSTEM ================= */
/* Fonts & base */
html, body { font-family: "Inter", "Avenir Next", "Segoe UI", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
::selection { background: rgba(255, 209, 102, 0.4); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: rgba(140, 165, 255, 0.35) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(140, 165, 255, 0.28); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }
button, .item, input, a.back { transition: background-color 0.18s ease-out, border-color 0.18s ease-out, color 0.18s ease-out, transform 0.18s ease-out, box-shadow 0.18s ease-out; }
#scene { cursor: grab; }
#scene:active { cursor: grabbing; }

/* Surfaces */
.hud.top, .explorer, .panel, .hud.bottom {
  background: color-mix(in srgb, #0a1028 92%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 18px 50px rgba(0, 0, 0, 0.45);
}

/* Titles & eyebrows */
.title-block h1 {
  font-family: "Archivo", Georgia, serif; font-weight: 600;
  letter-spacing: -0.01em; text-indent: 0; text-transform: none;
}
.subtitle { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; color: var(--accent); }
.sn-label { font-size: 10px; font-weight: 600; letter-spacing: 0.14em; }

/* Controls */
.back { display: inline-flex; align-items: center; min-height: 34px; background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.10); }
.ctl, .tab, .seg, .wide-btn {
  min-height: 34px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.10);
}
.wide-btn { border-color: rgba(255, 255, 255, 0.10); }
.seg { border: none; }
.ctl:hover, .tab:hover, .seg:hover, .wide-btn:hover, .back:hover { transform: translateY(-1px); border-color: var(--accent); }
.tab.active, .seg.active, .ctl.active {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 78%, white));
  color: #0b0e18; border-color: transparent; font-weight: 600;
  box-shadow: 0 6px 18px rgba(255, 209, 102, 0.45);
}
#search {
  height: 38px; border-radius: 12px; font-size: 13px;
  background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.10);
}
#search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.25); }

/* Sliders */
input[type="range"] { -webkit-appearance: none; appearance: none; height: 16px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.14); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.14); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); }

/* List rows */
.item { min-height: 40px; border-radius: 12px; padding: 8px 12px; font-size: 13.5px; }
.item:hover { background: rgba(255, 255, 255, 0.05); border-color: transparent; transform: translateX(2px); }
.item.active {
  background: rgba(255, 209, 102, 0.14); border-color: transparent;
  box-shadow: inset 3px 0 0 var(--accent); font-weight: 600;
}

/* Info panel anatomy */
.panel-kicker { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; }
.panel h2 { font-family: "Archivo", Georgia, serif; font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.p-tag { font-style: italic; color: #aebadd; font-size: 14px; }
.p-stats dt { font-size: 10px; letter-spacing: 0.14em; }
.p-stats dd { font-size: 15px; font-weight: 600; }
.p-desc { font-size: 14px; line-height: 1.65; }
.p-fact {
  font-size: 14px; line-height: 1.65; color: #a8d8b8;
  background: rgba(255, 209, 102, 0.08); border-top: none; border-left: 3px solid var(--accent);
  border-radius: 12px; padding: 12px 14px;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel.panel-in { animation: panelIn 0.35s ease-out; }

/* Tooltip, labels, hint */
#tooltip {
  background: rgba(10, 13, 22, 0.92); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px; padding: 6px 13px; font-size: 12px; font-weight: 500;
}
.body-label {
  background: rgba(10, 13, 22, 0.92);  
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 999px; padding: 3px 9px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-shadow: none;
}
.hint {
  left: 50%; right: auto; transform: translateX(-50%); bottom: 14px;
  width: max-content; max-width: calc(100% - 24px);
  background: rgba(10, 13, 22, 0.92);  
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 999px; padding: 7px 16px;
  font-size: 12px; letter-spacing: 0.06em; text-transform: none; color: #aebadd; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* Stage vignette */
.col-center::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.38) 100%);
}

/* Loading & failure */
.load-inner::before {
  content: "THE UNUSUAL MUSEUM"; display: block; margin-bottom: 16px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3em; color: var(--dim);
}
.load-inner::after {
  content: ""; display: block; width: 160px; height: 3px; margin: 18px auto 0; border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 200% 100%; animation: loadSlide 1.2s linear infinite;
}
@keyframes loadSlide { from { background-position: 200% 0; } to { background-position: -100% 0; } }
.fail-card {
  background: color-mix(in srgb, #0a1028 92%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 18px 50px rgba(0, 0, 0, 0.45);
  color: var(--dim); line-height: 1.6;
}
.fail-card h2 { font-family: "Archivo", Georgia, serif; letter-spacing: -0.01em; font-size: 22px; font-weight: 600; color: var(--ink); margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
  .panel.panel-in, .load-inner::after, .load-glyph { animation: none; }
  button, .item, input, a.back { transition: none; }
}
