/* Physics of Buildings: house style (first site: well pressure tank).
   Signature (spec/experience.md): the sectioned cutaway. Every system is drawn the way a good service manual draws it,
   cut open along a plane, steel shown in 45° section hatching, water as a flat blue fill, air as a dotted field, and
   dimension lines that measure the thing the text is about. Type is a DIN-like grotesque (Barlow, from signage and
   technical labelling) set heavy and condensed for titles, over a sturdy text serif for reading. One accent: a
   signal vermilion, the colour of the "cut" and of the running pump. */

:root {
  --bg: #fff; --surface: #f4f4f1; --ink: #15171a; --ink-soft: #2f3236; --muted: #5f6368; --rule: #d9dad6;
  --accent: #c8361b; --accent-ink: #fff; --link: #b02f16; --focus: #b02f16; --mark: rgba(200,54,27,.08);
  --font-serif: "Source Serif 4", Charter, "Bitstream Charter", Georgia, serif;
  --font-sans: "Barlow", "Helvetica Neue", Arial, sans-serif;
  --font-cond: "Barlow Semi Condensed", "Barlow", "Arial Narrow", sans-serif;
  --font-display: var(--font-cond); --font-body: var(--font-serif); --font-ui: var(--font-sans);
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, monospace;
  --fs-body: 1.1875rem; --lh-body: 1.6; --prose: 41rem; --wide: 68rem; --radius: 2px;
  --fig-bg: #fff; --fig-surface: #f4f4f1; --fig-ink: #15171a; --fig-muted: #5c6066; --fig-grid: rgba(0,0,0,.08);
  --fig-grid-strong: rgba(0,0,0,.45); --fig-border: transparent;
  /* Fixed meanings across the publication:
     primary = water (and things measured in water: gallons, flow); ref = the switch band (cut-in / cut-out);
     second = the pump running (and the "cut" accent); third = air; ok = within a rule; warn = outside a rule. */
  --c-primary: #1f6fb2; --c-ref: #8a5800; --c-second: #c8361b; --c-third: #6b6f76; --c-ok: #0b7a55; --c-warn: #b8400f;
  --water: #1f6fb2; --water-fill: #cfe3f3; --air-dot: #8d9198; --steel: #15171a;
  --ctl-accent: #c8361b; --ctl-bg: #fff;
  --font-h1: var(--font-cond);
}
:root[data-theme="dark"] {
  --bg: #141618; --surface: #1d2023; --ink: #ecebe6; --ink-soft: #cfcdc6; --muted: #a2a49f; --rule: #34373b;
  --accent: #ff7a57; --link: #ff8d6d; --focus: #ff8d6d; --mark: rgba(255,122,87,.12);
  --fig-bg: #141618; --fig-surface: #1d2023; --fig-ink: #ecebe6; --fig-muted: #a6a8a3; --fig-grid: rgba(255,255,255,.09);
  --fig-grid-strong: rgba(255,255,255,.5);
  --c-primary: #69aee6; --c-ref: #e3a536; --c-second: #ff7a57; --c-third: #a7abb2; --c-ok: #3cc59b; --c-warn: #ff8d5c;
  --water: #69aee6; --water-fill: #1f3b55; --air-dot: #80858c; --steel: #ecebe6;
  --ctl-accent: #ff7a57; --ctl-bg: #1d2023;
}

/* ---------------------------------------------------------------- type */
body { font-feature-settings: "kern", "liga"; }
h1, h2, h3 { font-family: var(--font-cond); letter-spacing: -0.005em; }
h1 { font-weight: 700; line-height: 1.0; }
h2 { font-weight: 700; font-size: clamp(1.55rem, 3.4vw, 2rem); line-height: 1.12; }
h3 { font-weight: 600; font-size: 1.28rem; }
.prose { font-size: var(--fs-body); }
.prose p { hyphens: auto; -webkit-hyphens: auto; }
.prose strong { font-weight: 600; }
.prose .lede { font-size: 1.18em; line-height: 1.5; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: .35rem 0; }
var { font-family: var(--font-serif); font-style: italic; }
.eq { font-family: var(--font-serif); font-size: 1.2rem; }
.num, .w, .w-readout dd, .inline-out { font-variant-numeric: tabular-nums; }
.fig-n { font: 600 .82rem var(--font-sans); font-variant-caps: all-small-caps; letter-spacing: .04em; color: var(--accent); margin-right: .25em; font-size: 1rem; }
.dek { font-family: var(--font-serif); }

