/* ============================================================
   Prism — shared design system
   ============================================================ */
:root{
  --bg:#06080f;
  --bg-soft:#0a0e1a;
  --panel:rgba(15,21,36,.72);
  --panel-solid:#0e1424;
  --edge:rgba(146,176,225,.16);
  --edge-strong:rgba(146,176,225,.34);
  --txt:#e8eefb;
  --txt-2:#c0cbe2;
  --dim:#8698b8;
  --faint:#61708c;
  --brand:#7fc4ff;
  --accent:#7fc4ff;          /* per-page override */
  --accent-2:#a78bfa;
  --ok:#5dd39e;
  --warn:#ffb347;
  --radius:16px;
  --shadow:0 24px 60px rgba(0,0,0,.5);
  --sans:-apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI",Inter,system-ui,sans-serif;
  --mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0; background:var(--bg); color:var(--txt); font-family:var(--sans);
  font-size:16px; line-height:1.6; -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
a{color:inherit;text-decoration:none}
h1,h2,h3,h4{margin:0;line-height:1.18;letter-spacing:-.02em;font-weight:650}
p{margin:0 0 1em}
p:last-child{margin-bottom:0}
img,svg{max-width:100%}
.mono{font-family:var(--mono);font-variant-numeric:tabular-nums}
.container{width:min(1240px,calc(100vw - 48px));margin-inline:auto}
.eyebrow{font-size:11px;letter-spacing:.26em;text-transform:uppercase;color:var(--dim);font-weight:600}
.lede{font-size:17px;color:var(--txt-2);line-height:1.7}
.dim{color:var(--dim)}
.hide{display:none!important}

/* ---------- header ---------- */
.site-header{
  position:sticky;top:0;z-index:50;
  background:linear-gradient(180deg,rgba(6,8,15,.92),rgba(6,8,15,.72));
  backdrop-filter:blur(16px) saturate(1.4);-webkit-backdrop-filter:blur(16px) saturate(1.4);
  border-bottom:1px solid var(--edge);
}
/* hbar, not bar: a lab page defining its own .bar for a chart was painting the
   shared header with it — site.css only scoped layout here, so background and
   anything else it did not set leaked straight through. */
.site-header .hbar{display:flex;align-items:center;gap:22px;height:62px}
.logo{display:flex;align-items:center;gap:10px;font-weight:700;letter-spacing:-.02em;font-size:17px}
.logo svg{width:26px;height:26px;flex:none}
.logo .sub{font-weight:500;font-size:11px;letter-spacing:.2em;text-transform:uppercase;color:var(--dim);
  border-left:1px solid var(--edge);padding-left:10px;margin-left:2px}
.nav{margin-left:auto;display:flex;align-items:center;gap:4px}
.nav a{padding:7px 12px;border-radius:9px;font-size:13.5px;color:var(--dim);transition:.16s}
.nav a:hover{color:var(--txt);background:rgba(255,255,255,.06)}
.nav a.active{color:var(--txt);background:rgba(255,255,255,.08)}
.nav .cta{border:1px solid var(--edge-strong);color:var(--txt)}
.menu-btn{display:none;margin-left:auto;background:none;border:1px solid var(--edge);color:var(--txt);
  border-radius:9px;padding:6px 10px;font-size:13px;cursor:pointer}

/* ---------- lab shell ---------- */
.lab-header{border-bottom:1px solid var(--edge)}
.lab-header .hbar{height:56px;display:flex;align-items:center;gap:14px}
.back{display:inline-flex;align-items:center;gap:7px;font-size:13px;color:var(--dim);
  padding:6px 11px;border-radius:9px;border:1px solid var(--edge);transition:.16s;white-space:nowrap}
.back:hover{color:var(--txt);border-color:var(--edge-strong);background:rgba(255,255,255,.05)}
.lab-title{display:flex;align-items:baseline;gap:10px;min-width:0}
/* nowrap alone pushed the document wider than the phone: a long lab name
   ('What Cannot Be Compressed') has no break point and the flex item would
   not shrink. min-width:0 lets it, and the ellipsis keeps the bar one line. */
.lab-title strong{font-size:15.5px;font-weight:650;white-space:nowrap;
  min-width:0;overflow:hidden;text-overflow:ellipsis}
.lab-title span{font-size:12.5px;color:var(--dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.lab-num{font-family:var(--mono);font-size:11px;color:var(--accent);border:1px solid var(--edge);
  padding:3px 7px;border-radius:6px;letter-spacing:.08em}
.level-chip{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dim);
  border:1px solid var(--edge);padding:3px 9px;border-radius:20px;white-space:nowrap;flex:none}
.level-chip i{font-style:normal;font-size:8px;letter-spacing:1.5px;color:var(--accent)}

/* ---------- buttons & controls ---------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  font-family:inherit;font-size:14px;font-weight:550;color:var(--txt);
  background:rgba(255,255,255,.055);border:1px solid var(--edge);
  border-radius:11px;padding:9px 16px;cursor:pointer;transition:.16s;white-space:nowrap;
}
.btn:hover{background:rgba(255,255,255,.1);border-color:var(--edge-strong);transform:translateY(-1px)}
.btn:active{transform:translateY(0)}
.btn.primary{background:linear-gradient(135deg,var(--accent),var(--accent-2));border-color:transparent;
  color:#08101d;font-weight:650;box-shadow:0 8px 26px -8px var(--accent)}
.btn.primary:hover{filter:brightness(1.08)}
.btn.sm{font-size:12.5px;padding:6px 11px;border-radius:9px}
.btn.on{background:color-mix(in srgb,var(--accent) 22%,transparent);border-color:var(--accent);color:#fff}
.btn-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center}

.field{display:flex;flex-direction:column;gap:6px}
.field label,.ctl-label{font-size:10.5px;letter-spacing:.16em;text-transform:uppercase;color:var(--dim);font-weight:600}
select,input[type=text],input[type=search]{
  font-family:inherit;font-size:13.5px;color:var(--txt);background:rgba(255,255,255,.05);
  border:1px solid var(--edge);border-radius:10px;padding:8px 11px;outline:none;transition:.16s;
}
select:focus,input:focus{border-color:var(--accent);background:rgba(255,255,255,.08)}
select option{background:#0e1424;color:var(--txt)}
input[type=range]{
  -webkit-appearance:none;appearance:none;height:4px;border-radius:4px;
  background:rgba(255,255,255,.16);outline:none;cursor:pointer;width:100%;
}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;border-radius:50%;
  background:var(--accent);cursor:pointer;box-shadow:0 0 0 4px color-mix(in srgb,var(--accent) 22%,transparent)}
input[type=range]::-moz-range-thumb{width:16px;height:16px;border:none;border-radius:50%;background:var(--accent)}

/* ---------- surfaces ---------- */
.panel{background:var(--panel);border:1px solid var(--edge);border-radius:var(--radius);
  backdrop-filter:blur(14px) saturate(1.3);-webkit-backdrop-filter:blur(14px) saturate(1.3)}
.card{background:var(--panel);border:1px solid var(--edge);border-radius:var(--radius);padding:18px 20px}
.rows{display:flex;flex-direction:column}
.row{display:flex;justify-content:space-between;gap:16px;padding:6px 0;font-size:13.5px;
  border-bottom:1px solid rgba(146,176,225,.08);align-items:baseline}
.row:last-child{border-bottom:none}
.row .k{color:var(--dim);white-space:nowrap}
.row .v{text-align:right;color:var(--txt);font-variant-numeric:tabular-nums}
.tag{display:inline-block;font-size:11px;padding:3px 9px;border-radius:20px;
  border:1px solid var(--edge);color:var(--dim);background:rgba(255,255,255,.03)}
.section-title{display:flex;align-items:center;gap:12px;margin-bottom:6px}
.section-title h2{font-size:clamp(24px,3.2vw,34px)}
.hr{height:1px;background:var(--edge);border:none;margin:0}

/* scrollbars */
*::-webkit-scrollbar{width:8px;height:8px}
*::-webkit-scrollbar-track{background:transparent}
*::-webkit-scrollbar-thumb{background:rgba(146,176,225,.22);border-radius:8px}
*::-webkit-scrollbar-thumb:hover{background:rgba(146,176,225,.4)}

/* ---------- footer ---------- */
.site-footer{border-top:1px solid var(--edge);margin-top:80px;padding:44px 0 40px;
  color:var(--dim);font-size:13px;
  background:linear-gradient(180deg,transparent,rgba(255,255,255,.014))}
/* auto-fill, not space-between: a wrapped flex row flung the leftover groups
   to opposite edges of the page. Grid tracks keep the last row aligned. */
.site-footer .cols{display:grid;gap:26px 30px;
  grid-template-columns:repeat(auto-fill,minmax(178px,1fr));align-items:start}
.site-footer .fbrand{grid-column:span 2;max-width:320px}
@media (max-width:760px){ .site-footer .fbrand{grid-column:span 1} }
.site-footer .fbrand .logo{margin-bottom:14px}
.site-footer .fbrand p{font-size:13px;line-height:1.7;margin:0 0 16px;color:var(--dim)}
.site-footer .fdoors{display:flex;flex-direction:column;gap:8px}
.site-footer .fdoors a{display:inline-flex;align-items:center;width:fit-content;
  padding:7px 14px;border-radius:10px;border:1px solid var(--edge);
  background:rgba(255,255,255,.04);color:var(--txt-2);font-size:12.5px;font-weight:500}
.site-footer .fdoors a:hover{color:var(--txt);border-color:var(--edge-strong);
  background:rgba(255,255,255,.075)}
/* not flex: when the heading wraps, flex pushes the count to the far edge */
.site-footer h4{font-size:10.5px;letter-spacing:.18em;text-transform:uppercase;color:var(--faint);
  margin-bottom:11px;font-weight:600;line-height:1.45}
.site-footer h4 b{font-family:var(--mono);font-size:10px;font-weight:400;letter-spacing:0;
  color:var(--dim);opacity:.7;margin-left:5px;white-space:nowrap}
.site-footer .fcol a{display:flex;gap:8px;align-items:baseline;padding:3.5px 0;
  color:var(--dim);transition:color .15s;line-height:1.4}
.site-footer .fcol a i{font-style:normal;font-family:var(--mono);font-size:10.5px;
  color:var(--faint);flex:none;min-width:16px;opacity:.8}
.site-footer .fcol a:hover{color:var(--txt)}
.site-footer .fcol a:hover i{color:var(--accent)}
.site-footer .fcol a.more{margin-top:7px;color:var(--txt-2);font-size:12.4px}
.site-footer a{color:var(--dim);transition:.15s}
.site-footer a:hover{color:var(--txt)}
.site-footer .fine{margin-top:34px;padding-top:18px;border-top:1px solid var(--edge);
  font-size:12px;color:var(--faint);display:flex;justify-content:space-between;
  gap:14px;flex-wrap:wrap}
.site-footer .made{margin-top:30px;font-size:11.8px;line-height:1.65;
  color:var(--faint);max-width:none}

/* ---------- next-lab strip ---------- */
.next-strip{display:flex;align-items:center;justify-content:space-between;gap:18px;flex-wrap:wrap;
  padding:20px 24px;border:1px solid var(--edge);border-radius:var(--radius);
  background:linear-gradient(120deg,rgba(255,255,255,.045),rgba(255,255,255,.015))}

/* ---------- a11y ---------- */
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:6px}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

@media (max-width:860px){
  .container{width:calc(100vw - 32px)}
  .nav{display:none}
  .nav.open{display:flex;position:absolute;top:62px;left:0;right:0;flex-direction:column;gap:2px;
    padding:10px 16px 16px;background:var(--bg-soft);border-bottom:1px solid var(--edge)}
  .menu-btn{display:block}
  .lab-title span{display:none}
  .level-chip{display:none}
}
@media (prefers-reduced-motion:reduce){
  *{animation-duration:.001ms!important;transition-duration:.001ms!important}
}
/* #noanim — settles every animation instantly (screenshots, printing, debugging) */
.no-anim *,.no-anim *::before,.no-anim *::after{
  animation-duration:.001ms!important;animation-delay:0s!important;
  transition-duration:.001ms!important;transition-delay:0s!important}

/* ============================================================
   Motion kit — shared transitions
   ============================================================ */
@view-transition { navigation: auto; }          /* cross-page fade where supported */
::view-transition-old(root){ animation: vt-out .22s ease both }
::view-transition-new(root){ animation: vt-in .34s cubic-bezier(.2,.7,.3,1) both }
@keyframes vt-out{ to{ opacity:0; transform:translateY(-6px) } }
@keyframes vt-in { from{ opacity:0; transform:translateY(10px) } }

@keyframes riseIn { from{ opacity:0; transform:translateY(16px) } to{ opacity:1; transform:none } }
@keyframes popIn  { from{ opacity:0; transform:scale(.94) }      to{ opacity:1; transform:none } }
@keyframes fadeIn { from{ opacity:0 } to{ opacity:1 } }
@keyframes slideFrom { from{ opacity:0; transform:translateX(10px) } to{ opacity:1; transform:none } }
@keyframes drawIn { from{ stroke-dashoffset:var(--len,600) } to{ stroke-dashoffset:0 } }

body{ animation: fadeIn .4s ease both }
.site-header{ animation: riseIn .45s cubic-bezier(.2,.7,.3,1) both }

/* Scroll reveals. Nothing is hidden by CSS alone — site.js adds .pre only to blocks that
   start below the fold, so a block can never end up permanently invisible. */
[data-reveal]{ transition: opacity .6s cubic-bezier(.2,.7,.3,1), transform .6s cubic-bezier(.2,.7,.3,1) }
[data-reveal].pre{ opacity:0; transform:translateY(18px) }
[data-reveal].in > *{ animation: riseIn .5s cubic-bezier(.2,.7,.3,1) both }
[data-reveal].in > *:nth-child(1){ animation-delay:.02s }
[data-reveal].in > *:nth-child(2){ animation-delay:.06s }
[data-reveal].in > *:nth-child(3){ animation-delay:.10s }
[data-reveal].in > *:nth-child(4){ animation-delay:.14s }
[data-reveal].in > *:nth-child(5){ animation-delay:.18s }
[data-reveal].in > *:nth-child(6){ animation-delay:.22s }
[data-reveal].in > *:nth-child(7){ animation-delay:.26s }
[data-reveal].in > *:nth-child(8){ animation-delay:.30s }
[data-reveal].in > *:nth-child(9){ animation-delay:.34s }

/* content that swaps in place */
.swap{ animation: slideFrom .34s cubic-bezier(.2,.7,.3,1) both }
.pop { animation: popIn .3s cubic-bezier(.2,.7,.3,1) both }

/* keep every hover/press consistent */
.btn,.chip,.el,.lab-card,.tag{ will-change:transform }

/* ══════════════════════════════════════════════════════════════════════
   The lab drawer. Present on every page; hidden until asked for.
   ══════════════════════════════════════════════════════════════════════ */

.pdrawer{position:fixed;left:0;top:0;bottom:0;width:min(360px,86vw);z-index:60;
  /* drawer-local surface tokens: this panel sits ABOVE the page, so it is a
     step lighter than --bg and its edges are a step brighter than --edge.
     Scoped here so the global tokens keep meaning the same thing elsewhere. */
  --pd-bg:#161d2f;
  --pd-edge:rgba(160,186,232,.20);
  --pd-edge-strong:rgba(160,186,232,.42);
  display:flex;flex-direction:column;overflow:hidden;
  background:var(--pd-bg);border-right:1px solid var(--pd-edge-strong);
  box-shadow:1px 0 0 rgba(255,255,255,.05) inset, 30px 0 70px -20px rgba(0,0,0,.92);
  transform:translateX(-101%);transition:transform .26s cubic-bezier(.2,.7,.3,1);
  will-change:transform}
.pdrawer.open{transform:none}
@media (prefers-reduced-motion: reduce){ .pdrawer{transition:none} }

.pd-top{flex:none;display:flex;gap:8px;align-items:center;padding:14px 14px 12px;
  border-bottom:1px solid var(--pd-edge);background:rgba(255,255,255,.028)}
/* `input[type=search]` in the base sheet is (0,1,1) and was quietly beating the
   plain `.pd-find` class (0,1,0) — the field kept the base's pale background and
   13.5px type. Qualifying with the drawer wins the cascade back. */
.pdrawer .pd-find{flex:1;min-width:0;font-family:inherit;font-size:14px;padding:10px 12px;border-radius:10px;
  border:1px solid var(--pd-edge);background:rgba(0,0,0,.32);color:var(--txt);transition:.16s}
.pdrawer .pd-find:focus{outline:none;border-color:var(--brand);background:rgba(0,0,0,.42);
  box-shadow:0 0 0 3px color-mix(in srgb,var(--brand) 20%,transparent)}
.pdrawer .pd-find::placeholder{color:var(--dim);opacity:1}
.pd-x{font-family:var(--mono);font-size:10.5px;letter-spacing:.06em;padding:7px 9px;border-radius:8px;
  border:1px solid var(--pd-edge);background:rgba(255,255,255,.06);color:var(--txt-2);cursor:pointer}
.pd-x:hover{color:var(--txt);border-color:var(--pd-edge-strong);background:rgba(255,255,255,.11)}

/* min-height:0 is load-bearing. A flex item defaults to min-height:auto, so
   without it this grows to fit all 29 labs instead of scrolling — the list
   runs off the bottom of the screen and the wheel scrolls the page behind. */
.pd-list{flex:1 1 auto;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;padding:8px 8px 14px}
.pd-g.off{display:none}
/* "Labs" / "Chapters": one label per section, above that section's sticky group headings */
.pd-labs.off,.pd-chapters.off{display:none}
.pd-sec{font-size:11.5px;font-weight:700;letter-spacing:.04em;color:var(--txt);padding:16px 10px 2px;
  display:flex;align-items:center;gap:10px}
.pd-sec::after{content:"";flex:1;height:1px;background:var(--pd-edge)}
.pd-labs+.pd-chapters,.pd-chapters+.pd-labs{margin-top:10px}
.pd-gh{font-size:10px;letter-spacing:.15em;text-transform:uppercase;color:var(--dim);font-weight:650;
  padding:14px 10px 6px;position:sticky;top:0;background:var(--pd-bg);z-index:1}
.pd-i{display:flex;gap:10px;align-items:baseline;padding:8px 10px;border-radius:9px;
  text-decoration:none;color:var(--txt);border:1px solid transparent}
.pd-i.off{display:none}
.pd-i:hover,.pd-i.sel{background:rgba(255,255,255,.085);color:#fff;border-color:var(--pd-edge-strong)}
.pd-i.sel{border-color:color-mix(in srgb,var(--c,#7fc4ff) 62%,transparent)}
.pd-i.cur{background:color-mix(in srgb,var(--c,#7fc4ff) 20%,transparent);
  border-color:color-mix(in srgb,var(--c,#7fc4ff) 55%,transparent);color:#fff}
.pd-n{font-family:var(--mono);font-size:10.5px;font-weight:600;color:var(--c,#7fc4ff);flex:none;width:20px}
.pd-t{font-size:13.4px;line-height:1.32;min-width:0;font-weight:500}
.pd-t em{display:block;font-style:normal;font-size:11.4px;color:var(--dim);font-weight:400;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pd-i:hover .pd-t em,.pd-i.sel .pd-t em,.pd-i.cur .pd-t em{color:var(--txt-2)}
.pd-none{display:none;padding:24px 12px;font-size:13px;color:var(--txt-2);text-align:center}
.pd-none.on{display:block}
.pd-foot{flex:none;display:flex;justify-content:space-between;gap:10px;padding:10px 16px;
  border-top:1px solid var(--pd-edge);background:rgba(0,0,0,.22);
  font-size:10.5px;color:var(--dim);font-family:var(--mono)}

/* the search field in the header: looks and behaves like a field, but opens the drawer */
.hsearch{position:relative;margin-left:auto;display:flex;align-items:center;gap:8px;width:min(300px,30vw);height:36px;
  padding:0 8px 0 11px;border-radius:10px;border:1px solid var(--edge);background:rgba(255,255,255,.045);
  color:var(--dim);cursor:text;transition:border-color .16s,background .16s;flex:0 1 auto;min-width:0}
.hsearch:hover{border-color:var(--edge-strong);background:rgba(255,255,255,.07)}
.hsearch:focus-within{border-color:var(--brand,#7fc4ff)}
.hsearch svg{width:15px;height:15px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round}
.hsearch input{flex:1;min-width:0;height:100%;border:0;background:none;outline:none;
  font-family:inherit;font-size:13px;color:var(--txt);cursor:text;padding:0}
.hsearch input::placeholder{color:var(--dim);opacity:1}
.hsearch input::-webkit-search-cancel-button{display:none}
.hsearch kbd{flex:none;font-family:var(--mono);font-size:10.5px;line-height:1;padding:3px 6px;border-radius:5px;
  border:1px solid var(--edge);color:var(--dim)}
/* the search takes the free space's left edge, so the links stay pinned right */
.hsearch~.nav,.hsearch~.menu-btn{margin-left:0}
.lab-header .hsearch{width:min(240px,22vw)}
/* narrow screens: just the magnifier, same target */
@media (max-width:1100px){ .lab-header .hsearch{width:38px;padding:0;justify-content:center;cursor:pointer;flex:none}
  .lab-header .hsearch input,.lab-header .hsearch kbd{position:absolute;width:1px;opacity:0;pointer-events:none} }
/* the header gains a search button on phones, so its gaps and the logo's label give way */
@media (max-width:860px){ .site-header .hbar{gap:12px} }
@media (max-width:420px){ .hbar .logo .sub{display:none} }
@media (max-width:860px){ .hsearch{width:38px;padding:0;justify-content:center;cursor:pointer;flex:none}
  .hsearch input,.hsearch kbd{position:absolute;width:1px;opacity:0;pointer-events:none} }

/* the button that opens it, in both header variants */
.pd-btn{display:inline-flex;align-items:center;gap:8px;font-family:inherit;font-size:12.5px;
  padding:7px 11px;border-radius:10px;border:1px solid var(--edge-strong);
  background:rgba(255,255,255,.06);color:var(--txt-2);cursor:pointer;transition:.16s;flex:none}
.pd-btn:hover{color:var(--txt);border-color:var(--edge-strong);background:rgba(255,255,255,.08)}
.pd-ic{display:flex;flex-direction:column;gap:3px;width:13px}
.pd-ic i{display:block;height:1.6px;border-radius:2px;background:currentColor}
.pd-ic i:nth-child(2){width:70%} .pd-ic i:nth-child(3){width:85%}

/* a scrim, so the page behind reads as inactive */
/* purely decorative dimming — it must never take the pointer, or it swallows
   the wheel and the drawer's list cannot scroll */
/* It hangs off BODY, not HTML. Chrome paints the root element's ::after above
   the whole document tree no matter what z-index it carries, so as html::after
   this overlay was tinting the drawer itself — which is what made a perfectly
   live panel read as greyed-out. On body::after the z-index is honoured and the
   drawer (z-index 60) sits above it. Still keyed off html.pd-on so site.js is
   unchanged. */
html.pd-on body::after{content:"";position:fixed;inset:0;z-index:59;background:rgba(3,5,11,.66);
  pointer-events:none;animation:pdFade .22s ease both}
@keyframes pdFade{from{opacity:0}to{opacity:1}}
@media (prefers-reduced-motion: reduce){ html.pd-on body::after{animation:none} }
