/* ============================================================
   H Heuristics — "No Income Source & Wealth Inequality"
   Research report stylesheet
   Brand: H Heuristics editorial system (navy / gold / cream)
   Type: Cormorant Garamond (display) + Source Sans 3 (body)
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* Brand navy */
  --navy-950: #0a1522;
  --navy-900: #0f1f33;
  --navy-800: #16304d;
  --navy-700: #1f4270;
  --navy-600: #2d5a94;
  --navy-500: #4775b0;
  --navy-400: #6f95c4;
  --navy-300: #9bb5d6;
  --navy-200: #c3d3e8;
  --navy-100: #e0e9f3;
  --navy-50:  #f0f4f9;

  /* Brand gold */
  --gold-600: #a8884a;
  --gold-500: #b89b5e;
  --gold-400: #c9af7a;
  --gold-300: #dac699;
  --gold-200: #e9ddbb;
  --gold-100: #f3ecd8;
  --gold-50:  #f9f5ea;

  /* Warm cream surface */
  --cream-50:  #faf7f0;
  --cream-100: #f5f0e6;
  --cream-200: #ece4d4;
  --cream-300: #dfd3bc;

  /* Neutral ink */
  --ink-900: #17202b;
  --ink-700: #3a4452;
  --ink-600: #55606e;
  --ink-500: #6e7886;
  --ink-400: #8b94a1;
  --ink-300: #b0b8c2;
  --ink-200: #d3d8df;
  --ink-100: #e7eaee;
  --ink-50:  #f3f5f7;

  /* Data-viz (colorblind-safe) */
  --viz-blue:   #2f6fb3;
  --viz-teal:   #2ca6a4;
  --viz-green:  #3fa36a;
  --viz-amber:  #d99a2b;
  --viz-orange: #d9722d;
  --viz-red:    #c04a3a;
  --viz-purple: #7a5ba6;
  --viz-navy:   #1f4270;
  --viz-gold:   #b89b5e;

  /* Semantic roles */
  --bg:          var(--cream-50);
  --bg-card:     #ffffff;
  --surface:     var(--cream-100);
  --ink:         var(--ink-900);
  --ink-soft:    var(--ink-700);
  --ink-muted:   var(--ink-600);
  --accent:      var(--gold-500);
  --accent-soft: var(--gold-100);
  --rule:        var(--gold-300);
  --rule-soft:   var(--cream-200);
  --dark:        var(--navy-950);
  --dark-2:      var(--navy-900);

  --font-display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --font-body:    "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 42rem;       /* comfortable prose width */
  --content-max: 72rem;   /* grid max */
  --gutter: clamp(1.25rem, 4vw, 3rem);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 6rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.72;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, canvas { max-width: 100%; display: block; }
a { color: var(--navy-700); text-decoration-color: var(--gold-400); text-underline-offset: 3px; }
a:hover { color: var(--gold-600); text-decoration-color: var(--gold-500); }
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--navy-950); line-height: 1.12; margin: 0; font-weight: 600; }
p { margin: 0 0 1.25rem; }
strong { color: var(--navy-900); }
em { font-style: italic; }

::selection { background: var(--gold-200); color: var(--navy-950); }

