/* ============================================================
   Inside a Tiny Transformer — site design system
   Editorial, minimal, theme-aware. No external assets.
   ============================================================ */

:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;      /* categorical slot 1 */
  --accent-deep: #184f95;
  --green: #008300;
  --magenta: #e87ba4;
  --yellow: #eda100;
  --aqua: #1baf7a;
  --orange: #eb6834;
  --violet: #4a3aa7;
  --red: #e34948;
  --pos: #2a78d6;
  --neg: #e34948;
  --divmid: #f0efec;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane: #0d0d0d; --surface: #1a1a19; --ink: #f2f1ec; --ink2: #c3c2b7;
    --muted: #898781; --grid: #2c2c2a; --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5; --accent-deep: #6da7ec; --green: #00a300;
    --magenta: #d55181; --yellow: #c98500; --aqua: #199e70;
    --orange: #d95926; --violet: #9085e9; --red: #e66767;
    --pos: #3987e5; --neg: #e66767; --divmid: #383835;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d; --surface: #1a1a19; --ink: #f2f1ec; --ink2: #c3c2b7;
  --muted: #898781; --grid: #2c2c2a; --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --accent-deep: #6da7ec; --green: #00a300;
  --magenta: #d55181; --yellow: #c98500; --aqua: #199e70;
  --orange: #d95926; --violet: #9085e9; --red: #e66767;
  --pos: #3987e5; --neg: #e66767; --divmid: #383835;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body {
  margin: 0; background: var(--plane); color: var(--ink);
  font: 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------- structure ---------- */
.prose { max-width: 700px; margin: 0 auto; padding: 0 20px; }
.wide { max-width: 980px; margin: 0 auto; padding: 0 20px; }
section { padding: clamp(48px, 9vh, 110px) 0; }
section + section { border-top: 1px solid var(--grid); }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.18;
  letter-spacing: -0.01em; }
h1 { font-size: clamp(2.1rem, 5.5vw, 3.4rem); margin: 0.4em 0; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); margin: 0 0 0.6em; }
h3 { font-size: 1.15rem; margin: 1.6em 0 0.5em; }
p { margin: 0.9em 0; color: var(--ink); }
.lede { font-size: 1.18em; color: var(--ink2); }
.kicker { font: 600 0.78rem/1 var(--sans); letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
a { color: var(--accent); text-underline-offset: 2px; }
strong { font-weight: 650; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
.small { font-size: 0.86rem; color: var(--ink2); }

/* ---------- header / footer ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; gap: 14px;
  align-items: center; padding: 10px 18px; background:
  color-mix(in srgb, var(--plane) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--grid); font-size: 0.9rem; }
.topbar .brand { font-family: var(--serif); font-weight: 700; color: var(--ink);
  text-decoration: none; margin-right: auto; }
.topbar a.navlink { color: var(--ink2); text-decoration: none; }
.topbar a.navlink:hover, .topbar a.navlink[aria-current="page"] { color: var(--ink); }
footer { border-top: 1px solid var(--grid); padding: 40px 0 70px;
  color: var(--ink2); font-size: 0.9rem; }

button, select {
  font: inherit; font-size: 0.9rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--baseline);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
button:focus-visible, select:focus-visible, a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button[aria-pressed="true"], .seg button.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 14px 0; }
.controls label { font-size: 0.85rem; color: var(--ink2); }
input[type="range"] { accent-color: var(--accent); }

/* ---------- figure card ---------- */
.viz { background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 18px 12px; margin: 22px 0; overflow-x: auto; }
.viz h3 { margin: 0 0 4px; font: 650 0.98rem var(--sans); }
.viz .sub { margin: 0 0 10px; font-size: 0.85rem; color: var(--ink2); }
figcaption, .caption { font-size: 0.85rem; color: var(--ink2); margin-top: 10px;
  line-height: 1.5; }
svg text { fill: var(--ink2); font-family: var(--sans); }
/* ink2 (not muted) keeps small tick text above the 4.5:1 AA contrast bar */
svg .tick { fill: var(--ink2); font-size: 10.5px; }
svg .axis-label { font-size: 11.5px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin: 20px 0; }
.tile { background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; }
.tile .v { font-size: 1.55rem; font-weight: 650; letter-spacing: -0.01em; }
.tile .l { font-size: 0.8rem; color: var(--ink2); margin-top: 2px; }

/* tables */
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums; }
th { color: var(--ink2); font-weight: 600; }
th:first-child, td:first-child { text-align: left; }

/* progressive disclosure */
details { border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; margin: 14px 0; background: var(--surface); }
details summary { cursor: pointer; font-weight: 600; font-size: 0.92rem; }
details[open] summary { margin-bottom: 8px; }

/* scroll reveal (motion-safe only) */
.reveal { opacity: 0; transform: translateY(14px);
  transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.on { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* tooltip */
#tooltip { position: fixed; pointer-events: none; z-index: 50;
  background: var(--surface); border: 1px solid var(--baseline);
  border-radius: 8px; padding: 7px 10px; font-size: 0.82rem; max-width: 280px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.16); opacity: 0; transition: opacity 0.1s; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.82rem;
  color: var(--ink2); margin: 8px 0 2px; }
.legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px;
  margin-right: 5px; vertical-align: -1px; }

/* explorer layout */
.explorer-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }

/* hero */
.hero { padding: clamp(60px, 14vh, 150px) 0 clamp(40px, 8vh, 90px); }
.hero .glyphs { font-family: var(--mono); color: var(--muted);
  letter-spacing: 0.35em; font-size: 0.8rem; margin-bottom: 26px; }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--accent);
  color: #fff; padding: 8px 14px; border-radius: 0 0 8px 0; z-index: 100; }
.skip-link:focus { left: 0; }
