/* Unemployment Watch styles.
   Colors are defined once as variables ("tokens") for light mode, then swapped for dark mode.
   Red / amber / green appear only for the Phase 3 risk signal (--sig-*), always with a text label and an icon. */

:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #73726d;
  --accent: #2a78d6;
  --accent-ink: #1d5fae;      /* accent dark enough for text on the light surface */
  --chip: #eceae5;
  --warn-bg: #fff3d6;          /* stale-data badge: a caution note, not a risk signal */
  --warn-text: #6b4a00;
  --focus: #2a78d6;
  --sig-green: #1f7a3a;
  --sig-amber: #b76e00;
  --sig-red: #c0392b;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --border: #33332f;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #a09f97;
  --accent: #3987e5;
  --accent-ink: #7fb2f0;
  --chip: #2a2a27;
  --warn-bg: #3a2e10;
  --warn-text: #f5d58a;
  --focus: #7fb2f0;
  --sig-green: #4cb46a;
  --sig-amber: #e8a33d;
  --sig-red: #ef6b5e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h2 { font-size: 1.05rem; margin: 0 0 0.25rem; }
h3 { font-size: 0.85rem; margin: 0; color: var(--text-2); font-weight: 600; }
.wrap { max-width: 1200px; margin: 0 auto; padding-inline: 16px; }
.muted { color: var(--muted); }
.soon { color: var(--muted); opacity: 0.6; cursor: default; }

/* ---- Top bar ---- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding-block: 10px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.pages { display: flex; flex-wrap: wrap; gap: 4px 16px; flex: 1; }
.pages a { color: var(--text-2); text-decoration: none; padding-block: 2px; }
.pages a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--accent); }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--chip);
  color: var(--text); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 0.85rem; cursor: pointer;
}
/* Phones: name and toggle on the first row, page links on their own row below */
@media (max-width: 759px) {
  .topbar-inner { gap: 6px 12px; }
  .brand { flex: 1; }
  .theme-toggle { order: 2; }
  .pages { order: 3; flex-basis: 100%; gap: 2px 14px; font-size: 0.9rem; }
}
.theme-icon::before { content: "☾"; }
:root[data-theme="dark"] .theme-icon::before { content: "☀"; }

