/* TokenBill v2 — "The Price Desk"
 * Hallmark · pre-emit critique: P5 H5 E5 S5 R5 V5
 * Macrostructure: Data desk (slim topbar + headline band + asymmetric desk + full-width board)
 * Theme: Price desk (neutral light · grotesk display · money-green accent)
 * Genre: modern-minimal / data-intelligence
 * Motion: press physics 140ms · tab fade · bar grow (JS) · count-up (JS) · one scroll reveal
 * Shape rule: radius 0 everywhere, except .chip pills (documented single exception)
 */

@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/spacegrotesk-var.woff2") format("woff2");
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibmplexmono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibmplexmono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibmplexmono-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #F6F6F4;
  --surface: #FFFFFF;
  --surface-2: #ECECE7;
  --ink: #16150F;
  --ink-2: #5F5D55;
  --ink-3: #9B988C;
  --line: #E2E0D6;
  --accent: #0E7A3D;
  --accent-deep: #0A5A2D;
  --accent-wash: rgba(14, 122, 61, 0.08);
  --neg: #BE3A3A;
  --warn: #A86A12;
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --topbar-h: 64px;
}

html, body { overflow-x: clip; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-style: normal; margin: 0; overflow-wrap: anywhere; min-width: 0; }

/* every numeral on the page is data */
.num, .mstat-v, .winner-cost, td.cost, td.r, .range-val,
.field input, .bar-row .val, .datestamp, .colophon, .share-url, .chip small {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 32px; }

/* ============ topbar ============ */
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--ink);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.brand .wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.02em;
}
.brand .descriptor {
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
}
.topbar-right { display: flex; align-items: center; gap: 24px; }
.topnav { display: flex; gap: 20px; }
.topnav a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.topnav a:hover { color: var(--ink); }
.datestamp {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-2);
  margin: 0;
  white-space: nowrap;
}
.livedot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

/* ============ headline band ============ */
.lede { padding: 72px 0 0; }
.lede h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(38px, 5.4vw, 68px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  max-width: 15ch;
  margin-bottom: 20px;
}
.lede .sub {
  color: var(--ink-2);
  font-size: 17px;
  max-width: 58ch;
  margin: 0 0 40px;
}

/* market strip — live data, hairline framed */
.market {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  margin-bottom: 56px;
}
.mstat { padding: 18px 24px 16px 0; }
.mstat + .mstat { border-left: 1px solid var(--line); padding-left: 24px; }
.mstat-v {
  display: block;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}
.mstat-l {
  font-size: 12.5px;
  color: var(--ink-2);
}

/* ============ view tabs ============ */
.tabs {
  display: flex;
  gap: 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 40px;
}
.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 2px 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 140ms ease-out;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ============ the desk ============ */
.desk {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 56px;
  align-items: start;
  padding-bottom: 88px;
}

/* control rail */
.rail-section { margin-bottom: 36px; }
.rail-label {
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 4px;
}
.preset-list { display: grid; grid-template-columns: 1fr 1fr; }
.preset {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 14px 12px 14px 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: background 140ms ease-out;
}
.preset:nth-child(odd) { border-right: 1px solid var(--line); padding-right: 16px; }
.preset:nth-child(even) { padding-left: 16px; }
.preset .pname { display: block; font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.preset small { display: block; font-family: var(--font-data); font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.preset:hover { background: var(--surface); }
.preset[aria-pressed="true"] { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--accent); }
.preset[aria-pressed="true"] .pname { color: var(--accent-deep); }
.preset:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.preset:active { transform: scale(0.99); }

.field { margin-bottom: 20px; }
.field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.range-val { color: var(--ink); font-weight: 600; font-size: 13px; }
.field input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 18px;
  padding: 10px 12px;
  transition: border-color 140ms ease-out;
}
.field input[type="number"]:focus { outline: none; border-color: var(--ink); }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 6px 0 0; }
.hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.55; margin: 4px 0 0; }

.models { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 12px; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms ease-out, color 140ms ease-out, border-color 140ms ease-out, transform 140ms ease-out;
}
.chip .prov { color: var(--ink-3); font-size: 11px; margin-left: 6px; }
.chip:hover { border-color: var(--ink-2); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip[aria-pressed="true"] .prov { color: rgba(255,255,255,.6); }
.chip:active { transform: scale(0.96); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.picker-actions { display: flex; gap: 16px; }
.link-btn {
  appearance: none; background: none; border: none; padding: 0;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink-2); cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: var(--line);
}
.link-btn:hover { color: var(--ink); text-decoration-color: var(--ink); }

/* result readout — the number is the hero */
.readout-label {
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 8px;
}
.winner { margin-bottom: 40px; }
.winner-cost {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(64px, 8vw, 108px);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent-deep);
  display: block;
}
.winner-model {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin-top: 10px;
}
.winner-per { color: var(--ink-2); font-size: 14px; margin: 2px 0 0; }

#results-empty {
  border: 1px dashed var(--line);
  padding: 32px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

/* ranked board */
table.results { width: 100%; border-collapse: collapse; }
table.results thead th {
  text-align: left;
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 12px 10px 0;
  border-bottom: 1px solid var(--ink);
}
table.results thead th.cost { text-align: right; }
table.results td {
  padding: 13px 12px 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
  vertical-align: baseline;
}
table.results td.cost {
  text-align: right;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}
