/* Research section. Tokens mirror public/index.html so this reads as the same site.
   Light is the default; dark applies via prefers-color-scheme unless data-theme
   pins it, and via data-theme="dark" so the toggle wins in both directions. */

:root {
  --font-display: "Didot", "Bodoni 72", "Bodoni MT", "Playfair Display", "Times New Roman", serif;
  --font-body: "Avenir Next", "Avenir", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "Menlo", "IBM Plex Mono", ui-monospace, monospace;

  --oxblood: #6E0E17;
  --lacquer: #A81C26;
  --cinnabar: #E0392E;

  --bg: #EFEAE6;
  --bg-2: #E6DFDA;
  --fg: #17100F;
  --fg-2: #6B605B;
  --fg-3: #938781;
  --rule: rgba(23, 16, 15, 0.17);
  --rule-soft: rgba(23, 16, 15, 0.09);
  --accent: #A81C26;
  --accent-2: #6E0E17;

  /* severity ramp — warm-biased so it sits with the oxblood palette */
  --sev-exposed: #A81C26;
  --sev-monitor: #B5532B;
  --sev-partial: #8A6414;
  --sev-secure:  #2F6B4F;

  --gut: clamp(1.25rem, 4vw, 3.5rem);
  --maxw: 1280px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0809;
    --bg-2: #120E10;
    --fg: #E9E3DF;
    --fg-2: #A29996;
    --fg-3: #766C69;
    --rule: rgba(233, 227, 223, 0.16);
    --rule-soft: rgba(233, 227, 223, 0.07);
    --accent: #E0392E;
    --accent-2: #A81C26;
    --sev-exposed: #E0392E;
    --sev-monitor: #D4703F;
    --sev-partial: #C89A4A;
    --sev-secure:  #5CA37E;
  }
}

:root[data-theme="dark"] {
  --bg: #0B0809;
  --bg-2: #120E10;
  --fg: #E9E3DF;
  --fg-2: #A29996;
  --fg-3: #766C69;
  --rule: rgba(233, 227, 223, 0.16);
  --rule-soft: rgba(233, 227, 223, 0.07);
  --accent: #E0392E;
  --accent-2: #A81C26;
  --sev-exposed: #E0392E;
  --sev-monitor: #D4703F;
  --sev-partial: #C89A4A;
  --sev-secure:  #5CA37E;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(168, 28, 38, 0.18); }
img, svg { max-width: 100%; }
button { font: inherit; color: inherit; }

.wrap { max-width: 62rem; margin: 0 auto; padding: 0 var(--gut); }
.narrow { max-width: 38rem; }

/* ---------- masthead (mirrors the homepage) ---------- */
.masthead { border-bottom: 1px solid var(--rule-soft); background: var(--bg); }
.masthead .wrap { display: flex; align-items: center; gap: 1.4rem; padding-block: 1.05rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: inherit; }
.brand svg { width: 20px; height: 20px; fill: var(--accent); flex: none; }
.brand-name { font-family: var(--font-display); font-size: 1.06rem; letter-spacing: .01em; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 1.35rem; font-size: .85rem; }
.nav a { color: var(--fg-2); text-decoration: none; }
.nav a:hover { color: var(--fg); }
.nav a[aria-current="page"] { color: var(--fg); }
.theme-toggle {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  background: none; border: 0; padding: 0; color: var(--fg-2); font-size: .85rem;
}
.theme-toggle:hover { color: var(--fg); }
.theme-toggle .dot {
  width: .72rem; height: .72rem; border-radius: 50%; border: 1px solid currentColor;
  background: linear-gradient(to right, currentColor 0 50%, transparent 50% 100%);
}
@media (max-width: 620px) { .theme-toggle .txt { display: none; } .nav { gap: 1rem; } }

/* ---------- type ---------- */
.eyebrow {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 1.1rem;
}
h1 {
  font-family: var(--font-display); font-weight: 400; text-wrap: balance;
  font-size: clamp(2.2rem, 5.4vw, 3.5rem); line-height: 1.06;
  letter-spacing: -.012em; margin: 0 0 1.3rem;
}
h2 {
  font-family: var(--font-display); font-weight: 400; font-size: clamp(1.6rem, 3vw, 2.05rem);
  line-height: 1.15; margin: 3.6rem 0 .5rem; text-wrap: balance;
}
h3 { font-size: .95rem; margin: 2rem 0 .6rem; }
p { color: var(--fg-2); margin: .75rem 0; }
.narrow strong, li strong, p strong { color: var(--fg); font-weight: 600; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
code { font-family: var(--font-mono); font-size: .86em; background: var(--bg-2); padding: .08em .34em; }
ul { color: var(--fg-2); padding-left: 1.15rem; }
li { margin: .42rem 0; }

header.lede { padding-block: 4.5rem 3rem; border-bottom: 1px solid var(--rule-soft); }
.standfirst { font-size: 1.15rem; color: var(--fg-2); margin: 0; text-wrap: pretty; }

/* ---------- headline figure ---------- */
.headline-stat {
  display: grid; grid-template-columns: auto 1fr; gap: 1.7rem; align-items: center;
  margin: 3rem 0; padding: 1.9rem; background: var(--bg-2);
  border: 1px solid var(--rule-soft); border-left: 2px solid var(--accent);
}
.bignum {
  font-family: var(--font-display); font-size: clamp(3.4rem, 10vw, 4.8rem); line-height: .88;
  color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: -.03em;
}
.headline-stat p { margin: 0; font-size: 1.02rem; }

/* ---------- cohorts ---------- */
.cohorts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1px; background: var(--rule-soft); border: 1px solid var(--rule-soft); margin-top: 1.6rem;
}
.cohort { background: var(--bg); padding: 1.5rem; }
.cohort h4 { margin: 0 0 .1rem; font-size: .95rem; font-weight: 600; }
.cohort .n { font-family: var(--font-mono); font-size: .7rem; color: var(--fg-3); }
.cohort .val {
  font-family: var(--font-display); font-size: 2.8rem; line-height: 1.05;
  font-variant-numeric: tabular-nums; margin: .55rem 0 .1rem;
}
.cohort .lbl { font-size: .83rem; color: var(--fg-2); }
.meter { height: 5px; background: var(--rule-soft); margin-top: 1rem; overflow: hidden; }
.meter span { display: block; height: 100%; }

/* ---------- distribution ---------- */
.dist { display: flex; height: 2.7rem; border: 1px solid var(--rule-soft); overflow: hidden; margin-top: 1.4rem; }
.dist div {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: .69rem; color: #fff; font-variant-numeric: tabular-nums;
}
.dist-key { display: flex; flex-wrap: wrap; gap: 1.1rem; margin-top: .85rem; font-size: .78rem; color: var(--fg-2); }
.dist-key span { display: inline-flex; align-items: center; gap: .42rem; }
.dot-key { width: 9px; height: 9px; flex: none; }

/* ---------- anonymised sample grid ---------- */
.sample { background: var(--bg-2); border: 1px solid var(--rule-soft); padding: 1.6rem; margin-top: 1.5rem; }
.sample-group + .sample-group { margin-top: 1.7rem; }
.sample-group h4 { margin: 0 0 .1rem; font-size: .9rem; font-weight: 600; }
.sample-group .n { font-family: var(--font-mono); font-size: .7rem; color: var(--fg-3); margin-bottom: .75rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(1.45rem, 1fr)); gap: 5px; }
.grid i { display: block; aspect-ratio: 1; }
.grid i.exposed { background: var(--sev-exposed); }
.grid i.monitor { background: var(--sev-monitor); }
.grid i.partial { background: var(--sev-partial); }
.grid i.secure  { background: var(--sev-secure); }

