/* science.fedecuci.com — Reading the numbers
   Shared fedecuci.com neutral base + a blue data accent.
   Chart colours are the validated categorical slots 1-3 (blue / orange / aqua). */

:root{
  /* --- shared fleet base (light) --- */
  --paper:#f7f8fa;
  --surface:#ffffff;
  --surface-2:#f0f2f5;
  --ink:#1a1d21;
  --muted:#5c6570;
  --line:#e6e9ee;

  /* --- accents --- */
  --accent:#2a78d6;
  --accent-soft:rgba(42,120,214,.10);
  --warm:#eb6834;
  --warm-soft:rgba(235,104,52,.12);

  /* --- data marks --- */
  --s1:#2a78d6;          /* categorical slot 1 — blue   */
  --s2:#eb6834;          /* categorical slot 2 — orange */
  --s3:#1baf7a;          /* categorical slot 3 — aqua   */
  --mark-quiet:#dfe4ea;  /* the "nothing happened" mass in dot grids */
  --grid:#eef1f5;
  --axis:#c8cfd8;
  --critical:#d03b3b;    /* status colour — fixed, never themed */

  --shadow:rgba(20,25,35,.07);

  --font:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --font-display:Georgia,"Iowan Old Style","Times New Roman",serif;
  --font-mono:"SF Mono",ui-monospace,"Cascadia Code",Menlo,Consolas,monospace;
  --wrap:min(720px,100%);
}
:root[data-theme="light"]{
  --paper:#f7f8fa;--surface:#ffffff;--surface-2:#f0f2f5;--ink:#1a1d21;--muted:#5c6570;--line:#e6e9ee;
  --accent:#2a78d6;--accent-soft:rgba(42,120,214,.10);--warm:#eb6834;--warm-soft:rgba(235,104,52,.12);
  --s1:#2a78d6;--s2:#eb6834;--s3:#1baf7a;--mark-quiet:#dfe4ea;--grid:#eef1f5;--axis:#c8cfd8;
  --shadow:rgba(20,25,35,.07);
}
:root[data-theme="dark"]{
  --paper:#0e1116;--surface:#161a20;--surface-2:#1d222a;--ink:#e8eaed;--muted:#9aa4b0;--line:#262c34;
  --accent:#3987e5;--accent-soft:rgba(57,135,229,.16);--warm:#d95926;--warm-soft:rgba(217,89,38,.18);
  --s1:#3987e5;--s2:#d95926;--s3:#199e70;--mark-quiet:#2b323b;--grid:#1e242c;--axis:#3a434e;
  --shadow:rgba(0,0,0,.45);
}
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --paper:#0e1116;--surface:#161a20;--surface-2:#1d222a;--ink:#e8eaed;--muted:#9aa4b0;--line:#262c34;
    --accent:#3987e5;--accent-soft:rgba(57,135,229,.16);--warm:#d95926;--warm-soft:rgba(217,89,38,.18);
    --s1:#3987e5;--s2:#d95926;--s3:#199e70;--mark-quiet:#2b323b;--grid:#1e242c;--axis:#3a434e;
    --shadow:rgba(0,0,0,.45);
  }
}

*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth}
body{
  margin:0;background:var(--paper);color:var(--ink);
  font-family:var(--font);font-size:16.5px;line-height:1.65;
  -webkit-font-smoothing:antialiased;
}
a{color:var(--accent)}
h1,h2,h3{font-family:var(--font-display);font-weight:600;letter-spacing:-.01em}

/* ---------- theme toggle (shared pattern across fedecuci.com) ---------- */
.theme-toggle{position:fixed;top:1rem;right:1rem;z-index:60;
  width:36px;height:36px;display:grid;place-items:center;padding:0;
  cursor:pointer;border-radius:999px;
  background:var(--surface);color:var(--muted);border:1px solid var(--line);
  transition:color .12s ease,border-color .12s ease}
.theme-toggle:hover{color:var(--ink);border-color:var(--muted)}
.theme-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.theme-toggle svg{width:18px;height:18px}
.theme-toggle .sun{display:none}
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]) .theme-toggle .sun{display:block}
  :root:not([data-theme="light"]) .theme-toggle .moon{display:none}
}
:root[data-theme="dark"] .theme-toggle .sun{display:block}
:root[data-theme="dark"] .theme-toggle .moon{display:none}

/* ---------- layout ---------- */
.shell{display:grid;grid-template-columns:250px minmax(0,1fr);gap:2.5rem;
  max-width:1160px;margin-inline:auto;padding:0 1.5rem}

.rail{position:sticky;top:0;align-self:start;height:100vh;overflow-y:auto;
  padding:2.2rem 0 2rem;display:flex;flex-direction:column;gap:1.1rem}
