/* ============================================================
   FedCalc design system v3 — "Treasury" premium finance theme
   Light-default + dark via prefers-color-scheme. Pure CSS, no build.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f4f7fb;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-soft: #eaf0f7;
  --border: #d8e1ec;
  --text: #0d1b2e;          /* deep navy ink — high AA */
  --text-dim: #586a82;      /* AA on white */
  --accent: #0a7d54;        /* emerald trust-green, AA on white */
  --accent-2: #0b5cad;      /* finance blue (links, charts) */
  --accent-hover: #08643f;
  --accent-soft: #d7eee6;
  --blue-soft: #e3eefc;
  --gold: #a9791a;          /* premium trust accent, used sparingly */
  --danger: #c0392b;
  --warn: #9a6700;
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 920px;
  --shadow: 0 1px 2px rgba(13,27,46,.05), 0 8px 30px rgba(13,27,46,.08);
  --shadow-sm: 0 1px 3px rgba(13,27,46,.07);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --hero-grad: radial-gradient(1200px 400px at 50% -120px, rgba(10,125,84,.10), transparent 70%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --bg-elev: #121a28; --bg-card: #15202f; --bg-soft: #1b2738;
    --border: #28384d; --text: #e9eef5; --text-dim: #9fb0c5;
    --accent: #2bd08a; --accent-2: #5b9cf0; --accent-hover: #25b87a;
    --accent-soft: rgba(43,208,138,.14); --blue-soft: rgba(91,156,240,.14); --gold: #d6a93f;
    --shadow: 0 4px 28px rgba(0,0,0,.4); --shadow-sm: 0 1px 3px rgba(0,0,0,.45);
    --hero-grad: radial-gradient(1200px 400px at 50% -120px, rgba(43,208,138,.10), transparent 70%);
  }
}
/* Manual theme override (set by the toggle button; beats the media query). */
html[data-theme="light"] {
  --bg: #f4f7fb; --bg-elev: #ffffff; --bg-card: #ffffff; --bg-soft: #eaf0f7;
  --border: #d8e1ec; --text: #0d1b2e; --text-dim: #586a82;
  --accent: #0a7d54; --accent-2: #0b5cad; --accent-hover: #08643f;
  --accent-soft: #d7eee6; --blue-soft: #e3eefc; --gold: #a9791a;
  --shadow: 0 1px 2px rgba(13,27,46,.05), 0 8px 30px rgba(13,27,46,.08); --shadow-sm: 0 1px 3px rgba(13,27,46,.07);
  --hero-grad: radial-gradient(1200px 400px at 50% -120px, rgba(10,125,84,.10), transparent 70%);
}
html[data-theme="dark"] {
  --bg: #0b1220; --bg-elev: #121a28; --bg-card: #15202f; --bg-soft: #1b2738;
  --border: #28384d; --text: #e9eef5; --text-dim: #9fb0c5;
  --accent: #2bd08a; --accent-2: #5b9cf0; --accent-hover: #25b87a;
  --accent-soft: rgba(43,208,138,.14); --blue-soft: rgba(91,156,240,.14); --gold: #d6a93f;
  --shadow: 0 4px 28px rgba(0,0,0,.4); --shadow-sm: 0 1px 3px rgba(0,0,0,.45);
  --hero-grad: radial-gradient(1200px 400px at 50% -120px, rgba(43,208,138,.10), transparent 70%);
}
/* floating theme toggle (injected by site.js) */
.theme-toggle {
  position: fixed; bottom: 16px; left: 16px; z-index: 90;
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); cursor: pointer; font-size: 1.1rem;
  box-shadow: var(--shadow-sm); display: grid; place-items: center; padding: 0;
  transition: transform .1s, box-shadow .15s;
}
.theme-toggle:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
@media print { .theme-toggle { display: none; } }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
/* keep focused result headings clear of the sticky header */
#r-heading, #d-heading, #m-heading { scroll-margin-top: 84px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  font-family: var(--font); background: var(--bg) var(--hero-grad) no-repeat; color: var(--text);
  line-height: 1.6; -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}