/* ---- Freshness line and time control ---- */
.controls { padding-block: 12px 4px; }
.freshness { margin: 0 0 8px; color: var(--text-2); font-size: 0.9rem; }
.badge {
  position: relative; display: inline-block; margin-left: 8px; padding: 1px 10px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn-text); font-weight: 600; font-size: 0.85rem; cursor: help;
}
.badge-detail {
  display: none; position: absolute; left: 0; top: 130%; z-index: 5; width: min(80vw, 420px);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-weight: 400; box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.badge:hover .badge-detail, .badge:focus .badge-detail { display: block; }

.timecontrol { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tc-label { color: var(--text-2); font-size: 0.9rem; margin-right: 2px; }
.tc-sep { width: 1px; height: 20px; background: var(--border); margin-inline: 4px; }
.timecontrol > button, .tc-custom button, .btn {
  font: inherit; font-size: 0.85rem; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 6px; padding: 4px 10px; cursor: pointer; min-height: 32px;
}
.timecontrol > button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tc-custom { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; margin-top: 4px; font-size: 0.85rem; }
.tc-custom[hidden] { display: none; }
.tc-custom input { font: inherit; padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); }

/* ---- Cards and grid ---- */
main { padding-block: 12px 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
.top-row { grid-template-columns: 1fr; }
@media (min-width: 760px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .top-row { grid-template-columns: 1fr 2fr; }
  .wide { grid-column: 1 / -1; }
}

.changes { margin-bottom: 16px; }
.changes ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.changes li { margin-bottom: 0.3rem; }

/* ---- Tiles: 5 across on wide screens, wrapping to 2 and then 1 ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tile-value { font-size: 1.7rem; font-weight: 650; margin: 4px 0 0; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile-asof { margin: 0; color: var(--muted); font-size: 0.8rem; }
.tile-changes { list-style: none; margin: 6px 0; padding: 0; font-size: 0.85rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tile-pct { margin: 0; font-size: 0.8rem; color: var(--text-2); }
.note { color: var(--muted); font-size: 0.8rem; margin: 6px 0 16px; }

/* ---- Chart cards ---- */
.page-intro h1 { font-size: 1.35rem; margin: 4px 0 4px; }
.page-intro p { margin: 0 0 16px; color: var(--text-2); max-width: 75ch; }
.fixed-note { margin: -2px 0 6px; color: var(--muted); font-size: 0.8rem; font-style: italic; }
.why { margin: 0 0 6px; color: var(--text-2); font-size: 0.88rem; }
.chart { width: 100%; height: 320px; }
.chart-footer { margin: 6px 0 0; color: var(--muted); font-size: 0.78rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.menu { position: relative; }
.menu-list {
  position: absolute; z-index: 5; top: 110%; left: 0; display: flex; flex-direction: column; min-width: 150px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.menu-list[hidden] { display: none; }
.menu-list button { font: inherit; font-size: 0.85rem; text-align: left; border: 0; background: none; color: var(--text);
  padding: 8px 12px; cursor: pointer; }
.menu-list button:hover { background: var(--chip); }

/* ---- Summary table (Leading page) ---- */
.summary { margin-bottom: 16px; }
.summary .units { display: block; font-size: 0.78rem; }
.summary td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.summary .arrow { color: var(--text-2); }
.summary table { min-width: 820px; }
.summary td.signal-cell { min-width: 190px; }

/* ---- Data & Downloads page ---- */
.bundle-list { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.bundle-list li { margin-bottom: 0.5rem; }
.howto ol { margin: 0.4rem 0; padding-left: 1.2rem; }
code { font-size: 0.85em; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; margin: 8px 0; font-size: 0.85rem; }
.filters label { display: flex; flex-direction: column; gap: 2px; color: var(--text-2); }
.filters label.grow { flex: 1 1 220px; }
.filters label.check { flex-direction: row; align-items: center; gap: 6px; }
.filters input[type=search], .filters select { font: inherit; padding: 4px 6px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); color: var(--text); min-height: 32px; }
table.files { min-width: 900px; font-size: 0.85rem; }
table.files td.num { white-space: nowrap; }
table.files td.dl, table.files td.nowrap { white-space: nowrap; }
.block { display: block; font-size: 0.78rem; }
.excluded ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

/* ---- About page ---- */
.toc { margin-bottom: 16px; font-size: 0.9rem; }
.prose { margin-bottom: 16px; max-width: 100%; }
.prose dl { margin: 0.5rem 0 0; }
.prose dt { font-weight: 600; margin-top: 0.7rem; }
.prose dd { margin: 0.15rem 0 0; color: var(--text-2); max-width: 80ch; }
.prose ul { padding-left: 1.1rem; margin: 0.4rem 0; }
.prose li { margin-bottom: 0.35rem; max-width: 85ch; }
.prose h3 { margin-top: 0.8rem; }
table.sources { min-width: 640px; font-size: 0.85rem; }
#sources { margin-bottom: 16px; }
.badge-inline { padding: 0 6px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-text); font-size: 0.85em; }

/* ---- Release calendar ---- */
.calendar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; margin-top: 6px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-2); font-weight: 600; font-size: 0.8rem; }

/* ---- Footer ---- */
.footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 0.85rem; }
.footer .wrap { padding-block: 12px 20px; }
.footer p { margin: 0.4rem 0; }

/* ---- Early-warning signal (Phase 3) ---- */
.signal { display: inline-flex; align-items: center; gap: 6px; padding: 2px 12px; border-radius: 999px;
  border: 2px solid currentColor; font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.signal-green { color: var(--sig-green); }
.signal-amber { color: var(--sig-amber); }
.signal-red { color: var(--sig-red); }
.signal-sm { padding: 0 8px; font-size: 0.82rem; border-width: 1.5px; }
.model-note { margin: 6px 0; padding: 6px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-text);
  font-size: 0.88rem; }
