/* =====================================================================
   Nijiati Abulizi — design system
   Three facets, one identity:
     All three share the burgundy brand colour.
   Every page sets <body data-facet="…">, which retints --color-accent so
   the page-level styles (written against --color-accent) follow along.
   ===================================================================== */

/* Self-hosted fonts (SIL OFL, see static/fonts/LICENSE-*.txt). The
   "Fallback" faces are metric-matched local fonts, so text keeps its layout
   while the web fonts load and nothing shifts when they swap in. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/inter-latin-wght-normal.260c81a4759b.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("fonts/newsreader-latin-wght-normal.175a37868200.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 200 800; font-display: swap; src: url("fonts/newsreader-latin-wght-italic.94402255a099.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/jetbrains-mono-latin-400-normal.caf0dfde4e44.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/jetbrains-mono-latin-500-normal.a21e038a03f7.woff2") format("woff2"); }
@font-face { font-family: "Inter Fallback"; src: local("Arial"), local("Helvetica"); size-adjust: 107.12%; ascent-override: 90.44%; descent-override: 22.52%; line-gap-override: 0%; }

:root {
  /* One brand colour: burgundy. The three facet names are kept so page
     styles written against them still work, but they all resolve to the
     brand. --tone-b / --tone-c are the companion hues for charts and other
     places where two or three series must be told apart. */
  --brand: #7a1c31;
  --brand-2: #a8405a;
  --tone-b: #b9566e;
  --tone-c: #5f5a66;
  --data: var(--brand);
  --data-2: #a8405a;
  --build: var(--brand);
  --build-2: #a8405a;
  --research: var(--brand);
  --research-2: #a8405a;

  /* Surfaces */
  --color-bg: #f8f5f1;
  --color-bg-soft: #efeae4;
  --color-card: #fdfcfa;
  --color-border: #e2dbd3;
  --color-text: #1c1719;
  --color-muted: #6b6660;
  --color-on-accent: #ffffff;
  --ink: #1c1719;

  --color-accent: var(--brand);
  --color-accent-dark: var(--brand-2);
  --title-accent: var(--brand);

  --signature: linear-gradient(90deg, var(--brand), var(--brand-2));

  --font-sans: "Inter", "Inter Fallback", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Fluid page width: fills more of a wide screen instead of leaving gutters. */
  --max-width: clamp(1100px, 88vw, 1400px);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-btn: 6px;
  --shadow-sm: 0 1px 2px rgba(28, 23, 25, 0.04);
  --shadow-md: 0 18px 40px -24px rgba(28, 23, 25, 0.2), 0 1px 3px rgba(28, 23, 25, 0.04);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
  --brand: #e8909f;
  --brand-2: #c9687f;
  --tone-b: #c9687f;
  --tone-c: #b9b3c4;
  --data-2: #c9687f;
  --build-2: #c9687f;
  --research-2: #c9687f;

  --color-bg: #181314;
  --color-bg-soft: #201a1b;
  --color-card: #241d1e;
  --color-border: #3a3031;
  --color-text: #f3ece9;
  --color-muted: #aea4a3;
  --color-on-accent: #181314;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 24px 48px -24px rgba(0, 0, 0, 0.6);
}

body[data-facet="data"]     { --color-accent: var(--data);     --color-accent-dark: var(--data-2);     --title-accent: var(--data); }
body[data-facet="build"]    { --color-accent: var(--build);    --color-accent-dark: var(--build-2);    --title-accent: var(--build); }
body[data-facet="research"] { --color-accent: var(--research); --color-accent-dark: var(--research-2); --title-accent: var(--research); }

/* ----- Base ----- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.011em;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}
body { transition: background-color 0.25s ease, color 0.25s ease; overflow-x: hidden; }

/* Display type: headlines are set in the serif at regular weight, with the
   italic reserved for the accented word. Page styles size them; this sets
   the voice. (main.site-main raises specificity above the per-page rules.) */