h1, h2, h3, .brand, .hero h1, .result-headline { font-family: var(--font-display); letter-spacing: -.01em; }
.result-headline, .stat-grid .val, table.data td, .compare-grid .val { font-variant-numeric: tabular-nums; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Accessibility: skip link + global focus ring */
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff;
  padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 200; font-weight: 700;
}
.skip-link:focus { left: 0; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border); background: var(--bg-elev);
  position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-sm);
}
.site-header .wrap {
  max-width: var(--maxw); margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); display: flex; align-items: center; gap: 9px; }
.brand .logo {
  width: 32px; height: 32px; background: linear-gradient(135deg, var(--accent), #0e9e6a); border-radius: 9px;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-family: var(--font);
  box-shadow: 0 2px 8px rgba(10,125,84,.35);
}
.site-header nav { display: flex; flex-wrap: wrap; }
.site-header nav a { color: var(--text-dim); margin-left: 18px; font-size: .92rem; font-weight: 600; }
.site-header nav a:hover { color: var(--accent); text-decoration: none; }

/* ---------- Layout ---------- */
main { flex: 1; max-width: var(--maxw); margin: 0 auto; padding: 32px 20px 60px; width: 100%; }
.hero { text-align: center; margin-bottom: 18px; padding-top: 8px; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); font-weight: 600; letter-spacing: -.015em; margin-bottom: 12px; line-height: 1.12; }
.hero p { color: var(--text-dim); font-size: 1.12rem; max-width: 660px; margin: 0 auto; }

/* breadcrumbs + byline */
.breadcrumb { font-size: .82rem; color: var(--text-dim); margin-bottom: 10px; }
.breadcrumb a { color: var(--text-dim); }
.byline {
  display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center; align-items: center;
  font-size: .85rem; color: var(--text-dim); margin: 4px 0 8px;
}
.byline strong { color: var(--text); }
.badge-updated { background: var(--accent-soft); color: var(--accent); padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: .78rem; }

