/* ──────────────────────────────────────────── 3D Skills Atlas ─── */

:root {
  --bg-0: #04060d;
  --bg-1: #0a0f1e;
  --bg-2: #121a2f;
  --ink-0: #f7f9ff;
  --ink-1: #d6dcec;
  --ink-2: #8a93ab;
  --ink-3: #5b6480;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.16);
  --accent: #ffb547;          /* highlight (selected skills) */
  --accent-soft: rgba(255,181,71,0.18);
  --font-display: "Söhne","Inter",ui-sans-serif,system-ui,sans-serif;
  --font-mono: ui-monospace,"JetBrains Mono","SF Mono",Menlo,monospace;
}

/* page reset ─ letterbox stage  -------------------------------------- */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: #000;
  color: var(--ink-0);
  font-family: var(--font-display);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 16:9 stage, letterboxed in black */
.stage {
  position: fixed;
  inset: 0;
  margin: auto;
  aspect-ratio: 16/9;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: auto;
  background:
    radial-gradient(120% 80% at 50% 40%, var(--bg-2) 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  overflow: hidden;
  isolation: isolate;
}
.stage::after {
  /* film grain */
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 2;
}

canvas#scene {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 1;
}

/* ────────────────────────────────────── HUD top  -------------------- */
#hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  padding: 28px 36px 0 36px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  pointer-events: none;
}
#hud-top > * { pointer-events: auto; }

.brand {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-0);
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(255,255,255,0.10), rgba(255,255,255,0.02));
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--accent);
  box-shadow: 0 6px 18px -8px rgba(0,0,0,0.6), inset 0 0 12px rgba(255,181,71,0.10);
}
.brand-name {
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 11.5px; color: var(--ink-2);
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-top: 2px;
}

/* picker -------------------------------------------------------------- */
.picker { position: relative; min-width: 260px; }
.picker-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; letter-spacing: 0.16em;
  color: var(--ink-2); text-transform: uppercase;
  margin-bottom: 6px; padding-left: 4px;
}
.compare-tag {
  font-size: 9px;
  letter-spacing: 0.12em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(95,198,255,0.15);
  color: #5fc6ff;
}
.picker-control {
  position: relative;
  background: rgba(8,12,24,0.72);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 30px -10px rgba(0,0,0,0.5);
}
#occ-search-a, #occ-search-b {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--ink-0);
  font-family: var(--font-display);
  font-size: 14px;
  padding: 12px 38px 12px 16px;
  outline: none;
  letter-spacing: -0.005em;
}
#occ-search-a::placeholder, #occ-search-b::placeholder { color: var(--ink-3); }
.occ-clear {
  position: absolute; top: 50%; right: 10px;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  display: none;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-2);
  cursor: pointer; font-size: 11px;
  align-items: center; justify-content: center;
  padding: 0;
}
.occ-clear:hover { background: rgba(255,255,255,0.12); color: var(--ink-0); }
.occ-clear.visible { display: flex; }

.occ-list {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: rgba(10,14,28,0.96);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 6px;
  display: none;
  z-index: 20;
  box-shadow: 0 18px 40px -12px rgba(0,0,0,0.6);
}
.occ-list.open { display: block; }
.occ-row {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-1);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.occ-row:hover, .occ-row.active {
  background: rgba(255,181,71,0.10);
  color: var(--ink-0);
}
.occ-row .skill-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}
.occ-empty {
  padding: 18px; text-align: center;
  font-size: 12.5px; color: var(--ink-3);
}

/* info panel ---------------------------------------------------------- */
.info {
  position: absolute;
  left: 36px; top: 110px;
  z-index: 4;
  width: 320px;
  padding: 22px 22px 18px;
  background: linear-gradient(180deg, rgba(10,14,28,0.78), rgba(10,14,28,0.55));
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 40px -16px rgba(0,0,0,0.65);
  opacity: 1;
}
.info.hidden { display: none; }

.info-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; letter-spacing: 0.18em;
  color: var(--accent); text-transform: uppercase;
}