.brand{font-family:var(--font-display);font-size:1.02rem;line-height:1.3;
  color:var(--ink);text-decoration:none;display:block}
.brand small{display:block;font-family:var(--font);font-size:.76rem;
  color:var(--muted);letter-spacing:.02em;margin-top:.15rem}
.toc{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:1px}
.toc button{
  width:100%;text-align:left;display:grid;grid-template-columns:1.5rem 1fr;gap:.35rem;
  background:none;border:0;padding:.4rem .5rem;border-radius:8px;cursor:pointer;
  font:inherit;font-size:.855rem;line-height:1.35;color:var(--muted)}
.toc button:hover{background:var(--surface-2);color:var(--ink)}
.toc button .num{font-variant-numeric:tabular-nums;font-size:.75rem;opacity:.65;padding-top:.1rem}
.toc button[aria-current="true"]{background:var(--accent-soft);color:var(--ink);font-weight:600}
.toc button[aria-current="true"] .num{color:var(--accent);opacity:1}
.rail-foot{margin-top:auto;font-size:.76rem;color:var(--muted)}
.rail-foot a{color:inherit}

/* min-width:0 all the way down, or the 520px-wide charts inside .scroller push
   the grid column wider than the screen instead of scrolling inside their box */
main{padding:2.4rem 0 5rem;max-width:100%;min-width:0}
.chapter,.fig{min-width:0}
.chapter{display:none;animation:rise .28s ease both}
.chapter.on{display:block}
@keyframes rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
@media (prefers-reduced-motion:reduce){.chapter{animation:none}html{scroll-behavior:auto}}

.eyebrow{font-size:.73rem;letter-spacing:.11em;text-transform:uppercase;
  color:var(--accent);font-weight:600;margin:0 0 .5rem}
.chapter h1{font-size:clamp(1.75rem,1.3rem + 1.6vw,2.5rem);line-height:1.15;margin:0 0 .8rem}
.chapter h2{font-size:1.22rem;margin:2.4rem 0 .6rem}
.chapter > p,.chapter > ul,.chapter > ol{max-width:var(--wrap)}
.lede{font-size:1.12rem;line-height:1.6;color:var(--muted);max-width:var(--wrap)}
.chapter p{margin:0 0 1rem}
.chapter ul,.chapter ol{padding-left:1.15rem;margin:0 0 1rem}
.chapter li{margin:0 0 .45rem}
b,strong{font-weight:650}
code,.mono{font-family:var(--font-mono);font-size:.9em;
  background:var(--surface-2);padding:.08em .35em;border-radius:5px}

/* ---------- callouts ---------- */
.hear{border-left:3px solid var(--warm);background:var(--warm-soft);
  padding:.85rem 1rem;border-radius:0 10px 10px 0;margin:1.6rem 0;max-width:var(--wrap)}
.hear p{margin:0 0 .5rem}
.hear p:last-child{margin:0}
.hear .tag{display:block;font-size:.7rem;letter-spacing:.1em;text-transform:uppercase;
  color:var(--warm);font-weight:700;margin-bottom:.35rem}
.hear q{font-style:italic}
.note{background:var(--surface-2);border-radius:10px;padding:.85rem 1rem;
  margin:1.5rem 0;font-size:.94rem;max-width:var(--wrap)}
.note p:last-child{margin:0}

/* ---------- figures ---------- */
.fig{background:var(--surface);border:1px solid var(--line);border-radius:14px;
  padding:1.1rem 1.2rem 1.2rem;margin:1.8rem 0;box-shadow:0 1px 2px var(--shadow)}
.fig h3{font-family:var(--font);font-size:.95rem;font-weight:650;margin:0 0 .15rem}
.fig .sub{font-size:.83rem;color:var(--muted);margin:0 0 .9rem}
.fig svg{display:block;width:100%;height:auto;overflow:visible}
.fig figcaption{font-size:.82rem;color:var(--muted);margin-top:.9rem;line-height:1.5}
.scroller{overflow-x:auto}
.scroller > svg{min-width:520px}

.controls{display:flex;flex-wrap:wrap;gap:.9rem 1.4rem;margin:1rem 0 .2rem;
  padding-top:.9rem;border-top:1px solid var(--line)}
.ctl{flex:1 1 190px;min-width:170px}
.ctl label{display:flex;justify-content:space-between;align-items:baseline;gap:.5rem;
  font-size:.8rem;color:var(--muted);margin-bottom:.15rem}
.ctl output{font-family:var(--font-mono);font-size:.82rem;color:var(--ink);
  font-variant-numeric:tabular-nums}
