/* Theme: a 1960s mobile home park drawn in a 1960s engineering-manual style.
   Cream paper, ink, turquoise and coral, with mustard as decoration only. */
:root {
  --bg: #f3ecd9;
  --surface: #fbf7ec;
  --surface-strong: #efe5cc;
  --text: #2b2622;
  --muted: #574b40;
  --border: #cbb994;
  --accent: #11606b;
  --bypass: #6e6253;
  --shadow: rgba(43, 38, 34, 0.1);
  /* Chart marks. Validated as a pair on cream (dataviz validate_palette.js): data = turquoise, rule = coral. */
  --data: #008e9e;
  --rule: #c9502f;
  --mustard: #d9a43a;
  --display: Futura, "Futura PT", "Century Gothic", "Avenir Next", "Trebuchet MS", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.125rem;
  line-height: 1.65;
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.12em;
}

a:hover {
  text-decoration-thickness: 0.12em;
}

a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 0.2rem;
}

p,
ul,
ol,
table,
figure,
aside {
  margin-block: 0 1.25rem;
}

ul,
ol {
  padding-left: 1.35rem;
}

li + li {
  margin-top: 0.7rem;
}

.page-shell {
  width: min(100% - 2rem, 47.5rem);
  margin-inline: auto;
}

.site-header {
  padding: 2rem 0 1.5rem;
}

.eyebrow {
  margin-bottom: 0.5rem;
  color: var(--accent);
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  font-family: var(--display);
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  padding-bottom: 0.35rem;
  border-bottom: 3px solid var(--text);
  box-shadow: 0 3px 0 var(--bg), 0 6px 0 var(--mustard);
}

h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 4vw, 2.85rem);
}

h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.45rem, 3vw, 1.85rem);
}

h3 {
  margin: 1.6rem 0 0.6rem;
  font-size: 1.15rem;
}

.intro {
  max-width: 40rem;
}

.status {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.98rem;
}