main.site-main h1,
main.site-main .section-title,
main.site-main .flagship h2,
main.site-main .bs h2,
main.site-main .mp-title,
main.site-main .spot h2,
main.site-main .cv-sec h2,
main.site-main .cs-sec h2,
.footer-statement {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
/* Every other heading and the headline numbers share the serif. :where()
   keeps this at zero specificity, so labels that set their own font (the
   small mono eyebrows) are untouched. */
:where(main.site-main) :where(h2, h3, h4) { font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.012em; }
main.site-main :is(.facet-stats .v, .f-stats .v, .teach-stats .v, .stats .v, .cs-results .v, .lab-stats dd, .spot-metrics b, .lk-stats b, .teach .num, .impact-stat .v, .facts b, .facts .v, .stat-card .v) {
  font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.02em; color: var(--brand);
  background: none; -webkit-text-fill-color: currentColor;
}
main.site-main h1 .serif,
main.site-main .section-title .serif,
main.site-main .flagship h2 .serif,
main.site-main .bs h2 .serif,
main.site-main .mp-title .serif,
.footer-statement .serif { font-size: 1em; letter-spacing: -0.02em; }

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
/* Links inside running text are underlined, not told apart by colour alone. */
p a:not([class]) { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
img { max-width: 100%; height: auto; }
::selection { background: color-mix(in srgb, var(--color-accent) 25%, transparent); }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; border-radius: 4px; }

.serif { font-family: var(--font-serif); font-weight: 500; font-style: italic; letter-spacing: -0.015em; }
.mono { font-family: var(--font-mono); }
.skip-link {
  position: absolute; left: -999px; top: 0.5rem; z-index: 200;
  background: var(--color-card); color: var(--color-text);
  padding: 0.5rem 0.9rem; border-radius: 8px; border: 1px solid var(--color-border);
}
.skip-link:focus { left: 0.75rem; }

/* ----- Navigation ----- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.85rem max(clamp(1rem, 3vw, 2rem), calc((100vw - var(--max-width)) / 2 + clamp(1rem, 3vw, 2rem)));
  background: color-mix(in srgb, var(--color-bg) 86%, transparent);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--color-border);
  transition: box-shadow 0.3s;
}
.site-nav.is-scrolled { box-shadow: 0 8px 24px -18px rgba(28, 23, 25, 0.35); }

/* Wordmark: "NA." monogram, a hairline, then the name over a role line. */
.site-nav .logo {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--color-text);
  white-space: nowrap;
}
.site-nav .logo:hover { text-decoration: none; }
.logo-mark {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.85rem;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--brand);
  transition: letter-spacing 0.4s var(--ease);
}
.site-nav .logo:hover .logo-mark { letter-spacing: 0; }
.logo-text { display: grid; gap: 0.2rem; padding-left: 0.9rem; border-left: 1px solid var(--color-border); }
.logo-name { font-family: var(--font-serif); font-weight: 500; font-size: 1.08rem; line-height: 1; letter-spacing: -0.01em; }
.logo-role { font-size: 0.6rem; line-height: 1; letter-spacing: 0.16em; text-transform: uppercase; color: var(--color-muted); }

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  position: relative;
}
/* Sliding underline that follows the pointer between links and rests on the
   current page (placed by base.html; without JS each link underlines itself). */
.nav-ind {
  position: absolute; bottom: 0; left: 0; height: 2px;
  width: var(--w, 0); translate: var(--x, 0) 0;
  background: var(--brand);
  opacity: 0;
  pointer-events: none;
  transition: translate 0.45s var(--ease), width 0.45s var(--ease), opacity 0.25s;
}
.nav-ind.is-on { opacity: 1; }
.nav-links li:not(.nav-ind) { position: relative; }
.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.8rem;
  color: var(--color-text);
  font-size: 0.93rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: inset 0 -2px 0 transparent;
  transition: color 0.2s, box-shadow 0.2s;
}
.nav-links a:hover { color: var(--brand); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); }
.nav-links.has-ind a[aria-current="page"] { box-shadow: none; }