input[type=range]{width:100%;accent-color:var(--accent);cursor:pointer;margin:0}

.chips{display:flex;flex-wrap:wrap;gap:.4rem;margin:.85rem 0 0}
.chip{font:inherit;font-size:.8rem;padding:.3rem .7rem;border-radius:999px;cursor:pointer;
  background:var(--surface-2);color:var(--muted);border:1px solid transparent;
  transition:color .12s,background .12s,border-color .12s}
.chip:hover{color:var(--ink)}
.chip[aria-pressed="true"]{background:var(--accent-soft);color:var(--accent);
  border-color:var(--accent);font-weight:600}
.chips .lbl{font-size:.75rem;color:var(--muted);align-self:center;
  letter-spacing:.06em;text-transform:uppercase;margin-right:.15rem}

.legend{display:flex;flex-wrap:wrap;gap:.35rem 1.1rem;margin:.85rem 0 0;font-size:.82rem}
.legend span{display:inline-flex;align-items:center;gap:.4rem;color:var(--muted)}
.legend i{width:11px;height:11px;border-radius:3px;flex:none;display:block}
.legend b{color:var(--ink);font-variant-numeric:tabular-nums;font-weight:650}

.readout{background:var(--surface-2);border-radius:10px;padding:.75rem .9rem;
  margin:.95rem 0 0;font-size:.92rem;line-height:1.55}
.readout .big{font-family:var(--font-mono);font-size:1.15rem;font-weight:650;color:var(--ink)}
.readout em{font-style:normal;color:var(--muted)}

/* svg text defaults — set here so charts follow the theme with no redraw */
.fig svg text{font-family:var(--font);font-size:11.5px;fill:var(--muted);
  font-variant-numeric:tabular-nums}
.fig svg text.lbl-ink{fill:var(--ink)}
.fig svg text.lbl-strong{fill:var(--ink);font-weight:650}
.sm svg{margin-top:.1rem}

/* small-multiples grid */
.sm-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(148px,1fr));gap:.9rem;margin-top:.4rem}
.sm{background:var(--surface-2);border-radius:10px;padding:.55rem .6rem .3rem}
.sm h4{margin:0;font-family:var(--font-mono);font-size:.82rem;font-weight:650;color:var(--ink)}
.sm p{margin:.05rem 0 .3rem;font-size:.72rem;color:var(--muted);line-height:1.35;min-height:2.7em}

/* glossary */
.gloss{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));
  gap:.1rem 2rem;margin:1.5rem 0 0;max-width:100%}
.gloss div{padding:.75rem 0;border-top:1px solid var(--line)}
.gloss dt{font-weight:650;font-size:.93rem;margin-bottom:.15rem}
.gloss dd{margin:0;font-size:.89rem;color:var(--muted);line-height:1.55}

/* pager + footer */
.pager{display:flex;justify-content:space-between;gap:1rem;margin:3.5rem 0 0;
  padding-top:1.4rem;border-top:1px solid var(--line)}
.pager button{font:inherit;font-size:.88rem;background:var(--surface);cursor:pointer;
  border:1px solid var(--line);border-radius:10px;padding:.6rem .95rem;color:var(--ink);
  max-width:47%;text-align:left;line-height:1.35}
.pager button:last-child{text-align:right}
.pager button:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}
.pager button:disabled{opacity:.35;cursor:default}
.pager small{display:block;font-size:.7rem;letter-spacing:.08em;text-transform:uppercase;
  color:var(--muted);margin-bottom:.1rem}
footer{margin-top:3rem;padding-top:1.4rem;border-top:1px solid var(--line);
  font-size:.82rem;color:var(--muted);max-width:var(--wrap)}
footer a{color:inherit}

/* ---------- mobile ---------- */
@media (max-width:860px){
  .shell{grid-template-columns:minmax(0,1fr);gap:0;padding:0 1.1rem}
  .rail{position:sticky;top:0;height:auto;z-index:40;padding:.9rem 0 .6rem;
    background:var(--paper);border-bottom:1px solid var(--line);gap:.7rem;
    margin:0 -1.1rem;padding-inline:1.1rem}
  .brand small{display:none}
  .toc{flex-direction:row;overflow-x:auto;gap:.35rem;scrollbar-width:none;
    margin:0 -1.1rem;padding:0 1.1rem}
  .toc::-webkit-scrollbar{display:none}
  .toc li{flex:none}
  .toc button{white-space:nowrap;display:block;padding:.32rem .7rem;border-radius:999px;
    background:var(--surface-2);font-size:.8rem}
  .toc button .num{display:none}
  .rail-foot{display:none}
  main{padding-top:1.6rem}
  body{font-size:16px}
}
