/* ═══════════════════════════════════════════
   Axiom Foundation PBIF concept note
   Tokens come from @axiom-foundation/ui (dist/tokens.css). The build script
   emits a transformed copy at `/tokens.css`, loaded ahead of this file in
   the template — see scripts/build-html.ts emitTokens().
   ═══════════════════════════════════════════ */

@import url("https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Newsreader:ital,wght@0,400;1,400&display=swap");

/* Patch font stacks. The Axiom UI tokens reference --font-geist-sans and
 * --font-mono which Next.js sets via `next/font`. In a static doc those
 * variables are undefined, so we point the family vars at the web fonts we
 * just loaded above. */
:root {
  --f-display: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --f-body: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --f-serif: "Newsreader", Georgia, "Times New Roman", serif;
}

/* ── Reset ── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--color-paper);
  color: var(--color-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 17px;
}

body {
  font-family: var(--f-body);
  font-feature-settings: "kern", "liga", "calt", "ss01";
  line-height: 1.55;
  margin: 0;
  padding: 0;
  position: relative;
}

::selection {
  background: rgba(146, 64, 14, 0.15);
  color: var(--color-ink);
}

/* ── Page container ── */

.doc {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2.5rem 5rem;
  position: relative;
  z-index: 1;
}

/* ── Masthead (single-row, page-1 only) ── */

.doc-masthead {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding-bottom: 0.9rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--color-rule);
}

.doc-masthead .wordmark {
  flex: 0 0 auto;
  height: 1.2rem;
  width: auto;
}

.masthead-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 auto;
  min-width: 0;
}

.masthead-title {
  font-family: var(--f-body);
  font-weight: 500;
  font-size: 1.4rem;
  line-height: 1.12;
  letter-spacing: -0.012em;
  margin: 0;
  color: var(--color-ink);
}

.masthead-meta {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  font-family: var(--f-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
}

.masthead-award {
  color: var(--color-accent);
  font-weight: 500;
}

.masthead-sep {
  color: var(--color-rule-strong);
}

.masthead-download {
  flex: 0 0 auto;
  align-self: center;
  font-family: var(--f-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-ink-secondary);
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--color-rule);
  border-radius: 999px;
  background: var(--color-paper-elevated);
  transition: border-color 150ms, color 150ms;
}

.masthead-download:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Hide the download chip in print — the file is the PDF. */
@media print {
  .masthead-download {
    display: none;
  }
}

/* ── Body typography ── */

.doc h2 {
  font-family: var(--f-body);
  font-weight: 500;
  font-size: 1.05rem;
  line-height: 1.25;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-ink);
  margin: 3rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-rule);
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
}

.doc h2 .section-number {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--color-accent);
  flex: 0 0 auto;
}

.doc h3 {
  font-family: var(--f-body);
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.3;
  letter-spacing: 0.01em;
  margin: 2rem 0 0.5rem;
  color: var(--color-ink);
}

.doc h4 {
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 0.75rem;
  line-height: 1.3;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 1.5rem 0 0.4rem;
  color: var(--color-ink-muted);
}

.doc p {
  margin: 0 0 1rem;
  color: var(--color-ink);
  font-size: 1rem;
  line-height: 1.65;
  text-align: left;
}

.doc p + p {
  margin-top: -0.15rem;
}

.doc ul,
.doc ol {
  margin: 0.25rem 0 1.25rem 0;
  padding-left: 1.4rem;
  color: var(--color-ink);
}

.doc li {
  margin: 0.4rem 0;
  line-height: 1.6;
}

.doc strong {
  font-weight: 600;
  color: var(--color-ink);
}

.doc em {
  font-style: italic;
  font-family: var(--f-serif);
  color: var(--color-ink);
}

.doc a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 0.16em;
  text-decoration-thickness: 0.04em;
  text-decoration-color: rgba(146, 64, 14, 0.35);
  transition: text-decoration-color 150ms;
}

