/* ============================================================
   Shared stylesheet for self-contained HTML research reports.
   Reports <link> to this file instead of embedding styles.

   Source of truth for tokens: src/styles/themes/ledger.css.
   Keep in sync if --signal etc. change.
   ============================================================ */

@font-face { font-family: 'Geist'; src: url('/fonts/geist-variable.woff2') format('woff2-variations'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'General Sans'; src: url('/fonts/general-sans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'General Sans'; src: url('/fonts/general-sans-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'General Sans'; src: url('/fonts/general-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/jetbrains-mono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --bg:       #FAF9F5;
  --surface:  #efebe4;
  --fg:       #1a1a1a;
  --dim:      #7b7266;
  --edge:     rgba(26, 26, 26, 0.12);
  --signal:   #9c3a2d;

  --font-body:    'General Sans', ui-sans-serif, system-ui, sans-serif;
  --font-display: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-ui:      'Inter', ui-sans-serif, system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

html { scroll-behavior: smooth; }

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "ss02", "kern";
}
.container { max-width: 1080px; margin: 0 auto; background: var(--bg); }

/* ── Links ── */
a { color: var(--signal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
.header { padding: 56px 48px 36px; border-bottom: 1px solid var(--edge); }
.header .eyebrow { font-family: var(--font-ui); font-size: 11px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--signal); margin-bottom: 18px; }
.header h1 { font-family: var(--font-display); font-size: 38px; font-weight: 500; letter-spacing: -0.025em; line-height: 1.1; color: var(--fg); margin-bottom: 14px; }
.header .subtitle { font-family: var(--font-body); font-size: 18px; font-weight: 400; line-height: 1.5; color: var(--dim); margin-bottom: 22px; max-width: 56ch; }
.header-meta { font-family: var(--font-mono); font-size: 12px; color: var(--dim); display: flex; flex-wrap: wrap; gap: 8px 22px; letter-spacing: 0.02em; }

/* ── Metrics dashboard ── */
.metrics-dashboard { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--edge); }
.metric { padding: 22px 20px; background: var(--bg); border-right: 1px solid var(--edge); text-align: left; }
.metric:last-child { border-right: none; }
.metric-number { font-family: var(--font-display); font-size: 26px; font-weight: 500; letter-spacing: -0.02em; color: var(--fg); display: block; margin-bottom: 6px; }
.metric-label { font-family: var(--font-ui); font-size: 11px; font-weight: 500; color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; line-height: 1.4; }

/* ── TOC ── */
.toc { background: var(--surface); border-bottom: 1px solid var(--edge); padding: 22px 48px; }
.toc-title { font-family: var(--font-ui); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.16em; color: var(--signal); margin-bottom: 14px; }
.toc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 24px; list-style: none; }
.toc-grid li a { color: inherit; text-decoration: none; }
.toc-grid li a:hover, .toc-grid li a:focus-visible { text-decoration: underline; }
.toc-item { font-family: var(--font-mono); font-size: 12px; color: var(--fg); padding: 2px 0; letter-spacing: 0.02em; }
.toc-num { color: var(--signal); font-weight: 400; margin-right: 10px; }

/* ── Content ── */
.content { padding: 8px 48px 48px; }

p { margin-bottom: 16px; line-height: 1.7; max-width: 68ch; }
ul, ol { margin: 12px 0 16px 22px; max-width: 68ch; }
ul li { margin-bottom: 6px; line-height: 1.65; }
ul li::marker { color: var(--dim); }
strong { color: var(--fg); font-weight: 600; }

h2[id], .section-title[id] { scroll-margin-top: 24px; }

.exec-summary { background: var(--surface); border-left: 2px solid var(--signal); padding: 28px 32px; margin: 36px 0; border-radius: 4px; }
.exec-summary h2 { font-family: var(--font-ui); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.16em; color: var(--signal); margin-bottom: 18px; }
.exec-summary p { margin-bottom: 14px; font-size: 15px; line-height: 1.7; color: var(--fg); }
.exec-summary p:last-child { margin-bottom: 0; }

.section { margin: 48px 0 0; border-top: 1px solid var(--edge); padding-top: 28px; }
.section-title { font-family: var(--font-display); font-size: 24px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; color: var(--fg); margin-bottom: 8px; }
.section-label { font-family: var(--font-ui); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.16em; color: var(--signal); margin-bottom: 10px; }

.subsection { margin: 28px 0 0; }
.subsection h3 { font-family: var(--font-display); font-size: 17px; font-weight: 500; letter-spacing: -0.005em; color: var(--fg); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--edge); }

.citation { font-family: var(--font-mono); font-size: 11px; color: var(--signal); font-weight: 400; letter-spacing: 0.02em; }

.finding-box { border: 1px solid var(--edge); padding: 18px 22px; margin: 18px 0; background: var(--surface); border-radius: 4px; }
.finding-box .finding-label { font-family: var(--font-ui); font-size: 10px; text-transform: uppercase; letter-spacing: 0.16em; font-weight: 500; color: var(--signal); margin-bottom: 8px; }

.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.stack-table { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: 14px; min-width: 600px; }
.stack-table th { background: transparent; color: var(--dim); padding: 10px 14px; text-align: left; font-family: var(--font-ui); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 500; border-bottom: 1px solid var(--fg); }
.stack-table td { padding: 12px 14px; border-bottom: 1px solid var(--edge); vertical-align: top; line-height: 1.55; }
.stack-table tr:nth-child(even) td { background: transparent; }
.stack-table td:first-child { font-weight: 500; color: var(--fg); white-space: nowrap; }

.callout { background: var(--surface); border-left: 2px solid var(--signal); padding: 16px 20px; margin: 18px 0; font-size: 14px; line-height: 1.6; border-radius: 4px; }
.callout strong { color: var(--signal); font-weight: 600; }

.bibliography { background: var(--surface); border-top: 1px solid var(--edge); padding: 36px 48px; margin-top: 56px; }
.bibliography h2 { font-family: var(--font-ui); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.16em; color: var(--signal); margin-bottom: 18px; }
.bib-entry { font-family: var(--font-mono); font-size: 12px; line-height: 1.65; margin-bottom: 10px; padding-left: 32px; text-indent: -32px; color: var(--fg); letter-spacing: 0.01em; }
.bib-entry a { color: var(--signal); text-decoration: none; background-image: linear-gradient(var(--signal), var(--signal)); background-repeat: no-repeat; background-position: 0 100%; background-size: 0% 1px; transition: background-size 200ms ease-out; padding-bottom: 1px; }
.bib-entry a:hover { background-size: 100% 1px; }

.appendix { background: var(--bg); border-top: 1px solid var(--edge); padding: 28px 48px; font-size: 14px; color: var(--dim); }
.appendix h2 { font-family: var(--font-ui); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.16em; color: var(--signal); margin-bottom: 14px; }
.appendix p { margin-bottom: 10px; line-height: 1.65; }

.footer { border-top: 1px solid var(--edge); padding: 18px 48px; font-family: var(--font-mono); font-size: 11px; color: var(--dim); display: flex; justify-content: space-between; letter-spacing: 0.02em; }
.footer a { color: var(--signal); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .header { padding: 36px 20px 28px; }
  .header h1 { font-size: 28px; line-height: 1.15; }
  .header .subtitle { font-size: 16px; }
  .header-meta { gap: 6px 16px; font-size: 11px; }

  .metrics-dashboard { grid-template-columns: repeat(2, 1fr); }
  .metric { padding: 16px 14px; border-right: 1px solid var(--edge); border-bottom: 1px solid var(--edge); }
  .metric:nth-child(5) { grid-column: span 2; border-right: none; }
  .metric:nth-child(even) { border-right: none; }
  .metric:nth-child(odd):not(:nth-child(5)) { border-right: 1px solid var(--edge); }
  .metric-number { font-size: 22px; }
  .metric-label { font-size: 10px; }

  .toc { padding: 16px 20px; }
  .toc-grid { grid-template-columns: 1fr; gap: 6px; }

  .content { padding: 0 20px 36px; }

  .exec-summary { padding: 20px 20px; margin: 24px 0; }
  .exec-summary p { font-size: 14px; }

  .section { margin: 36px 0 0; padding-top: 22px; }
  .section-title { font-size: 20px; }
  .subsection h3 { font-size: 15px; }

  .callout { font-size: 13px; padding: 14px 16px; }

  .bibliography { padding: 24px 20px; }
  .bib-entry { font-size: 11px; padding-left: 24px; text-indent: -24px; }

  .appendix { padding: 22px 20px; }

  .footer { padding: 14px 20px; flex-direction: column; gap: 6px; font-size: 11px; }
}

@media (max-width: 480px) {
  .header h1 { font-size: 24px; }
  .header .subtitle { font-size: 15px; }
  body { font-size: 15px; }
  .section-title { font-size: 18px; }
  .metric-number { font-size: 20px; }
}

/* ── Print ── */
@media print {
  @page { size: A4; margin: 0.75in 0.6in; }
  .header { page-break-after: always; }
  h2 { page-break-before: always; }
  .footer { display: none; }
}