.score-panel { margin-bottom: 16px; }
.score-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.score-asof { margin: 0; color: var(--muted); font-size: 0.82rem; }
.score-body { display: grid; grid-template-columns: 1fr; gap: 12px 24px; margin-top: 6px; }
@media (min-width: 760px) { .score-body { grid-template-columns: 5fr 6fr; } }
.score-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 4px 0 0; }
.score-value { font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score-unit { color: var(--text-2); }
.score-change { margin: 2px 0 8px; color: var(--text-2); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.drivers { list-style: none; margin: 4px 0 8px; padding: 0; font-size: 0.9rem; }
.drivers li { margin-bottom: 0.25rem; }
.drivers .arrow { display: inline-block; width: 1.1em; color: var(--text-2); font-weight: 700; }
.score-link { margin: 0; font-size: 0.9rem; }
.chart.chart-small { height: 230px; }
.chart-note { margin: 6px 0 0; color: var(--text-2); font-size: 0.85rem; }
.whatif-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 4px; font-size: 0.85rem;
  color: var(--text-2); cursor: pointer; }
.whatif-toggle input { width: 16px; height: 16px; }

/* ---- Outlook page ---- */
.outlook-head { margin-bottom: 16px; }
.outlook-head .score-line { margin-top: 8px; }
.outlook-cards { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
@media (min-width: 760px) { .outlook-cards { grid-template-columns: 1fr 1fr; } }
.outlook-section { margin-bottom: 16px; }
table.model-table { min-width: 560px; }
table.model-table.compact { min-width: 0; }
td.nowrap { white-space: nowrap; }
table.model-table td.num, table.model-table th.num { text-align: right; padding-right: 14px; white-space: nowrap; }
.small { font-size: 0.82rem; }
.method details { border-top: 1px solid var(--border); padding: 8px 0; }
.method details:first-of-type { border-top: 0; }
.method summary { cursor: pointer; font-weight: 600; }
.method details p, .method details li { max-width: 85ch; color: var(--text-2); }
.method details ul { padding-left: 1.1rem; }

/* ---- States page (Phase 4) ---- */
.states-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-bottom: 8px; }
.viewswitch { display: flex; align-items: center; gap: 6px; }
.viewswitch button, .state-table th button {
  font: inherit; font-size: 0.85rem; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 6px; padding: 4px 12px; cursor: pointer; min-height: 32px;
}
.viewswitch button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.states-asof { margin: 0; color: var(--text-2); font-size: 0.9rem; }
.weighted-note { margin: 0 0 10px; color: var(--text-2); font-size: 0.88rem; max-width: 80ch; }
.states-tiles { margin-bottom: 4px; }
.tile-weighted { margin: 2px 0 0; font-size: 0.95rem; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.states-tiles .tile-value { font-size: 1.35rem; }
.map-card { margin-bottom: 16px; }
.measure-switch { display: flex; flex-wrap: wrap; gap: 4px 14px; border: 0; margin: 4px 0 8px; padding: 0; font-size: 0.88rem; }
.measure-switch legend { float: left; margin-right: 4px; padding: 0; }
.measure-switch label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; min-height: 28px; }
.map { width: 100%; height: 460px; }
@media (max-width: 759px) { .map { height: 300px; } }
.section-title { font-size: 1.15rem; margin: 4px 0 2px; }
.weighted-section > .why { margin-bottom: 10px; }
.state-table-card { margin-bottom: 16px; }
table.state-table { min-width: 960px; font-size: 0.85rem; }
.state-table th { padding-right: 6px; }
.state-table th button { border: 0; background: none; padding: 2px 0; min-height: 0; font-weight: 600; font-size: 0.8rem;
  color: var(--text-2); text-align: inherit; }
.state-table th[aria-sort="ascending"] button::after { content: " ▲"; }
.state-table th[aria-sort="descending"] button::after { content: " ▼"; }
.state-table th.num, .state-table td.num { text-align: right; padding-right: 14px; white-space: nowrap; }
.state-table tr.late td { color: var(--warn-text); }

/* ---- States page: review Gates 2-3 ---- */
.states-lists { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
@media (min-width: 760px) { .states-lists { grid-template-columns: 1fr 1fr; } }
.rising-list { margin: 0.4rem 0 0; padding-left: 1.1rem; font-size: 0.9rem; }
.rising-list li { margin-bottom: 0.3rem; }
.linklike { font: inherit; color: var(--accent-ink); background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline; }
table.contrib-table { font-size: 0.88rem; }
table.contrib-table td.num, table.contrib-table th.num { text-align: right; padding-right: 14px; }
.drill { margin-bottom: 16px; }
.drill-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; }
.drill-head select { font: inherit; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); min-height: 32px; }
.drill-grid { display: grid; grid-template-columns: 1fr; gap: 12px 20px; margin-top: 8px; }
@media (min-width: 760px) { .drill-grid { grid-template-columns: 1fr 1fr; } }
.drill-chart { width: 100%; height: 220px; }
.state-table tbody tr { cursor: pointer; }
.state-table tbody tr:hover { background: var(--chip); }
.state-table .cell-date { color: var(--muted); font-size: 0.78em; }
.state-table td.muted { color: var(--muted); font-size: 0.85em; }
.th-plain { font-weight: 600; font-size: 0.8rem; color: var(--text-2); }
svg.spark { display: block; overflow: visible; }
svg.spark polyline { fill: none; stroke-width: 1.5; stroke-linejoin: round; }
svg.spark .spark-now { stroke: var(--accent); }
svg.spark .spark-prev { stroke: var(--muted); stroke-width: 1; }
table.state-table { min-width: 1180px; }

