/* ==========================================================
   Stackroom — control-room aesthetic
   Display: Cabinet Grotesk · Body: Satoshi · Data: JetBrains Mono
   ========================================================== */

:root {
  --font-display: 'Cabinet Grotesk', 'Satoshi', system-ui, sans-serif;
  --font-body: 'Satoshi', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.85rem + 0.15vw, 0.9375rem);
  --text-base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.02rem + 0.5vw, 1.375rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.3rem + 2.4vw, 3.25rem);

  --space-1: .25rem; --space-2: .5rem;  --space-3: .75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem;  --space-10: 2.5rem;
  --space-12: 3rem;  --space-16: 4rem;  --space-20: 5rem;  --space-24: 6rem;

  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --ease: cubic-bezier(.2,.7,.3,1);
  --maxw: 1220px;
}

/* ---------- Dark (default) ---------- */
:root, [data-theme='dark'] {
  --bg: #0d0e10;
  --bg-grid: #16181c;
  --surface: #16181c;
  --surface-2: #1c1f24;
  --surface-3: #23272d;
  --border: #2a2f36;
  --border-strong: #3a4048;
  --text: #eef0f2;
  --muted: #969ca5;
  --faint: #6a7079;
  --accent: #ff5c3d;
  --accent-soft: rgba(255,92,61,.13);
  --accent-text: #ff7a5f;
  --gold: #f0b429;
  --gold-soft: rgba(240,180,41,.13);
  --green: #35c98b;
  --green-soft: rgba(53,201,139,.13);
  --blue: #5aa9ff;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 26px rgba(0,0,0,.32);
}

/* ---------- Light ---------- */
[data-theme='light'] {
  --bg: #f5f4f1;
  --bg-grid: #eae8e3;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --surface-3: #f0eeea;
  --border: #e2dfd9;
  --border-strong: #cdc9c1;
  --text: #171819;
  --muted: #676c72;
  --faint: #9aa0a6;
  --accent: #d63b1e;
  --accent-soft: rgba(214,59,30,.09);
  --accent-text: #c1361c;
  --gold: #a97400;
  --gold-soft: rgba(169,116,0,.10);
  --green: #10855b;
  --green-soft: rgba(16,133,91,.10);
  --blue: #1f6fd0;
  --shadow: 0 1px 2px rgba(20,18,15,.05), 0 6px 20px rgba(20,18,15,.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: -1px -1px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: -.022em; line-height: 1.08; margin: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ================= TOPBAR ================= */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: var(--space-6);
  padding: var(--space-3) var(--space-6);
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; color: var(--text); }
.brand .mark { color: var(--text); flex: none; }
.brand-text { font-family: var(--font-display); font-weight: 800; font-size: 1.0625rem; letter-spacing: -.02em; }
.topnav { display: flex; gap: var(--space-1); margin-left: auto; }
.navlink {
  background: none; border: 0; cursor: pointer;
  font-size: var(--text-sm); color: var(--muted);
  padding: var(--space-2) var(--space-3); border-radius: var(--r-sm);
  transition: color .18s var(--ease), background .18s var(--ease);
}
.navlink:hover { color: var(--text); background: var(--surface-2); }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer; color: var(--muted);
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
[data-theme='dark'] .i-sun { display: block; }
[data-theme='dark'] .i-moon { display: none; }
[data-theme='light'] .i-sun { display: none; }
[data-theme='light'] .i-moon { display: block; }

/* ================= HERO ================= */
.hero { padding: clamp(var(--space-16), 9vw, var(--space-24)) var(--space-6) var(--space-12); }
.hero-inner { max-width: var(--maxw); margin: 0 auto; }
.eyebrow {
  font-family: var(--font-mono); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: .1em; color: var(--accent-text);
  margin-bottom: var(--space-5);
}
.hero h1 { font-size: var(--text-2xl); max-width: 17ch; }
.lede { margin-top: var(--space-6); max-width: 62ch; color: var(--muted); font-size: var(--text-base); }
.hero-stats {
  display: flex; flex-wrap: wrap; gap: var(--space-10);
  margin-top: var(--space-10); padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}
.hero-stats > div { display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 700; letter-spacing: -.03em; }
.stat-lab { font-size: var(--text-xs); color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }

/* ================= SECTIONS ================= */
.section { max-width: var(--maxw); margin: 0 auto; padding: var(--space-16) var(--space-6); }
.section-head { display: flex; align-items: baseline; gap: var(--space-4); margin-bottom: var(--space-8); }
.section-num { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--faint); padding-top: 4px; }
.section-head h2 { font-size: var(--text-xl); }
.section-lede { color: var(--muted); max-width: 68ch; margin-top: calc(var(--space-8) * -0.5); margin-bottom: var(--space-8); font-size: var(--text-sm); }
.ghost-btn {
  margin-left: auto; background: var(--surface); border: 1px solid var(--border);
  padding: var(--space-2) var(--space-4); border-radius: var(--r-sm);
  font-size: var(--text-sm); cursor: pointer; color: var(--muted);
  transition: all .18s var(--ease);
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent); }