/* ---------------------------------------------------------------- header: a heavy rule like a manual's running head */
.site-header { border-bottom: 3px solid var(--ink); padding: .6rem var(--gutter); }
.wordmark { font: 700 1.14rem/1 var(--font-cond); letter-spacing: 0; display: inline-flex; align-items: center; gap: .5rem; }
.wordmark .wm-cut { width: 18px; height: 18px; color: var(--accent); flex: none; }
.site-nav a { font: 500 .95rem var(--font-sans); }

/* ---------------------------------------------------------------- home: title, then the sectioned system */
.home-hero { padding-top: 1rem; }
.home-hero .kicker { font: 600 .98rem var(--font-sans); color: var(--accent); }
.home-hero h1 { font-size: clamp(2.5rem, 10.5vw, 4.6rem); margin: .12em 0 .2em; max-width: 11ch; }
.home-hero .dek { font-size: clamp(1.08rem, 2.3vw, 1.32rem); line-height: 1.42; max-width: 31rem; margin-bottom: .2rem; }
@media (min-width: 980px) {
  .home-hero.has-hero { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); align-items: start; }
  .home-hero-text { padding-top: 2.5rem; }
}
.home-hero-fig figcaption { font-size: .9rem; }

/* ---------------------------------------------------------------- essays */
.essay-head { padding-top: 1.6rem; }
.essay-head .kicker { font: 600 .98rem var(--font-sans); color: var(--accent); }
.essay-head .kicker span { color: var(--accent); }
.essay-head h1 { font-size: clamp(2.2rem, 7vw, 4rem); margin: .15em 0 .25em; max-width: 17ch; }
.essay-head .dek { max-width: 36rem; }
.essay-hero { margin: 0; }
h2 { padding-top: .55rem; border-top: 1px solid var(--ink); }
.home-body h2, .tool-body h2 { border-top: 1px solid var(--ink); }

/* ---------------------------------------------------------------- figures: drawn on the page */
.figure figcaption { font: 400 .95rem/1.5 var(--font-sans); }
.w-readout { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.w-readout dt { font-size: .86rem; }
.w-readout dd { font-size: 1.12rem; white-space: nowrap; }
.w-seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.w-btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
input[type=range] { accent-color: var(--ctl-accent); }
.w-note { font-family: var(--font-sans); }
.w-say { font: 400 1rem/1.45 var(--font-sans); color: var(--ink-soft); margin: .2rem 0 0; }
.w-say strong { color: var(--fig-ink); font-weight: 600; }

/* Symptom → cause panel */
.dx { display: grid; gap: 0; border-top: 2px solid var(--ink); }
.dx-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: .3rem .9rem; align-items: center; width: 100%; text-align: left;
  background: transparent; border: 0; border-bottom: 1px solid var(--rule); padding: .7rem .2rem; cursor: pointer; color: var(--ink); font: inherit; min-height: 56px; }
.dx-row:hover .dx-s { text-decoration: underline; }
.dx-row[aria-pressed="true"] { background: var(--mark); box-shadow: inset 3px 0 0 var(--accent); }
.dx-s { font: 600 1.06rem/1.3 var(--font-sans); }
.dx-c { grid-column: 1; font: 400 .92rem/1.35 var(--font-sans); color: var(--muted); }
.dx-row svg { grid-column: 2; grid-row: 1 / span 2; width: 96px; height: 34px; }
.dx-say { margin: .8rem 0 0; font: 400 1rem/1.5 var(--font-sans); color: var(--ink-soft); min-height: 4.6em; }