table.results td .model-name { font-weight: 600; }
table.results td .delta { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; }
table.results .save { color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
table.results tr.winner-row .save { color: var(--accent-deep); font-weight: 700; }
table.results tr.winner-row td { background: var(--accent-wash); }
table.results tr.winner-row td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
table.results tr.winner-row td.cost { color: var(--accent-deep); }
.table-scroll { overflow-x: auto; }

/* relative scale chart */
.chart { margin-top: 36px; }
.chart h3 {
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 14px;
}
.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 170px) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 8px;
}
.bar-row .lbl {
  font-size: 13px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-track { height: 6px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; background: var(--ink-3); width: 0; transition: width 0.7s var(--ease-out); }
.bar-row.top .bar-fill { background: var(--accent); }
.bar-row.top .lbl { color: var(--ink); font-weight: 600; }
.bar-row .val { font-size: 12.5px; color: var(--ink-2); min-width: 96px; text-align: right; }

.share-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line);
}
.btn {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 11px 22px;
  cursor: pointer;
  transition: transform 140ms ease-out, background 140ms ease-out;
}
.btn:hover { background: #2A2822; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.share-url { font-size: 12px; color: var(--ink-3); word-break: break-all; }

/* ============ price board tab ============ */
.board-head { margin-bottom: 24px; }
.board-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 3.4vw, 40px);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.price-note { color: var(--ink-2); font-size: 14px; max-width: 68ch; margin: 0; }
table.prices { width: 100%; border-collapse: collapse; min-width: 560px; }
table.prices thead th {
  position: sticky; top: var(--topbar-h);
  background: var(--bg);
  text-align: left;
  font-family: var(--font-data);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3);
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--ink);
}
table.prices td {
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
table.prices td.r, table.prices th.r { text-align: right; font-weight: 500; }
table.prices td:first-child { font-weight: 600; }
table.prices td:nth-child(2) { color: var(--ink-2); font-size: 13px; }
table.prices tbody tr:hover td { background: var(--surface); }

/* ============ footer ============ */
footer { border-top: 1px solid var(--ink); padding: 32px 0 48px; }
.foot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 32px;
}
.footnav { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.footnav a { color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; width: fit-content; }
.footnav a:hover { text-decoration: underline; text-underline-offset: 3px; }
.sister { font-size: 13.5px; color: var(--ink-2); margin: 0; max-width: 34ch; }
.sister a { color: var(--ink); font-weight: 600; }
.foot-note { font-size: 13px; color: var(--ink-2); margin: 0; max-width: 44ch; }
.colophon {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: var(--ink-3);
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 8px;
}

/* ============ doc pages ============ */
.doc { padding: 64px 0 80px; max-width: 1200px; }
.doc-inner { max-width: 68ch; }
.doc h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(32px, 4.4vw, 52px);
  letter-spacing: -0.025em;
  line-height: 1.04;
  margin-bottom: 16px;
}
.doc .lede-sub { color: var(--ink-2); font-size: 17px; margin: 0 0 48px; max-width: 56ch; }
.doc-section { border-top: 1px solid var(--ink); padding: 28px 0; }
.doc-section h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}
.doc-section p { color: var(--ink-2); margin: 0 0 12px; max-width: 64ch; }
.doc-section p:last-child { margin-bottom: 0; }
.doc-section a { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.doc-section ol, .doc-section ul { color: var(--ink-2); padding-left: 24px; margin: 0 0 12px; }
.doc-section li { margin-bottom: 6px; }
.doc-section .figure {
  font-family: var(--font-data);
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 18px 20px;
  margin: 16px 0;
  text-align: center;
}
.doc-section .figure strong { color: var(--accent-deep); }

/* entrance */
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.lede > * { animation: rise-in 0.55s var(--ease-out) both; }
.lede > *:nth-child(2) { animation-delay: 0.07s; }
.lede > *:nth-child(3) { animation-delay: 0.14s; }
[role="tabpanel"]:not([hidden]) { animation: rise-in 0.28s var(--ease-out) both; }
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }

/* ============ responsive ============ */
@media (max-width: 960px) {
  .desk { grid-template-columns: minmax(0, 1fr); gap: 48px; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-note { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 20px; }
  .topnav { display: none; }
  .datestamp { font-size: 10.5px; max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lede { padding-top: 48px; }
  .market { grid-template-columns: 1fr; margin-bottom: 40px; }
  .mstat + .mstat { border-left: none; border-top: 1px solid var(--line); padding-left: 0; padding-top: 14px; }
  .mstat { padding: 14px 0; }
  .preset-list { grid-template-columns: 1fr; }
  .preset:nth-child(odd) { border-right: none; padding-right: 0; }
  .preset:nth-child(even) { padding-left: 0; }
  .foot-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: minmax(0, 110px) minmax(0, 1fr) auto; }
  .bar-row .val { min-width: 78px; font-size: 11.5px; }
  .winner-cost { font-size: clamp(56px, 17vw, 72px); }
  table.prices thead th { top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0ms !important; transition-duration: 0.001ms !important; }
  .bar-fill { transition: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
}