/* ================= CONFIG ================= */
.config-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: var(--space-6); align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--space-6);
}
.panel-title { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.panel-hint { font-size: var(--text-sm); color: var(--muted); margin-bottom: var(--space-5); max-width: 52ch; }

.niche-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-3); }
.niche {
  text-align: left; cursor: pointer; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--space-4); transition: all .18s var(--ease);
}
.niche:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.niche strong { display: block; font-size: var(--text-sm); font-weight: 700; margin-bottom: 2px; }
.niche span { display: block; font-size: var(--text-xs); color: var(--muted); line-height: 1.45; }
.niche[aria-checked='true'] {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.niche[aria-checked='true'] strong { color: var(--accent-text); }

.field { margin-bottom: var(--space-6); }
.field:last-child { margin-bottom: 0; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-3); }
.field-head label { font-size: var(--text-sm); font-weight: 500; }
.field-val { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 700; letter-spacing: -.03em; }
.field-note { font-size: var(--text-xs); color: var(--faint); margin-top: var(--space-2); }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 4px; background: var(--surface-3); cursor: pointer; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface); cursor: grab;
  box-shadow: 0 0 0 1px var(--accent);
}
input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); cursor: grab;
}
.presets { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.chip {
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
  font-size: var(--text-xs); padding: var(--space-1) var(--space-3);
  border-radius: 100px; color: var(--muted); transition: all .16s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }

.toggles { display: flex; flex-direction: column; gap: var(--space-4); padding-top: var(--space-5); border-top: 1px solid var(--border); }
.switch { display: flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.track { flex: none; width: 38px; height: 22px; border-radius: 100px; background: var(--surface-3); border: 1px solid var(--border); position: relative; transition: all .2s var(--ease); }
.track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--faint); transition: all .2s var(--ease); }
.switch input:checked + .track { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-label { font-size: var(--text-sm); }
.switch-label em { display: block; font-style: normal; font-size: var(--text-xs); color: var(--faint); }

/* ================= SUMMARY ================= */
.summary-bar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden; margin-bottom: var(--space-6);
}
.sum-cell { padding: var(--space-5) var(--space-6); border-right: 1px solid var(--border); }
.sum-cell:last-child { border-right: 0; }
.sum-lab { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
.sum-val { font-family: var(--font-mono); font-size: var(--text-xl); font-weight: 700; letter-spacing: -.035em; line-height: 1.15; margin-top: var(--space-1); }
.sum-sub { font-size: var(--text-xs); color: var(--muted); margin-top: var(--space-1); }
.sum-val.over { color: var(--accent); }
.sum-val.good { color: var(--green); }
.meter { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: var(--space-3); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--green); border-radius: 4px; transition: width .5s var(--ease); }
.meter > i.over { background: var(--accent); }

