@import url('fonts.css');

/* ============ TOKENS ============ */
:root {
  --ice: #F5F8F9;
  --paper: #FFFFFF;
  --ink: #13242E;
  --ink-soft: #5A6B75;
  --tide: #0E6E6B;
  --tide-tint-1: color-mix(in oklch, var(--tide) 12%, white);
  --tide-tint-2: color-mix(in oklch, var(--tide) 32%, white);
  --tide-tint-3: color-mix(in oklch, var(--tide) 60%, white);
  --seal: #C03B21;
  --rule: #D7E0E4;

  --font-display: 'Archivo', 'Arial Narrow', sans-serif;
  --font-body: 'Source Sans 3', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px; --space-9: 96px;

  --radius: 3px;
  --focus: var(--tide);
}

/* ============ RESET ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ice);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--tide); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.12; margin: 0; color: var(--ink); letter-spacing: -0.01em; }
p { margin: 0 0 var(--space-4); }
table { border-collapse: collapse; width: 100%; }
button { font-family: inherit; }

:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ============ TYPE SCALE ============ */
.h1 { font-size: 40px; }
.h2 { font-size: 28px; }
.h3 { font-size: 22px; }
.lead { font-size: 17px; color: var(--ink-soft); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.mono { font-family: var(--font-mono); }
.tabular { font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .h1 { font-size: 30px; }
  .h2 { font-size: 22px; }
  .h3 { font-size: 18px; }
}

/* ============ LAYOUT ============ */
.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding-left: var(--space-5);
  padding-right: var(--space-5);
}
.section { padding-top: var(--space-8); padding-bottom: var(--space-8); }
.section-tight { padding-top: var(--space-6); padding-bottom: var(--space-6); }
.stack > * + * { margin-top: var(--space-5); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-7); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
@media (max-width: 860px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
/* Grid items default to min-width:auto, so a non-wrapping descendant (a mono
   meta line, a flex row of buttons) can force the track — and the whole
   page — wider than the viewport. This is the fix, applied to every grid
   container on the site. */
.grid-2 > *, .grid-3 > *, .hero__grid > * { min-width: 0; }

/* ============ NAV ============ */
.nav {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.nav__row {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; row-gap: var(--space-2);
  padding-top: var(--space-4); padding-bottom: var(--space-4);
}
.nav__brand {
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  color: var(--ink); text-decoration: none; letter-spacing: -0.01em;
  white-space: nowrap;
}
.nav__brand:hover { text-decoration: none; }
.nav__brand span { color: var(--tide); }
.nav__links { display: flex; gap: var(--space-6); align-items: center; flex-wrap: wrap; row-gap: var(--space-2); }
.nav__links a {
  color: var(--ink-soft); text-decoration: none; font-size: 14px; font-weight: 600;
  white-space: nowrap;
}
.nav__links a:hover, .nav__links a.is-active { color: var(--ink); }
.nav__links a.is-active { border-bottom: 2px solid var(--tide); padding-bottom: 2px; }
@media (max-width: 640px) {
  .nav__brand { font-size: 15px; }
  .nav__links { gap: var(--space-3); width: 100%; }
  .nav__links span.nav__label { display: none; }
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-body); font-weight: 600; font-size: 15px;
  padding: 11px 20px; border-radius: var(--radius); border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn--primary { background: var(--tide); color: #fff; }
.btn--primary:hover { background: #0b5b58; }
.btn--ghost { background: transparent; color: var(--tide); border-color: var(--tide); }
.btn--ghost:hover { background: var(--tide-tint-1); }

/* ============ FORM ============ */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field select, .field input {
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
  border: 1.5px solid var(--rule); border-radius: var(--radius);
  background: var(--paper); padding: 9px 10px;
}
.field select:focus, .field input:focus { border-color: var(--tide); }
.filter-row {
  display: grid; grid-template-columns: repeat(5, 1fr) auto;
  gap: var(--space-3); align-items: end;
}
.filter-row > * { min-width: 0; }
.field select { max-width: 100%; }
@media (max-width: 860px) {
  .filter-row { grid-template-columns: 1fr 1fr; }
}

/* ============ RECORD CARD ============ */
.record {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(19,36,46,0.04);
  overflow: hidden;
}
.record__spec {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--rule);
}
.record__spec strong { color: var(--ink); }
.record__body { padding: var(--space-6) var(--space-5); }
.record__price {
  font-family: var(--font-display); font-weight: 700;
  font-size: 44px; color: var(--ink); line-height: 1;
}
.record__price small { font-family: var(--font-body); font-weight: 600; font-size: 16px; color: var(--ink-soft); }
.record__range {
  margin-top: var(--space-4);
  display: flex; gap: var(--space-6); flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 13px; color: var(--ink-soft);
}
.record__range b { color: var(--ink); font-weight: 500; }

/* p25-p75-min-max range bar (honest substitute for a bin histogram — public.db
   stores percentile summaries per month, not raw price draws) */
.rangebar { margin-top: var(--space-5); }
.rangebar__track {
  position: relative; height: 8px; border-radius: 4px;
  background: var(--tide-tint-1);
}
.rangebar__iqr {
  position: absolute; top: 0; height: 100%; border-radius: 4px;
  background: var(--tide-tint-3);
}
.rangebar__avg {
  position: absolute; top: -4px; width: 3px; height: 16px;
  background: var(--tide); border-radius: 2px;
}
.rangebar__labels {
  display: flex; justify-content: space-between; margin-top: var(--space-2);
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft);
}

.record__footer {
  border-top: 1px solid var(--rule);
  padding: var(--space-4) var(--space-5);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: var(--space-3);
  background: var(--ice);
}
.record__meta {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft);
}
.record__cta { padding: var(--space-4) var(--space-5); border-top: 1px dashed var(--rule); }

/* ============ SEAL (signature element — the one thing allowed to be loud) ============ */
.seal {
  display: inline-flex; align-items: center; gap: 6px;
  border: 2px solid var(--seal);
  color: var(--seal);
  border-radius: 999px;
  padding: 5px 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transform: rotate(-3deg);
  white-space: nowrap;
}
.seal--in {
  animation: seal-stamp 220ms ease-out both;
}
@media (max-width: 480px) {
  .seal { font-size: 10px; padding: 4px 10px; letter-spacing: 0.04em; gap: 4px; }
}
@keyframes seal-stamp {
  from { transform: rotate(-3deg) scale(1.15); opacity: 0; }
  to   { transform: rotate(-3deg) scale(1); opacity: 1; }
}

/* ============ EMPTY / N<10 STATE ============ */
.empty {
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: var(--space-6) var(--space-5);
  background: var(--paper);
}
.empty .eyebrow { color: var(--seal); }

/* ============ LEDGER TABLE ============ */
.ledger { font-family: var(--font-mono); font-size: 13.5px; }
.ledger th {
  text-align: left; font-weight: 500; color: var(--ink-soft);
  border-bottom: 1px solid var(--rule); padding: var(--space-2) var(--space-3);
  text-transform: uppercase; letter-spacing: 0.04em; font-size: 12px;
}
.ledger td { padding: var(--space-3); border-bottom: 1px solid var(--rule); color: var(--ink); }
.ledger tr:last-child td { border-bottom: none; }
.ledger tr:hover td { background: var(--tide-tint-1); }
.ledger .num { text-align: right; font-variant-numeric: tabular-nums; }
.ledger .bar-cell { position: relative; }
.ledger .bar {
  position: absolute; inset: 6px 0; background: var(--tide-tint-2); border-radius: 2px; z-index: 0;
}
.ledger .bar-label { position: relative; z-index: 1; }

/* ============ HERO ============ */
.hero { padding-top: var(--space-8); padding-bottom: var(--space-9); }
.hero__grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: var(--space-8); align-items: center; }
@media (max-width: 860px) {
  .hero__grid { grid-template-columns: 1fr; gap: var(--space-6); }
}
.hero__actions { display: flex; gap: var(--space-3); margin-top: var(--space-6); flex-wrap: wrap; }
.hero__thesis { font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.hero__thesis .n { color: var(--tide); }

/* mini line chart (single self-drawing moment on load) */
.trend-svg { width: 100%; height: auto; overflow: visible; }
.trend-svg .line {
  fill: none; stroke: var(--tide); stroke-width: 2px;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: var(--len, 600); stroke-dashoffset: var(--len, 600);
  animation: draw 650ms ease-out 80ms forwards;
}
.trend-svg .dot { fill: var(--tide); }
.trend-svg .axis { stroke: var(--rule); stroke-width: 1px; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ============ TEASER / CTA BOX ============ */
.teaser {
  border-left: 3px solid var(--tide);
  background: var(--tide-tint-1);
  padding: var(--space-5);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.teaser p { margin-bottom: var(--space-4); color: var(--ink); }
.teaser p:last-child { margin-bottom: 0; }

/* ============ FOOTER ============ */
.site-footer {
  border-top: 1px solid var(--rule);
  background: var(--paper);
  padding-top: var(--space-7); padding-bottom: var(--space-7);
}
.footer__profile { display: flex; gap: var(--space-4); align-items: center; }
.footer__badge {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  flex-shrink: 0;
}
.footer__cred { font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; }
.footer__cred strong { color: var(--ink); }
.footer__links { margin-top: var(--space-4); display: flex; gap: var(--space-5); flex-wrap: wrap; }
.footer__links a { font-size: 13.5px; font-weight: 600; }

/* ============ WORK-WITH-ME ============ */
.offer {
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper);
  padding: var(--space-5);
}
.offer__title { font-family: var(--font-display); font-weight: 700; font-size: 17px; margin-bottom: var(--space-2); }
.offer__desc { color: var(--ink-soft); font-size: 14px; }

/* ============ UTILS ============ */
.text-soft { color: var(--ink-soft); }
.text-seal { color: var(--seal); }
.up::before { content: '▲ '; }
.down::before { content: '▼ '; }