/* A / B color dots */
.dot-a, .dot-b {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.dot-a { background: #ffb547; box-shadow: 0 0 6px #ffb547; }
.dot-b { background: #5fc6ff; box-shadow: 0 0 6px #5fc6ff; }
.clr-a { color: #ffb547; }
.clr-b { color: #5fc6ff; }
.clr-both { color: #ffffff; }

/* Comparison header */
.compare-header {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0 14px 0;
}
.compare-name {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600;
  color: var(--ink-0);
  letter-spacing: -0.01em;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
}
.compare-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compare-vs {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  flex-shrink: 0;
}

.compare-stats {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.cmp-stat {
  flex: 1;
  display: flex; flex-direction: column; line-height: 1;
  text-align: center;
}
.cmp-num {
  font-family: var(--font-mono);
  font-size: 22px; font-weight: 500;
  letter-spacing: -0.02em;
}
.cmp-stat em {
  font-style: normal; font-size: 9.5px;
  letter-spacing: 0.12em; color: var(--ink-2);
  text-transform: uppercase; margin-top: 4px;
}

/* Cluster comparison chips — show A/B/shared counts */
.cmp-counts {
  display: flex; gap: 6px; align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
}
.cmp-counts .ca { color: #ffb547; }
.cmp-counts .cb { color: #5fc6ff; }
.cmp-counts .cs { color: #fff; }

/* Skill tags in comparison dropdown */
.skill-tag {
  display: inline-block;
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  line-height: 1.4;
}
.skill-tag.tag-a { background: rgba(255,181,71,0.18); color: #ffb547; }
.skill-tag.tag-b { background: rgba(95,198,255,0.18); color: #5fc6ff; }
.skill-tag.tag-both { background: rgba(255,255,255,0.12); color: #fff; }
.info h1 {
  margin: 6px 0 14px 0;
  font-size: 24px; line-height: 1.15;
  font-weight: 600; letter-spacing: -0.015em;
  color: var(--ink-0);
  text-wrap: balance;
}
.info-stats {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.stat { display: flex; flex-direction: column; line-height: 1; }
.stat span {
  font-family: var(--font-mono);
  font-size: 26px; font-weight: 500;
  color: var(--ink-0); letter-spacing: -0.02em;
}
.stat em {
  font-style: normal; font-size: 10.5px;
  letter-spacing: 0.14em; color: var(--ink-2);
  text-transform: uppercase; margin-top: 4px;
}
.stat-divider { width: 1px; height: 28px; background: var(--line); }

.info-clusters {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.cluster-chip {
  display: flex; flex-direction: column;
  font-size: 12.5px;
  color: var(--ink-1);
}
.chip-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 4px 4px 4px 0;
  margin: 0;
  text-align: left;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-1);
  cursor: pointer;
  border-radius: 6px;
  transition: background 160ms ease, color 160ms ease;
}
.chip-row:hover { background: rgba(255,255,255,0.04); color: var(--ink-0); }
.cluster-chip .dot {
  width: 9px; height: 9px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.cluster-chip .name { flex: 1; }
.cluster-chip .pct {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
}
.chip-row .chev {
  color: var(--ink-3);
  transition: transform 200ms ease, color 200ms ease;
}
.cluster-chip.expanded .chip-row .chev {
  transform: rotate(180deg);
  color: var(--accent);
}
.cluster-chip.expanded .chip-row { color: var(--ink-0); }

.chip-skills {
  list-style: none;
  padding: 4px 0 6px 19px;
  margin: 0 0 2px 0;
  border-left: 1px solid var(--line);
  margin-left: 4px;
  display: flex; flex-direction: column; gap: 4px;
}
.chip-skills[hidden] { display: none; }
.skill-item {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 11.5px;
  color: var(--ink-1);
  padding: 3px 0 3px 8px;
  line-height: 1.35;
}
.skill-name { flex: 1; text-wrap: balance; }
.skill-code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* 3D label billboards ------------------------------------------------- */
.labels-layer {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 3;
}
.cluster-label {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 8px;
  background: rgba(8,12,24,0.78);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--ink-0);
  white-space: nowrap;
  letter-spacing: -0.005em;
  opacity: 0;
  transition: opacity 350ms ease;
  box-shadow: 0 6px 18px -8px rgba(0,0,0,0.6);
}
.cluster-label.visible { opacity: 1; }
.cluster-label .l-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}
.cluster-label .l-count {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
}
.cluster-label .l-leader {
  position: absolute;
  bottom: 100%; left: 50%;
  width: 1px; height: 18px;
  background: linear-gradient(180deg, transparent, var(--line-strong));
  pointer-events: none;
}

/* HUD bottom ---------------------------------------------------------- */
#hud-bot {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 5;
  padding: 0 36px 28px 36px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  pointer-events: none;
}
#hud-bot > * { pointer-events: auto; }
.hint {
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  max-width: 540px;
}
.transport { display: flex; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: rgba(8,12,24,0.72);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-0);
  font: inherit;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
  backdrop-filter: blur(14px);
  transition: background 200ms ease, transform 200ms ease, color 200ms ease;
}
.btn:hover {
  background: rgba(255,181,71,0.12);
  border-color: rgba(255,181,71,0.42);
  color: var(--ink-0);
}
.btn:active { transform: scale(0.98); }
.cinematic-btn { color: var(--accent); }
.cinematic-btn:hover { color: var(--ink-0); }
.cinematic-btn.playing {
  background: var(--accent);
  color: var(--bg-0);
  border-color: var(--accent);
}

.rec-btn { color: var(--ink-1); }
.rec-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-2);
  transition: background 220ms ease;
}
.rec-btn.recording .rec-dot {
  background: #ff4d4d;
  box-shadow: 0 0 10px #ff4d4d;
  animation: rec-pulse 1.4s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%,100% { opacity: 1 } 50% { opacity: 0.35 }
}

.data-badge {
  position: absolute;
  left: 36px; bottom: 78px;
  z-index: 4;
  display: flex; flex-direction: column;
  pointer-events: none;
  opacity: 0.85;
}
.badge-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-1);
  letter-spacing: -0.01em;
}
.badge-lbl {
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Splash -------------------------------------------------------------- */
.splash {
  position: absolute; inset: 0;
  z-index: 10;
  display: grid; place-items: center;
  gap: 18px;
  background: var(--bg-0);
  transition: opacity 600ms ease;
}
.splash.hidden { opacity: 0; pointer-events: none; }
.splash-ring {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 1.1s linear infinite;
  position: relative;
  top: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.splash-text {
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ink-2);
  text-transform: uppercase;
}

/* ────────────────────────── Tweaks Panel  ---------------------------- */
.tweaks-panel {
  position: fixed;
  right: 16px; bottom: 16px;
  width: 280px;
  background: rgba(10,14,28,0.92);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 14px;
  z-index: 100;
  font-family: var(--font-display);
  color: var(--ink-0);
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.7);
  display: none;
}
.tweaks-panel.open { display: block; }
.tweaks-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.tweaks-title {
  font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ink-2);
}
.tweaks-close {
  background: transparent; border: 0; cursor: pointer;
  color: var(--ink-2); font-size: 14px; padding: 0 4px;
}
.tweaks-close:hover { color: var(--ink-0); }
.tweak-section {
  margin-bottom: 14px;
}
.tweak-section:last-child { margin-bottom: 0; }
.tweak-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 8px;
}

/* swatches */
.tweak-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.tweak-swatch {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1.5px solid transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.tweak-swatch.active { border-color: var(--ink-0); }
.tweak-swatch[data-multi] {
  display: flex;
}
.tweak-swatch[data-multi] span {
  flex: 1; height: 100%;
}

/* segmented */
.tweak-segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.tweak-seg {
  background: transparent; border: 0;
  padding: 7px 8px;
  font: inherit; font-size: 11.5px;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 6px;
  text-align: center;
}
.tweak-seg.active {
  background: rgba(255,255,255,0.10);
  color: var(--ink-0);
}

/* Floating "open tweaks" handle when the panel is closed */
.tweaks-handle {
  position: fixed;
  right: 16px; bottom: 16px;
  z-index: 99;
  display: none;
  align-items: center; gap: 6px;
  padding: 8px 12px;
  background: rgba(10,14,28,0.78);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-1);
  font: inherit; font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(14px);
}
.tweaks-handle.visible { display: inline-flex; }
.tweaks-handle:hover { color: var(--ink-0); border-color: rgba(255,181,71,0.4); }

/* ─── Theme variants applied to the stage ───────────────────────────── */
.stage[data-theme="light"] {
  --bg-0: #f6f4ef;
  --bg-1: #faf8f2;
  --bg-2: #fff;
  --ink-0: #16182a;
  --ink-1: #303449;
  --ink-2: #5d6378;
  --ink-3: #8a90a4;
  --line: rgba(0,0,0,0.08);
  --line-strong: rgba(0,0,0,0.16);
  color: var(--ink-0);
  background:
    radial-gradient(120% 90% at 50% 40%, var(--bg-2) 0%, var(--bg-1) 50%, var(--bg-0) 100%);
}
.stage[data-theme="light"]::after { mix-blend-mode: multiply; opacity: 0.25; }
.stage[data-theme="light"] .splash { background: var(--bg-0); }

.stage[data-theme="holo"] {
  --bg-0: #06031a;
  --bg-1: #0d0533;
  --bg-2: #1a0840;
  --accent: #ff66c4;
  --accent-soft: rgba(255,102,196,0.18);
  background:
    radial-gradient(120% 80% at 30% 30%, #1f0a4d 0%, #0d0533 50%, #04021a 100%),
    radial-gradient(80% 60% at 80% 80%, rgba(0,255,255,0.25) 0%, transparent 60%);
}

.stage[data-theme="mono"] {
  --bg-0: #050505;
  --bg-1: #0a0a0a;
  --bg-2: #141414;
  --accent: #ffffff;
  --accent-soft: rgba(255,255,255,0.18);
  background:
    radial-gradient(120% 80% at 50% 40%, var(--bg-2) 0%, var(--bg-1) 50%, var(--bg-0) 100%);
}

/* small screens — keep stage visible */
@media (max-width: 700px) {
  #hud-top { padding: 16px 16px 0 16px; flex-direction: column; }
  .info { left: 16px; right: 16px; width: auto; top: 200px; }
  #hud-bot { padding: 0 16px 16px 16px; flex-direction: column; align-items: stretch; }
  .data-badge { left: 16px; bottom: 64px; }
}
