/* ── fonts ── */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../assets/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../assets/sg-500.woff2') format('woff2');
}

:root {
  --bg: #0a0d10;
  --panel: rgba(13, 17, 21, 0.86);
  --panel-border: rgba(255, 255, 255, 0.07);
  --txt: #e8edf1;
  --txt-2: #97a3ad;
  --txt-3: #5d6a74;
  --ev: #4fd8ff;
  --ice: #ffa04d;
  --hair: rgba(255, 255, 255, 0.08);
  --r: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* ── loading ── */
#loading {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity 0.7s ease 0.15s, visibility 0.7s 0.15s;
}
#loading.done { opacity: 0; visibility: hidden; }
.ld-mark { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ld-main {
  font-family: 'Space Grotesk'; font-size: 34px; letter-spacing: 0.32em;
  text-transform: uppercase; padding-left: 0.32em;
}
.ld-sub { color: var(--txt-3); letter-spacing: 0.42em; text-transform: uppercase; font-size: 11px; padding-left: 0.42em; }
.ld-bar { width: 160px; height: 1px; background: var(--hair); margin-top: 18px; overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 40%; background: var(--ev); animation: ldslide 1.2s ease-in-out infinite; }
@keyframes ldslide { 0% { transform: translateX(-100%); } 100% { transform: translateX(420%); } }

/* ── no WebGL ── */
#nogl { position: absolute; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; padding: 32px; }
#nogl.show { display: flex; }
#nogl > div { max-width: 560px; }
#nogl h1 { font-family: 'Space Grotesk'; font-size: 24px; margin-bottom: 16px; }
#nogl p { color: var(--txt-2); line-height: 1.65; margin-bottom: 12px; }

/* ── top bar ── */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; gap: 16px;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.wordmark { display: flex; flex-direction: column; gap: 2px; user-select: none; }
.wm-main {
  font-family: 'Space Grotesk'; font-size: 17px; letter-spacing: 0.3em;
  text-transform: uppercase;
}
.wm-sub { font-size: 10.5px; color: var(--txt-3); letter-spacing: 0.14em; text-transform: uppercase; }

.modes {
  display: flex; gap: 2px; padding: 3px;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 999px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.mode-btn {
  padding: 7px 16px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  color: var(--txt-2); letter-spacing: 0.02em;
  transition: color 0.25s, background 0.25s;
  white-space: nowrap;
}
.mode-btn:hover { color: var(--txt); }
.mode-btn.active { background: rgba(255, 255, 255, 0.1); color: var(--txt); }

.flow-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  color: var(--txt-2);
  background: var(--panel); border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: color 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.ft-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--txt-3);
  transition: background 0.25s, box-shadow 0.25s;
}
.flow-toggle:hover { color: var(--txt); }
.flow-toggle.active { color: var(--txt); border-color: rgba(79, 216, 255, 0.4); }
.flow-toggle.active .ft-dot { background: var(--ev); box-shadow: 0 0 8px var(--ev); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ── component index ── */
#index {
  position: absolute; left: 24px; top: 88px; bottom: 24px; z-index: 15;
  display: flex; flex-direction: column; align-items: flex-start;
  pointer-events: none;
  max-width: 246px;
}
#index > * { pointer-events: auto; }
.index-toggle {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-size: 12.5px; font-weight: 500; color: var(--txt-2);
  transition: color 0.2s;
}
.index-toggle:hover { color: var(--txt); }
.it-icon {
  width: 12px; height: 8px;
  border-top: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  position: relative;
}
.it-icon::after { content: ''; position: absolute; left: 0; right: 0; top: 2.2px; border-top: 1.5px solid currentColor; }
.index-body {
  margin-top: 10px; width: 246px;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--r);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  overflow-y: auto; overscroll-behavior: contain;
  opacity: 0; transform: translateY(-6px); visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
  padding: 6px 0 10px;
  scrollbar-width: thin; scrollbar-color: #2c353d transparent;
  max-height: calc(100% - 54px);
}
#index.open .index-body { opacity: 1; transform: none; visibility: visible; }
.index-sec h3 {
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase;
  padding: 12px 18px 6px; display: flex; align-items: center; gap: 8px;
}
.index-sec h3::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
h3.h-ev { color: var(--ev); } h3.h-ev::before { background: var(--ev); }
h3.h-ice { color: var(--ice); } h3.h-ice::before { background: var(--ice); }
.index-sec ul { list-style: none; }
.index-sec li button {
  display: block; width: 100%; text-align: left;
  padding: 5.5px 18px; font-size: 12.5px; color: var(--txt-2);
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.index-sec li button:hover { color: var(--txt); background: rgba(255, 255, 255, 0.04); }
.index-sec li button.active {
  color: var(--txt); background: rgba(255, 255, 255, 0.06);
  border-left-color: currentColor;
}

/* ── info panel ── */
#panel {
  position: absolute; top: 88px; right: 24px; bottom: 24px; z-index: 18;
  width: min(392px, calc(100vw - 48px));
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--r);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  transform: translateX(calc(100% + 32px));
  transition: transform 0.5s cubic-bezier(0.32, 0.9, 0.28, 1);
  display: flex; flex-direction: column;
}
#panel.open { transform: none; }
.panel-close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 20px; line-height: 1; color: var(--txt-3);
  transition: color 0.2s, background 0.2s;
}
.panel-close:hover { color: var(--txt); background: rgba(255, 255, 255, 0.07); }
.panel-scroll {
  overflow-y: auto; overscroll-behavior: contain; padding: 26px 26px 30px;
  scrollbar-width: thin; scrollbar-color: #2c353d transparent;
}
.p-head { margin-bottom: 16px; }
.p-kicker {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 500;
}
.p-head.ev .p-kicker { color: var(--ev); }
.p-head.ice .p-kicker { color: var(--ice); }
.p-kicker .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.p-head h2 { font-family: 'Space Grotesk'; font-size: 24px; font-weight: 500; margin: 8px 0 6px; line-height: 1.15; }
.p-tagline { color: var(--txt-2); font-size: 13.5px; font-style: italic; }
.p-body { color: var(--txt-2); line-height: 1.68; font-size: 13.5px; margin-bottom: 12px; }
.p-body:first-of-type::first-letter { color: var(--txt); }
.p-specs {
  margin: 18px 0 6px; border-top: 1px solid var(--hair);
}
.p-specs div {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 7.5px 0; border-bottom: 1px solid var(--hair);
}
.p-specs dt { color: var(--txt-3); font-size: 12px; }
.p-specs dd { font-size: 12px; font-weight: 500; text-align: right; }
.p-compare {
  margin-top: 24px; padding: 18px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--panel-border); border-radius: 12px;
}
.pc-kicker {
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--txt-3); font-weight: 500;
}
.p-compare h3 { font-family: 'Space Grotesk'; font-size: 16.5px; font-weight: 500; margin: 7px 0 10px; line-height: 1.3; }
.p-compare p { color: var(--txt-2); font-size: 13px; line-height: 1.64; margin-bottom: 10px; }
.pc-table { width: 100%; border-collapse: collapse; margin: 14px 0 6px; }
.pc-table th {
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500;
  text-align: left; padding: 4px 8px 6px;
}
.pc-table th.c-ev, .pc-table td.c-ev { color: var(--ev); }
.pc-table th.c-ice, .pc-table td.c-ice { color: var(--ice); }
.pc-table td {
  font-size: 12px; padding: 6.5px 8px; border-top: 1px solid var(--hair);
  vertical-align: top; line-height: 1.4;
}
.pc-table td:first-child { color: var(--txt-3); width: 38%; }
.pc-jump {
  display: flex; align-items: center; gap: 12px; width: 100%;
  margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--panel-border);
  text-align: left; transition: background 0.2s, border-color 0.2s;
}
.pc-jump:hover { background: rgba(255, 255, 255, 0.07); }
.pc-jump.ev:hover { border-color: rgba(79, 216, 255, 0.4); }
.pc-jump.ice:hover { border-color: rgba(255, 160, 77, 0.4); }
.pcj-arrow { font-size: 17px; }
.pc-jump.ev .pcj-arrow { color: var(--ev); }
.pc-jump.ice .pcj-arrow { color: var(--ice); }
.pc-jump span:last-child { display: flex; flex-direction: column; gap: 1px; font-size: 13px; font-weight: 500; }
.pc-jump em { font-style: normal; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--txt-3); }
.pc-absence {
  margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  border: 1px dashed rgba(159, 180, 194, 0.35);
}
.pca-badge {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 500;
  color: #9fb4c2;
}
.pc-absence p { margin: 6px 0 0; font-size: 12.5px; }