.doc a:hover {
  text-decoration-color: var(--color-accent);
}

.doc blockquote {
  margin: 1.25rem 0;
  padding: 0.6rem 0 0.6rem 1.4rem;
  border-left: 2px solid var(--color-accent);
  font-family: var(--f-serif);
  font-style: italic;
  color: var(--color-ink-secondary);
  font-size: 1.05rem;
  line-height: 1.55;
}

.doc code {
  font-family: var(--f-mono);
  font-size: 0.85em;
  background: var(--color-accent-light);
  color: var(--color-accent);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.doc hr {
  border: 0;
  height: 1px;
  background: var(--color-rule);
  margin: 2.5rem 0;
}

/* ── Stat cards (top of problem section) ── */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1.4rem 0 1.6rem;
  padding: 0;
}

.stat-card {
  position: relative;
  padding: 1.05rem 1rem 1rem;
  background: var(--color-paper-elevated);
  border: 1px solid var(--color-rule);
  border-radius: 4px;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-accent);
  border-radius: 4px 4px 0 0;
  opacity: 0.85;
}

.stat-card .stat-value {
  font-family: var(--f-body);
  font-weight: 500;
  font-size: 1.5rem;
  letter-spacing: -0.015em;
  line-height: 1.05;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.4rem;
}

.stat-card .stat-label {
  font-family: var(--f-body);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--color-ink);
  margin-bottom: 0.5rem;
}

.stat-card .stat-note {
  font-family: var(--f-body);
  font-size: 0.7rem;
  line-height: 1.42;
  color: var(--color-ink-secondary);
}

.stat-card .stat-note a {
  color: var(--color-accent);
  text-decoration: none;
}

.stat-card .stat-note a:hover {
  text-decoration: underline;
}

/* ── Provider table (Governments provide / Axiom delivers) ── */

.provider-table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 1.1rem 0 1.4rem;
  border: 1px solid var(--color-rule);
  border-radius: 4px;
  background: var(--color-paper-elevated);
  overflow: hidden;
}

.provider-col {
  padding: 0.9rem 1rem 1rem;
}

.provider-col + .provider-col {
  border-left: 1px solid var(--color-rule);
}

.provider-head {
  font-family: var(--f-mono);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 0.55rem;
}

.provider-col ul {
  margin: 0;
  padding-left: 1.1rem;
}

.provider-col li {
  font-size: 0.92rem;
  line-height: 1.4;
  margin: 0.22rem 0;
}

/* ── Diagrams ── */

.diagram {
  margin: 1.4rem 0;
  padding: 0;
}

.diagram svg {
  display: block;
  width: 100%;
  height: auto;
}

.diagram figcaption {
  font-family: var(--f-mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  margin: 0.7rem 0 0;
  text-align: center;
}

figure {
  margin: 0;
}

/* ── Footer ── */

footer.doc-footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-rule);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--f-mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
}

footer.doc-footer a {
  color: inherit;
  text-decoration: none;
}

footer.doc-footer a:hover {
  color: var(--color-accent);
}

/* ── Paper texture (subtle, screen only) ── */

@media screen {
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.11  0 0 0 0 0.10  0 0 0 0 0.09  0 0 0 0.045 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  }
}

/* ── Print ── */

/*
 * Margins are owned by Playwright's `page.pdf({ margin: ... })` because the
 * runner controls running headers/footers via its template options. Keep
 * @page free of margin boxes so Chromium doesn't double-stamp content.
 */
@page {
  size: Letter;
}