/* ---------- provider mix ---------- */
.prov { display: grid; gap: .45rem; margin-top: 1.4rem; }
.prov-row { display: grid; grid-template-columns: 11rem 1fr 3rem; align-items: center; gap: .9rem; font-size: .85rem; }
.prov-row .bar { height: .9rem; background: var(--accent); opacity: .8; }
.prov-row .pct { font-family: var(--font-mono); font-size: .75rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--fg-2); }
.prov-row .nm { color: var(--fg-2); }

/* ---------- blocks ---------- */
.method { background: var(--bg-2); border: 1px solid var(--rule-soft); padding: 1.8rem; margin-top: 1.5rem; }
.method h3 {
  margin-top: 1.6rem; font-family: var(--font-mono); font-size: .7rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--fg-3); font-weight: 400;
}
.method h3:first-child { margin-top: 0; }
.method p, .method li { font-size: .88rem; }
.caveat { border-left: 2px solid var(--sev-partial); padding: .2rem 0 .2rem 1.1rem; margin: 1.5rem 0; }
.caveat p { font-size: .88rem; margin: .4rem 0; }
.disclosure {
  border: 1px solid var(--rule-soft); border-left: 2px solid var(--sev-secure);
  background: var(--bg-2); padding: 1.5rem 1.7rem; margin-top: 1.6rem;
}
.disclosure p { font-size: .9rem; margin: .45rem 0; }

/* ---------- research index ---------- */
.reports { display: grid; gap: 1px; background: var(--rule-soft); border: 1px solid var(--rule-soft); margin-top: 2rem; }
.report-card { background: var(--bg); padding: 1.9rem; display: block; text-decoration: none; color: inherit; }
.report-card:hover { background: var(--bg-2); }
.report-card .meta { font-family: var(--font-mono); font-size: .69rem; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-3); }
.report-card h2 { font-size: clamp(1.4rem, 2.6vw, 1.85rem); margin: .55rem 0 .5rem; }
.report-card p { margin: 0; }
.report-card .more { color: var(--accent); font-size: .85rem; margin-top: .9rem; display: inline-block; }
.empty { color: var(--fg-3); font-size: .9rem; font-style: italic; }

footer { border-top: 1px solid var(--rule-soft); margin-top: 4.5rem; padding-block: 2.2rem 3.5rem; }
footer p { font-size: .79rem; color: var(--fg-3); margin: .3rem 0; }
footer a { color: var(--fg-2); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .headline-stat { grid-template-columns: 1fr; gap: .85rem; padding: 1.5rem; }
  .prov-row { grid-template-columns: 7.5rem 1fr 2.7rem; font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
