/* FreeHealthInsurance.com design system (SITE-PLAN 4.1-4.3, 4.7).
   Tokens are deliberately distinct from FreedInsure (navy/cream/red, DM Serif/DM Sans)
   and from .gov sites (USWDS, Public Sans/Merriweather, flag palette).
   Contrast: every text/background pair in src/site.json "contrast_pairs" is checked by tools/lint.py (WCAG 2.2 AA, 4.5:1).
   Marigold is a marker/outline color only, never text. Dark mode is v2 (plan 4.2). */

:root {
  --ink: #1D2321;
  --paper: #FBF8F2;
  --surface: #FFFFFF;
  --pine: #1F4D3F;
  --pine-700: #163A2F;
  --clay: #A8492A;
  --marigold: #E8B23A;
  --mist: #E7EFEA;
  --sand: #F3EEE4;
  --line: #D9D3C7;
  --muted: #4A524E;
  --on-pine: #FBF8F2;

  --font-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-head: "Source Serif 4", Georgia, "Times New Roman", serif;
  --measure: 68ch;
  --radius: 10px;
  --gutter: 16px;
  color-scheme: light;
}

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

html {
  font-size: 112.5%; /* 18px base */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  overflow-wrap: break-word;
}

img, svg { max-width: 100%; height: auto; }

a { color: var(--clay); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--pine-700); text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; border-radius: 2px; }

.wrap { max-width: 72rem; margin: 0 auto; padding: 0 var(--gutter); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Skip link */
.skip-link {
  position: absolute; left: var(--gutter); top: -100px; z-index: 10;
  background: var(--surface); color: var(--pine); padding: 0.5rem 0.9rem;
  border: 2px solid var(--pine); border-radius: var(--radius); font-weight: 700;
}
.skip-link:focus { top: 0.5rem; }

/* B. Top bar: private guide, not a government website */
.topbar { background: var(--pine-700); color: var(--on-pine); font-size: 0.9rem; line-height: 1.45; }
.topbar p { margin: 0; padding: 0.45rem 0; }
.topbar a, .site-footer a, .crisis a { color: var(--on-pine); text-decoration: underline; }
.topbar a:hover, .site-footer a:hover, .crisis a:hover { color: var(--on-pine); text-decoration-thickness: 2px; }
.topbar :focus-visible, .site-footer :focus-visible, .crisis :focus-visible { outline-color: var(--marigold); }

/* Header with "by FreedInsure" lockup */
.site-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem; padding-top: 0.75rem; padding-bottom: 0.75rem; }
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; color: var(--ink); min-height: 44px; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 44px; height: 44px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.wordmark { overflow-wrap: anywhere; font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; color: var(--pine); letter-spacing: -0.01em; }
.lockup { font-size: 0.85rem; color: var(--muted); }
.header-fi { margin-left: auto; font-size: 0.9rem; }
.header-fi a { display: inline-block; padding: 0.35rem 0; min-height: 24px; }