.nav-actions { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.nav-cta {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-btn);
  background: var(--brand);
  color: var(--color-on-accent);
  font-size: 0.85rem;
  font-weight: 550;
  transition: scale 0.35s var(--spring), background 0.2s;
}
.nav-cta:hover { text-decoration: none; scale: 1.04; }
.nav-cta:active { scale: 0.97; }
.nav-cta span, .btn span[aria-hidden] { display: inline-block; transition: translate 0.35s var(--ease); }
.nav-cta:hover span, .btn:hover span[aria-hidden] { translate: 3px 0; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--color-text);
  transition: background 0.2s, scale 0.35s var(--spring);
  flex-shrink: 0;
  padding: 0;
}
.icon-btn:hover { background: color-mix(in srgb, var(--color-text) 10%, transparent); scale: 1.06; }
.icon-btn:active { scale: 0.94; }
.icon-btn svg { width: 17px; height: 17px; transition: rotate 0.6s var(--ease); }
.theme-toggle:hover svg { rotate: 30deg; }

.theme-toggle .icon-moon, .theme-toggle .icon-sun { display: none; }
:root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.menu-toggle { display: none; }
.nav-links .only-menu { display: none; }

@media (max-width: 1400px) { .logo-role { display: none; } }
@media (max-width: 1040px) {
  .nav-cta { display: none; }
}
@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .site-nav nav {
    position: absolute;
    top: 100%; left: 0; right: 0;
    padding: 0.75rem 1rem 1.25rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    display: none;
  }
  .site-nav.nav-open nav { display: block; }
  .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  .nav-ind { display: none; }
  .nav-links .only-menu { display: block; }
  .nav-links a { font-size: 1.05rem; padding: 0.8rem 0.4rem; border-bottom: 1px solid var(--color-border); box-shadow: none !important; }
  .nav-links li:last-child a { border-bottom: 0; }
}

/* ----- Main ----- */
.site-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem clamp(1rem, 3vw, 2rem);
}

/* ----- Shared building blocks ----- */
.eyebrow-label {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--brand);
}
.eyebrow-label .bar { width: 34px; height: 1.5px; background: currentColor; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e;
  animation: live-pulse 2.4s cubic-bezier(0.66, 0, 0, 1) infinite;
}
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.page-hero { padding: clamp(1.5rem, 5vw, 4rem) 0 clamp(1.5rem, 4vw, 3rem); max-width: 860px; }
.page-hero h1 {
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  line-height: 1.04;
  margin: 1rem 0 1.1rem;
}
.page-hero h1 .serif { color: var(--color-accent); }
.page-hero .lede { font-size: clamp(1.05rem, 1.6vw, 1.22rem); color: var(--color-muted); max-width: 60ch; margin: 0; line-height: 1.6; }

.section-title {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  margin: 0.6rem 0 0.75rem;
}
.section-title .serif { color: var(--color-accent); }

.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.75rem; font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  background: var(--color-card);
  white-space: nowrap;
}

/* Scroll reveal: blur-to-focus rise (progressive: visible without JS).
   Uses the individual translate/scale properties so an element's own
   hover `transform` still composes with it. Stagger siblings with --i. */
.js [data-reveal] {
  opacity: 0;
  translate: 0 28px;
  scale: 0.985;
  filter: blur(8px);
  transition:
    opacity 0.9s var(--ease) calc(var(--i, 0) * 110ms),
    translate 1s var(--ease) calc(var(--i, 0) * 110ms),
    scale 1s var(--ease) calc(var(--i, 0) * 110ms),
    filter 0.9s var(--ease) calc(var(--i, 0) * 110ms);
}
.js [data-reveal].is-in { opacity: 1; translate: 0 0; scale: 1; filter: none; }

/* Scroll-linked motion. The engine in base.html writes --p (0 → 1) on every
   [data-scroll] element each frame:
     enter   0 when its top meets the bottom of the viewport, 1 at 40% up
     through 0 entering at the bottom, 1 leaving at the top
     leave   0 while its top is at the top of the viewport, 1 once scrolled past
     pin     progress through a tall container whose child is position: sticky
   Defaults are the finished state, so nothing is stuck without JS. */
[data-scroll] { --p: 1; }
[data-scroll="leave"] { --p: 0; }
[data-scroll="through"] { --p: 0.5; }

/* Count-up numbers keep their width steady while animating */
.count-up { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] { opacity: 1; translate: none; scale: none; filter: none; transition: none; }
}