.toc {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.toc ul {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 0.55rem 0.9rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

main {
  padding-bottom: 3rem;
}

section + section {
  margin-top: 2.7rem;
}

.callout {
  padding: 1rem 1.1rem;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-left: 0.35rem solid var(--accent);
  border-radius: 0.9rem;
  box-shadow: 0 0.45rem 1rem var(--shadow);
}

.diagram-figure {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 0.5rem 1.2rem var(--shadow);
}

.diagram {
  display: block;
  width: 100%;
  height: auto;
  font-family: inherit;
  color: var(--text);
}

.diagram-horizontal {
  display: none;
}

.diagram-vertical {
  max-width: 24rem;
  margin-inline: auto;
}

.diagram-box {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 2.5;
}

.flow {
  stroke: var(--data);
  stroke-width: 4;
}

.arrowhead-main {
  fill: var(--data);
  stroke: var(--data);
}

.bypass {
  fill: none;
  stroke: var(--bypass);
  stroke-width: 3;
  stroke-dasharray: 10 8;
}

.arrowhead-bypass {
  fill: var(--bypass);
  stroke: var(--bypass);
}

/* SVG font sizes are in viewBox units; each diagram scales them to a legible on-screen size. */
.box-label {
  fill: currentColor;
  font-weight: 700;
}

.box-sub-label,
.bypass-label {
  fill: var(--muted);
  font-weight: 500;
}

.diagram-vertical .box-label {
  font-size: 20px;
}

.diagram-vertical .box-sub-label {
  font-size: 17px;
}

.diagram-vertical .bypass-label {
  font-size: 15px;
}

.diagram-horizontal .box-label {
  font-size: 26px;
}

.diagram-horizontal .box-sub-label,
.diagram-horizontal .bypass-label {
  font-size: 22px;
}

.table-wrap {
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.table-wrap:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
  border-radius: 0.5rem;
}

/* Sized to fit a 390px phone; .table-wrap scrolls only on narrower screens. */
table {
  width: 100%;
  font-size: 1.0625rem;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
}

caption {
  margin-bottom: 0.85rem;
  font-weight: 700;
  text-align: left;
}

th,
td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

thead th {
  background: var(--surface-strong);
  text-align: left;
}

thead th:not(:first-child) {
  text-align: right;
}

tbody th,
tfoot th {
  text-align: left;
}

tbody th {
  font-weight: 500;
}

tfoot th,
tfoot td {
  background: var(--surface-strong);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.notes {
  color: var(--muted);
  font-size: 0.98rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.2rem 0 2rem;
  color: var(--muted);
  font-size: 0.98rem;
}

@media (min-width: 40rem) {
  .site-header {
    padding-top: 2.7rem;
  }

  .toc ul {
    flex-direction: row;
  }

  .toc li:not(:last-child)::after {
    content: "·";
    margin-left: 0.9rem;
    color: var(--muted);
  }

  table {
    font-size: 1.125rem;
  }

  th,
  td {
    padding: 0.8rem 0.9rem;
  }
}

/* The five-box row only reads well once the content column is near full width. */
@media (min-width: 48rem) {
  .diagram-horizontal {
    display: block;
  }

  .diagram-vertical {
    display: none;
  }

  .diagram-figure {
    padding: 1.25rem;
  }
}

@media print {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-strong: #ffffff;
    --text: #000000;
    --muted: #000000;
    --border: #000000;
    --accent: #000000;
    --bypass: #000000;
    --shadow: transparent;
  }

  body {
    background: #ffffff;
    color: #000000;
  }

  .page-shell {
    width: 100%;
    max-width: none;
  }

  .diagram-figure,
  .callout,
  .table-wrap,
  table,
  tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .diagram-horizontal {
    display: block;
  }

  .diagram-vertical {
    display: none;
  }

  .table-wrap {
    overflow: visible;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.95em;
  }
}

/* ---- Cost chart (inline SVG; font sizes are in viewBox units, 400 wide) ---- */
.chart-figure {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  max-width: 30rem;
}

.chart-heading {
  font-size: 20px;
  font-weight: 700;
  fill: var(--text);
}

.chart-label {
  font-size: 18px;
  fill: var(--text);
}

.chart-value {
  font-size: 18px;
  fill: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chart-value-strong {
  font-weight: 700;
  fill: var(--text);
}

.chart-track {
  stroke: var(--border);
  stroke-width: 4;
  stroke-linecap: round;
}

.chart-range {
  fill: var(--surface-strong);
  stroke: var(--data);
  stroke-width: 2;
}

.chart-expected,
.chart-bar {
  fill: var(--data);
}

/* ---- Illustrations ---- */
.art-figure {
  margin: 1.5rem 0;
}

.art-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

figcaption {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.art-figure img {
  background: var(--surface);
}

/* ---- Engineering plates: the new figures ----
   Each figure is a numbered "plate", as in a 1960s service manual.
   SVG font sizes are in viewBox units; plates are 480 wide and capped at 32rem,
   so 16-unit text renders at about 12-16px from phone to desktop. */
.plate {
  margin: 1.75rem 0;
  padding: 1rem 1rem 0.9rem;
  background: var(--surface);
  border: 2px solid var(--text);
  border-radius: 4px;
  box-shadow: 5px 5px 0 var(--mustard);
}

.plate figcaption {
  margin-top: 0.75rem;
  color: var(--muted);
}

.fig-no {
  margin-right: 0.4em;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.plate table {
  margin: 0;
}

.plate-svg {
  display: block;
  width: 100%;
  max-width: 32rem;
  height: auto;
  margin-inline: auto;
  font-family: var(--display);
  overflow: visible;
}

.plate .art {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
}

.p-title { font-size: 17px; font-weight: 700; fill: var(--text); letter-spacing: 0.06em; text-transform: uppercase; }
.p-label { font-size: 16px; font-weight: 700; fill: var(--text); }
.p-label-s { font-size: 15px; font-weight: 700; fill: var(--text); }
.p-text { font-size: 16px; fill: var(--text); }
.p-sub { font-size: 15px; fill: var(--muted); }
.p-num { font-size: 15px; fill: var(--muted); font-variant-numeric: tabular-nums; }

/* On phones the plates run edge to edge, so the diagrams get every pixel of width. */
@media (max-width: 39.99rem) {
  .plate {
    margin-inline: -1rem;
    padding: 0.75rem 0.5rem 0.75rem;
    border-left-width: 0;
    border-right-width: 0;
    border-radius: 0;
    box-shadow: 0 5px 0 var(--mustard);
  }

  .plate figcaption,
  .plate .numbered-key,
  .plate .legend-row {
    padding-inline: 0.5rem;
  }
}
.p-badge { font-size: 15px; font-weight: 700; fill: var(--surface); }

.p-box { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
.p-box-soft { fill: var(--surface-strong); stroke: var(--border); stroke-width: 1.5; }
.p-box-key { fill: var(--surface-strong); stroke: var(--data); stroke-width: 3; }
.p-box-maybe { fill: var(--surface); stroke: var(--text); stroke-width: 2; stroke-dasharray: 7 5; }
.p-home { fill: var(--surface-strong); stroke: var(--text); stroke-width: 2.5; }
.p-axis { stroke: var(--text); stroke-width: 2; }
.p-tick { stroke: var(--text); stroke-width: 1.5; }
.p-grid { stroke: var(--border); stroke-width: 1; }
.p-data { fill: var(--data); }
.p-data-line { fill: none; stroke: var(--data); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.p-pipe-small { fill: none; stroke: var(--data); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.p-pipe-big { fill: none; stroke: var(--data); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.p-pipe-alt { fill: none; stroke: var(--data); stroke-width: 3; stroke-dasharray: 2 7; stroke-linecap: round; }
.p-rule { stroke: var(--rule); stroke-width: 2.5; }
.p-rule-dash { stroke: var(--rule); stroke-width: 2.5; stroke-dasharray: 6 4; }
.p-rule-fill { fill: var(--rule); }
.p-band { fill: var(--rule); opacity: 0.12; }
.p-arrow { fill: none; stroke: var(--text); stroke-width: 2; }
.p-arrowhead { fill: var(--text); }
.p-ink { fill: var(--text); }
.p-mustard { fill: var(--mustard); }
.p-water { fill: var(--data); opacity: 0.35; }

/* Matrix and rule tables in the plate style. The matrix fits a 390px phone, so it only scrolls on very narrow screens. */
.plate .table-wrap { margin: 0; }
@media (min-width: 24rem) {
  .plate .table-wrap { overflow: visible; }
}
.matrix td, .matrix th { text-align: center; }
.matrix tbody th { text-align: left; }
.matrix thead th:not(:first-child) { text-align: center; }
.mark { display: inline-flex; align-items: center; gap: 0.45em; font-family: var(--display); font-weight: 700; }
.dot { display: inline-block; flex: none; width: 0.8em; height: 0.8em; margin-right: 0.35em; border-radius: 50%; border: 2px solid var(--text); vertical-align: -0.05em; }
.mark .dot { margin-right: 0; }
.dot-yes { background: var(--data); border-color: var(--data); }
.dot-no { background: transparent; border-color: var(--muted); }
.dot-dep { background: linear-gradient(90deg, var(--muted) 50%, transparent 50%); border-color: var(--muted); }
.legend-row { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin: 0.75rem 0 0; padding: 0; list-style: none; font-size: 0.95rem; color: var(--muted); }
.legend-row li { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.chips li { margin: 0; padding: 0.35rem 0.75rem; border: 2px solid var(--text); border-radius: 999px; background: var(--surface-strong); font-size: 0.98rem; }
.chips .chip-big { background: var(--mustard); font-weight: 700; }

.rule-card { display: grid; gap: 0.6rem; margin: 0; padding: 0; list-style: none; }
.rule-card li { display: grid; grid-template-columns: 1fr auto; gap: 0.75rem; align-items: center; margin: 0; padding: 0.6rem 0.8rem; border: 2px solid var(--text); border-radius: 4px; background: var(--surface-strong); }
.rule-card .then { font-family: var(--display); font-weight: 700; white-space: nowrap; }
.rule-card .arrow { color: var(--rule); }

.numbered-key { margin: 0.75rem 0 0; padding-left: 1.6rem; }
.numbered-key li::marker { font-family: var(--display); font-weight: 700; color: var(--rule); }

@media print {
  .chart-figure,
  .art-figure,
  .plate {
    break-inside: avoid;
  }

  .plate {
    box-shadow: none;
  }
}