.site-nav { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-nav ul { list-style: none; margin: 0; padding: 0.35rem 0; display: flex; flex-wrap: wrap; gap: 0.15rem 0.4rem; }
.site-nav a { display: inline-block; padding: 0.35rem 0.55rem; min-height: 24px; color: var(--ink); text-decoration: none; border-radius: 6px; font-size: 0.95rem; }
.site-nav a:hover { background: var(--mist); color: var(--pine-700); }
.site-nav a[aria-current="page"], .site-nav a.in-section { box-shadow: inset 0 -3px 0 var(--marigold); }

/* Breadcrumb */
.breadcrumb ol { list-style: none; margin: 0; padding: 0.8rem 0 0; display: flex; flex-wrap: wrap; font-size: 0.9rem; color: var(--muted); }
.breadcrumb li + li::before { content: "\203A"; padding: 0 0.45rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }

/* Main article */
main { display: block; padding-bottom: 3rem; }
.article { max-width: var(--measure); }
.article > * { max-width: 100%; }

h1, h2, h3, h4 { font-family: var(--font-head); color: var(--pine); line-height: 1.25; margin: 1.6em 0 0.5em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.5rem); margin-top: 0.9rem; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
p, ul, ol, dl, table, figure, blockquote { margin: 0 0 1rem; }
li { margin-bottom: 0.35rem; }
li > ul, li > ol { margin-top: 0.35rem; }
strong { font-weight: 700; }
abbr[title] { text-decoration: underline dotted; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

/* Answer box (AEO, 40-60 words) */
.answer { background: var(--mist); border-left: 6px solid var(--pine); border-radius: var(--radius); padding: 1rem 1.15rem; margin: 0.5rem 0 1rem; }
.answer-label { display: block; font-size: 0.85rem; font-weight: 700; color: var(--pine); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.25rem; }
.answer p { margin: 0; font-size: 1.05rem; }

/* Byline row */
.byline { font-size: 0.92rem; color: var(--muted); margin: 0 0 1.5rem; }
.byline-row { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; margin: 0 0 0.35rem; }
.byline-row > span + span::before { content: "\00B7"; margin-right: 0.9rem; }
.byline a { color: var(--muted); }
.author-note { margin: 0; }

.lang-switch { margin: -0.75rem 0 1.25rem; font-size: 0.95rem; }
.lead { font-size: 1.1rem; }

/* 988 crisis block (mental-health pages) */
.crisis { background: var(--pine-700); color: var(--on-pine); border-radius: var(--radius); padding: 0.9rem 1.1rem; margin: 1rem 0 0.5rem; }
.crisis p { margin: 0; }

/* TX: official application block (first on Medicaid/CHIP pages) */
.apply { background: var(--surface); border: 2px solid var(--pine); border-radius: var(--radius); padding: 1rem 1.15rem; margin: 0 0 1.75rem; }
.apply h2 { margin-top: 0.1rem; font-size: 1.35rem; }
.apply-picker label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
.apply-picker select { font: inherit; padding: 0.45rem 0.6rem; min-height: 44px; max-width: 100%; border: 2px solid var(--muted); border-radius: 6px; background: var(--surface); color: var(--ink); }
.apply-result { margin: 0.6rem 0 0.4rem; font-weight: 700; min-height: 1.6em; }
.apply-all summary { cursor: pointer; padding: 0.35rem 0; color: var(--pine); font-weight: 700; min-height: 24px; }
.apply-list { columns: 1; padding-left: 1.1rem; font-size: 0.95rem; }
@media (min-width: 48rem) { .apply-list { columns: 2; column-gap: 2rem; } }
.apply-source { font-size: 0.85rem; color: var(--muted); margin: 0.5rem 0 0; }

/* Official link domain label ("medicaid.gov ↗"). It may wrap: long hostnames must never widen the page at 320px. */
.dom { color: var(--muted); font-size: 0.85em; overflow-wrap: anywhere; }

/* Options ladder ("cheapest first") */
.ladder { display: grid; grid-template-columns: 1fr; gap: 0.9rem; margin: 0 0 1.25rem; }
@media (min-width: 48rem) { .ladder { grid-template-columns: 1fr 1fr; } }
.ladder-card { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--pine); border-radius: var(--radius); padding: 0.9rem 1rem; }
.ladder-card h3 { margin-top: 0.1rem; }
.ladder-card dl { margin: 0; }
.ladder-card dt { font-weight: 700; margin-top: 0.5rem; }
.ladder-card dd { margin: 0; }

/* Steps, checklist, script, letter, callout, note */
.steps { padding-left: 1.4rem; }
.steps > li { margin-bottom: 0.6rem; }
.checklist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem 0.5rem; margin: 0 0 1.25rem; }
.checklist ul { list-style: none; padding-left: 0; }
.checklist li { position: relative; padding-left: 1.8rem; }
.checklist li::before { content: ""; position: absolute; left: 0; top: 0.3em; width: 1.05rem; height: 1.05rem; border: 2px solid var(--pine); border-radius: 3px; background: var(--surface); }
.script, .letter { background: var(--surface); border: 2px dashed var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; margin: 0 0 1.25rem; }
.script blockquote, .letter blockquote { margin: 0 0 0.75rem; padding-left: 0.9rem; border-left: 4px solid var(--marigold); }
.callout { background: var(--mist); border-radius: var(--radius); padding: 0.9rem 1rem; margin: 0 0 1.25rem; }
.note { font-size: 0.95rem; color: var(--muted); }
.callout > :last-child, .script > :last-child, .letter > :last-child, .checklist > :last-child { margin-bottom: 0; }