/* Calculator */
.calc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem .9rem; margin: 0 0 .6rem; }
@media (min-width: 760px) { .calc-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.calc-f { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.calc-f label { font: 500 .92rem var(--font-sans); color: var(--fig-ink); }
.calc-f .calc-in { display: flex; align-items: center; gap: .35rem; }
.calc-f input { width: 100%; min-width: 0; font: 500 1.1rem var(--font-sans); font-variant-numeric: tabular-nums; padding: .4rem .5rem;
  border: 1px solid var(--fig-grid-strong); border-radius: var(--radius); background: var(--ctl-bg); color: var(--fig-ink); min-height: 44px; }
.calc-f input[aria-invalid="true"] { border-color: var(--c-warn); box-shadow: inset 0 0 0 1px var(--c-warn); }
.calc-f .unit { font: 400 .9rem var(--font-sans); color: var(--fig-muted); flex: none; }
.calc-msg { font: 500 .92rem/1.4 var(--font-sans); color: var(--c-warn); min-height: 1.4em; margin: 0 0 .3rem; }
.calc-out { display: grid; gap: .6rem 1.4rem; align-items: start; }
@media (min-width: 760px) { .calc-out { grid-template-columns: minmax(0, 1fr) 15rem; } }
.calc-big { font: 700 clamp(1.7rem, 5vw, 2.4rem)/1.05 var(--font-cond); margin: .1rem 0 .3rem; font-variant-numeric: tabular-nums; }
.calc-big small { font: 500 1rem var(--font-sans); color: var(--muted); }
.calc-verdict { font: 600 1.02rem/1.4 var(--font-sans); margin: 0 0 .5rem; padding-left: .7rem; border-left: 4px solid var(--c-ok); }
.calc-verdict.bad { border-left-color: var(--c-warn); }
.calc-table { width: 100%; font: 400 .95rem var(--font-sans); font-variant-numeric: tabular-nums; }
.calc-table td:last-child { text-align: right; font-weight: 600; white-space: nowrap; }
.calc-work { font: 400 1rem/1.6 var(--font-serif); margin: .6rem 0 0; padding: .6rem .8rem; background: var(--surface); overflow-x: auto; }
.calc-work p { margin: .2rem 0; }

/* Safety note: one plain rule, no box */
.safety { border-left: 4px solid var(--accent); padding: .1rem 0 .1rem 1rem; margin: 1.6rem 0; font-size: .98em; }
.safety strong { font-family: var(--font-sans); }
.safety p { hyphens: manual; -webkit-hyphens: manual; }
.calc-adv summary { font: 500 .95rem/2 var(--font-sans); cursor: pointer; min-height: 32px; }
.calc-adv .calc-f { margin: .4rem 0; max-width: 22rem; }

/* Sources */
.refs li { margin: .5rem 0; }
.ref-type { font: 500 .78rem var(--font-sans); color: var(--muted); }
.ref-note { display: block; font-size: .9rem; color: var(--muted); }

/* Symptom panel inside the home hero */
.dx-head { margin: 1.1rem 0 .3rem; padding-top: .6rem; border-top: 2px solid var(--ink); scroll-margin-top: 1rem; }
.dx-title { font: 700 1.3rem/1.2 var(--font-cond); margin: 0 0 .25rem; color: var(--fig-ink); }
.dx-note { font: 400 .92rem/1.4 var(--font-sans); color: var(--ink-soft); margin: 0 0 .3rem; }
.dx { border-top: 1px solid var(--rule); }
.dx-row { grid-template-columns: minmax(0, 1fr) 120px; }
.dx-row svg { width: 120px; height: 38px; }
.dx-k { font-weight: 600; color: var(--ink-soft); }
.dx-own { margin: 1rem 0 .3rem; font: 600 1rem var(--font-sans); }
@media (max-width: 600px) { .dx-row { grid-template-columns: minmax(0, 1fr) 84px; } .dx-row svg { width: 84px; height: 34px; } .prose p, .prose li { hyphens: manual; -webkit-hyphens: manual; } }
.eq .nw { white-space: nowrap; }
.eq-br { display: none; }
.eq { padding-right: 2.4rem; }
@media (max-width: 600px) {
  .eq-br { display: block; }
  .eq { padding-right: 0; }
  .eq-label { position: static; display: block; text-align: right; margin-top: .2rem; }
}

/* Scroll story: the pinned simulation */
.w-compact > .lf-steady, .w-compact > .w-readout { display: none; }
.story-step h3 { margin-top: .2rem; font-size: 1.3rem; }
.story-step p { font-size: 1.02rem; }
.story-figure .figure { margin: 0; }
@media (max-width: 999px) {
  .story-figure .w-stage { margin-top: .3rem; }
  .story-figure .w-toolbar, .story-figure .w-compact > .w-deck { display: none; }
  .story-figure { border-bottom: 1px solid var(--rule); }
}
.dx-row { text-decoration: none; }
