/* Chance Fits After Search: shared styles (static site, no external dependencies) */

:root {
  color-scheme: light;
  --bg: #f9f9f9;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --text: #191919;
  --text-2: #555555;
  --text-3: #6b6b6b;
  --border: rgba(11, 11, 11, 0.12);
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --link: #1b64be;
  --accent: #257de0;
  --series-1: #257de0;
  --series-2: #f47230;
  --series-3: #00b894;
  --ref: #191919;
  --notice-bg: #fff6e0;
  --notice-border: #e8b64a;
  --notice-text: #5a3d00;
  --code-bg: #f1f1f1;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0b0b;
    --surface: #191919;
    --surface-2: #222222;
    --text: #efefef;
    --text-2: #b9b9b9;
    --text-3: #9c9c9c;
    --border: rgba(255, 255, 255, 0.12);
    --grid: #303030;
    --axis: #474747;
    --link: #6aabf1;
    --accent: #338ced;
    --series-1: #338ced;
    --series-2: #e76624;
    --series-3: #00a888;
    --ref: #efefef;
    --notice-bg: #2a2110;
    --notice-border: #a57a1c;
    --notice-text: #f3d9a0;
    --code-bg: #262626;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0b;
  --surface: #191919;
  --surface-2: #222222;
  --text: #efefef;
  --text-2: #b9b9b9;
  --text-3: #9c9c9c;
  --border: rgba(255, 255, 255, 0.12);
  --grid: #303030;
  --axis: #474747;
  --link: #6aabf1;
  --accent: #338ced;
  --series-1: #338ced;
  --series-2: #e76624;
  --series-3: #00a888;
  --ref: #efefef;
  --notice-bg: #2a2110;
  --notice-border: #a57a1c;
  --notice-text: #f3d9a0;
  --code-bg: #262626;
  --shadow: none;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
}

a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

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

code, .mono { font-family: var(--mono); font-size: 0.88em; overflow-wrap: anywhere; }
code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; word-break: break-word; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--surface); color: var(--text); padding: 8px 12px; z-index: 10;
}
.skip-link:focus { left: 16px; top: 16px; }

/* ---------- Header / nav ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { font-weight: 650; letter-spacing: -0.01em; color: var(--text); text-decoration: none; }
.brand small { display: block; font-weight: 400; color: var(--text-3); font-size: 13px; letter-spacing: 0; }
.site-nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: 15px; }
.site-nav a { color: var(--text-2); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); text-decoration: underline; }

/* ---------- Status banner ---------- */
.status-banner {
  background: var(--notice-bg);
  border-bottom: 1px solid var(--notice-border);
  color: var(--notice-text);
  font-size: 14.5px;
}
.status-banner .inner { max-width: 1080px; margin: 0 auto; padding: 10px 16px; }
.status-banner strong { letter-spacing: 0.02em; }

.badge {
  display: inline-block; font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid var(--notice-border); color: var(--notice-text); background: var(--notice-bg);
  padding: 2px 8px; border-radius: 999px; vertical-align: middle;
}

/* ---------- Layout ---------- */
main { display: block; }
.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.prose { max-width: 720px; }

section { padding: 40px 0; border-bottom: 1px solid var(--border); }
section:last-of-type { border-bottom: 0; }

h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 0.5em; }
h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 700; }
h2 { font-size: clamp(23px, 3.2vw, 30px); font-weight: 680; margin-top: 0; }
h3 { font-size: 20px; font-weight: 650; margin-top: 1.6em; }
p { margin: 0 0 1em; }
.lede { font-size: clamp(18px, 2.2vw, 21px); color: var(--text-2); max-width: 760px; }
.eyebrow { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); font-weight: 600; margin-bottom: 10px; }
.muted { color: var(--text-3); }
.small { font-size: 14.5px; }

.hero { padding: 56px 0 40px; }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

.button {
  display: inline-block; padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: 15.5px;
  text-decoration: none; border: 1px solid var(--border); color: var(--text); background: var(--surface);
}
.button.primary { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.button:hover { text-decoration: none; filter: brightness(0.97); }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 28px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow);
}
.tile .label { font-size: 14px; color: var(--text-2); }
.tile .value { font-size: 34px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; margin: 4px 0 2px; }
.tile .note { font-size: 13px; color: var(--text-3); }