.tool-btn {
  font: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer;
  min-height: 44px; min-width: 44px; padding: 0.45rem 0.9rem; margin: 0.4rem 0.5rem 0.2rem 0;
  border: 2px solid var(--pine); border-radius: 8px; background: var(--surface); color: var(--pine);
}
.tool-btn:hover { background: var(--mist); }

/* Data tables: caption + "as of" + source; stack on phones (no horizontal page scroll).
   overflow-x is a safety net for wide tables between the phone breakpoint and the full measure:
   the table scrolls inside its block instead of the page scrolling sideways. */
.table-block { margin: 0 0 1.5rem; max-width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 0.95rem; }
table.data caption { text-align: left; font-weight: 700; color: var(--pine); padding: 0 0 0.5rem; caption-side: top; }
table.data th, table.data td { border: 1px solid var(--line); padding: 0.5rem 0.6rem; text-align: left; vertical-align: top; }
table.data thead th { background: var(--mist); color: var(--ink); }
table.data tbody th { font-weight: 700; }
.table-meta { font-size: 0.85rem; color: var(--muted); margin: 0.45rem 0 0; }
.table-meta + .table-meta { margin-top: 0.2rem; }
.table-filter { margin: 0 0 0.6rem; }
.table-filter label { display: block; font-weight: 700; font-size: 0.92rem; }
.table-filter input { font: inherit; padding: 0.4rem 0.55rem; min-height: 44px; width: 100%; max-width: 22rem; border: 2px solid var(--muted); border-radius: 6px; }
@media (max-width: 40rem) {
  table.data, table.data thead, table.data tbody, table.data tr, table.data th, table.data td { display: block; width: 100%; }
  table.data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 0.7rem; background: var(--surface); }
  table.data th, table.data td { border: 0; border-bottom: 1px solid var(--line); }
  table.data tr > :last-child { border-bottom: 0; }
  table.data tbody th { background: var(--mist); border-radius: 8px 8px 0 0; }
  table.data caption { display: block; width: 100%; }
  table.data td[data-label]::before { content: attr(data-label); display: block; font-weight: 700; font-size: 0.85rem; color: var(--muted); }
  table.data tbody th[data-label]::before { content: attr(data-label) ": "; font-weight: 400; color: var(--muted); }
}

/* Official-finder strip */
.finders { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0.75rem 0; margin: 1.5rem 0; }
.finders h2 { margin-top: 0.4rem; font-size: 1.25rem; }
.finders ul { list-style: none; padding: 0; display: grid; gap: 0.6rem; grid-template-columns: 1fr; }
@media (min-width: 48rem) { .finders ul { grid-template-columns: 1fr 1fr; } }
.finders li { margin: 0; }
.finders .how { display: block; font-size: 0.92rem; color: var(--muted); }

/* Tool privacy note (disclosure H) */
.privacy-note { font-size: 0.92rem; background: var(--mist); border-radius: 8px; padding: 0.6rem 0.8rem; }

/* FAQ */
.faq dt { font-family: var(--font-head); font-weight: 700; color: var(--pine); font-size: 1.1rem; margin-top: 1rem; }
.faq dd { margin: 0.25rem 0 0; }

/* Block D, notices E/F/SBE */
.block-d, .notice { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--marigold); border-radius: var(--radius); padding: 0.9rem 1rem; margin: 2rem 0 1rem; }
.block-d p, .notice p { margin: 0; }

