/* ============================================================
   demo-house.css — the house style for experiment pages.

   The first twenty-two demos arrived as self-contained Claude Artifacts and
   each carries its own copy of all of this. Demos written directly in the
   repository link this file instead, so they stay identical to one another
   and one edit restyles them all. Nothing here is specific to any experiment:
   a page adds its own <style> for its own stage.

   The shape a page is expected to have:

     <body data-depth="1" data-neuro-demos="12">
       <header class="mast">   h1, a lede p, and a p.series of related demos
       <div class="depthbar">  three button[data-depth="1|2|3"]
       <main><section class="demo">
         <div class="lab">
           <div class="demo-head">     optional, when the masthead is not enough
           <div class="exp-q panel">   quiz-kit mounts here
           <div class="stage"><div class="stage-in panel">   the model
           <div class="exp-r panel" hidden>   quiz-kit writes the verdict here
           <div class="controls panel">       the sliders
         <article class="explain">     the reading
       <footer class="foot">
   ============================================================ */

/* ---------- tokens ---------- */
:root{
  --paper:#EEF2F2; --sheet:#FAFCFC; --ink:#14212B; --ink-2:#4B5B67; --ink-3:#7A8993;
  --rule:#C9D3D8; --grid:#E0E7EA; --tint:#E4EBEE;
  --vm:#B8184A; --na:#C8661A; --k:#5B3FB8; --cl:#12806A; --ca:#2466B5;
  --good:#1F7A4D; --bad:#A3321F; --partly:#8A6A12;
  --focus:#2466B5;
  --serif:"Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans:"Source Sans 3", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
  box-sizing:border-box;
  padding-top:env(safe-area-inset-top,0px);
  padding-bottom:env(safe-area-inset-bottom,0px);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --paper:#0E161B; --sheet:#152129; --ink:#E2EAEE; --ink-2:#A3B2BA; --ink-3:#74858F;
    --rule:#2B3B45; --grid:#1D2B33; --tint:#1B2830;
    --vm:#FF5A86; --na:#F29A4A; --k:#A58FFF; --cl:#3FC79E; --ca:#5CA3F5;
    --good:#4CC486; --bad:#F07A63; --partly:#E0B44A; --focus:#7DB6FF;
    color-scheme: dark;
  }
}
:root[data-theme="dark"]{
  --paper:#0E161B; --sheet:#152129; --ink:#E2EAEE; --ink-2:#A3B2BA; --ink-3:#74858F;
  --rule:#2B3B45; --grid:#1D2B33; --tint:#1B2830;
  --vm:#FF5A86; --na:#F29A4A; --k:#A58FFF; --cl:#3FC79E; --ca:#5CA3F5;
  --good:#4CC486; --bad:#F07A63; --partly:#E0B44A; --focus:#7DB6FF;
  color-scheme: dark;
}

/* ---------- ground ---------- */
html{ scroll-padding-top:calc(env(safe-area-inset-top,0px) + 56px); -webkit-text-size-adjust:100%; }
*,*::before,*::after{ box-sizing:border-box; }
body{ overflow-anchor:none; margin:0; background:var(--paper); color:var(--ink);
  font-family:var(--serif); font-size:18px; line-height:1.55; font-optical-sizing:auto; }
button,input,select{ font:inherit; color:inherit; }
:focus-visible{ outline:2px solid var(--focus); outline-offset:2px; border-radius:4px; }
sub,sup{ line-height:0; font-size:.72em; }
canvas{ -webkit-user-select:none; user-select:none; }
button, .chip, summary{ touch-action:manipulation; -webkit-tap-highlight-color:transparent; }

/* the ion colours, so prose can name a current and show it */
.na{color:var(--na)} .k{color:var(--k)} .cl{color:var(--cl)}
.ca{color:var(--ca)} .vmc{color:var(--vm)}

/* ---------- masthead ---------- */
.mast{ max-width:1180px; margin:0 auto; padding:28px 20px 18px; }
.mast h1{ font-weight:500; font-size:clamp(34px,6vw,54px); line-height:1.02;
  letter-spacing:-.015em; margin:0 0 10px; text-wrap:balance; }
.mast p{ margin:0; max-width:64ch; color:var(--ink-2); font-size:17px; }
.mast .series{ font-family:var(--sans); font-size:14.5px; color:var(--ink-3);
  margin-top:10px; max-width:70ch; line-height:1.45; }
.mast .series a{ color:var(--ink-2); }

/* ---------- depth ---------- */
.depthbar{ position:sticky; top:env(safe-area-inset-top,0px); z-index:20;
  background:color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter:blur(8px); -webkit-backdrop-filter:blur(8px);
  border-bottom:1px solid var(--rule); }
