/* Blueprint drawing set: shared sheet layout, typography, and diagram primitives.
   Two inks only: drafting blue for what is bought, burnt orange for what the organisation builds.
   Red pencil is reserved for warnings, like a revision mark on a real drawing. */

:root {
  /* Default sheet: drafting-blue ink on warm reading paper. */
  color-scheme: light;
  --bg: #f4ecd8;
  --bg-deep: #ebe1c8;
  --line: #1f4a8c;
  --line-dim: rgba(31, 74, 140, 0.5);
  --line-faint: rgba(31, 74, 140, 0.2);
  --grid-minor: rgba(31, 74, 140, 0.055);
  --grid-major: rgba(31, 74, 140, 0.11);
  --ink: #1b2a47;
  --muted: #586480;
  --own: #b5461b;
  --own-wash: rgba(181, 70, 27, 0.1);
  --on-own: #fff8ea;
  --warn: #a8123e;
  --warn-wash: rgba(168, 18, 62, 0.07);
  --panel: rgba(255, 251, 238, 0.6);
  --display: 'Bricolage Grotesque', 'Be Vietnam Pro', system-ui, sans-serif;
  --body: 'Be Vietnam Pro', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --measure: 68ch;
  --gut: clamp(16px, 4vw, 44px);
}

/* Alternate sheet: the classic white-on-blue print, for reading in the dark. */
:root[data-theme='blue'] {
  color-scheme: dark;
  --bg: #0d326c;
  --bg-deep: #0a2857;
  --line: #dbe8ff;
  --line-dim: rgba(219, 232, 255, 0.42);
  --line-faint: rgba(219, 232, 255, 0.2);
  --grid-minor: rgba(219, 232, 255, 0.055);
  --grid-major: rgba(219, 232, 255, 0.11);
  --ink: #edf3ff;
  --muted: #a9c2ea;
  --own: #ffb65c;
  --own-wash: rgba(255, 182, 92, 0.14);
  --on-own: #10264d;
  --warn: #ff9f8a;
  --warn-wash: rgba(255, 159, 138, 0.1);
  --panel: rgba(8, 32, 74, 0.55);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 76px; }

body {
  margin: 0;
  color: var(--ink);
  font: 400 17px/1.7 var(--body);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  overflow-x: hidden;
}

/* The drawing border that every sheet carries. */
body::before {
  content: '';
  position: fixed;
  inset: 8px;
  border: 1px solid var(--line-dim);
  pointer-events: none;
  z-index: 30;
}

a { color: inherit; text-decoration-color: var(--line-dim); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: var(--own); color: var(--own); }
:focus-visible { outline: 2px solid var(--own); outline-offset: 3px; }

.skip { position: absolute; left: -999px; top: 12px; z-index: 50; background: var(--own); color: var(--on-own); padding: 8px 14px; }
.skip:focus { left: 20px; }

.wrap { width: min(1180px, 100%); margin-inline: auto; padding-inline: var(--gut); }

/* ---------- sheet strip (top navigation) ---------- */

.strip {
  position: sticky; top: 8px; z-index: 20;
  margin: 8px 8px 0;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line-dim);
}
.strip-in { display: flex; align-items: stretch; gap: 0; min-height: 46px; }
.strip-name {
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  font: 600 12px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; text-decoration: none;
  border-right: 1px solid var(--line-dim); white-space: nowrap;
}
.strip-name svg { flex: none; }
.sheets { display: flex; flex: 1; overflow-x: auto; scrollbar-width: none; margin: 0; padding: 0; list-style: none; }
.sheets::-webkit-scrollbar { display: none; }
.sheets a {
  display: flex; align-items: center; gap: 8px; height: 100%; padding: 0 14px;
  font: 500 12px/1 var(--mono); letter-spacing: 0.04em; text-decoration: none; white-space: nowrap;
  color: var(--muted); border-right: 1px solid var(--line-faint);
}
.sheets a b { font-weight: 600; color: var(--line); }
.sheets a:hover { color: var(--ink); background: var(--own-wash); }
.sheets a[aria-current='page'] { color: var(--on-own); background: var(--own); }
.sheets a[aria-current='page'] b { color: inherit; }
.theme {
  flex: none; padding: 0 14px; background: none; border: 0; border-left: 1px solid var(--line-dim);
  color: var(--muted); font: 500 12px/1 var(--mono); letter-spacing: 0.06em; cursor: pointer;
}
.theme:hover { color: var(--own); }