/* ---------- Reading progress ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: transparent; z-index: 60; pointer-events: none;
}
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold-500), var(--gold-400));
  transition: width 80ms linear;
}

/* ---------- Masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250, 247, 240, 0.9);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--rule-soft);
}
.masthead-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0.8rem var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand {
  display: flex; align-items: center; gap: 0.7rem;
  text-decoration: none; color: var(--navy-950);
}
.brand-mark {
  width: 1.9rem; height: 1.9rem; flex: none;
  background: var(--navy-950); color: var(--gold-400);
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 700;
  border-radius: 3px;
}
.brand-name { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; letter-spacing: 0.01em; }
.brand-tag {
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--gold-600); margin-top: 1px;
}
.masthead-meta { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-muted); }

/* ---------- Report grid (TOC + content) ---------- */
.report {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

/* ---------- Table of contents ---------- */
.toc {
  position: sticky; top: 6rem;
  align-self: start;
  padding: 0.25rem 0 2rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.toc-label {
  font-size: 0.66rem; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--gold-600); margin: 0 0 0.85rem; padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}
.toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.toc a {
  display: block; padding: 0.32rem 0.55rem; border-left: 2px solid transparent;
  color: var(--ink-600); text-decoration: none; letter-spacing: 0.02em;
  transition: color .15s, border-color .15s, background .15s;
  line-height: 1.4;
}
.toc a:hover { color: var(--navy-900); background: var(--gold-50); }
.toc a.active {
  color: var(--navy-950); border-left-color: var(--gold-500);
  background: var(--gold-50); font-weight: 600;
}
.toc .toc-sub { padding-left: 0.9rem; }

/* ---------- Hero ---------- */
.hero { padding: clamp(2.5rem, 6vw, 4.5rem) 0 2.5rem; border-bottom: 1px solid var(--rule); margin-bottom: 0; }
.kicker {
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--gold-600); margin: 0 0 1.2rem;
}
.hero-title {
  font-size: clamp(2.4rem, 5.4vw, 3.9rem);
  font-weight: 600; line-height: 1.04; letter-spacing: -0.01em;
  margin: 0 0 1.4rem; max-width: 22ch;
}
.hero-deck {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.3vw, 1.5rem); line-height: 1.5;
  color: var(--ink-700); font-weight: 500; max-width: 46ch; margin: 0 0 1.75rem;
}
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-500);
  padding-top: 1.25rem; border-top: 1px solid var(--rule-soft);
}
.hero-meta span { display: inline-flex; align-items: center; gap: 0.5rem; }
.hero-meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--gold-500); }

/* ---------- KPI / stat strip ---------- */
.stat-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--rule-soft); border: 1px solid var(--rule-soft);
  margin: 2rem 0 0; border-radius: 6px; overflow: hidden;
}
.stat {
  background: var(--bg-card); padding: 1.4rem 1.25rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.stat-value {
  font-family: var(--font-mono); font-weight: 600; font-size: clamp(1.3rem, 2.2vw, 1.65rem);
  color: var(--navy-950); letter-spacing: -0.02em; line-height: 1.1;
}
.stat-value .unit { font-size: 0.6em; color: var(--gold-600); font-weight: 600; }
.stat-label { font-size: 0.82rem; line-height: 1.4; color: var(--ink-600); }
.stat-src { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-400); }

/* ---------- Sections & prose ---------- */
.section { padding: clamp(2.5rem, 5vw, 3.75rem) 0; border-bottom: 1px solid var(--rule-soft); }
.section:last-of-type { border-bottom: none; }
.section-head { margin-bottom: 1.5rem; }
.section-index {
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--gold-600); display: block; margin-bottom: 0.6rem;
}
.section-title {
  font-size: clamp(1.7rem, 3.2vw, 2.35rem); font-weight: 600;
  line-height: 1.1; max-width: 24ch;
}
.section-lede { font-size: 1.15rem; color: var(--ink-700); }
.prose { max-width: var(--measure); }
.prose p { margin: 0 0 1.25rem; }

/* Drop cap on opening paragraph */
.lead::first-letter {
  font-family: var(--font-display); font-weight: 600;
  float: left; font-size: 4.4em; line-height: 0.82;
  padding: 0.06em 0.14em 0 0; color: var(--navy-950);
}

/* Sub-lever heading */
.lever {
  margin-top: 2.5rem; padding-top: 2.25rem; border-top: 1px solid var(--rule-soft);
}
.lever:first-of-type { margin-top: 0.25rem; border-top: none; padding-top: 0.25rem; }
.lever-title { font-size: clamp(1.35rem, 2.4vw, 1.7rem); font-weight: 600; margin-bottom: 1rem; }
.lever-title .tag {
  font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--gold-600); display: block; margin-bottom: 0.4rem; font-weight: 600;
}

/* ---------- Figure / chart ---------- */
.figure {
  margin: 2.25rem 0; background: var(--bg-card);
  border: 1px solid var(--rule-soft); border-radius: 8px;
  padding: 1.5rem 1.5rem 1.1rem; max-width: 46rem;
}
.figure-title { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; color: var(--navy-950); margin-bottom: 0.3rem; }
.figure-note { font-size: 0.9rem; color: var(--ink-600); margin-bottom: 1.1rem; }
.chart-wrap { position: relative; height: clamp(220px, 34vw, 320px); }
.figure-caption { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.04em; color: var(--ink-400); margin-top: 0.9rem; padding-top: 0.75rem; border-top: 1px solid var(--rule-soft); line-height: 1.5; }

