/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:        #090c14;
  --surface:   #111827;
  --surface2:  #1a2235;
  --border:    #1e2d45;
  --text:      #e2e8f0;
  --muted:     #8892a4;
  --subtle:    #4b5563;
  --blue:      #3b82f6;
  --purple:    #a78bfa;
  --green:     #34d399;
  --red:       #f87171;
  --yellow:    #fbbf24;
  --r:         12px;
}

/* ── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { color: var(--text); }
em { color: var(--purple); font-style: normal; }

/* ── Nav ───────────────────────────────────────────────────────────────── */
nav {
  position: sticky; top: 0; z-index: 200;
  height: 52px;
  background: rgba(9, 12, 20, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 40px; gap: 0;
}
.nav-brand {
  font-size: 0.88rem; font-weight: 700;
  color: var(--blue); letter-spacing: -0.01em;
  white-space: nowrap; margin-right: auto;
}
.nav-links { display: flex; gap: 2px; }
.nav-link {
  font-size: 0.78rem; color: var(--muted);
  padding: 6px 12px; border-radius: 6px;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface); text-decoration: none; }

/* ── Section base ──────────────────────────────────────────────────────── */
.page-section {
  padding: 80px 40px;
  max-width: 1160px;
  margin: 0 auto;
}
.page-section.full-bleed {
  max-width: 100%;
  padding-left: 0; padding-right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.page-section.full-bleed .inner { max-width: 1160px; margin: 0 auto; padding: 80px 40px; }
hr.divider { border: none; border-top: 1px solid var(--border); }

/* ── Section headings ──────────────────────────────────────────────────── */
.eyebrow {
  display: inline-block;
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 12px;
}
h2.sh {
  font-size: 2rem; font-weight: 800;
  letter-spacing: -0.025em; color: #f0f4ff;
  line-height: 1.2; margin-bottom: 16px;
}
h2.sh span { color: var(--purple); }
.lead {
  font-size: 1rem; color: var(--muted);
  max-width: 700px; line-height: 1.8;
  margin-bottom: 40px;
}

/* ── Hero ──────────────────────────────────────────────────────────────── */
#hero {
  padding: 110px 40px 90px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(59,130,246,.08) 0%, transparent 70%);
}
.hero-tag {
  display: inline-block;
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--blue);
  background: rgba(59,130,246,.1);
  border: 1px solid rgba(59,130,246,.25);
  padding: 4px 14px; border-radius: 100px;
  margin-bottom: 28px;
}
#hero h1 {
  font-size: 3.2rem; font-weight: 900;
  letter-spacing: -.035em; line-height: 1.15;
  color: #f8fafc; max-width: 760px; margin: 0 auto 20px;
}
#hero h1 em { color: var(--purple); font-style: normal; }
#hero p {
  font-size: 1.1rem; color: var(--muted);
  max-width: 580px; margin: 0 auto 44px; line-height: 1.8;
}
.cta-link {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.88rem; color: var(--muted);
  border: 1px solid var(--border);
  padding: 10px 22px; border-radius: 8px;
  transition: border-color .15s, color .15s;
}
.cta-link:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }

/* ── Architecture diagram ──────────────────────────────────────────────── */
.arch-flow {
  display: flex; align-items: center; gap: 0;
  overflow-x: auto; padding-bottom: 8px;
  margin: 36px 0 32px;
}
.arch-box {
  flex-shrink: 0; min-width: 120px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 18px; text-align: center;
}
.arch-box.highlight {
  border-color: var(--purple);
  background: rgba(167,139,250,.06);
}
.arch-box .alabel {
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--subtle); margin-bottom: 6px;
}
.arch-box.highlight .alabel { color: var(--purple); }
.arch-box .atitle { font-size: .88rem; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.arch-box .asub   { font-size: .72rem; color: var(--muted); }
.arch-sep {
  flex-shrink: 0; padding: 0 4px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px; width: 50px;
}
.arch-sep .ar   { color: var(--subtle); font-size: 1.1rem; line-height: 1; }
.arch-sep .albl { font-size: .65rem; color: var(--subtle); white-space: nowrap; }

/* ── Formula box ───────────────────────────────────────────────────────── */
.formula-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px 28px; margin: 28px 0;
}
.formula-box .flabel {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--blue); margin-bottom: 14px;
}
.formula-box .fmain {
  font-family: "Courier New", monospace;
  font-size: 1.05rem; color: #c4b5fd; margin-bottom: 20px;
  line-height: 1.5;
}
.formula-terms { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.fterm .ftname { font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.fterm .ftdesc { font-size: .8rem; color: var(--muted); line-height: 1.65; }

/* ── Concept cards ─────────────────────────────────────────────────────── */
.concept-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; }
.concept-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 22px 24px;
}
.concept-card.blue-top   { border-top: 3px solid var(--blue); }
.concept-card.purple-top { border-top: 3px solid var(--purple); }
.concept-card .ctitle { font-size: .92rem; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.concept-card .ctext  { font-size: .83rem; color: var(--muted); line-height: 1.7; }

/* ── Canvas infrastructure ─────────────────────────────────────────────── */
.canvas-wrap {
  position: relative;
  background: #060910;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: crosshair;
  display: block;
  aspect-ratio: 1;
}
.canvas-wrap canvas { display: block; }
.canvas-wrap canvas.lmap { image-rendering: pixelated; width: 100%; height: 100%; }
.canvas-wrap canvas.overlay {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.canvas-footer {
  background: var(--surface);
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 9px 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.coord-mono { font-family: monospace; font-size: .75rem; color: var(--muted); }
.class-pill {
  font-size: .72rem; font-weight: 700;
  padding: 1px 9px; border-radius: 100px;
  background: rgba(167,139,250,.12); color: #c4b5fd;
}
.check-label {
  display: flex; align-items: center; gap: 5px;
  font-size: .78rem; color: var(--muted); cursor: pointer;
}
input[type=checkbox] { accent-color: var(--blue); cursor: pointer; width: 13px; height: 13px; }

/* ── Main explorer layout ──────────────────────────────────────────────── */
.explorer-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px; align-items: start;
}
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.scard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
}
.scard-head {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--subtle); margin-bottom: 12px;
}
.preview-row { display: flex; align-items: center; gap: 14px; }
.preview-img-box {
  width: 92px; height: 92px;
  background: #111827;
  border-radius: 8px; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.preview-img-box img { width: 84px; height: 84px; image-rendering: pixelated; }
.preview-class { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 5px; }
.preview-desc  { font-size: .78rem; color: var(--muted); line-height: 1.55; }

/* ── Legend ────────────────────────────────────────────────────────────── */
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: .74rem; color: #94a3b8;
  padding: 4px 5px; border-radius: 5px;
  cursor: pointer; user-select: none;
  transition: background .1s;
}
.legend-item:hover { background: rgba(255,255,255,.05); }
.ldot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Callout ───────────────────────────────────────────────────────────── */
.callout {
  border-radius: var(--r);
  padding: 16px 20px;
  font-size: .83rem; line-height: 1.7;
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: 20px;
}
.callout.blue   { background: rgba(59,130,246,.06);  border: 1px solid rgba(59,130,246,.2);  color: #93c5fd; }
.callout.purple { background: rgba(167,139,250,.06); border: 1px solid rgba(167,139,250,.2); color: #c4b5fd; }
.callout-icon   { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.callout p + p  { margin-top: 6px; }

/* ── Interpolation panel ───────────────────────────────────────────────── */
.interp-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 22px;
  margin-top: 24px;
  transition: opacity .3s;
}
.interp-panel.locked { opacity: .35; pointer-events: none; }
.interp-panel h3 { font-size: .82rem; font-weight: 700; color: var(--muted); margin-bottom: 14px; }
.interp-status { font-size: .8rem; color: var(--subtle); font-style: italic; }
input[type=range] { width: 100%; accent-color: var(--purple); cursor: pointer; }
.interp-tick-row {
  display: flex; justify-content: space-between;
  font-size: .7rem; color: var(--subtle);
  margin-top: 4px; margin-bottom: 12px;
}
.interp-images { display: flex; align-items: center; gap: 10px; }
.ipin {
  width: 52px; height: 52px;
  border-radius: 7px; border: 2px solid var(--subtle);
  background: #111827; image-rendering: pixelated; flex-shrink: 0;
}
.ipin.a { border-color: var(--purple); }
.ipin.b { border-color: #f472b6; }
.imid-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 6px;
}
.iline { width: 100%; height: 1px; background: linear-gradient(to right, var(--purple), #f472b6); }
.imid {
  width: 68px; height: 68px;
  border-radius: 8px; border: 2px solid #6366f1;
  background: #111827; image-rendering: pixelated;
}
.interp-hint { font-size: .72rem; color: var(--subtle); margin-top: 10px; }

/* ── KL section ────────────────────────────────────────────────────────── */
.kl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 32px; }
.kl-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
}
.kl-card h3 { font-size: .9rem; font-weight: 700; margin-bottom: 14px; }
.kl-canvas { width: 100%; height: 150px; border-radius: 8px; display: block; margin-bottom: 18px; }
.kl-points { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.kl-point {
  font-size: .81rem; color: var(--muted);
  display: flex; gap: 8px; align-items: flex-start; line-height: 1.55;
}
.kl-point::before { content: "▸"; color: var(--blue); flex-shrink: 0; }

.insight-box {
  background: rgba(167,139,250,.05);
  border: 1px solid rgba(167,139,250,.2);
  border-radius: var(--r);
  padding: 22px 26px; margin-top: 32px;
}
.insight-box h3 { font-size: .88rem; font-weight: 700; color: var(--purple); margin-bottom: 10px; }
.insight-box p  { font-size: .84rem; color: #a78bfa; line-height: 1.75; }

/* ── Comparison layout ─────────────────────────────────────────────────── */
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 32px; }
.cmp-col { display: flex; flex-direction: column; gap: 12px; }
.cmp-header { display: flex; align-items: center; gap: 10px; }
.cmp-header h3 { font-size: 1rem; font-weight: 700; }
.badge {
  font-size: .68rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; padding: 2px 9px; border-radius: 4px;
}
.badge.bvae { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge.bae  { background: rgba(248,113,113,.15); color: #f87171; }
.cmp-preview {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px;
}
.cmp-img {
  width: 52px; height: 52px; border-radius: 5px;
  background: #111827; border: 1px solid var(--border);
  image-rendering: pixelated; flex-shrink: 0;
}
.cmp-class { font-size: .84rem; font-weight: 700; color: #c4b5fd; }
.cmp-coord { font-size: .74rem; color: var(--muted); font-family: monospace; }
.obs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px;
  font-size: .82rem; color: var(--muted); line-height: 1.65;
}

/* ── Interp steps ──────────────────────────────────────────────────────── */
.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 28px 0 36px; }
.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 18px; text-align: center;
}
.step-num {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(167,139,250,.12); color: #c4b5fd;
  font-size: .82rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.step-title { font-size: .85rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.step-desc  { font-size: .78rem; color: var(--muted); line-height: 1.6; }

/* ── Tooltip ───────────────────────────────────────────────────────────── */
#tooltip {
  position: fixed; pointer-events: none; z-index: 9999;
  background: rgba(14, 19, 30, .98);
  border: 1px solid #2d3f60;
  border-radius: 10px;
  padding: 10px 13px;
  display: none; align-items: center; gap: 13px;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
#tooltip img { width: 108px; height: 108px; image-rendering: pixelated; border-radius: 6px; }
#tt-class { font-size: .9rem; font-weight: 700; color: #c4b5fd; margin-bottom: 3px; }
#tt-coord { font-size: .72rem; color: var(--muted); font-family: monospace; }
#tt-hint  { font-size: .7rem;  color: var(--subtle); margin-top: 5px; }

/* ── Loading ───────────────────────────────────────────────────────────── */
#loading {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
}
#loading h2 { font-size: 1.1rem; color: var(--text); }
#loading p  { font-size: .85rem; color: var(--muted); }
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ────────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 40px; text-align: center;
  font-size: .78rem; color: var(--subtle);
}