/* FreedInsure module (one per page; sand background, clay rule) */
.fi-module { background: var(--sand); border-left: 6px solid var(--clay); border-radius: var(--radius); padding: 1rem 1.15rem; margin: 2rem 0 1.5rem; }
.fi-module .module-label { margin: 0 0 0.5rem; font-size: 0.9rem; font-weight: 700; color: var(--clay); }
.fi-module .module-body { margin: 0 0 0.75rem; }
.fi-module .module-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 0.6rem; }
.btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0.55rem 1rem; border-radius: 8px;
  font-weight: 700; text-decoration: none; line-height: 1.3; border: 2px solid var(--pine);
}
.btn-primary { background: var(--pine); color: var(--on-pine); }
.btn-primary:hover { background: var(--pine-700); color: var(--on-pine); }
.btn-secondary { background: var(--surface); color: var(--pine); }
.btn-secondary:hover { background: var(--mist); color: var(--pine-700); }
.fi-module .module-phone { margin: 0 0 0.75rem; }
.fi-module .disclosure-c { margin: 0; font-size: 0.92rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 0.6rem; }
.fi-module .disclosure-c a { color: var(--clay); }

/* Sources, related, part-of */
.sources { border-top: 1px solid var(--line); margin-top: 2.5rem; padding-top: 0.5rem; }
.sources ol { font-size: 0.95rem; padding-left: 1.4rem; }
.sources .accessed { color: var(--muted); }
.related ul { padding-left: 1.2rem; }
.part-of { font-size: 0.95rem; color: var(--muted); }

/* Footer: A2 official help + disclosure A (normal size, AA contrast, never a tiny grey footnote) */
.site-footer { background: var(--pine-700); color: var(--on-pine); padding: 1.75rem 0 2rem; margin-top: 2rem; }
.site-footer p { margin: 0 0 1rem; max-width: 80ch; }
.site-footer .a2 { font-weight: 700; }
.site-footer .disclosure-a { font-size: 1rem; }
.footer-nav { display: grid; gap: 1rem 2rem; grid-template-columns: 1fr; margin: 0 0 1.25rem; }
@media (min-width: 48rem) { .footer-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.footer-nav h2 { font-size: 1rem; color: var(--on-pine); margin: 0 0 0.4rem; font-family: var(--font-body); font-weight: 700; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; }
.footer-nav a { display: inline-block; min-height: 24px; padding: 0.15rem 0; }
.copyright { font-size: 0.9rem; }

/* Gone / not found */
.system-page { padding: 1rem 0 2rem; max-width: var(--measure); }

@media (max-width: 30rem) {
  .header-fi { margin-left: 0; width: 100%; }
  .wordmark { font-size: 1.15rem; }
  .byline-row { flex-direction: column; gap: 0.15rem; }
  .byline-row > span + span::before { content: none; }
}
@media (max-width: 21rem) {
  .wordmark { font-size: 1.05rem; }
}

/* The skip link moves focus to <main tabindex="-1">; it is not an interactive control, so no ring there. */
main:focus { outline: none; }

/* Print: checklists, scripts, letters and tables are printed by helpers (SITE-PLAN 3). */
@media print {
  html { font-size: 11pt; }
  body { background: #fff; color: #000; }
  .skip-link, .site-nav, .header-fi, .breadcrumb, .fi-module .module-actions, .fi-module .module-phone,
  .tool-btn, .apply-picker, .table-filter, .related, .part-of, .footer-nav { display: none !important; }
  .topbar, .site-footer { background: #fff; color: #000; border-top: 1px solid #000; }
  .topbar a, .site-footer a, .crisis a { color: #000; }
  .crisis { background: #fff; color: #000; border: 2px solid #000; }
  .answer, .callout, .privacy-note, .fi-module, .apply, .checklist, .script, .letter, .block-d, .notice { background: #fff; border-color: #000; }
  h1, h2, h3, h4, .wordmark { color: #000; }
  a { color: #000; }
  .article a.ext[href^="http"]::after { content: " <" attr(href) ">"; font-size: 0.85em; word-break: break-all; }
  .article .dom { display: none; }
  table.data, table.data th, table.data td { border-color: #000; }
  table.data thead th { background: #eee; }
  h2, h3 { break-after: avoid; }
  table.data tr, .ladder-card, .checklist li { break-inside: avoid; }
  .apply-all[open] summary, .apply-all summary { display: none; }
  .apply-all .apply-list { display: block; }
}