/* ---------- Pull quote / takeaway ---------- */
.takeaway {
  margin: 2.25rem 0; padding: 1.4rem 1.6rem 1.4rem 1.5rem;
  background: var(--gold-50); border-left: 3px solid var(--gold-500);
  border-radius: 0 6px 6px 0; max-width: var(--measure);
}
.takeaway .label { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold-600); display: block; margin-bottom: 0.5rem; }
.takeaway p { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.45; color: var(--navy-950); margin: 0; font-weight: 500; }

/* ---------- Data table ---------- */
.table-scroll { overflow-x: auto; max-width: 46rem; margin: 1.75rem 0; }
table.calc { width: 100%; border-collapse: collapse; font-size: 0.95rem; background: var(--bg-card); border: 1px solid var(--rule-soft); border-radius: 8px; overflow: hidden; }
table.calc caption { text-align: left; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-400); padding: 0.85rem 1rem 0; }
table.calc th, table.calc td { padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid var(--rule-soft); }
table.calc thead th { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); background: var(--ink-50); border-bottom: 1px solid var(--rule); }
table.calc tbody tr:last-child td { border-bottom: none; }
table.calc td.num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
table.calc tr.total td { font-weight: 600; color: var(--navy-950); background: var(--gold-50); border-top: 1px solid var(--rule); }

/* ---------- Binding term ---------- */
.binding {
  margin: 2.5rem 0 0; padding: 1.75rem 1.9rem;
  background: var(--dark); color: var(--cream-50);
  border-radius: 8px; max-width: var(--measure);
}
.binding .label { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold-400); display: block; margin-bottom: 0.8rem; }
.binding p { font-family: var(--font-display); font-size: 1.4rem; line-height: 1.5; font-weight: 500; color: #fff; margin: 0; }

/* ---------- References ---------- */
.refs { list-style: none; margin: 0; padding: 0; counter-reset: ref; max-width: 46rem; }
.refs li { counter-increment: ref; padding: 0.65rem 0 0.65rem 2.4rem; position: relative; border-bottom: 1px solid var(--rule-soft); font-size: 0.94rem; line-height: 1.5; color: var(--ink-700); }
.refs li:last-child { border-bottom: none; }
.refs li::before { content: "[" counter(ref) "]"; position: absolute; left: 0; top: 0.65rem; font-family: var(--font-mono); font-size: 0.74rem; color: var(--gold-600); }
.refs .ref-src { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-500); }
.refs a { color: var(--navy-700); }

/* ---------- Footer ---------- */
footer {
  background: var(--dark); color: var(--cream-200); margin-top: 0;
  border-top: 1px solid var(--gold-500);
}
.footer-inner {
  max-width: var(--content-max); margin: 0 auto; padding: 2.5rem var(--gutter) 2.75rem;
  display: flex; flex-wrap: wrap; gap: 1.5rem 3rem; justify-content: space-between; align-items: flex-start;
}
.footer-brand .brand-name { color: var(--cream-50); }
.footer-brand p { margin: 0.4rem 0 0; font-size: 0.85rem; color: var(--cream-300); max-width: 40ch; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1.5rem; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.footer-links a { color: var(--gold-300); text-decoration: none; }
.footer-links a:hover { color: #fff; }
.footer-note { font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-400); letter-spacing: 0.04em; margin-top: 1.5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .report { grid-template-columns: 1fr; gap: 0; }
  .toc {
    position: sticky; top: 4.1rem; z-index: 40;
    background: rgba(250, 247, 240, 0.96);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    margin: 0 calc(var(--gutter) * -1); padding: 0.6rem var(--gutter);
    border-bottom: 1px solid var(--rule-soft);
  }
  .toc-label { margin-bottom: 0.5rem; padding-bottom: 0; border-bottom: none; }
  .toc ol { flex-direction: row; overflow-x: auto; gap: 0.35rem; padding-bottom: 0.25rem; scrollbar-width: thin; }
  .toc a { white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; padding: 0.3rem 0.55rem; }
  .toc a.active { border-left: none; border-bottom-color: var(--gold-500); }
  .toc .toc-sub { padding-left: 0.55rem; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  body { font-size: 1rem; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .hero-title { font-size: 2.1rem; }
  .brand-tag, .masthead-meta { display: none; }
}

/* ---------- Print ---------- */
@media print {
  .progress, .masthead, .toc, footer { display: none; }
  body { background: #fff; color: #000; }
  .report { display: block; max-width: none; }
  .section { break-inside: auto; }
}