/* ----- Page header -----
   Every section page opens the same way: eyebrow, the page name, an italic
   one-line tagline, a short lede, then a row of icon-led facts. An optional
   second column holds a figure. */
.ph { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(2rem, 5vw, 4.5rem); align-items: center; padding: clamp(1rem, 3vw, 2.5rem) 0 clamp(2rem, 4vw, 3rem); }
.ph.ph-solo { grid-template-columns: minmax(0, 1fr); }
.ph h1 { font-size: clamp(2.8rem, 6vw, 5rem); line-height: 1; margin: 0.9rem 0 0.6rem; }
.ph-sub { margin: 0 0 1rem; font-family: var(--font-serif); font-style: italic; font-weight: 500; font-size: clamp(1.35rem, 2.5vw, 2.05rem); line-height: 1.2; letter-spacing: -0.015em; color: var(--brand); text-wrap: balance; }
.ph .lede { margin: 0; max-width: 58ch; font-size: clamp(1.02rem, 1.4vw, 1.15rem); line-height: 1.6; color: var(--color-muted); }
.ph-facts { display: flex; flex-wrap: wrap; gap: 1.2rem clamp(1.5rem, 3vw, 3rem); margin: 1.8rem 0 0; padding: 0; list-style: none; }
.ph-facts li { display: flex; align-items: center; gap: 0.85rem; }
.ph-facts li + li { padding-left: clamp(1.5rem, 3vw, 3rem); border-left: 1px solid var(--color-border); }
.ph-facts svg { width: 34px; height: 34px; flex: none; color: var(--brand); }
.ph-facts b { display: block; font-family: var(--font-serif); font-weight: 600; font-size: 1.7rem; line-height: 1; color: var(--brand); font-variant-numeric: tabular-nums; }
.ph-facts span { display: block; margin-top: 0.2rem; font-size: 0.86rem; line-height: 1.3; color: var(--color-muted); }
.ph-facts.is-wide { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; padding: 1.6rem 0; border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
.ph-facts.is-wide li { padding: 0 clamp(1rem, 2vw, 2rem); }
.ph-facts.is-wide li:first-child { padding-left: 0; }
.ph-facts.is-wide b { font-size: clamp(1.7rem, 2.6vw, 2.3rem); }
@media (max-width: 860px) {
  .ph { grid-template-columns: minmax(0, 1fr); }
  .ph-facts.is-wide { grid-template-columns: 1fr 1fr; row-gap: 1.3rem; }
  .ph-facts.is-wide li:nth-child(odd) { padding-left: 0; border-left: 0; }
}
@media (max-width: 520px) {
  .ph-facts li + li { padding-left: 0; border-left: 0; }
  .ph-facts { gap: 1rem 1.6rem; }
  .ph-facts.is-wide li { padding: 0; border-left: 0; }
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.78rem 1.35rem;
  border-radius: var(--radius-btn);
  font-weight: 550;
  font-family: inherit;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-text);
  cursor: pointer;
  transition: scale 0.35s var(--spring), background 0.2s, border-color 0.2s, box-shadow 0.3s;
  font-size: 0.92rem;
  line-height: 1.2;
}
.btn:hover { background: var(--color-bg-soft); border-color: color-mix(in srgb, var(--color-text) 22%, transparent); text-decoration: none; scale: 1.03; }
.btn:active { scale: 0.97; }
.btn-primary { background: var(--color-accent); color: var(--color-on-accent); border-color: var(--color-accent); }
.btn-primary:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
  box-shadow: 0 12px 28px -12px color-mix(in srgb, var(--color-accent) 75%, transparent);
}
.btn-ink { background: var(--brand); color: var(--color-on-accent); border-color: var(--brand); }
.btn-ink:hover { background: var(--brand); color: var(--color-on-accent); border-color: var(--brand); box-shadow: 0 12px 28px -12px color-mix(in srgb, var(--brand) 75%, transparent); }

