/* The Abyss — Deep-Sea Specimens. Dark specimen-lab styling, all original. */

:root {
  --ink: #dceef5;
  --dim: #7d99a8;
  --accent: #63ffd8;
  --accent2: #7db4ff;
  : rgba(8, 22, 32, 0.92);
  --line: rgba(120, 200, 220, 0.22);
}

* { box-sizing: border-box; }

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

/* ---------- three-section layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 340px;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}
.col-left, .col-right {
  background: #050e16;
  background: linear-gradient(180deg, #071521, #040b12);
  display: flex; flex-direction: column; gap: 16px;
  padding: 18px; min-height: 0; min-width: 0; overflow: hidden;
  position: relative; z-index: 20;
}
.col-left { border-right: 1px solid var(--line); }
.col-right { border-left: 1px solid var(--line); }
.stage {
  position: relative; min-width: 0; min-height: 0; overflow: hidden;
  background: #010407;
}
#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%, #04141f 0%, #010407 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: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 0.25; transform: scale(0.9);} 50% { opacity: 1; transform: scale(1.1);} }

#webgl-fail { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: #010407; }
#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); }

/* ---------- HUD ---------- */
.hud { position: static; pointer-events: none; }
.hud > * { pointer-events: auto; }
.header-card {
  flex: none; display: flex; flex-direction: column; align-items: stretch; gap: 12px;
  padding: 18px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--glass); 
  box-shadow: inset 0 1px 0 rgba(160,230,255,0.08);
}
.header-card .back { align-self: flex-start; }

.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);
}
.back:hover { color: var(--accent); border-color: var(--accent); }

.title-block { text-align: left; }
.title-block h1 {
  margin: 0; font-size: clamp(1.7rem, 2.6vw, 2.3rem); font-weight: 200; letter-spacing: 0.01em;
   text-indent: 0.42em;
  background: linear-gradient(180deg, #eafcff, #6fb7cf 75%, #2b5b74);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 42px rgba(99, 255, 216, 0.12);
}
.subtitle { margin: 4px 0 0; color: var(--dim); font-size: 0.78rem; letter-spacing: 0.01em; }

.depth-gauge {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  text-align: right; border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px;
  background: var(--glass);  min-width: 110px;
}
.dg-label { display: block; font-size: 0.6rem; letter-spacing: 0.3em; color: var(--dim); }
.dg-value { font-size: 1rem; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---------- labels & tooltip ---------- */
#labels { position: absolute; inset: 0; z-index: 10; pointer-events: none; overflow: hidden; }
.spec-label {
  position: absolute; transform: translate(-50%, -130%); white-space: nowrap;
  font-size: 0.68rem; letter-spacing: 0.01em;  color: #bfe9f5;
  text-shadow: 0 1px 8px #000;
}
.spec-label::after {
  content: ""; display: block; width: 1px; height: 14px; margin: 3px auto 0;
  background: linear-gradient(180deg, rgba(190,240,255,0.8), transparent);
}
#tooltip {
  position: absolute; 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);
}

/* ---------- info panel ---------- */
.panel {
  position: relative; z-index: 25; width: auto;
  flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 24px 24px; 
  box-shadow: 0 24px 70px rgba(0,0,0,0.65), inset 0 1px 0 rgba(160,230,255,0.08);
  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-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; letter-spacing: 0.03em; }
