/* Te trage curentul — ozalid prints of 1970s housing plans: violet-blue ink on cool paper */
:root {
  --paper: #eceef5; --room: #f8f9fd; --ink: #24226a; --ink-soft: #46448a; --ink-faint: #6b6aa2;
  --wall: #d6d8e8; --hatch: #b4b6d2; --accent: #b93c0e; --fresh: #2f9fc0; --probe: #9c1458;
  --text: #1b1a4a; --muted: #3c3b76; --line: #c7c9df; --line-soft: #d9dbea; --card: #f7f8fc;
  --vh: 1vh;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #0e1023; --room: #161a34; --ink: #d3d6ff; --ink-soft: #b0b4ea; --ink-faint: #8a8fc6;
  --wall: #232849; --hatch: #343b69; --accent: #ff9b5c; --fresh: #4fc4de; --probe: #ff7ab0;
  --text: #ebecff; --muted: #c6c9f2; --line: #353a66; --line-soft: #272b50; --card: #14172e;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1023; --room: #161a34; --ink: #d3d6ff; --ink-soft: #b0b4ea; --ink-faint: #8a8fc6;
    --wall: #232849; --hatch: #343b69; --accent: #ff9b5c; --fresh: #4fc4de; --probe: #ff7ab0;
    --text: #ebecff; --muted: #c6c9f2; --line: #353a66; --line-soft: #272b50; --card: #14172e;
    color-scheme: dark;
  }
}
[hidden] { display: none !important; }
svg[hidden] { display: none; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--text);
  font: 400 1.075rem/1.62 Newsreader, Georgia, "Times New Roman", serif;
  font-optical-sizing: auto;
}
a { color: var(--ink); text-underline-offset: .18em; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--probe); outline-offset: 2px; }
.mono, .kicker, .topbar, .panel h3, .legend, .status, .readout dt, .preset, .seat, .opts, button.reset, .share-label, .fig-note, .sources h3 {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--card); padding: 6px 10px; z-index: 50; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; height: 44px; display: flex; align-items: center; gap: 14px; padding: 0 16px; padding-top: var(--inset-top, 0px); box-sizing: content-box;
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line-soft); font-size: .78rem; }
.topbar .home { text-decoration: none; color: var(--ink); font-weight: 500; letter-spacing: .02em; white-space: nowrap; }
.topbar .sp { flex: 1; }
.topbar a.lang { text-decoration: none; color: var(--muted); }
.theme { background: none; border: 1px solid var(--line); color: var(--ink); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.theme svg { width: 16px; height: 16px; }

/* hero */
.hero { padding: 16px 0 4px; }
.kicker { font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 10px; }
h1 { font-weight: 500; font-size: clamp(1.9rem, 4.2vw, 3.25rem); line-height: 1.08; letter-spacing: -.012em; margin: 0 0 14px; max-width: 22ch; color: var(--ink); }
.deck { font-size: clamp(1.08rem, 1.6vw, 1.28rem); max-width: 46rem; margin: 0; color: var(--muted); }

/* lab */
.lab { max-width: 1320px; margin: 0 auto; padding: 12px 20px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.stage-wrap { position: sticky; top: calc(44px + var(--inset-top, 0px)); z-index: 5; background: var(--paper); margin: 0 -20px; padding: 6px 20px 4px; }
.stage { position: relative; width: 100%; height: min(calc(var(--vh) * 36), 92vw); touch-action: pinch-zoom; }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: pinch-zoom; }
#mini { display: none; position: absolute; left: 50%; top: 2px; transform: translateX(-50%); white-space: nowrap; font: 500 .72rem/1.2 "IBM Plex Mono", monospace; color: var(--ink); background: color-mix(in srgb, var(--paper) 86%, transparent); padding: 3px 7px; border-radius: 3px; pointer-events: none; }
.tip { position: absolute; transform: translate(12px, -130%); pointer-events: none; background: var(--ink); color: var(--paper); font: 500 .74rem/1.3 "IBM Plex Mono", monospace; padding: 5px 8px; border-radius: 3px; white-space: nowrap; z-index: 6; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: .7rem; color: var(--muted); margin-top: 4px; }
.ramp { width: 200px; height: 8px; border-radius: 2px; background: linear-gradient(90deg, transparent, #8cc9d4 20%, #2f9fb0 42%, #e2a23b 62%, #d9622b 82%, #b8243a); border: 1px solid var(--line); }
:root[data-theme="dark"] .ramp { background: linear-gradient(90deg, transparent, #1f6f86 20%, #2bb3b0 42%, #e6b84a 62%, #f07a3a 82%, #ff4d5e); }
.ramp { position: relative; }
.ramp .felt { position: absolute; left: 35.4%; top: -4px; width: 2px; height: 14px; background: var(--ink); }
.ramp-wrap { display: inline-flex; align-items: center; gap: 6px; }
.status { font-size: .7rem; color: var(--muted); }
.status[data-steady="0"]::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 6px; animation: pulse 1.2s infinite; vertical-align: 1px; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .status[data-steady="0"]::before { animation: none; } }
.hint { font-size: .9rem; color: var(--muted); margin: 6px 0 0; max-width: 60ch; }

.side { min-width: 0; }
.panel { background: var(--card); border: 1px solid var(--line-soft); border-radius: 6px; padding: 16px; margin-bottom: 26px; }
.panel h3 { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin: 18px 0 8px; }
.panel h3:first-child { margin-top: 0; }
.readout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; }
.readout div { min-width: 0; }
.readout dt { font-size: .66rem; letter-spacing: .04em; color: var(--muted); line-height: 1.3; }
.readout dd { margin: 2px 0 0; font: 500 1.65rem/1.1 Newsreader, Georgia, serif; color: var(--ink); font-variant-numeric: tabular-nums; }
.readout dd small { font-size: .8rem; color: var(--muted); }
.where { font: 500 .8rem/1.3 "IBM Plex Mono", monospace; color: var(--ink); margin: 0 0 8px; }
.where span { color: var(--muted); font-weight: 400; }
.drbar { height: 6px; border-radius: 3px; margin: 10px 0 8px; position: relative; background: linear-gradient(90deg, var(--line-soft) 0 10%, var(--line) 10% 20%, color-mix(in srgb, var(--accent) 35%, var(--line)) 20% 30%, color-mix(in srgb, var(--accent) 60%, var(--line)) 30%); }
.drbar::after { content: ""; position: absolute; top: -4px; left: calc(var(--dr, 0%) - 1px); width: 2px; height: 14px; background: var(--ink); }
.say { margin: 0; font-size: 1rem; line-height: 1.45; color: var(--text); min-height: 2.9em; }
.presets, .seats { display: flex; flex-wrap: wrap; gap: 6px; }
.preset, .seat, button.reset { font-size: .74rem; border: 1px solid var(--line); background: transparent; color: var(--ink); padding: 7px 10px; border-radius: 3px; cursor: pointer; min-height: 36px; text-align: left; }
.preset:hover, .seat:hover, button.reset:hover { border-color: var(--ink); }
.preset[aria-current="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pnote { font-size: .92rem; color: var(--muted); margin: 8px 0 0; min-height: 0; }
.wind { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: center; }
#dial { width: 96px; height: 96px; cursor: grab; touch-action: none; border-radius: 50%; }
#dial text { font: 500 9px "IBM Plex Mono", monospace; fill: var(--muted); }
.wind label, .opts { font-size: .76rem; color: var(--muted); }
.wind .val { font: 500 .82rem "IBM Plex Mono", monospace; color: var(--ink); }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 32px; }
.opts { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.opts label { display: flex; gap: 8px; align-items: center; min-height: 30px; cursor: pointer; }
details.all summary { cursor: pointer; font: 500 .76rem "IBM Plex Mono", monospace; color: var(--ink); min-height: 32px; display: flex; align-items: center; }
#openings { list-style: none; padding: 0; margin: 6px 0 0; font-size: .74rem; }
#openings li { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 6px 0; border-top: 1px solid var(--line-soft); }
#openings .oname { font-family: "IBM Plex Mono", monospace; color: var(--ink); }
#openings [role=radiogroup] { display: flex; gap: 12px; flex-wrap: wrap; font-family: "IBM Plex Mono", monospace; color: var(--muted); }
#openings label { display: inline-flex; gap: 4px; align-items: center; min-height: 28px; cursor: pointer; }
.share { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.share-label { font-size: .7rem; color: var(--muted); margin-right: 4px; }
.share a, .share button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-soft); background: transparent; color: var(--ink); display: inline-grid; place-items: center; cursor: pointer; }
.share a:hover, .share button:hover { border-color: var(--accent); color: var(--accent); }
.share svg { width: 17px; height: 17px; }
@media (pointer: coarse) { .share a, .share button { width: 44px; height: 44px; } }
#sh-status { font-size: .74rem; color: var(--muted); }

/* story */
.story section { margin: 0 0 40px; scroll-margin-top: 90px; }
.story h2 { font-weight: 500; font-size: clamp(1.35rem, 2.1vw, 1.7rem); line-height: 1.2; margin: 0 0 12px; color: var(--ink); }
.story p { margin: 0 0 14px; }
.story .num { font-variant-numeric: tabular-nums; }
.show { font: 500 .76rem "IBM Plex Mono", monospace; border: 1px solid var(--ink); background: transparent; color: var(--ink); padding: 8px 12px; border-radius: 3px; cursor: pointer; min-height: 38px; }
.show:hover { background: var(--ink); color: var(--paper); }
.formula { font: 400 1rem/1.5 "IBM Plex Mono", monospace; color: var(--ink); background: var(--card); border-left: 3px solid var(--accent); padding: 10px 14px; overflow-x: auto; margin: 0 0 14px; }
figure { margin: 6px 0 18px; }
figure svg { width: 100%; height: auto; display: block; }
figure svg text { font: 400 11px "IBM Plex Mono", monospace; fill: var(--muted); }
figure svg .ax { stroke: var(--line); }
figure svg .grid { stroke: var(--line-soft); }
figure svg .c20 { stroke: var(--accent); }
figure svg .c23 { stroke: var(--ink-soft); }
figure svg .c26 { stroke: var(--fresh); }
figure svg .lim { stroke: var(--ink-faint); stroke-dasharray: 3 4; }
figcaption, .fig-note { font-size: .86rem; color: var(--muted); margin-top: 6px; }
.limits { padding-left: 1.1em; margin: 0 0 14px; }
.limits li { margin-bottom: 6px; }
.sources { max-width: 1320px; margin: 0 auto; padding: 10px 20px 30px; border-top: 1px solid var(--line-soft); }
.sources h2 { font-weight: 500; color: var(--ink); font-size: 1.3rem; }
.sources ol { padding-left: 1.2em; font-size: .92rem; color: var(--muted); max-width: 70rem; }
.sources li { margin-bottom: 6px; }
.sources a, .story a { overflow-wrap: anywhere; }
footer { max-width: 1320px; margin: 0 auto; padding: 18px 20px 60px; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: .86rem; color: var(--muted); border-top: 1px solid var(--line-soft); }

@media (min-width: 1000px) {
  .lab { grid-template-columns: minmax(0, 1.3fr) minmax(360px, .7fr); grid-template-areas: "stage hero" "stage side"; grid-template-rows: auto 1fr; column-gap: 40px; row-gap: 8px; align-items: start; padding-top: 18px; }
  .hero { grid-area: hero; padding-top: 6px; }
  .side { grid-area: side; }
  h1 { font-size: clamp(1.9rem, 2.7vw, 2.75rem); }
  .deck { font-size: 1.08rem; }
  .stage-wrap { grid-area: stage; margin: 0; padding: 0; top: calc(56px + var(--inset-top, 0px)); }
  .stage { height: min(calc(var(--vh) * 100 - 100px), 940px); min-height: 460px; }
  #mini { display: none; }
  .story { padding-top: 6px; }
}
@media (max-width: 999px) {
  .story, .panel { max-width: 44rem; }
  .legend { flex-wrap: nowrap; font-size: .64rem; gap: 10px; margin-top: 2px; }
  .legend .cap { display: none; }
  .story section, .sources { scroll-margin-top: calc(var(--vh) * 36 + 96px); }
  .ramp { width: 90px; }
}
@media (max-width: 420px) {
  .readout dd { font-size: 1.35rem; }
  .wind { grid-template-columns: 84px 1fr; }
  #dial { width: 84px; height: 84px; }
}
@media print { .topbar, .stage-wrap, .panel, .share { display: none; } }
