@font-face {
  font-family: "Ledger Sans";
  src: local("Avenir Next Condensed"), local("Arial Narrow");
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #eef2ec;
  --paper-raised: #f8faf6;
  --ink: #17211d;
  --ink-soft: #52605a;
  --rule: #aab7ae;
  --blue: #0757c9;
  --rust: #c84e2f;
  --teal: #147a78;
  --dark: #17211d;
  --grid: rgba(23, 33, 29, 0.075);
  --measure: 72rem;
  --gutter: clamp(1rem, 4vw, 3.5rem);
  --sans: "Ledger Sans", "Arial Narrow", "Avenir Next Condensed", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: Menlo, Monaco, Consolas, monospace;
}

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

html {
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: var(--serif);
  font-size: clamp(1.05rem, 1.4vw, 1.2rem);
  line-height: 1.58;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--blue);
}

a:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 4px;
  border-radius: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  min-height: 2.75rem;
  padding: 0.65rem 1rem;
  color: white;
  background: var(--blue);
  font: 800 0.9rem/1.4 var(--sans);
  letter-spacing: 0.04em;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--ink);
  background: rgba(238, 242, 236, 0.94);
}

.header-inner,
.footer-inner {
  width: min(100%, var(--measure));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.header-inner {
  min-height: 4.25rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(0.75rem, 3vw, 2.5rem);
}

.brand {
  display: inline-grid;
  width: 2.75rem;
  min-height: 2.75rem;
  place-items: center;
  border: 1px solid var(--ink);
  color: var(--paper);
  background: var(--ink);
  font: 900 1rem/1 var(--sans);
  letter-spacing: 0.06em;
  text-decoration: none;
}

.utility-nav,
.language-nav,
.site-footer nav {
  display: flex;
  align-items: center;
  gap: clamp(0.35rem, 2vw, 1.5rem);
  font: 800 0.76rem/1.2 var(--sans);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.utility-nav a,
.language-nav a,
.site-footer nav a {
  display: inline-flex;
  min-width: 2.75rem;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
}

.language-nav a {
  min-width: 2.75rem;
  justify-content: center;
  border: 1px solid var(--ink);
  text-decoration: none;
}

.language-nav a[aria-current="page"] {
  color: var(--paper);
  background: var(--ink);
}

.hero {
  width: min(100%, 90rem);
  margin-inline: auto;
  padding: clamp(2.5rem, 7vw, 7rem) var(--gutter) clamp(3.5rem, 7vw, 7rem);
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(22rem, 0.96fr);
  align-items: end;
  gap: clamp(2.5rem, 7vw, 7rem);
  border-bottom: 1px solid var(--ink);
}

.hero-copy {
  max-width: 48rem;
}

.eyebrow,
.chapter-number,
.source-locator,
.ledger-heading,
.method-label,
.consultation-record span,
.method-note,
.site-footer,
.small-print {
  font-family: var(--sans);
}

.eyebrow,
.chapter-number {
  margin: 0 0 1rem;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: break-word;
}

h1 {
  max-width: 15ch;
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(3rem, 7.2vw, 7.4rem);
  font-stretch: condensed;
  font-weight: 900;
  letter-spacing: -0.055em;
  line-height: 0.91;
  text-wrap: balance;
}

.deck {
  max-width: 44rem;
  margin: clamp(1.5rem, 4vw, 2.5rem) 0 0;
  font-size: clamp(1.12rem, 1.75vw, 1.45rem);
  line-height: 1.48;
}

.source-locator {
  display: flex;
  max-width: 38rem;
  margin: 1.5rem 0 0;
  align-items: baseline;
  gap: 0.7rem;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.025em;
}

.source-locator span {
  flex: none;
  padding: 0.12rem 0.4rem;
  color: var(--paper);
  background: var(--teal);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scope-line,
.hero-boundary {
  max-width: 40rem;
  margin: 0.75rem 0 0;
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.45;
}

.scope-line {
  color: var(--ink-soft);
  font-weight: 750;
}

.hero-boundary {
  padding-left: 0.75rem;
  border-left: 4px solid var(--rust);
  color: var(--ink);
}

.ledger-figure {
  position: relative;
  margin: 0;
  border: 1px solid var(--ink);
  background: var(--paper-raised);
  box-shadow: 10px 10px 0 var(--rule);
}

.ledger-figure::before,
.ledger-figure::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.ledger-figure::before {
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 30px, rgba(23, 33, 29, 0.07) 31px);
}

.ledger-figure::after {
  top: -0.45rem;
  right: 1.25rem;
  width: 3.5rem;
  height: 0.9rem;
  background: var(--rust);
}

.ledger-heading {
  position: relative;
  z-index: 1;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.ledger-heading p {
  margin: 0;
}

.physical-layer {
  position: relative;
  z-index: 1;
  min-height: 8rem;
  padding: 2.4rem 1rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0;
}

.meter-node {
  display: grid;
  width: 4.4rem;
  aspect-ratio: 1;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 50%;
  color: var(--paper);
  background: var(--blue);
  font: 900 0.62rem/1 var(--mono);
  letter-spacing: 0.05em;
}

.meter-node:last-child {
  background: var(--teal);
}

.pipe-run {
  height: 1.25rem;
  border-block: 3px solid var(--ink);
  background: var(--paper);
}

.ledger-registers {
  position: relative;
  z-index: 1;
  padding: 0 1rem 1rem;
  display: grid;
  gap: 0.75rem;
}

.register {
  padding: 0.8rem;
  border: 1px solid var(--ink);
  background: rgba(238, 242, 236, 0.88);
}

.register p,
.register small {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.64rem;
  line-height: 1.35;
  text-transform: uppercase;
}

.allocation-track {
  position: relative;
  height: 1.9rem;
  margin: 0.55rem 0;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--ink);
  background:
    repeating-linear-gradient(135deg, transparent 0 8px, rgba(23, 33, 29, 0.08) 8px 9px),
    var(--paper);
}

.allocation-track span {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font: 800 0.58rem/1 var(--sans);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.allocation-toward-leak {
  box-shadow: inset 0 -5px 0 var(--rust);
}

.allocation-toward-input {
  box-shadow: inset 0 -5px 0 var(--blue);
}

.ledger-figure figcaption,
.balance-strip figcaption {
  position: relative;
  z-index: 1;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--ink);
  color: var(--ink-soft);
  background: var(--paper);
  font: 0.72rem/1.45 var(--sans);
}

.article-flow {
  background: var(--paper-raised);
}

.chapter {
  width: min(100%, 76rem);
  margin-inline: auto;
  padding: clamp(4rem, 9vw, 8rem) var(--gutter);
  border-bottom: 1px solid var(--rule);
}

.chapter h2 {
  max-width: 17ch;
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(2.4rem, 5.4vw, 5.5rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 0.96;
  text-wrap: balance;
}

.lead {
  max-width: 43rem;
  margin: clamp(1.5rem, 4vw, 2.5rem) 0 0;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  line-height: 1.5;
}

.method-pair {
  margin-top: clamp(2rem, 5vw, 4rem);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  border: 1px solid var(--ink);
  background: var(--ink);
}

.method-line {
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--paper);
}

.method-line p {
  margin: 0;
}

.method-line p:last-child {
  margin-top: 1rem;
}

.method-label {
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.balance-strip {
  margin: 1.25rem 0 0;
  border: 1px solid var(--ink);
  background: var(--paper);
}

.equation {
  padding: clamp(1rem, 2.5vw, 1.75rem);
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
}

.term,
.operator {
  display: grid;
  min-height: 3.4rem;
  place-items: center;
  font: 800 0.68rem/1 var(--mono);
  text-transform: uppercase;
}

.term {
  flex: 1 1 auto;
  padding: 0.5rem;
  border: 1px solid var(--rule);
}

.term-input {
  color: white;
  border-color: var(--blue);
  background: var(--blue);
}

.term-leak {
  color: white;
  border-color: var(--rust);
  background: var(--rust);
}

.term-gap {
  color: white;
  border-color: var(--teal);
  background: var(--teal);
}

.operator {
  flex: 0 0 1.3rem;
}

.allocation-steps {
  max-width: 53rem;
  margin: clamp(2rem, 5vw, 4rem) 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--ink);
}

.allocation-steps li {
  padding: 1.4rem 0;
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 1rem;
  border-bottom: 1px solid var(--ink);
}

.step-mark {
  display: grid;
  width: 2.75rem;
  min-height: 2.75rem;
  place-items: center;
  color: white;
  background: var(--blue);
  font: 900 0.8rem/1 var(--mono);
}

.chapter-dark {
  width: 100%;
  max-width: none;
  padding-inline: max(var(--gutter), calc((100vw - 76rem) / 2 + var(--gutter)));
  color: var(--paper);
  background: var(--dark);
}

.chapter-dark .chapter-number {
  color: #72b7ff;
}

.fixed-pipe {
  position: relative;
  max-width: 62rem;
  min-height: clamp(22rem, 42vw, 34rem);
  margin-top: clamp(2.5rem, 6vw, 5rem);
  overflow: hidden;
  border: 1px solid var(--rule);
  background:
    linear-gradient(rgba(238, 242, 236, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(238, 242, 236, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}

.fixed-baseline {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 51%;
  height: 2rem;
  border: 3px solid var(--paper);
  background: var(--teal);
}

.fixed-baseline::before,
.fixed-baseline::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 4.4rem;
  aspect-ratio: 1;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--dark);
  transform: translateY(-50%);
}

.fixed-baseline::before {
  left: -2.2rem;
}

.fixed-baseline::after {
  right: -2.2rem;
}

.fixed-baseline span {
  position: absolute;
  left: 50%;
  bottom: -3.4rem;
  width: max-content;
  max-width: 70vw;
  color: var(--paper);
  font: 700 0.72rem/1.3 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: translateX(-50%);
}

.overlay {
  position: absolute;
  width: 38%;
  padding: 1rem;
  border: 2px solid;
  font-family: var(--sans);
}

.overlay span,
.overlay b {
  display: block;
}

.overlay span {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.overlay b {
  margin-top: 0.45rem;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  line-height: 1.05;
}

.overlay-one {
  top: 10%;
  left: 8%;
  border-color: var(--rust);
  color: var(--paper);
  background: rgba(200, 78, 47, 0.2);
}

.overlay-two {
  right: 8%;
  bottom: 9%;
  border-color: #72b7ff;
  color: var(--paper);
  background: rgba(7, 87, 201, 0.25);
}

.boundary-note {
  max-width: 52rem;
  margin: 2rem 0 0;
  padding-left: 1rem;
  border-left: 5px solid var(--rust);
  color: #ced7d1;
  font-family: var(--sans);
  font-size: 0.9rem;
}

.safeguard-ledger {
  max-width: 62rem;
  margin: 2rem 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid #6f7d75;
}

.safeguard-ledger p {
  margin: 0;
  padding: 1rem;
  border-right: 1px solid #6f7d75;
  color: #dce4df;
  font: 0.78rem/1.45 var(--sans);
}

.safeguard-ledger p:last-child {
  border-right: 0;
}

.safeguard-ledger strong {
  display: block;
  margin-bottom: 0.35rem;
  color: white;
  font-size: 0.95rem;
}

.range-ledger {
  max-width: 64rem;
  margin: clamp(2.5rem, 6vw, 5rem) 0 0;
  border-top: 3px solid var(--ink);
}

.range-row {
  display: grid;
  grid-template-columns: minmax(13rem, 1.2fr) minmax(11rem, 1fr) minmax(15rem, 1.2fr);
  border-bottom: 1px solid var(--ink);
}

.range-row dt,
.range-row dd {
  margin: 0;
  padding: 1.3rem 1rem;
}

.range-row dt {
  font-weight: 700;
}

.range-row dd {
  border-left: 1px solid var(--ink);
  font-family: var(--sans);
}

.range-row span,
.range-row strong {
  display: block;
}

.range-row span {
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.range-row strong {
  margin-top: 0.4rem;
  color: var(--blue);
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  line-height: 1.15;
}

.small-print {
  max-width: 52rem;
  margin: 1.5rem 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.limits-list {
  max-width: 59rem;
  margin-top: clamp(2.5rem, 6vw, 5rem);
  counter-reset: limit;
  border-top: 1px solid var(--ink);
}

.limits-list p {
  position: relative;
  margin: 0;
  padding: 1.4rem 1rem 1.4rem 4.25rem;
  border-bottom: 1px solid var(--ink);
  counter-increment: limit;
}

.limits-list p::before {
  content: "0" counter(limit);
  position: absolute;
  left: 0;
  top: 1.5rem;
  color: var(--rust);
  font: 900 0.76rem/1 var(--mono);
}

.consultation-record {
  max-width: 60rem;
  margin: clamp(2.5rem, 6vw, 4rem) 0 2rem;
  border: 1px solid var(--ink);
}

.consultation-record p {
  margin: 0;
  padding: 1.2rem;
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 1.25rem;
  border-bottom: 1px solid var(--ink);
}

.consultation-record p:last-child {
  border-bottom: 0;
}

.consultation-record span {
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-link {
  display: inline-flex;
  min-height: 3.1rem;
  padding: 0.7rem 1rem;
  align-items: center;
  border: 2px solid var(--ink);
  color: var(--paper);
  background: var(--ink);
  font: 900 0.82rem/1.2 var(--sans);
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
}

.primary-link:hover {
  color: white;
  background: var(--blue);
}

.sources {
  background: #e2e9e2;
}

.source-list {
  max-width: 59rem;
  margin: clamp(2.5rem, 6vw, 4rem) 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--ink);
  counter-reset: source;
}

.source-list li {
  position: relative;
  padding: 1.4rem 0 1.4rem 4rem;
  border-bottom: 1px solid var(--ink);
  counter-increment: source;
}

.source-list li::before {
  content: "S" counter(source, decimal-leading-zero);
  position: absolute;
  top: 1.6rem;
  left: 0;
  color: var(--teal);
  font: 900 0.75rem/1 var(--mono);
}

.source-list a,
.source-list span {
  display: block;
}

.source-list a {
  width: fit-content;
  min-height: 2.75rem;
  padding-block: 0.45rem;
  font-weight: 700;
}

.source-list span {
  color: var(--ink-soft);
  font: 0.84rem/1.45 var(--sans);
}

.method-note {
  max-width: 50rem;
  margin: 1.6rem 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.site-footer {
  color: var(--paper);
  background: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
}

.footer-inner {
  min-height: 7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.footer-inner p {
  margin: 0;
}

.footer-inner p a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .ledger-figure {
    max-width: 38rem;
  }

  .range-row {
    grid-template-columns: 1fr 1fr;
  }

  .range-row dt {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--ink);
  }

  .range-row dd:first-of-type {
    border-left: 0;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 1rem;
    background-size: 20px 20px;
  }

  .header-inner {
    min-height: 3.75rem;
    grid-template-columns: auto 1fr;
  }

  .utility-nav {
    display: none;
  }

  .language-nav {
    justify-self: end;
  }

  .brand,
  .language-nav a {
    min-height: 2.75rem;
  }

  .hero {
    padding-top: 2.25rem;
    gap: 2.75rem;
  }

  h1 {
    max-width: 13ch;
    font-size: clamp(2.75rem, 13.2vw, 4.1rem);
    line-height: 0.92;
  }

  .deck {
    font-size: 1.05rem;
    line-height: 1.46;
  }

  .source-locator {
    display: block;
    line-height: 1.55;
  }

  .source-locator span {
    display: table;
    margin-bottom: 0.35rem;
  }

  .ledger-heading {
    display: grid;
  }

  .physical-layer {
    padding-inline: 0.75rem;
  }

  .meter-node {
    width: 3.6rem;
    font-size: 0.52rem;
  }

  .method-pair {
    grid-template-columns: 1fr;
  }

  .equation {
    display: grid;
    grid-template-columns: 1fr 2rem 1fr;
  }

  .term,
  .operator {
    min-height: 2.75rem;
  }

  .fixed-pipe {
    min-height: 28rem;
  }

  .fixed-baseline {
    left: 12%;
    right: 12%;
  }

  .overlay {
    width: 72%;
  }

  .overlay-one {
    top: 7%;
    left: 6%;
  }

  .overlay-two {
    right: 6%;
    bottom: 8%;
  }

  .range-row {
    grid-template-columns: 1fr;
  }

  .range-row dd,
  .range-row dd:first-of-type {
    border-top: 1px solid var(--rule);
    border-left: 0;
  }

  .safeguard-ledger {
    grid-template-columns: 1fr;
  }

  .safeguard-ledger p {
    border-right: 0;
    border-bottom: 1px solid #6f7d75;
  }

  .safeguard-ledger p:last-child {
    border-bottom: 0;
  }

  .consultation-record p {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .footer-inner {
    padding-block: 1.5rem;
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .skip-link {
    display: none;
  }

  body {
    background: white;
    font-size: 10pt;
  }

  .hero,
  .chapter {
    padding: 2rem 0;
  }

  .chapter-dark {
    color: var(--ink);
    background: white;
  }
}