/* ----- Footer ----- */
.site-footer {
  position: relative;
  margin-top: 6rem;
  background: var(--color-bg-soft);
  color: var(--color-muted);
  font-size: 0.9rem;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3.5rem clamp(1rem, 3vw, 2rem) 2rem;
}
.footer-top {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr));
  gap: 2.5rem;
  padding-bottom: 2.5rem;
}
.footer-statement {
  font-size: clamp(1.9rem, 3.6vw, 2.7rem);
  line-height: 1.08;
  color: var(--color-text);
  margin: 0 0 1.25rem;
}
.footer-statement .serif { color: var(--color-accent); font-style: italic; }
.footer-col h2 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin: 0 0 0.9rem;
  color: var(--color-muted);
}
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.1rem; }
.footer-col a { display: inline-block; padding: 0.3rem 0; color: var(--color-text); font-weight: 450; transition: color 0.2s, translate 0.35s var(--ease); }
.footer-col a:hover { color: var(--color-accent); text-decoration: none; translate: 3px 0; }
.footer-bottom {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.82rem;
}
.footer-bottom .facets { display: inline-flex; gap: 1rem; flex-wrap: wrap; }
.footer-bottom .facets span { display: inline-flex; align-items: center; gap: 0.4rem; }
.footer-bottom .facets i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
@media (max-width: 760px) {
  .footer-top { grid-template-columns: 1fr 1fr; }
  .footer-top > :first-child { grid-column: 1 / -1; }
}

/* Mobile */
@media (max-width: 700px) {
  .site-main { padding: 1.5rem 1rem; }
}

/* ===================== Data visualisation (static/js/dsviz.js) ===================== */
:root { --viz-grid: color-mix(in srgb, var(--color-text) 9%, transparent); }
.viz { --tone: var(--color-accent); position: relative; font-size: 0.88rem; }
.viz [data-tone="data"] { --tone: var(--data); }
.viz [data-tone="research"] { --tone: var(--tone-c); }
.viz [data-tone="build"] { --tone: var(--tone-b); }
.viz [data-tone="muted"] { --tone: color-mix(in srgb, var(--color-text) 38%, transparent); }
.viz [data-tone="soft"] { --tone: color-mix(in srgb, var(--color-accent) 28%, var(--color-bg-soft)); }
.viz-readout { margin: 0.9rem 0 0; min-height: 2.9em; padding: 0.7rem 0.9rem; border-radius: 12px; background: var(--color-bg-soft); border: 1px solid var(--color-border); font-size: 0.84rem; line-height: 1.5; color: var(--color-text); }
.viz-readout b { color: var(--color-accent); font-weight: 650; }
.viz-note { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--color-muted); }
.viz-note:empty { display: none; }
.viz-seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; margin: 0 0 1rem; border-radius: 999px; background: var(--color-bg-soft); border: 1px solid var(--color-border); }
.viz-seg button { font: inherit; font-size: 0.8rem; font-weight: 600; padding: 0.4rem 0.85rem; border: 0; border-radius: 999px; background: transparent; color: var(--color-muted); cursor: pointer; transition: background 0.2s, color 0.2s; }
.viz-seg button[aria-pressed="true"] { background: var(--color-card); color: var(--color-text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--color-border); }
.viz-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; list-style: none; margin: 0 0 0.8rem; padding: 0; font-size: 0.78rem; color: var(--color-muted); }
.viz-legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.viz-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--tone); }