/* ================= PIPELINE ================= */
.pipeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
.stage {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-4);
  position: relative;
}
.stage-head { display: flex; align-items: baseline; gap: var(--space-2); }
.stage-num { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--accent-text); }
.stage-name { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.pick-name { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 800; letter-spacing: -.02em; }
.pick-tier {
  display: inline-block; font-family: var(--font-mono); font-size: var(--text-xs);
  padding: 2px var(--space-2); border-radius: var(--r-sm);
  background: var(--surface-3); border: 1px solid var(--border); color: var(--muted);
  margin-left: var(--space-2); vertical-align: 2px;
}
.pick-price { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 700; letter-spacing: -.03em; }
.pick-price em { font-style: normal; font-size: var(--text-xs); color: var(--faint); font-weight: 400; }
.pick-quota { font-size: var(--text-xs); color: var(--muted); line-height: 1.5; }
.pick-why { font-size: var(--text-xs); color: var(--muted); line-height: 1.55; padding-top: var(--space-3); border-top: 1px dashed var(--border); }
.pick-why b { color: var(--text); font-weight: 500; }

.impact { display: flex; align-items: center; gap: var(--space-3); }
.impact-bar { flex: 1; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.impact-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); border-radius: 6px; transition: width .5s var(--ease); }
.impact-num { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 700; }
.impact-lab { font-size: var(--text-xs); color: var(--faint); text-transform: uppercase; letter-spacing: .07em; }

.warn-row {
  display: flex; gap: var(--space-2); align-items: flex-start;
  font-size: var(--text-xs); line-height: 1.45;
  background: var(--gold-soft); border: 1px solid color-mix(in oklab, var(--gold) 40%, transparent);
  color: var(--text); padding: var(--space-2) var(--space-3); border-radius: var(--r-sm);
}
.warn-row.bad { background: var(--accent-soft); border-color: color-mix(in oklab, var(--accent) 45%, transparent); }
.alt-line { font-size: var(--text-xs); color: var(--faint); }
.alt-line a { color: var(--muted); }
.stage-link { font-size: var(--text-xs); font-family: var(--font-mono); margin-top: auto; }
.note-card .stage-link { margin-top: var(--space-2); display: inline-block; }
.disclaimer { font-size: var(--text-xs); color: var(--faint); margin-top: var(--space-6); max-width: 80ch; }
.inline-flag { font-family: var(--font-mono); color: var(--gold); }

/* ================= ROI ================= */
.roi-list { display: flex; flex-direction: column; gap: var(--space-2); }
.roi-row {
  display: grid; grid-template-columns: 26px 1.5fr 1fr 1fr 1.1fr;
  gap: var(--space-4); align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--space-4) var(--space-5);
  transition: border-color .18s var(--ease);
}
.roi-row:hover { border-color: var(--border-strong); }
.roi-row.top { border-color: var(--green); background: linear-gradient(90deg, var(--green-soft), transparent 55%); }
.roi-rank { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--faint); }
.roi-row.top .roi-rank { color: var(--green); }
.roi-what strong { font-size: var(--text-sm); font-weight: 700; }
.roi-what span { display: block; font-size: var(--text-xs); color: var(--muted); }
.roi-cell { font-family: var(--font-mono); font-size: var(--text-sm); }
.roi-cell em { display: block; font-style: normal; font-family: var(--font-body); font-size: var(--text-xs); color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.roi-verdict { font-size: var(--text-xs); font-weight: 500; }
.roi-verdict.yes { color: var(--green); }
.roi-verdict.no { color: var(--muted); }
.empty-state { color: var(--muted); font-size: var(--text-sm); padding: var(--space-8); text-align: center; border: 1px dashed var(--border); border-radius: var(--r-md); }

/* ================= TABLE ================= */
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-5); }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
table.cmp { width: 100%; border-collapse: collapse; min-width: 940px; }
.cmp th {
  text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 500; padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  position: sticky; top: 0; z-index: 2;
}
.cmp td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); font-size: var(--text-sm); vertical-align: top; }
.cmp tr:last-child td { border-bottom: 0; }
.cmp .c-num { text-align: right; }
.cmp td.c-num { font-family: var(--font-mono); white-space: nowrap; }
.cmp tbody tr:hover { background: var(--surface-2); }
.cmp tr.picked { background: var(--accent-soft); }
.cmp tr.picked:hover { background: var(--accent-soft); }
.cmp tr.dead td { opacity: .5; }
.tool-cell { display: flex; align-items: center; gap: var(--space-2); }
.tool-cell a { font-weight: 700; text-decoration: none; color: var(--text); }
.tool-cell a:hover { color: var(--accent-text); text-decoration: underline; }
.stage-tag { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); color: var(--faint); }
.quota-cell { font-size: var(--text-xs); color: var(--muted); line-height: 1.5; max-width: 34ch; }
.flag { font-family: var(--font-mono); font-size: 11px; color: var(--gold); cursor: help; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }
.score-pill {
  display: inline-block; min-width: 44px; text-align: center;
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 700;
  padding: 3px var(--space-2); border-radius: 100px;
  background: var(--surface-3); border: 1px solid var(--border);
}
.score-pill.s-hi { background: var(--green-soft); border-color: color-mix(in oklab, var(--green) 40%, transparent); color: var(--green); }
.score-pill.s-mid { background: var(--gold-soft); border-color: color-mix(in oklab, var(--gold) 40%, transparent); color: var(--gold); }