.depthbar-in{ max-width:1180px; margin:0 auto; padding:8px 20px; display:flex;
  align-items:center; gap:12px; font-family:var(--sans); font-size:15px; }
.depthbar-in .lbl{ color:var(--ink-2); white-space:nowrap; }
.seg{ display:inline-flex; border:1px solid var(--rule); border-radius:8px;
  background:var(--sheet); padding:2px; gap:2px; }
.seg button{ appearance:none; border:0; background:none; border-radius:6px; padding:5px 11px;
  cursor:pointer; font-family:var(--sans); font-size:14.5px; font-weight:600;
  color:var(--ink-2); white-space:nowrap; }
.seg button[aria-pressed="true"]{ background:var(--ink); color:var(--sheet); }
.seg.small button{ font-size:13px; padding:3px 8px; }
.subviews{ display:flex; width:100%; margin-bottom:10px; }
.subviews button{ flex:1 1 0; white-space:normal; line-height:1.2; }
@media (max-width:420px){
  .depthbar-in{ padding:8px 12px; gap:8px; }
  .depthbar-in .lbl{ display:none; }
  .seg button{ padding:5px 8px; font-size:14px; }
  .seg.depth{ width:100%; } .seg.depth button{ flex:1; }
}

/* depth gating is cumulative: level 2 shows 1 and 2, level 3 shows everything */
body[data-depth="1"] .d2,
body[data-depth="1"] .d3,
body[data-depth="2"] .d3{ display:none !important; }

/* ---------- the lab ---------- */
.demo{ max-width:1180px; margin:0 auto; padding:18px 20px 60px; }
.demo[hidden]{ display:none; }
.lab{ display:grid; gap:14px; grid-template-columns:minmax(0,1fr);
  grid-template-areas:"head" "q" "stage" "r" "controls"; }
.demo-head{ grid-area:head; }
.demo-head h2{ font-weight:500; font-size:clamp(28px,4.4vw,38px); line-height:1.1;
  margin:6px 0 8px; letter-spacing:-.01em; }
.demo-head p{ margin:0; max-width:66ch; }
.stage{ grid-area:stage; min-width:0; }
.exp-q{ grid-area:q; } .exp-r{ grid-area:r; } .controls{ grid-area:controls; min-width:0; }
@media (min-width:980px){
  .lab{ grid-template-columns:minmax(0,1.15fr) minmax(0,.85fr); column-gap:28px;
    grid-template-areas:"head head" "stage q" "stage r" "stage controls";
    grid-template-rows:auto auto auto 1fr; }
  .stage-in{ position:sticky; top:60px; max-height:calc(100vh - 72px); overflow-y:auto;
    overscroll-behavior:contain; scrollbar-width:thin; }
}

.panel{ background:var(--sheet); border:1px solid var(--rule); border-radius:10px; }
.stage-in{ padding:12px 12px 10px; }
.stage svg, .stage canvas{ display:block; width:100%; }
.cap{ font-family:var(--sans); font-size:13.5px; color:var(--ink-2); line-height:1.4; }
.hint{ font-family:var(--sans); font-size:14px; color:var(--ink-2); }
.plotlabel{ display:flex; justify-content:space-between; align-items:center;
  font-family:var(--sans); font-size:13.5px; color:var(--ink-2); margin:8px 0 2px;
  gap:8px; flex-wrap:wrap; }
.playrow{ display:flex; align-items:center; gap:8px 10px; flex-wrap:wrap;
  font-family:var(--sans); font-size:14px; margin:8px 0 2px; }
.playrow .btn{ min-width:78px; }

/* readouts and small tables */
.readouts{ display:flex; flex-wrap:wrap; gap:6px 18px; font-family:var(--sans);
  font-size:14.5px; margin-top:8px; padding-top:8px; border-top:1px solid var(--grid); }
.readouts .ro b{ font-weight:700; font-variant-numeric:tabular-nums; }
.readouts .ro span{ color:var(--ink-2); margin-right:5px; }
.tablewrap{ overflow-x:auto; }
table.data{ width:100%; border-collapse:collapse; font-family:var(--sans); font-size:14px;
  font-variant-numeric:tabular-nums; margin-top:8px; }
table.data th{ text-align:right; font-weight:600; color:var(--ink-2); padding:4px 6px;
  border-bottom:1px solid var(--rule); white-space:nowrap; }
table.data td{ text-align:right; padding:4px 6px; border-bottom:1px solid var(--grid);
  white-space:nowrap; }
table.data th:first-child, table.data td:first-child{ text-align:left; font-weight:700; }