/* Forest plot */
.vf-group { margin: 0.9rem 0 0.2rem; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-muted); }
.vf-group:first-child { margin-top: 0; }
.vf-row, .vf-axis { display: grid; grid-template-columns: minmax(150px, 0.95fr) minmax(0, 2fr) 7.2rem; gap: 0.9rem; align-items: center; }
.vf-row { padding: 0.5rem 0.4rem; margin: 0 -0.4rem; border-top: 1px solid var(--color-border); border-radius: 8px; outline-offset: 2px; transition: background 0.2s; cursor: default; }
.vf-row:hover, .vf-row.is-active { background: color-mix(in srgb, var(--tone) 7%, transparent); }
.vf-row[hidden] { display: none; }
.vf-name b { display: block; font-weight: 600; line-height: 1.3; }
.vf-name span { display: block; color: var(--color-muted); font-size: 0.76rem; }
.vf-flag { display: inline-block; margin-top: 0.2rem; font-style: normal; font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 0.1rem 0.4rem; border-radius: 4px; border: 1px dashed var(--color-muted); color: var(--color-muted); }
.vf-track { position: relative; height: 22px; background: var(--grid, none); }
.vf-track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--viz-grid); }
.vf-ref { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 1.5px dashed color-mix(in srgb, var(--color-text) 40%, transparent); }
.vf-ci { position: absolute; top: 50%; height: 3px; transform: translateY(-50%); border-radius: 2px; background: color-mix(in srgb, var(--tone) 55%, transparent); transition: left 0.9s var(--ease), width 0.9s var(--ease); }
.vf-ci::before, .vf-ci::after { content: ""; position: absolute; top: -4px; width: 2px; height: 11px; border-radius: 1px; background: var(--tone); }
.vf-ci::before { left: 0; } .vf-ci::after { right: 0; }
.vf-dot { position: absolute; top: 50%; width: 13px; height: 13px; border-radius: 50%; translate: -50% -50%; background: var(--tone); box-shadow: 0 0 0 3px var(--color-card), 0 0 0 5px color-mix(in srgb, var(--tone) 20%, transparent); transition: left 0.9s var(--ease); }
.is-flagged .vf-dot { background: var(--color-card); border: 2.5px solid var(--tone); }
.is-flagged .vf-ci { background: repeating-linear-gradient(90deg, var(--tone) 0 4px, transparent 4px 7px); }
.vf-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vf-val small { display: block; font-weight: 500; font-size: 0.72rem; color: var(--color-muted); }
.vf-axis { margin-top: 0.3rem; font-family: var(--font-mono); font-size: 0.66rem; color: var(--color-muted); }
.vf-ticks { position: relative; height: 1.2em; }
.vf-ticks span { position: absolute; translate: -50% 0; white-space: nowrap; }
.vf-axis-label { text-align: right; }

/* Funnel */
.vfn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.vfn-step { display: grid; grid-template-columns: minmax(150px, 0.95fr) minmax(0, 2fr) 7.2rem; gap: 0.9rem; align-items: center; padding: 0.45rem 0.4rem; margin: 0 -0.4rem; border-radius: 8px; transition: background 0.2s; }
.vfn-step:hover, .vfn-step.is-active { background: color-mix(in srgb, var(--color-accent) 7%, transparent); }
.vfn-head b { display: block; font-weight: 600; line-height: 1.3; }
.vfn-head span { font-size: 0.76rem; color: var(--color-muted); }
.vfn-ratio { font-family: var(--font-mono); font-size: 0.7rem; color: var(--color-accent); }
.vfn-bar { height: 26px; border-radius: 7px; background: var(--color-bg-soft); overflow: hidden; }
.vfn-bar i { display: block; height: 100%; width: 0; border-radius: 7px; background: linear-gradient(90deg, var(--color-accent), color-mix(in srgb, var(--color-accent) 55%, var(--research))); transition: width 1.2s var(--ease); }
.vfn-n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.vfn-n small { font-weight: 500; color: var(--color-muted); font-size: 0.72rem; }

/* Bars */
.vb-body { display: grid; gap: 0.2rem; }
.vb-row { display: grid; grid-template-columns: minmax(150px, 0.95fr) minmax(0, 2fr) 7.2rem; gap: 0.9rem; align-items: center; padding: 0.45rem 0.4rem; margin: 0 -0.4rem; border-radius: 8px; transition: background 0.2s; }
.vb-row:hover, .vb-row.is-active { background: color-mix(in srgb, var(--color-accent) 7%, transparent); }
.vb-name b { display: block; font-weight: 600; }
.vb-name span { display: block; font-size: 0.76rem; color: var(--color-muted); }
.vb-track { display: flex; height: 22px; border-radius: 6px; background: var(--color-bg-soft); overflow: hidden; }
.vb-track i { display: block; width: 0; height: 100%; background: var(--tone); transition: width 1.1s var(--ease); }
.vb-track i + i { box-shadow: inset 1px 0 0 var(--color-card); }
.vb-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Tabs used by chart panels */
.viz-tabs [role="tablist"] { display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; margin: 0 0 1.25rem; padding-bottom: 1px; border-bottom: 1px solid var(--color-border); }
.viz-tabs [role="tab"] { flex: none; font: inherit; font-size: 0.86rem; font-weight: 600; padding: 0.7rem 0.95rem; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--color-muted); cursor: pointer; transition: color 0.2s, border-color 0.2s; }
.viz-tabs [role="tab"]:hover { color: var(--color-text); }
.viz-tabs [role="tab"][aria-selected="true"] { color: var(--color-text); border-bottom-color: var(--color-accent); }
.viz-tabs [role="tabpanel"] { animation: viz-in 0.45s var(--ease); }
.viz-tabs [role="tabpanel"] > p:first-child { margin-top: 0; }
@keyframes viz-in { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }

@media (max-width: 640px) {
  .viz-tabs [role="tablist"] { flex-wrap: wrap; overflow: visible; }
  .viz-tabs [role="tab"] { padding: 0.6rem 0.7rem; }
  .vf-row, .vf-axis, .vfn-step, .vb-row { grid-template-columns: minmax(0, 1fr) 5.6rem; gap: 0.35rem 0.6rem; }
  .vf-name, .vfn-head, .vb-name { grid-column: 1 / -1; }
  .vf-axis > :first-child, .vf-axis-label { display: none; }
  .vf-axis { grid-template-columns: minmax(0, 1fr) 5.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .vf-ci, .vf-dot, .vfn-bar i, .vb-track i { transition: none; }
  .viz-tabs [role="tabpanel"] { animation: none; }
}

/* ===================== Pointer glow + reading progress ===================== */
/* A soft light that follows the pointer across cards (fine pointers only;
   the class is added by base.html). Only background-image is set, so each
   card keeps its own background colour. */
.glow { background-image: radial-gradient(520px circle at var(--mx, -999px) var(--my, -999px), color-mix(in srgb, var(--tone, var(--color-accent)) 10%, transparent), transparent 55%) !important; }
.scroll-progress { position: fixed; top: 0; left: 0; right: 0; z-index: 200; height: 2px; background: var(--brand); transform-origin: 0 50%; transform: scaleX(var(--sp, 0)); pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .scroll-progress { display: none; } }
@media print { .scroll-progress { display: none; } }

/* ===================== Tilt, press and theme transition ===================== */
/* Cards lean a few degrees toward the pointer (class and --rx/--ry are set
   by base.html on fine pointers only). Uses the individual `rotate`-free
   transform so it composes with each card's own hover translate. */
.tilt { transform-style: preserve-3d; will-change: transform; transition: transform 0.6s var(--ease), box-shadow 0.4s var(--ease), border-color 0.3s; }
.tilt.is-tilting { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-3px) !important; transition-duration: 0.12s, 0.4s, 0.3s; }

/* Theme switch: the new theme opens as a circle from the toggle button. */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: theme-reveal 0.65s var(--ease); }
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--vt-x, 100%) var(--vt-y, 0)); }
  to { clip-path: circle(150vmax at var(--vt-x, 100%) var(--vt-y, 0)); }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-new(root) { animation: none; }
  .tilt.is-tilting { transform: none !important; }
}

/* ===================== Back to top ===================== */
.to-top {
  position: fixed; right: clamp(1rem, 3vw, 2rem); bottom: clamp(1rem, 3vw, 2rem); z-index: 90;
  width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: var(--radius-btn);
  background: color-mix(in srgb, var(--color-card) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  box-shadow: 0 8px 24px -10px rgba(20, 20, 19, 0.35), 0 0 0 1px color-mix(in srgb, var(--color-text) 8%, transparent);
  color: var(--color-text); cursor: pointer;
  opacity: 0; translate: 0 12px; pointer-events: none;
  transition: opacity 0.3s, translate 0.4s var(--ease), scale 0.35s var(--spring);
}
.to-top.is-on { opacity: 1; translate: 0 0; pointer-events: auto; }
.to-top:hover { scale: 1.08; }
.to-top:active { scale: 0.94; }
.to-top svg { width: 18px; height: 18px; }
@media print { .to-top { display: none; } }