.p-sci { margin: 2px 0 10px; font-style: italic; color: var(--accent2); }
.p-tag { margin: 0 0 14px; color: #bfe0ec; 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: #c8dde7; margin: 0 0 12px; }
.p-fact { font-size: 0.88rem; line-height: 1.6; color: #9fd8c9; margin: 0; border-top: 1px dashed var(--line); padding-top: 12px; }

/* ---------- right-column controls (switcher / options) ---------- */
.hud.bottom {
  display: flex; flex-direction: column; gap: 18px; align-items: stretch; padding: 0;
}
.switcher, .lab-controls { display: flex; flex-direction: column; gap: 8px; align-items: stretch; flex-wrap: nowrap; }
.switcher .ctl, .lab-controls .ctl { width: 100%; text-align: center; }
.lab-controls .slider-wrap { justify-content: space-between; }
.lab-controls input[type="range"] { flex: 1; width: auto; min-width: 90px; }
.ctl {
  pointer-events: auto; cursor: pointer; color: var(--ink); background: var(--glass);
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 15px; font-size: 0.82rem;
  letter-spacing: 0.04em;  transition: border-color .2s, color .2s, background .2s;
}
.ctl:hover { border-color: var(--accent); color: #fff; }
.ctl.active { background: rgba(99, 255, 216, 0.14); border-color: var(--accent); color: #eafffa; }
.ctl.accent { border-color: rgba(99,255,216,0.55); 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: var(--glass); 
}
input[type="range"] { accent-color: var(--accent); width: 110px; }

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

/* ---------- tablet: narrower side columns ---------- */
@media (max-width: 1023px) {
  .layout { grid-template-columns: 272px minmax(0, 1fr) 272px; }
  .col-left, .col-right { padding: 14px; gap: 12px; }
  .title-block h1 { font-size: clamp(1.45rem, 3vw, 1.9rem); letter-spacing: 0.26em; }
  .hud.bottom { gap: 12px; }
}

/* ---------- mobile: single-column stack
   header -> stage (56vh) -> switcher -> data (specimen panel) -> controls.
   The side columns and the bottom nav become display:contents so their
   children can be ordered directly in the stack. ---------- */
@media (max-width: 640px) {
  html, body { height: auto; overflow-x: hidden; overflow-y: auto; }
  .layout { display: flex; flex-direction: column; height: auto; min-height: 100dvh; }
  .col-left, .col-right { display: contents; }
  .hud.bottom { display: contents; }
  .header-card { order: 1; margin: 12px 12px 0; padding: 14px; }
  .depth-gauge { display: none; }
  .title-block { text-align: center; }
  .title-block h1 { letter-spacing: 0.24em; font-size: 1.5rem; }
  .subtitle { letter-spacing: 0.14em; font-size: 0.62rem; }
  .stage { order: 2; flex: none; width: 100%; height: 56vh; margin-top: 12px; }
  .switcher {
    order: 3; margin: 12px 12px 0;
    flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center;
  }
  .switcher .ctl { width: auto; }
  .panel {
    order: 4; flex: none; margin: 12px 12px 0; width: auto;
    max-height: none; overflow-y: visible; padding: 18px 18px 20px;
  }
  .lab-controls {
    order: 5; margin: 12px 12px 12px;
    flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center;
  }
  .lab-controls .ctl { width: auto; }
  .lab-controls .slider-wrap { justify-content: center; }
  .lab-controls input[type="range"] { flex: none; width: 110px; }
  .spec-btn { padding: 8px 10px; font-size: 0.74rem; }
  .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(99, 255, 216, 0.35); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: rgba(120, 200, 220, 0.35) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(120, 200, 220, 0.28); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }
button, input { 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 */
.header-card, .panel {
  background: color-mix(in srgb, #081620 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 & instrument labels */
.title-block h1 { font-family: "Archivo", Georgia, serif; font-weight: 600; letter-spacing: -0.01em; text-indent: 0; }
.subtitle { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; color: var(--accent); }
.dg-label { font-size: 10px; font-weight: 600; letter-spacing: 0.14em; }
.dg-value { font-size: 15px; font-weight: 600; }
.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); }
.back:hover { transform: translateY(-1px); }

/* Controls & switcher rows */
.ctl {
  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-color: rgba(255, 255, 255, 0.10);
}
.ctl:hover { transform: translateY(-1px); border-color: var(--accent); color: #fff; }
.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(99, 255, 216, 0.45);
}
.spec-btn { min-height: 40px; border-radius: 12px; padding: 8px 12px 8px 14px; text-align: left; justify-content: flex-start; }
.spec-btn:hover { transform: translateX(2px); }

/* 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); }

/* 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: #a9c6d2; 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;
  background: rgba(99, 255, 216, 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;
}
.spec-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: #a9c6d2; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* Stage vignette */
.stage::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, #081620 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, input { transition: none; }
}
