/* U.S. Economic Indicators Dashboard — mobile-first, two themes, no framework. */

/* ---------- Fonts (self-hosted, SIL OFL) ---------- */
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("fonts/fraunces-normal-latin.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("fonts/inter-normal-latin.woff2") format("woff2"); }
@font-face { font-family: "Fraunces Fallback"; src: local("Georgia"), local("Times New Roman"); size-adjust: 104%; ascent-override: 95%; descent-override: 25%; }
@font-face { font-family: "Inter Fallback"; src: local("Arial"), local("Helvetica"); size-adjust: 107%; ascent-override: 90%; descent-override: 22%; line-gap-override: 0%; }

/* ---------- Tokens ---------- */
:root {
  --bg: #fbf6ef; --bg-2: #f4ebdf; --surface: #fffdf9; --surface-2: #faf3ea;
  --ink: #2b211b; --ink-2: #5e4f45; --muted: #6f5f54; --line: #e8dccd; --chip: #f4ebe0;
  --accent: #a9471f; --accent-ink: #fffaf4; --accent-soft: #f6e2d3;
  /* data palette: distinguishable in both themes and for common colour-vision deficiencies */
  --c1: #b4532a; --c2: #1f6f78; --c3: #a8740f; --c4: #5b4a8a;
  --pos: #23744a; --pos-soft: #dcefe3; --neg: #b3361f; --neg-soft: #f8ddd5; --warn: #a8740f; --warn-soft: #f7e9cf;
  --band: rgba(94, 79, 69, .10); --grid: rgba(94, 79, 69, .13); --zero: rgba(43, 33, 27, .45);
  --shadow-sm: 0 1px 2px rgba(74, 44, 24, .06);
  --shadow: 0 1px 2px rgba(74, 44, 24, .05), 0 10px 28px -14px rgba(74, 44, 24, .20);
  --r-sm: 10px; --r: 18px; --r-lg: 24px;
  --maxw: 1180px;
  --serif: "Fraunces", "Fraunces Fallback", Georgia, serif;
  --sans: "Inter", "Inter Fallback", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --top: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1612; --bg-2: #231b16; --surface: #261e19; --surface-2: #2d241e;
    --ink: #f5ece2; --ink-2: #dccbbb; --muted: #bfae9e; --line: #3b2f28; --chip: #33281f;
    --accent: #ec9a6e; --accent-ink: #2a140a; --accent-soft: rgba(236, 154, 110, .15);
    --c1: #ef9a6c; --c2: #63c5c9; --c3: #e6b85c; --c4: #b3a5ec;
    --pos: #74d39d; --pos-soft: rgba(116, 211, 157, .14); --neg: #ff8f7a; --neg-soft: rgba(255, 143, 122, .14); --warn: #e6b85c; --warn-soft: rgba(230, 184, 92, .14);
    --band: rgba(220, 203, 187, .08); --grid: rgba(220, 203, 187, .10); --zero: rgba(245, 236, 226, .45);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px -14px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1612; --bg-2: #231b16; --surface: #261e19; --surface-2: #2d241e;
  --ink: #f5ece2; --ink-2: #dccbbb; --muted: #bfae9e; --line: #3b2f28; --chip: #33281f;
  --accent: #ec9a6e; --accent-ink: #2a140a; --accent-soft: rgba(236, 154, 110, .15);
  --c1: #ef9a6c; --c2: #63c5c9; --c3: #e6b85c; --c4: #b3a5ec;
  --pos: #74d39d; --pos-soft: rgba(116, 211, 157, .14); --neg: #ff8f7a; --neg-soft: rgba(255, 143, 122, .14); --warn: #e6b85c; --warn-soft: rgba(230, 184, 92, .14);
  --band: rgba(220, 203, 187, .08); --grid: rgba(220, 203, 187, .10); --zero: rgba(245, 236, 226, .45);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--top) + 64px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden; font-feature-settings: "cv11", "ss01"; }