/* ---------- Card ---------- */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), #0e9468); color: #fff; font-weight: 700; font-size: 1rem;
  border: none; border-radius: var(--radius-sm); padding: 13px 22px; cursor: pointer;
  transition: filter .15s, transform .05s, box-shadow .15s; min-height: 46px;
  box-shadow: 0 2px 10px rgba(10,125,84,.25);
}
.btn:hover { filter: brightness(1.06); text-decoration: none; box-shadow: 0 4px 16px rgba(10,125,84,.32); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-sm { padding: 8px 14px; font-size: .88rem; min-height: 38px; }

label { display: block; font-size: .9rem; color: var(--text-dim); font-weight: 600; margin-bottom: 6px; }
input, textarea, select {
  width: 100%; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 12px 14px;
  font-size: 1rem; font-family: var(--font); min-height: 46px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(192,57,43,.12); }
.field-error { color: var(--danger); font-size: .8rem; margin-top: 4px; display: none; }
.field-error.show { display: block; }

/* currency / percent adornments */
.input-adorn { position: relative; }
.input-adorn .adorn { position: absolute; top: 50%; transform: translateY(-50%); color: var(--text-dim); font-weight: 600; pointer-events: none; }
.input-adorn .adorn-l { left: 13px; }
.input-adorn .adorn-r { right: 13px; }
.input-adorn input.has-l { padding-left: 26px; }
.input-adorn input.has-r { padding-right: 30px; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* tooltip (focusable, touch-accessible) */
.tip { position: relative; display: inline-flex; }
.tip button { background: none; border: none; color: var(--accent-2); cursor: help; font-size: .9rem; padding: 0 2px; }
.tip .tip-body {
  position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg-elev); padding: 8px 11px; border-radius: 8px;
  width: 220px; font-size: .8rem; font-weight: 400; line-height: 1.45; z-index: 20;
  opacity: 0; visibility: hidden; transition: opacity .12s; box-shadow: var(--shadow);
}
.tip:hover .tip-body, .tip button:focus + .tip-body { opacity: 1; visibility: visible; }

/* ---------- Results ---------- */
.result-headline { font-size: clamp(2.4rem, 6.5vw, 3.4rem); font-weight: 700; color: var(--accent); letter-spacing: -.02em; line-height: 1.05; }
.takeaway { color: var(--text-dim); font-size: 1.02rem; margin-top: 4px; }
.stat-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.stat-grid > div { flex: 1 1 140px; text-align: center; background: var(--bg-soft); border-radius: var(--radius-sm); padding: 14px 10px; }
.stat-grid .lbl { color: var(--text-dim); font-size: .82rem; }
.stat-grid .val { font-size: 1.3rem; font-weight: 800; }

/* share / action row */
.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.action-row .btn { flex: 1 1 auto; }
.copied-note { color: var(--accent); font-size: .85rem; font-weight: 600; align-self: center; }

/* share card */
#share-card-wrap { margin-top: 18px; text-align: center; }
#share-canvas { width: 100%; max-width: 520px; height: auto; border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); }
#share-card-wrap .share-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* CTA / next-step card */
.cta-card {
  margin-top: 20px; padding: 20px; border-radius: var(--radius);
  background: var(--blue-soft); border: 1px solid var(--border);
}
.cta-card h3 { margin: 0 0 6px; font-size: 1.15rem; }
.cta-card .cta-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.cta-card .disclosure { font-size: .78rem; color: var(--text-dim); margin-top: 10px; }

/* ---------- Charts (inline SVG) ---------- */
.chart-wrap { margin-top: 18px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 16px; justify-content: center; font-size: .85rem; color: var(--text-dim); margin-top: 8px; flex-wrap: wrap; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: middle; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .94rem; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.data thead th { color: var(--text-dim); font-size: .85rem; }
table.data tbody tr:hover { background: var(--bg-soft); }
.compare-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.compare-grid .plan { flex: 1 1 200px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; background: var(--bg-card); }
.compare-grid .plan.best { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.compare-grid .plan h4 { margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; }
.compare-grid .plan .tag { font-size: .72rem; background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 999px; }
.verdict { margin-top: 14px; padding: 14px; background: var(--accent-soft); border-radius: var(--radius-sm); font-weight: 600; }

/* trust strip */
.trust { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin: 18px 0; color: var(--text-dim); font-size: .9rem; }
.trust span { display: inline-flex; align-items: center; gap: 6px; }
.trust .ic { color: var(--accent); font-weight: 800; }

/* ---------- Content ---------- */
.content { margin-top: 44px; }
.content h2 { font-size: 1.45rem; margin: 30px 0 12px; }
.content h3 { font-size: 1.12rem; margin: 20px 0 8px; }
.content p, .content li { color: var(--text); margin-bottom: 10px; }
.content ul, .content ol { padding-left: 22px; }
.faq details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 10px; background: var(--bg-card); }
.faq summary { cursor: pointer; font-weight: 700; color: var(--text); }
.faq details[open] summary { margin-bottom: 8px; }

/* sources + author box */
.sources { background: var(--bg-soft); border-radius: var(--radius-sm); padding: 16px 18px; margin-top: 24px; font-size: .9rem; }
.sources h3 { margin: 0 0 8px; font-size: 1rem; }
.sources ul { padding-left: 20px; }
.author-box { display: flex; gap: 14px; align-items: flex-start; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-top: 28px; }
.author-box .avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; flex: 0 0 auto; }
.author-box .who { font-size: .92rem; }
.author-box .who strong { color: var(--text); }

.related { margin-top: 26px; }
.related .links { display: flex; flex-wrap: wrap; gap: 10px; }
.related .links a { background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: .9rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 28px 20px; text-align: center; color: var(--text-dim); font-size: .88rem; background: var(--bg-elev); }
.site-footer a { color: var(--text-dim); margin: 0 10px; }
.site-footer a:hover { color: var(--accent); }
.gov-note { font-size: .8rem; max-width: 600px; margin: 8px auto 0; }

/* ---------- Cookie consent ---------- */
#cookie-consent {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  max-width: 580px; width: calc(100% - 32px); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  display: none; align-items: center; gap: 14px; z-index: 100; box-shadow: var(--shadow);
  font-size: .88rem; color: var(--text-dim);
}
#cookie-consent.show { display: flex; }
#cookie-consent .btn { padding: 8px 16px; font-size: .9rem; white-space: nowrap; min-height: 38px; }