/* ---------- sheet head ---------- */

.head { padding-block: clamp(40px, 8vw, 96px) clamp(24px, 4vw, 48px); }
.head-grid { display: grid; gap: 28px 56px; grid-template-columns: minmax(0, 1fr); align-items: end; }
@media (min-width: 900px) { .head-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); } }
.sheet-no {
  display: inline-flex; align-items: baseline; gap: 12px; margin: 0 0 18px;
  font: 500 13px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.sheet-no b { font: 600 13px/1 var(--mono); color: var(--on-own); background: var(--own); padding: 5px 8px; letter-spacing: 0.08em; }
h1 {
  margin: 0; font: 700 clamp(34px, 6.2vw, 68px)/1.04 var(--display); letter-spacing: -0.02em; text-wrap: balance;
}
h1 em { font-style: normal; color: var(--own); }
.lede { margin: 22px 0 0; max-width: 60ch; font-size: clamp(18px, 2vw, 21px); line-height: 1.6; color: var(--ink); }
.head-note { margin: 0; padding: 14px 0 0; border-top: 1px solid var(--line-dim); font: 400 13px/1.7 var(--mono); color: var(--muted); }
.head-note b { color: var(--ink); font-weight: 500; }

/* ---------- sections ---------- */

.sec { padding: clamp(36px, 6vw, 72px) 0; border-top: 1px solid var(--line-faint); }
.sec-head { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 22px; }
/* Detail marker: the circle an architect draws to say "see detail N on sheet X". */
.mark {
  flex: none; width: 52px; height: 52px; border: 1.5px solid var(--line); border-radius: 50%;
  display: grid; grid-template-rows: 1fr 1fr; text-align: center; font: 600 12px/1 var(--mono);
  background: var(--bg);
}
.mark span { display: grid; place-items: center; }
.mark span:first-child { border-bottom: 1.5px solid var(--line); font-size: 15px; }
.mark span:last-child { font-size: 9.5px; letter-spacing: 0.06em; color: var(--muted); }
h2 { margin: 4px 0 0; font: 700 clamp(24px, 3.4vw, 36px)/1.15 var(--display); letter-spacing: -0.015em; text-wrap: balance; }
h3 { margin: 34px 0 8px; font: 600 19px/1.3 var(--display); }
.prose { max-width: var(--measure); }
.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose li::marker { color: var(--own); }
strong { font-weight: 600; }
code, kbd { font: 500 0.86em var(--mono); padding: 1px 5px; border: 1px solid var(--line-faint); background: var(--panel); }
.own { color: var(--own); }
pre { margin: 20px 0; padding: 14px 16px; max-width: var(--measure); overflow-x: auto; border: 1px solid var(--line-dim); background: var(--bg-deep); font: 400 13px/1.65 var(--mono); tab-size: 2; }
pre code { padding: 0; border: 0; background: none; font: inherit; }
pre .c { color: var(--muted); }
pre .k { color: var(--own); }

.cols { display: grid; gap: 28px 48px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .cols { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
  .cols.flip { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
}

/* ---------- figures ---------- */

.fig { margin: 28px 0; border: 1px solid var(--line-dim); background: var(--panel); }
.fig-body { overflow-x: auto; padding: 10px; }
.fig svg { display: block; width: 100%; height: auto; min-width: var(--min, 0); }
.fig figcaption {
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; padding: 9px 12px;
  border-top: 1px solid var(--line-dim); font: 400 12px/1.5 var(--mono); color: var(--muted);
}
.fig figcaption b { color: var(--ink); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.fig figcaption .cap { flex: 1 1 260px; }
.scroll-hint { display: none; }
@media (max-width: 720px) { .fig[style*='--min'] .scroll-hint { display: inline; color: var(--own); } }

.ctl { display: inline-flex; border: 1px solid var(--line-dim); }
.ctl button {
  min-width: 40px; min-height: 34px; padding: 0 10px; background: none; border: 0; border-right: 1px solid var(--line-dim);
  color: var(--ink); font: 500 12px/1 var(--mono); cursor: pointer;
}
.ctl button:hover { background: var(--own-wash); color: var(--own); }
.ctl output { display: grid; place-items: center; min-width: 52px; padding: 0 8px; font: 500 12px/1 var(--mono); color: var(--own); }

.steps { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line-dim); counter-reset: step; }
.steps li {
  counter-increment: step; position: relative; padding: 10px 12px 10px 48px;
  border-bottom: 1px solid var(--line-faint); font-size: 15px; line-height: 1.55; color: var(--muted); cursor: pointer;
  transition: color 0.25s, background 0.25s;
}
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(step, decimal-leading-zero); position: absolute; left: 14px; top: 10px; font: 600 12px/1.9 var(--mono); color: var(--line-dim); }
.steps li.on { color: var(--ink); background: var(--own-wash); }
.steps li.on::before { color: var(--own); }
.steps li b { color: var(--ink); font-weight: 600; }

/* ---------- SVG drawing primitives ---------- */

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
svg text { font-family: var(--body); fill: var(--ink); }
.s { fill: none; stroke: var(--line); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.s2 { stroke-width: 2.25; }
.s-thin { stroke-width: 1; }
.s-dim { stroke: var(--line-dim); }
.s-faint { stroke: var(--line-faint); }
.s-dash { stroke-dasharray: 6 5; }
.s-own { stroke: var(--own); }
.s-warn { stroke: var(--warn); }
.f-bg { fill: var(--bg); }
.f-deep { fill: var(--bg-deep); }
.f-own { fill: var(--own-wash); }
.f-warn { fill: var(--warn-wash); }
.f-line { fill: var(--line); }
.f-ownsolid { fill: var(--own); }
.f-warnsolid { fill: var(--warn); }
.hatch { fill: url(#hatch); }
.hatch-own { fill: url(#hatch-own); }
.t { font-size: 13px; }
.t-s { font-size: 11.5px; }
.t-h { font: 600 15px var(--display); }
.t-xl { font: 700 22px var(--display); }
.t-m { font: 500 10.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; fill: var(--muted); }
.t-mc { font: 500 11.5px var(--mono); }
.t-dim { fill: var(--muted); }
.t-own { fill: var(--own); }
.t-warn { fill: var(--warn); }
.t-inv { fill: var(--on-own); }
.mid { text-anchor: middle; }
.end { text-anchor: end; }

/* Lines draw themselves when the figure scrolls into view. */
.js .fig .draw { stroke-dasharray: 1; stroke-dashoffset: 1; }
.js .fig.in .draw { stroke-dashoffset: 0; transition: stroke-dashoffset 1.1s cubic-bezier(0.6, 0, 0.2, 1) var(--d, 0s); }
.js .fig .pop { opacity: 0; transform: translateY(8px); }
.js .fig.in .pop { opacity: 1; transform: none; transition: opacity 0.5s ease var(--d, 0s), transform 0.5s ease var(--d, 0s); }

/* Something moving along a connector: data, a request, a release. */
.flow { fill: none; stroke: var(--own); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 1 13; animation: flow 1.1s linear infinite; }
.flow-slow { animation-duration: 2.2s; }
.flow-line { stroke: var(--line); }
@keyframes flow { to { stroke-dashoffset: -14; } }
.blink { animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.spin { transform-box: fill-box; transform-origin: center; animation: spin 9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Step-through figures: [data-s] lights up on its step, [data-from] appears and stays. */
.js [data-steps] svg [data-s] { opacity: 0.22; transition: opacity 0.45s ease; }
.js [data-steps] svg [data-s].on { opacity: 1; }
.js [data-steps] svg [data-from] { opacity: 0; transition: opacity 0.45s ease; }
.js [data-steps] svg [data-from].on { opacity: 1; }
.js [data-steps] svg [data-until] { transition: opacity 0.45s ease; }
.js [data-steps] svg [data-until].off { opacity: 0; }

/* ---------- schedules (tables) ---------- */

.table { margin: 26px 0; overflow-x: auto; border: 1px solid var(--line-dim); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-faint); border-right: 1px solid var(--line-faint); }
/* A floor on column width: on a phone the schedule scrolls sideways instead of stacking one word per line. */
td { min-width: 8.5em; }
@media (max-width: 700px) { td { min-width: 11em; } }
th:last-child, td:last-child { border-right: 0; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
thead th { font: 600 11px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line-dim); white-space: nowrap; }
tbody th { font-weight: 600; white-space: nowrap; }
td.yes { color: var(--own); }
td.no { color: var(--warn); }
.col-own { background: var(--own-wash); }

/* ---------- notes ---------- */

.note { margin: 24px 0; padding: 14px 18px; border-left: 3px solid var(--own); background: var(--own-wash); max-width: var(--measure); }
.note p { margin: 0; }
.note .tag, .rev .tag { display: block; margin-bottom: 4px; font: 600 11px/1.4 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--own); }
.rev { margin: 24px 0; padding: 14px 18px; border: 1.5px dashed var(--warn); border-radius: 14px; background: var(--warn-wash); max-width: var(--measure); }
.rev p { margin: 0; }
.rev .tag { color: var(--warn); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0; padding: 0; list-style: none; font: 400 12px/1.4 var(--mono); color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend svg { flex: none; }

.cards { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 26px 0; border: 1px solid var(--line-dim); background: var(--panel); }
.card { padding: 20px 20px 22px; border-right: 1px solid var(--line-faint); border-bottom: 1px solid var(--line-faint); text-decoration: none; display: block; }
.card .k { font: 600 11px/1 var(--mono); letter-spacing: 0.12em; color: var(--own); text-transform: uppercase; }
.card h3 { margin: 10px 0 6px; }
.card p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--muted); }
a.card:hover { background: var(--own-wash); color: inherit; }
a.card:hover h3 { color: var(--own); }

/* ---------- title block (sheet footer) ---------- */

.tb { margin: clamp(40px, 7vw, 80px) 0 28px; border: 1.5px solid var(--line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--bg-deep); }
@media (min-width: 860px) { .tb { grid-template-columns: 2fr 2fr 1fr 1fr; } }
.tb > * { padding: 12px 14px; border-right: 1px solid var(--line-dim); border-bottom: 1px solid var(--line-dim); min-width: 0; }
.tb .k { display: block; margin-bottom: 5px; font: 500 10px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.tb .v { font: 600 15px/1.3 var(--display); }
.tb .v.big { font-size: 26px; color: var(--own); }
.tb a { text-decoration: none; display: block; }
.tb a:hover { background: var(--own-wash); }
@media (min-width: 860px) { .tb .half { grid-column: span 2; } }
.foot { padding: 0 0 36px; font: 400 12px/1.7 var(--mono); color: var(--muted); }
.foot p { margin: 0; max-width: 90ch; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .flow, .blink, .spin { animation: none; }
  .js .fig .draw { stroke-dashoffset: 0; transition: none !important; }
  .js .fig .pop { opacity: 1; transform: none; transition: none !important; }
  .js [data-steps] svg [data-s], .js [data-steps] svg [data-from], .js [data-steps] svg [data-until] { transition: none; }
  .packet { display: none; }
}

@media print {
  .strip, .ctl, .theme { display: none; }
  body { background: #fff; color: #000; }
}