/* ---- Review WP7: "Where things stand" panel, tile groups, chart caveats ---- */
.stand { margin-bottom: 16px; }
.stand-cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
@media (max-width: 759px) { .stand-cells { grid-template-columns: 1fr; } }
.stand-cell { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.stand-cell h3 { font-size: 0.9rem; color: var(--text); margin-bottom: 6px; }
.stand-cell h3 .muted { font-weight: 400; }
.stand-badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 12px; border-radius: 999px;
  border: 2px solid currentColor; font-weight: 700; font-size: 0.92rem; white-space: nowrap; }
.stand-main { margin: 8px 0 6px; font-size: 0.95rem; }
.stand-small { margin: 0; font-size: 0.84rem; color: var(--text-2); }
.stand-meaning { margin: 12px 0 0; padding: 8px 12px; border-left: 4px solid var(--sig-green); background: var(--chip);
  border-radius: 4px; font-size: 0.95rem; }
.stand-meaning.edge-amber { border-left-color: var(--sig-amber); }
.stand-meaning.edge-red { border-left-color: var(--sig-red); }
.stand-sub { font-size: 0.92rem; color: var(--text); margin: 12px 0 4px; }
.stand-watch { margin: 0 0 6px; padding-left: 1.3rem; font-size: 0.92rem; }
.stand-watch li { margin-bottom: 0.3rem; }
.meter { display: inline-block; position: relative; vertical-align: middle; width: 110px; height: 8px; margin: 0 6px;
  background: var(--border); border-radius: 4px; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--sig-green); border-radius: 4px; }
.meter b { position: absolute; right: 0; top: -3px; bottom: -3px; width: 2px; background: var(--sig-amber); }
@media (max-width: 759px) { .meter { width: 70px; } }
.overview-tiles { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 1000px) { .overview-tiles { grid-template-columns: 1fr 2fr 2fr; } }
.tile-group { min-width: 0; }
.tile-group-label { margin: 0 0 4px; font-size: 0.8rem; font-weight: 600; color: var(--text-2); }
.tile-row { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 480px) { .tile-group-2 .tile-row { grid-template-columns: 1fr 1fr; } }
.tile.edge-green { border-left: 4px solid var(--sig-green); }
.tile.edge-amber { border-left: 4px solid var(--sig-amber); }
.tile.edge-red { border-left: 4px solid var(--sig-red); }
.chart-caveat { margin: 6px 0 0; font-size: 0.9rem; }
details.chart-source { margin-top: 6px; }
details.chart-source summary { cursor: pointer; color: var(--text-2); font-size: 0.82rem; }
.three-things { margin: 0.4rem 0 0; padding-left: 1.3rem; }
.three-things li { margin-bottom: 0.3rem; max-width: 85ch; }
.watch-card { margin-bottom: 16px; }
.watch-headline { margin: 8px 0 4px; font-size: 0.98rem; max-width: 85ch; }
tr.current td { font-weight: 700; }

/* Review WP9 C7: what-if numbers under a chart, shown only while "Show what-if paths" is ticked */
.whatif-table { margin: 8px 0 4px; }
.whatif-table caption { caption-side: top; text-align: left; font-size: 0.85rem; color: var(--muted); padding-bottom: 4px; }
