/* =====================================================================
   Nijiati Abulizi — design system
   Three facets, one identity:
     data      Data Scientist          sage
     build     Business Builder        clay
     research  Researcher & Teacher    sky
   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: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap; src: url("fonts/instrument-serif-latin-400-italic.bc891bdd08ad.woff2") format("woff2"); }
@font-face { font-family: "Instrument Serif"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/instrument-serif-latin-400-normal.9b8dd1ecf641.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%; }
@font-face { font-family: "Instrument Serif Fallback"; font-style: italic; src: local("Times New Roman Italic"), local("Times-Italic"), local("Georgia Italic"); size-adjust: 92%; ascent-override: 98%; descent-override: 24%; line-gap-override: 0%; }

:root {
  /* Facet hues: a warm, paper-and-ink palette. The plain value is the
     text-safe tone (AA on the page background); -2 is the brighter fill. */
  --data: #4d6a3c;
  --data-2: #788c5d;
  --build: #ad4f2c;
  --build-2: #d97757;
  --research: #2c6496;
  --research-2: #6a9bcc;

  /* Surfaces */
  --color-bg: #faf9f5;
  --color-bg-soft: #f0eee6;
  --color-card: #ffffff;
  --color-border: #e8e6dc;
  --color-text: #141413;
  --color-muted: #66655f;
  --color-on-accent: #ffffff;
  --ink: #141413;

  /* Accent (retinted per facet below) */
  --color-accent: var(--build);
  --color-accent-dark: var(--build-2);
  --title-accent: var(--build);

  --signature: linear-gradient(90deg, var(--data-2), var(--build-2) 50%, var(--research-2));

  --font-sans: "Inter", "Inter Fallback", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-serif: "Instrument Serif", "Instrument Serif Fallback", "Iowan Old Style", 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: 18px;
  --radius-lg: 28px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 19, 0.04);
  --shadow-md: 0 24px 48px -24px rgba(20, 20, 19, 0.18), 0 2px 6px rgba(20, 20, 19, 0.04);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
  --data: #a3bb85;
  --data-2: #8fa672;
  --build: #e38d6f;
  --build-2: #d97757;
  --research: #8fb7e0;
  --research-2: #6a9bcc;

  --color-bg: #1f1e1d;
  --color-bg-soft: #262523;
  --color-card: #2a2927;
  --color-border: #3b3a36;
  --color-text: #f5f4ee;
  --color-muted: #a8a69d;
  --color-on-accent: #1f1e1d;

  --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: 400;
  letter-spacing: -0.012em;
  font-size-adjust: 0.49;
  text-wrap: balance;
}
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: 400; font-style: italic; letter-spacing: -0.01em; }
.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.25rem;
  padding: 0.7rem clamp(1rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--color-bg) 72%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, background 0.3s;
}
.site-nav.is-scrolled { border-bottom-color: color-mix(in srgb, var(--color-text) 8%, transparent); }
.site-nav::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--signature);
  opacity: 0;
  transition: opacity 0.3s;
}
.site-nav.is-scrolled::after { opacity: 0; }

.site-nav .logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-text);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.site-nav .logo:hover { text-decoration: none; }
.logo-mark {
  position: relative;
  padding-top: 1px;
  width: 30px; height: 30px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--build-2);
  color: #fff;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1;
  overflow: hidden;
  transition: transform 0.5s var(--spring);
}
.site-nav .logo:hover .logo-mark { transform: rotate(-8deg) scale(1.08); }

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin: 0;
  padding: 0.25rem;
  position: relative;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-text) 5%, transparent);
}
/* Sliding highlight that follows the pointer between links (placed by
   base.html; without JS the links fall back to their own hover fill). */
.nav-ind {
  position: absolute; top: 0.25rem; bottom: 0.25rem; left: 0;
  width: var(--w, 0); translate: var(--x, 0) 0;
  border-radius: 999px;
  background: var(--color-card);
  box-shadow: 0 1px 3px rgba(20, 20, 19, 0.1), 0 0 0 0.5px rgba(20, 20, 19, 0.06);
  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.5rem;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  color: var(--color-muted);
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}
.nav-links a:hover { color: var(--color-text); background: var(--color-card); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--color-text); background: var(--color-card); }
.nav-links.has-ind a:hover, .nav-links.has-ind a[aria-current="page"] { background: transparent; }
.nav-links .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--dot, var(--color-muted));
  transition: scale 0.4s var(--spring);
}
.nav-links a:hover .dot { scale: 1.5; }
.nav-links .f-data { --dot: var(--data); }
.nav-links .f-build { --dot: var(--build); }
.nav-links .f-research { --dot: var(--research); }

.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.5rem 1rem;
  border-radius: 999px;
  background: var(--color-text);
  color: var(--color-bg);
  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: color-mix(in srgb, var(--color-text) 5%, transparent);
  border: 0;
  border-radius: 999px;
  width: 36px; height: 36px;
  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: 980px) {
  .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;
    border: none;
    background: transparent;
    padding: 0;
    gap: 0.2rem;
  }
  .nav-ind { display: none; }
  .nav-links .only-menu { display: block; }
  .nav-links a { font-size: 1.05rem; padding: 0.75rem 0.9rem; border-radius: 12px; color: var(--color-text); }
}

/* ----- 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.14em;
  color: var(--color-muted);
}
.eyebrow-label .bar { width: 22px; height: 1px; background: currentColor; opacity: 0.6; }
.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.8rem, 6.6vw, 5rem);
  line-height: 1;
  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; }
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.72rem 1.3rem;
  border-radius: 999px;
  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(--color-text); color: var(--color-bg); border-color: var(--color-text); }
.btn-ink:hover { background: var(--color-text); color: var(--color-bg); opacity: 0.9; }

/* ----- 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(--research); }
.viz [data-tone="build"] { --tone: var(--build); }
.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(--build-2); 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: 50%;
  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; } }