/* ── hint ── */
#hint {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 10; pointer-events: none;
  font-size: 12px; color: var(--txt-3); letter-spacing: 0.05em;
  padding: 9px 18px; border-radius: 999px;
  background: rgba(13, 17, 21, 0.6); border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.8s;
  animation: hintin 1s ease 2.2s backwards;
}
@keyframes hintin { from { opacity: 0; transform: translate(-50%, 8px); } }
#hint.gone { opacity: 0; }

/* ── focus vignette ── */
#app::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(ellipse 68% 62% at 44% 48%, transparent 58%, rgba(4, 6, 8, 0.55) 100%);
  opacity: 0; transition: opacity 0.9s ease;
}
body.focused #app::after { opacity: 1; }

/* ── flow legend ── */
#flowLegend {
  position: absolute; bottom: 26px; right: 28px; z-index: 10;
  display: flex; gap: 16px; pointer-events: none;
  padding: 9px 16px; border-radius: 999px;
  background: rgba(13, 17, 21, 0.6); border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 11px; color: var(--txt-2); letter-spacing: 0.04em;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
#flowLegend.on { opacity: 1; transform: none; }
#flowLegend span { display: flex; align-items: center; gap: 6px; }
#flowLegend i { width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }

/* ── 3D labels ── */
.leader-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.leader { stroke-width: 1; opacity: 0.75; transition: opacity 0.2s; }
.leader-dot { opacity: 0.9; }
.label3d {
  position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column; gap: 1px;
  padding: 7px 12px; border-radius: 9px;
  background: rgba(13, 17, 21, 0.82); border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-left: 2px solid var(--acc, #fff);
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.3s ease;
  will-change: transform;
}
.label3d.in { opacity: 1; }
.l-kicker { font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--acc, var(--txt-3)); font-weight: 500; }
.l-title { font-size: 12.5px; font-weight: 500; }
.label3d.small { padding: 5px 10px; }
.label3d.small .l-title { font-size: 11.5px; }

/* ── responsive ── */
@media (max-width: 900px) {
  #topbar { padding: 12px 14px; flex-wrap: wrap; }
  .wm-sub { display: none; }
  .wm-main { font-size: 14px; }
  .mode-btn { padding: 6px 11px; font-size: 11.5px; }
  .modes { order: 3; flex-basis: 100%; justify-content: center; }
  .flow-toggle { padding: 8px 12px; font-size: 11.5px; }
  #index { left: 14px; top: auto; bottom: 14px; max-height: 60vh; flex-direction: column-reverse; }
  .index-body { margin-top: 0; margin-bottom: 10px; width: min(246px, calc(100vw - 28px)); max-height: 46vh; }
  #panel {
    top: auto; right: 0; bottom: 0; left: 0; width: 100%;
    max-height: 56vh; border-radius: var(--r) var(--r) 0 0;
    transform: translateY(105%);
  }
  #hint { bottom: 18px; width: max-content; max-width: calc(100vw - 32px); text-align: center; }
  #flowLegend { bottom: 70px; right: 14px; gap: 10px; padding: 8px 12px; }
}