/* legends */
.legend{ display:flex; flex-wrap:wrap; gap:4px 14px; font-family:var(--sans);
  font-size:13px; color:var(--ink-2); margin-top:6px; }
.legend i{ display:inline-block; width:14px; height:3px; vertical-align:middle;
  margin-right:5px; border-radius:2px; }
.legend i.dash{ background:repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px);
  height:2px; }

/* ---------- the question ---------- */
.exp-q{ padding:14px 16px 16px; }
.picker-lbl{ font-family:var(--sans); font-size:14px; color:var(--ink-2); margin:0 0 6px; }
.picker{ display:flex; gap:6px; overflow-x:auto; padding:0 4px 6px; margin:0 -4px 8px;
  scrollbar-width:thin; }
.picker button{ appearance:none; flex:0 0 auto; border:1px solid var(--rule);
  background:var(--paper); border-radius:999px; padding:5px 12px; font-family:var(--sans);
  font-size:14px; font-weight:600; cursor:pointer; color:var(--ink-2); white-space:nowrap; }
.picker button .n{ color:var(--ink-3); margin-right:5px; font-variant-numeric:tabular-nums; }
.picker button[aria-pressed="true"]{ border-color:var(--ink); color:var(--ink);
  background:var(--sheet); box-shadow:inset 0 0 0 1px var(--ink); }
.picker button.done::after{ content:"✓"; margin-left:6px; color:var(--good); }
.exp-q h3{ font-weight:500; font-size:22px; line-height:1.2; margin:4px 0 6px; }
.exp-q .setup{ margin:0 0 8px; font-size:16.5px; color:var(--ink-2); }
.exp-q .question{ margin:0 0 10px; font-size:18px; }
.freeplay{ margin:0; font-size:16.5px; color:var(--ink-2); }

.options{ display:grid; gap:6px; }
.options button{ appearance:none; text-align:left; border:1px solid var(--rule);
  background:var(--paper); border-radius:8px; padding:9px 12px 9px 36px; position:relative;
  cursor:pointer; font-family:var(--sans); font-size:15.5px; line-height:1.35; }
.options button::before{ content:""; position:absolute; left:12px; top:50%; width:14px;
  height:14px; margin-top:-7px; border-radius:50%; border:1.5px solid var(--ink-3); }
.options button[aria-pressed="true"]{ border-color:var(--ink); background:var(--sheet); }
.options button[aria-pressed="true"]::before{ border-color:var(--ink);
  background:radial-gradient(circle, var(--ink) 0 4px, transparent 4.5px); }
.options button:disabled{ cursor:default; }
.options button.right{ border-color:var(--good); box-shadow:inset 3px 0 0 var(--good); }
.options button.partly{ border-color:var(--partly); box-shadow:inset 3px 0 0 var(--partly); }
.options button.wrong[aria-pressed="true"]{ border-color:var(--bad); box-shadow:inset 3px 0 0 var(--bad); }
.options button .tag{ display:block; font-size:13px; font-weight:600; margin-top:2px; }
.options button.right .tag{ color:var(--good); }
.options button.partly .tag{ color:var(--partly); }
.options button.wrong .tag{ color:var(--bad); }