/* ---------- Cards / grid ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; font-size: 18px; }
.card p:last-child, .card ul:last-child { margin-bottom: 0; }

ul.clean { padding-left: 1.15em; margin: 0 0 1em; }
ul.clean li { margin: 0.3em 0; }

/* ---------- Figures / charts ---------- */
figure { margin: 24px 0; }
.chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 18px 12px; box-shadow: var(--shadow);
  position: relative;
}
.chart-title { font-weight: 650; font-size: 16.5px; margin: 0 0 2px; }
.chart-sub { font-size: 14px; color: var(--text-2); margin: 0 0 10px; }
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--sans); fill: var(--text-2); font-size: 12px; }
.chart .value-label { fill: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .cat-label { fill: var(--text); font-size: 12.5px; }
.chart .axis-label { fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .ref-line { stroke: var(--ref); stroke-width: 1.5; stroke-dasharray: none; opacity: 0.7; }
.chart .ref-text { fill: var(--text); font-weight: 600; }
.chart .halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.chart .bar { fill: var(--series-1); }
.chart .bar:hover, .chart .bar.is-active { filter: brightness(1.08); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.s1 { stroke: var(--series-1); fill: var(--series-1); }
.s2 { stroke: var(--series-2); fill: var(--series-2); }
.s3 { stroke: var(--series-3); fill: var(--series-3); }
.line.s1, .line.s2, .line.s3 { fill: none; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13.5px; color: var(--text-2); margin: 6px 0 4px; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 7px; }
.legend .key { width: 16px; height: 3px; border-radius: 2px; display: inline-block; }
.legend .key.s1 { background: var(--series-1); }
.legend .key.s2 { background: var(--series-2); }
.legend .key.s3 { background: var(--series-3); }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); padding: 8px 10px; font-size: 13px; line-height: 1.4;
  min-width: 160px; max-width: 280px; opacity: 0; transition: opacity 0.08s;
}
.tooltip.show { opacity: 1; }
.tooltip .tt-title { font-weight: 650; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row span.k { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip .tt-row .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; }

figcaption { font-size: 14px; color: var(--text-2); margin-top: 10px; }

details.table-view { margin-top: 10px; font-size: 14px; }
details.table-view summary { cursor: pointer; color: var(--link); }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 14px 0 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
caption { text-align: left; font-size: 14px; color: var(--text-2); padding: 10px 12px 4px; caption-side: top; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { font-weight: 650; background: var(--surface-2); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.hl { font-weight: 700; }
.mark { font-size: 0.85em; color: var(--text-3); }

/* ---------- Notice boxes ---------- */
.notice {
  border: 1px solid var(--notice-border); background: var(--notice-bg); color: var(--notice-text);
  border-radius: 10px; padding: 14px 16px; margin: 18px 0; font-size: 15.5px;
}
.notice h2, .notice h3 { color: var(--notice-text); font-size: 17px; margin: 0 0 6px; }
.notice ul { margin: 6px 0 0; padding-left: 1.2em; }
.notice p:last-child { margin-bottom: 0; }

.callout { border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; margin: 16px 0; color: var(--text); }

/* ---------- White paper ---------- */
.paper { max-width: 760px; margin: 0 auto; padding: 0 16px 64px; }
.paper-head { padding: 44px 0 20px; text-align: left; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.paper-head .doc-meta { font-size: 13.5px; color: var(--text-3); margin-top: 10px; line-height: 1.5; }
.paper-head h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(28px, 4.4vw, 40px); letter-spacing: -0.01em; }
.paper-head .authors { font-size: 16px; color: var(--text-2); margin-top: 6px; }
.paper .body { font-family: var(--serif); font-size: 18px; line-height: 1.65; }
.paper .body h2 { font-family: var(--sans); font-size: 22px; margin-top: 2em; padding-top: 0.4em; }
.paper .body h3 { font-family: var(--sans); font-size: 18px; }
.paper .body .table-wrap, .paper .body figure, .paper .body .notice { font-family: var(--sans); }
.paper .body table { font-size: 14px; }
.abstract { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin: 20px 0; }
.abstract h2 { margin-top: 0 !important; padding-top: 0 !important; font-size: 15px !important; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.toc { font-family: var(--sans); font-size: 15px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 18px; margin: 18px 0; }
.toc ol { margin: 6px 0 0; padding-left: 1.3em; }
.toc li { margin: 2px 0; }
.eqn { font-family: var(--mono); font-size: 15px; background: var(--code-bg); padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 12px 0; }
.refs { font-size: 15px; line-height: 1.5; padding-left: 1.6em; }
.refs li { margin: 0.45em 0; }
.access { font-family: var(--sans); font-size: 11.5px; font-weight: 650; letter-spacing: 0.04em; border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; color: var(--text-2); white-space: nowrap; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); font-size: 14px; color: var(--text-3); }
.site-footer .inner { max-width: 1080px; margin: 0 auto; padding: 22px 16px 30px; }
.site-footer p { margin: 0 0 0.5em; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .paper .body { font-size: 17px; }
  section { padding: 30px 0; }
  .tile .value { font-size: 30px; }
  th, td { padding: 7px 9px; }
}

@media print {
  .site-header, .site-nav, .status-banner, .site-footer, details.table-view summary { display: none; }
  body { background: #fff; color: #000; }
  .chart-card, .card, .tile, .abstract, .toc, .table-wrap { box-shadow: none; }
}

@media (forced-colors: active) {
  .chart .bar, .legend .key, .tooltip .tt-row .sw { forced-color-adjust: none; }
}