.tool-notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-4); margin-top: var(--space-6); }
.note-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--space-5); }
.note-card h4 { font-family: var(--font-display); font-size: var(--text-sm); font-weight: 800; margin: 0 0 var(--space-1); display: flex; align-items: center; gap: var(--space-2); }
.note-card .vendor { font-family: var(--font-mono); font-size: 11px; color: var(--faint); font-weight: 400; }
.note-card p { font-size: var(--text-xs); color: var(--muted); line-height: 1.6; margin-bottom: var(--space-2); }
.note-card p b { color: var(--text); font-weight: 500; }

/* ================= CHANGELOG ================= */
.changelog { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.changelog li {
  display: flex; gap: var(--space-4); align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--r-md); padding: var(--space-4) var(--space-5); font-size: var(--text-sm);
}
.changelog li.bad { border-left-color: var(--accent); }
.changelog li.warn { border-left-color: var(--gold); }
.changelog li.ok { border-left-color: var(--green); }
.cl-tag { font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--faint); flex: none; width: 96px; padding-top: 3px; }

/* ================= FOOTER / TOAST ================= */
.foot { max-width: var(--maxw); margin: 0 auto; padding: var(--space-12) var(--space-6) var(--space-20); border-top: 1px solid var(--border); }
.foot p { font-size: var(--text-xs); color: var(--faint); max-width: 78ch; }
.foot-links { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-top: var(--space-4); }
.foot-links a { color: var(--muted); text-decoration: none; font-size: var(--text-xs); }
.foot-links a:hover { color: var(--accent-text); text-decoration: underline; }

.toast {
  position: fixed; bottom: var(--space-6); left: 50%; transform: translate(-50%, 20px);
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text);
  padding: var(--space-3) var(--space-5); border-radius: 100px; font-size: var(--text-sm);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease); z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================= RESPONSIVE ================= */
@media (max-width: 1080px) {
  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .summary-bar { grid-template-columns: repeat(2, 1fr); }
  .sum-cell:nth-child(2) { border-right: 0; }
  .sum-cell:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 900px) {
  .config-grid { grid-template-columns: 1fr; }
  .roi-row { grid-template-columns: 22px 1fr 1fr; row-gap: var(--space-3); }
  .roi-verdict { grid-column: 2 / -1; }
}
@media (max-width: 720px) {
  .topnav { display: none; }
  .section { padding: var(--space-12) var(--space-5); }
  .hero { padding: var(--space-12) var(--space-5) var(--space-8); }
  .hero-stats { gap: var(--space-6); }
  .pipeline, .niche-grid { grid-template-columns: 1fr; }
  .summary-bar { grid-template-columns: 1fr; }
  .sum-cell { border-right: 0; border-bottom: 1px solid var(--border); }
  .sum-cell:last-child { border-bottom: 0; }
  .section-head { flex-wrap: wrap; }
  .ghost-btn { margin-left: 0; }
  .changelog li { flex-direction: column; gap: var(--space-2); }
  .cl-tag { width: auto; }
}