@media print {
  /* PBIF concept note requirement: 11 point font and 1 inch margins. */
  html {
    font-size: 11pt;
    background: white;
  }

  body {
    background: white;
    color: black;
  }

  body::before {
    display: none;
  }

  .doc {
    max-width: none;
    padding: 0;
    margin: 0;
  }

  /* Compact body rhythm — about 13pt leading on 11pt body. Tight enough
     to land at the PBIF 2-3 page target, open enough to read cleanly. */
  .doc p {
    margin: 0 0 0.3rem;
    line-height: 1.28;
    orphans: 3;
    widows: 3;
  }

  .doc ul,
  .doc ol {
    margin: 0.05rem 0 0.35rem 0;
    padding-left: 1.1rem;
  }

  .doc li {
    margin: 0.05rem 0;
    line-height: 1.28;
  }

  .doc blockquote {
    margin: 0.3rem 0;
    padding: 0.1rem 0 0.1rem 0.75rem;
    font-size: 0.95rem;
    line-height: 1.32;
    border-left-width: 1.5px;
  }

  /* Masthead — single compact band on page 1, ~0.65in tall. */
  .doc-masthead {
    padding-bottom: 0.5rem;
    margin-bottom: 0.65rem;
    gap: 0.95rem;
  }

  .doc-masthead .wordmark {
    height: 0.95rem;
  }

  .masthead-text {
    gap: 0.15rem;
  }

  .masthead-title {
    font-size: 1.15rem;
    line-height: 1.1;
  }

  .masthead-meta {
    font-size: 0.55rem;
    gap: 0.4rem;
  }

  /* Section headers — small uppercase rule + tight numbering.
     In print, drop the top border to recover ~1pt × 7 sections of vertical
     space and tighten margins; the colored section number alone is enough
     visual hierarchy at this font size. */
  .doc h2 {
    margin: 0.35rem 0 0.15rem;
    padding-top: 0;
    border-top: none;
    font-size: 0.82rem;
    letter-spacing: 0.12em;
    gap: 0.5rem;
  }

  .doc h2 .section-number {
    font-size: 0.62rem;
  }

  .doc h3 {
    margin: 0.55rem 0 0.2rem;
    font-size: 0.92rem;
  }

  .doc h4 {
    margin: 0.5rem 0 0.18rem;
  }

  .doc h2,
  .doc h3,
  .doc h4 {
    page-break-after: avoid;
    break-after: avoid;
  }

  .doc h2 + p,
  .doc h3 + p,
  .doc h4 + p,
  .doc h2 + ul,
  .doc h3 + ul,
  .doc h4 + ul {
    page-break-before: avoid;
    break-before: avoid;
  }

  .doc blockquote,
  .doc ul,
  .doc ol,
  .doc pre,
  .stat-cards,
  .stat-card,
  .provider-table,
  .diagram {
    page-break-inside: avoid;
  }

  /* Trim stat cards and provider table to fit on the page */
  .stat-cards {
    gap: 0.45rem;
    margin: 0.7rem 0 0.85rem;
  }

  .stat-card {
    padding: 0.6rem 0.65rem 0.65rem;
  }

  .stat-card .stat-value {
    font-size: 1.15rem;
    margin-bottom: 0.2rem;
  }

  .stat-card .stat-label {
    font-size: 0.7rem;
    line-height: 1.25;
    margin-bottom: 0.3rem;
  }

  .stat-card .stat-note {
    font-size: 0.58rem;
    line-height: 1.3;
  }

  .provider-table {
    margin: 0.6rem 0 0.9rem;
  }

  .provider-col {
    padding: 0.55rem 0.7rem 0.65rem;
  }

  .provider-head {
    font-size: 0.58rem;
    margin-bottom: 0.32rem;
  }

  .provider-col li {
    font-size: 0.78rem;
    line-height: 1.28;
    margin: 0.1rem 0;
  }

  .diagram {
    margin: 0.8rem 0;
  }

  .diagram figcaption {
    font-size: 0.58rem;
    margin-top: 0.4rem;
  }

  .doc strong {
    font-weight: 600;
  }

  .doc a {
    color: var(--color-accent);
    text-decoration: none;
  }

  footer.doc-footer {
    margin-top: 1rem;
    padding-top: 0.5rem;
    font-size: 0.62rem;
    page-break-before: avoid;
  }
}