svg { display: block; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 600; line-height: 1.12; letter-spacing: -0.015em; font-optical-sizing: auto; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
code { font: 500 .88em/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--chip); padding: .15em .4em; border-radius: 6px; }
.num, .kpi-value, .sig-value, td { font-variant-numeric: tabular-nums; }
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 10px; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 10px; z-index: 100; font-weight: 600; }
.skip:focus { left: 12px; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
::selection { background: var(--accent-soft); }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(150%) blur(14px); -webkit-backdrop-filter: saturate(150%) blur(14px); border-bottom: 1px solid var(--line); }
.nav { display: flex; align-items: center; gap: 8px; height: var(--top); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.brand-mark { width: 30px; height: 30px; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { fill: none; stroke: var(--accent-ink); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark circle { fill: var(--accent-ink); }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 18px; letter-spacing: -0.01em; }
.nav-links { display: none; gap: 2px; }
.nav-links a { padding: 8px 12px; font-size: 14.5px; font-weight: 500; color: var(--ink-2); text-decoration: none; border-radius: 999px; transition: background .2s var(--ease), color .2s var(--ease); }
.nav-links a:hover { background: var(--chip); color: var(--ink); }
.theme-toggle { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); cursor: pointer; transition: transform .25s var(--ease), border-color .2s var(--ease); }
.theme-toggle:hover { transform: rotate(-14deg); border-color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-toggle .i-moon { display: none; fill: currentColor; stroke: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}

/* ---------- Hero ---------- */
.hero { padding-top: 24px; padding-bottom: 4px; }
.kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--pos); box-shadow: 0 0 0 0 color-mix(in srgb, var(--pos) 60%, transparent); animation: pulse 2.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
h1 { margin-top: 12px; font-size: clamp(34px, 9.5vw, 60px); line-height: 1.03; letter-spacing: -0.025em; }
h1 em { font-style: italic; font-weight: 500; color: var(--accent); }
.lede { margin-top: 12px; max-width: 60ch; font-size: 16px; color: var(--ink-2); }
@media (min-width: 560px) { .lede { font-size: 17.5px; } }
.stamp { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; color: var(--muted); min-height: 22px; }
.stamp b { color: var(--ink-2); font-weight: 600; }

/* ---------- Sections ---------- */
.section { padding-top: 30px; }
.section-head { margin-bottom: 14px; }
.section-head h2 { font-size: clamp(23px, 5.6vw, 30px); }
.section-head .sub { margin-top: 4px; font-size: 14.5px; color: var(--muted); }
.card-base, .signal, .kpi, .chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }

/* ---------- Signals ---------- */
.signals { display: grid; grid-template-columns: 1fr; gap: 12px; }
.signal { padding: 16px 16px 15px; display: flex; flex-direction: column; gap: 8px; min-height: 150px; }
.sig-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sig-name { font-family: var(--sans); font-size: 13.5px; font-weight: 600; letter-spacing: 0; line-height: 1.3; color: var(--ink-2); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .02em; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--pos); background: var(--pos-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.bad { color: var(--neg); background: var(--neg-soft); }
.sig-value { font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.sig-value small { font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.sig-desc { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.meter { position: relative; height: 8px; border-radius: 99px; background: var(--chip); margin: 4px 0 2px; }
.meter > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--pos); transition: width .8s var(--ease); }
.meter.warn > i { background: var(--warn); } .meter.bad > i { background: var(--neg); }
.meter > b { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 2px; }
.meter-scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { position: relative; display: flex; flex-direction: column; padding: 13px 13px 10px; text-decoration: none; color: inherit; min-height: 168px; overflow: hidden; transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease); }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); line-height: 1.3; min-height: 2.6em; }
.kpi-value { margin-top: 2px; font-family: var(--serif); font-size: clamp(26px, 7.4vw, 34px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; }
.kpi-value .u { font-size: .58em; font-weight: 500; margin-left: 1px; color: var(--ink-2); }
.delta { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; color: var(--muted); }
.chg { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--chip); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chg.good { color: var(--pos); background: var(--pos-soft); }
.chg.bad { color: var(--neg); background: var(--neg-soft); }
.chg svg { width: 9px; height: 9px; fill: currentColor; }
.spark { margin-top: auto; padding-top: 8px; height: 40px; }
.spark svg { width: 100%; height: 34px; overflow: visible; }
.spark .line { fill: none; stroke: var(--c1); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark .area { fill: var(--c1); opacity: .10; }
.spark .zero { stroke: var(--zero); stroke-width: 1; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.kpi-foot { display: flex; justify-content: space-between; gap: 6px; font-size: 10.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.kpi-foot span:last-child { overflow: hidden; text-overflow: ellipsis; letter-spacing: .02em; }
.kpi-note { font-size: 11.5px; color: var(--ink-2); margin-top: 4px; }

/* ---------- Range bar ---------- */
.rangebar { position: sticky; top: calc(var(--top) + 8px); z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 4px; margin: 0 auto 14px; max-width: 340px; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
.rangebar button { min-height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font: 600 14px/1 var(--sans); cursor: pointer; transition: background .2s var(--ease), color .2s var(--ease); }
.rangebar button:hover { color: var(--ink); background: var(--chip); }
.rangebar button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- Charts ---------- */
.charts { display: grid; grid-template-columns: 1fr; gap: 14px; }
.chart-card { padding: 16px 14px 12px; scroll-margin-top: calc(var(--top) + 70px); min-width: 0; }
.chart-card h3 { font-size: 19px; }
.chart-card .what { margin-top: 3px; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 6px; font-size: 12.5px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; background: currentColor; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px); }
.legend i.box { height: 10px; width: 10px; border-radius: 3px; }
.legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.canvas-box { position: relative; height: 230px; }
.canvas-box canvas { position: absolute; inset: 0; animation: fade .5s var(--ease) both; }
@keyframes fade { from { opacity: 0; } }
.chart-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.chart-foot a { color: inherit; }
.clip-note { margin-top: 6px; font-size: 12px; color: var(--muted); }
.chart-error { display: grid; place-items: center; height: 100%; font-size: 14px; color: var(--muted); }

/* ---------- Inversion table ---------- */
.table-wrap { max-width: 780px; position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.inv-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.inv-table th, .inv-table td { padding: 10px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); white-space: nowrap; line-height: 1.4; }
.inv-table th:first-child, .inv-table td:first-child { padding-left: 14px; }
.inv-table .lead { font-size: 12px; color: var(--muted); }
@media (min-width: 560px) { .inv-table th, .inv-table td { padding: 11px 16px; } }
.inv-table th { font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.inv-table tr:last-child td { border-bottom: 0; }
.inv-table td.r, .inv-table th.r { text-align: right; }
.inv-table .neg { color: var(--neg); font-weight: 600; }

/* ---------- Method ---------- */
.method { display: grid; gap: 8px; }
.method details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 16px; }
.method summary { cursor: pointer; padding: 14px 0; font-weight: 600; font-size: 15px; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 48px; }
.method summary::-webkit-details-marker { display: none; }
.method summary::after { content: "+"; font-size: 20px; font-weight: 400; color: var(--accent); transition: transform .25s var(--ease); }
.method details[open] summary::after { transform: rotate(45deg); }
.method details p, .method .notes { padding-bottom: 14px; font-size: 14.5px; color: var(--ink-2); }
.method .notes li { position: relative; padding-left: 16px; margin-top: 4px; }
.method .notes li::before { content: ""; position: absolute; left: 2px; top: .65em; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }

/* ---------- Footer ---------- */
.footer { margin-top: 48px; padding: 26px 0 calc(30px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg-2); }
.foot { display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.noscript { margin: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }

/* ---------- Skeletons ---------- */
.skel, .skel-card { position: relative; overflow: hidden; background: var(--chip); border-color: transparent; }
.skel { display: inline-block; height: 14px; border-radius: 6px; }
.skel.w-60 { width: 60%; max-width: 360px; }
.skel::after, .skel-card::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 55%, transparent), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.load-error { padding: 16px; border-radius: var(--r); background: var(--neg-soft); color: var(--neg); font-weight: 500; }

/* ---------- Larger screens ---------- */
@media (min-width: 560px) {
  .signals { grid-template-columns: repeat(2, 1fr); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 15px 15px 11px; }
  .canvas-box { height: 270px; }
}
@media (min-width: 820px) {
  :root { --top: 64px; }
  .nav-links { display: flex; }
  .hero { padding-top: 54px; }
  .section { padding-top: 52px; }
  .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .chart-card { padding: 20px 20px 14px; }
  .chart-card.wide { grid-column: 1 / -1; }
  .chart-card.wide .canvas-box { height: 330px; }
  .rangebar { margin-right: 0; }
  .section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
}
@media (min-width: 1040px) {
  .signals { grid-template-columns: repeat(4, 1fr); }
  .canvas-box { height: 290px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .topbar, .rangebar, .theme-toggle { display: none; }
  .chart-card, .kpi, .signal { break-inside: avoid; box-shadow: none; }
}
.pill.neutral { color: var(--ink-2); background: var(--chip); }