/* newsletter / lead capture */
.newsletter {
  margin: 32px auto; max-width: var(--maxw); padding: 26px 24px; text-align: center;
  background: linear-gradient(160deg, var(--accent-soft), var(--bg-card));
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.newsletter h2 { margin: 0 0 6px; font-size: 1.35rem; }
.newsletter p { color: var(--text-dim); max-width: 540px; margin: 0 auto 14px; }
.news-form { display: flex; gap: 10px; max-width: 460px; margin: 0 auto; flex-wrap: wrap; }
.news-form input[type=email] { flex: 1 1 220px; }
.news-form .btn { flex: 0 0 auto; }

/* confidence badges (per-figure accuracy/trust signal) */
.badge { display:inline-flex; align-items:center; gap:5px; font-size:.72rem; font-weight:800; padding:2px 9px; border-radius:999px; letter-spacing:.02em; }
.badge.confirmed { background: var(--accent-soft); color: var(--accent); }
.badge.provisional { background: rgba(154,103,0,.14); color: var(--warn); }
.badge.derived { background: var(--bg-soft); color: var(--text-dim); }

/* direct-answer block (featured-snippet target) */
.answer-box { background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 14px 18px; border-radius: 0 10px 10px 0; margin: 16px 0; font-size: 1.05rem; }
.answer-box strong { color: var(--text); }

/* scenario chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip { background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: 8px 15px; font-size: .86rem; cursor: pointer; font-weight: 600; color: var(--text); }
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }

/* embed snippet box */
.embed-box { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-top: 14px; }
.embed-box code { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; background: var(--bg-elev); padding: 10px; border-radius: 6px; overflow-x: auto; color: var(--text); border: 1px solid var(--border); }

/* hub grid */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 20px; }
.hub-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); transition: border-color .15s, transform .05s; }
.hub-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.hub-card h3 { margin: 0 0 6px; font-size: 1.08rem; color: var(--text); }
.hub-card p { color: var(--text-dim); font-size: .9rem; margin: 0; }
.hub-card .pill { font-size: .72rem; font-weight: 700; color: var(--accent); }

/* embed mode (calculator iframed on other sites) */
html.embed .site-header, html.embed .site-footer, html.embed #cookie-consent,
html.embed .ad-slot, html.embed .breadcrumb, html.embed .content, html.embed .byline,
html.embed .skip-link, html.embed .answer-box, html.embed .trust, html.embed .chips,
html.embed .hero p { display: none !important; }
html.embed body { background: transparent; }
html.embed main { padding: 12px; }
html.embed .hero { margin-bottom: 8px; }
.embed-attr { text-align: center; font-size: .78rem; color: var(--text-dim); padding: 10px; }
.embed-attr a { color: var(--accent); font-weight: 600; }

/* ad slots — reserve height so ads cause zero layout shift (CLS) when they load.
   Hidden entirely until AdSense is configured (see js/site.js). */
.ad-slot { margin: 28px auto; max-width: var(--maxw); min-height: 280px; display: grid; place-items: center; background: var(--bg-soft); border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--text-dim); font-size: .8rem; overflow: hidden; }
@media (max-width: 760px) { .ad-slot { min-height: 250px; } }
.ad-slot.placeholder::after { content: "Advertisement"; }

/* utilities */
.hidden { display: none !important; }
.center { text-align: center; }
.mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 220px; }
.muted { color: var(--text-dim); font-size: .9rem; }

@media (max-width: 760px) {
  .site-header nav a { margin-left: 12px; font-size: .85rem; }
  .card { padding: 20px; }
  main { padding: 24px 16px 48px; }
}

/* ---------- Print / PDF ---------- */
@media print {
  .site-header, .site-footer, #cookie-consent, .ad-slot, .action-row, .cta-card, .skip-link, nav { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: 100%; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  .result-headline { color: #000; }
}