.actions{ display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.btn{ appearance:none; border:1px solid var(--ink); background:var(--ink); color:var(--sheet);
  border-radius:8px; padding:8px 14px; font-family:var(--sans); font-weight:700; font-size:15px;
  cursor:pointer; }
.btn:disabled{ opacity:.35; cursor:default; }
.btn.ghost{ background:transparent; color:var(--ink); border-color:var(--rule); font-weight:600; }

/* ---------- the verdict ---------- */
.exp-r{ padding:14px 16px 16px; border-left:4px solid var(--ink); }
.exp-r[hidden]{ display:none; }
.exp-r .verdict{ font-family:var(--sans); font-weight:700; font-size:16px; margin:0 0 4px; }
.exp-r .verdict.right{ color:var(--good); }
.exp-r .verdict.partly{ color:var(--partly); }
.exp-r .verdict.wrong{ color:var(--bad); }
.exp-r .measured{ font-family:var(--sans); font-size:15px; margin:0 0 10px;
  font-variant-numeric:tabular-nums; color:var(--ink-2); }
.exp-r .why p{ margin:0 0 10px; font-size:17px; }
.exp-r .why p.d2{ padding-left:12px; border-left:2px solid var(--grid); }
.exp-r .why p.d3{ padding-left:12px; border-left:2px solid var(--grid); font-size:16px;
  color:var(--ink-2); }
.lvl{ font-family:var(--sans); font-size:12.5px; font-weight:700; color:var(--ink-3);
  margin-right:6px; }

/* ---------- controls ---------- */
.controls{ padding:12px 16px 16px; }
.controls h3{ font-family:var(--sans); font-size:15px; font-weight:700; margin:14px 0 6px;
  color:var(--ink); }
.controls h3:first-child{ margin-top:2px; }
.controls .cgroup + .cgroup{ margin-top:16px; }
.cgroup[hidden]{ display:none !important; }
.ctl{ margin:0 0 10px; font-family:var(--sans); }
.ctl label{ display:flex; justify-content:space-between; align-items:baseline; gap:10px;
  font-size:14.5px; }
.ctl label .name{ color:var(--ink); }
.ctl label output{ font-variant-numeric:tabular-nums; font-weight:700; white-space:nowrap; }
.ctl .note{ font-size:12.5px; color:var(--ink-3); margin-top:1px; }
.row-btns{ display:flex; flex-wrap:wrap; gap:6px; margin:4px 0 10px; }
.chip{ appearance:none; border:1px solid var(--rule); background:var(--paper);
  border-radius:999px; padding:5px 12px; font-family:var(--sans); font-size:14px;
  font-weight:600; cursor:pointer; color:var(--ink-2); }
.chip[aria-pressed="true"]{ border-color:var(--ink); color:var(--sheet); background:var(--ink); }
.switch{ display:flex; align-items:center; justify-content:space-between; gap:10px;
  font-family:var(--sans); font-size:14.5px; margin:2px 0 10px; }

input[type=range]{ -webkit-appearance:none; appearance:none; width:100%; margin:2px 0 0;
  height:32px; background:transparent; cursor:pointer; touch-action:pan-y; }
input[type=range]::-webkit-slider-runnable-track{ height:4px; border-radius:2px; background:var(--rule); }
input[type=range]::-webkit-slider-thumb{ -webkit-appearance:none; width:22px; height:22px;
  margin-top:-9px; border-radius:50%; background:var(--ink); border:3px solid var(--sheet);
  box-shadow:0 0 0 1px var(--ink); }
input[type=range]::-moz-range-track{ height:4px; border-radius:2px; background:var(--rule); }
input[type=range]::-moz-range-thumb{ width:16px; height:16px; border-radius:50%;
  background:var(--ink); border:3px solid var(--sheet); box-shadow:0 0 0 1px var(--ink); }
input[type=range]:focus-visible{ outline:none; }
input[type=range]:focus-visible::-webkit-slider-thumb{ box-shadow:0 0 0 3px var(--focus); }
input[type=range]:focus-visible::-moz-range-thumb{ box-shadow:0 0 0 3px var(--focus); }
input[type=range]:disabled::-webkit-slider-thumb{ background:var(--ink-3); box-shadow:0 0 0 1px var(--ink-3); }
.scrub{ display:flex; align-items:center; gap:10px; font-family:var(--sans); font-size:14px;
  margin-top:6px; }
.scrub input{ flex:1; }
.scrub output{ font-variant-numeric:tabular-nums; min-width:62px; text-align:right; font-weight:700; }

/* the verdict banner that rides above the stage on a narrow screen */
.stage-verdict{ display:flex; align-items:center; justify-content:space-between; gap:10px;
  font-family:var(--sans); font-size:15px; font-weight:700; padding:6px 6px 6px 12px;
  margin:0 0 10px; border-radius:8px; background:var(--tint); }
.stage-verdict[hidden]{ display:none; }
.stage-verdict .right{ color:var(--good); }
.stage-verdict .partly{ color:var(--partly); }
.stage-verdict .wrong{ color:var(--bad); }
.stage-verdict button{ appearance:none; border:1px solid var(--ink); background:var(--sheet);
  color:var(--ink); border-radius:8px; padding:7px 12px; font:700 14px var(--sans);
  cursor:pointer; min-height:38px; }
@media (min-width:980px){ .stage-verdict{ display:none !important; } }

/* ---------- the reading ---------- */
.explain{ margin-top:36px; border-top:1px solid var(--rule); padding-top:8px;
  max-width:1180px; margin-left:auto; margin-right:auto; padding-left:20px; padding-right:20px; }
.explain-in{ max-width:70ch; }
.explain h2{ font-weight:500; font-size:30px; margin:16px 0 4px; letter-spacing:-.01em; }
.explain h3{ font-weight:600; font-size:21px; margin:28px 0 6px; line-height:1.25; }
.explain p{ margin:0 0 12px; }
.explain p.d2, .explain div.d2{ border-left:2px solid var(--rule); padding-left:14px; }
.explain p.d3, .explain div.d3{ border-left:2px solid var(--ink-3); padding-left:14px;
  font-size:16.5px; }
.explain ol.refs{ font-size:15.5px; padding-left:22px; color:var(--ink-2); }
.explain ol.refs li{ margin-bottom:6px; }
.keybox{ font-family:var(--sans); font-size:14.5px; color:var(--ink-2); margin:10px 0 18px; }
.eq{ font-family:var(--serif); font-size:18px; background:var(--sheet);
  border:1px solid var(--grid); border-radius:8px; padding:10px 14px; margin:8px 0 12px;
  overflow-x:auto; white-space:nowrap; }
.eq .frac{ display:inline-flex; flex-direction:column; vertical-align:middle;
  text-align:center; margin:0 3px; }
.eq .frac > span:first-child{ border-bottom:1px solid currentColor; padding:0 4px 1px; }
.eq .frac > span:last-child{ padding:1px 4px 0; }
.eq i{ font-style:italic; }
.calc{ font-family:var(--sans); font-size:15px; background:var(--sheet);
  border:1px solid var(--grid); border-radius:8px; padding:10px 14px; margin:8px 0 14px; }
.calc output{ font-weight:700; font-variant-numeric:tabular-nums; }

details.sec{ border-top:1px solid var(--grid); }
details.sec > summary{ list-style:none; cursor:pointer; font-family:var(--serif);
  font-weight:600; font-size:21px; line-height:1.25; padding:16px 36px 12px 0; position:relative; }
details.sec > summary::-webkit-details-marker{ display:none; }
details.sec > summary::after{ content:""; position:absolute; right:8px; top:50%; width:9px;
  height:9px; margin-top:-7px; border-right:2px solid var(--ink-2);
  border-bottom:2px solid var(--ink-2); transform:rotate(45deg); transition:transform .2s; }
details.sec[open] > summary::after{ transform:rotate(225deg); margin-top:-2px; }
details.sec[open]{ padding-bottom:6px; }

footer.foot{ max-width:1180px; margin:0 auto; padding:0 20px 40px; font-family:var(--sans);
  font-size:13.5px; color:var(--ink-3); }

/* ---------- touch and small screens ---------- */
@media (pointer:coarse){
  input[type=range]{ height:40px; }
  input[type=range]::-webkit-slider-thumb{ width:28px; height:28px; margin-top:-12px; }
  input[type=range]::-moz-range-thumb{ width:22px; height:22px; }
  .chip, .picker button{ min-height:40px; padding:8px 14px; }
  .seg button{ min-height:38px; }
  .btn{ min-height:44px; }
  .options button{ padding-top:11px; padding-bottom:11px; }
}
@media (max-width:560px){
  body{ font-size:17px; line-height:1.5; }
  .mast{ padding:16px 14px 12px; }
  .mast h1{ font-size:32px; margin-bottom:6px; }
  .mast p{ font-size:15px; line-height:1.45; }
  .depthbar-in{ padding:6px 10px; }
  .demo{ padding:12px 10px 40px; }
  .demo-head h2{ font-size:26px; margin-top:2px; }
  .demo-head p{ font-size:16px; line-height:1.45; }
  .lab{ gap:10px; }
  .stage-in{ padding:10px 8px 8px; }
  .exp-q, .exp-r{ padding:12px 12px 14px; }
  .exp-q h3{ font-size:20px; }
  .exp-q .question{ font-size:17px; }
  .exp-r .why p{ font-size:16.5px; }
  .actions .btn{ flex:1 1 auto; }
  .picker{ scroll-snap-type:x proximity; padding-right:28px;
    -webkit-mask-image:linear-gradient(90deg,#000 88%,transparent);
    mask-image:linear-gradient(90deg,#000 88%,transparent); }
  .picker button{ scroll-snap-align:start; }
  .explain{ margin-top:24px; padding-left:14px; padding-right:14px; }
  .explain h2{ font-size:25px; }
  details.sec > summary{ font-size:19px; padding:14px 34px 10px 0; }
  .explain p.d2, .explain div.d2, .explain p.d3, .explain div.d3{ padding-left:10px; }
  .eq{ font-size:15.5px; padding:8px 10px; }
  table.data{ font-size:13px; }
  table.data th, table.data td{ padding:4px 3px; }
  .readouts{ font-size:14px; gap:4px 14px; }
  .cap{ font-size:12.5px; }
  footer.foot{ padding:0 14px 36px; }
}
@media (prefers-reduced-motion: reduce){
  *{ scroll-behavior:auto !important; }
  details.sec > summary::after{ transition:none; }
}
