/* GenomeRx site styles. Tokens, component rules and accepted decisions live in DESIGN.md. */

/* ---- tokens ---- */
:root {
  color-scheme: light dark;

  /* primitives: one blue-green accent hue, deep on paper and mint on the dark base */
  --l-paper: #f4f1ea;
  --l-ink: #1f2422;
  --l-ink-2: #4b504e;
  --l-ink-3: #656b69;
  --l-rule: #d3d0c7;
  --l-accent: #176a5e;
  --d-paper: #11161b;
  --d-ink: #eceeeb;
  --d-ink-2: #aeb7be;
  --d-ink-3: #8a95a0;
  --d-rule: #2a333b;
  --d-accent: #8fd1bd;

  /* semantic, light theme */
  --paper: var(--l-paper);
  --ink: var(--l-ink);
  --ink-2: var(--l-ink-2);
  --ink-3: var(--l-ink-3);
  --rule: var(--l-rule);
  --accent: var(--l-accent);
  --on-accent: var(--l-paper);
  --focus: var(--l-accent);

  --sans: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --wrap: 75rem;
  --gutter: 1.25rem;
  --gap: 1.5rem;
}

/* The dark mapping appears twice on purpose: once for the system setting, once for the stored choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: var(--d-paper);
    --ink: var(--d-ink);
    --ink-2: var(--d-ink-2);
    --ink-3: var(--d-ink-3);
    --rule: var(--d-rule);
    --accent: var(--d-accent);
    --on-accent: var(--d-paper);
    --focus: var(--d-accent);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: var(--d-paper);
  --ink: var(--d-ink);
  --ink-2: var(--d-ink-2);
  --ink-3: var(--d-ink-3);
  --rule: var(--d-rule);
  --accent: var(--d-accent);
  --on-accent: var(--d-paper);
  --focus: var(--d-accent);
}

:root[data-theme="light"] {
  color-scheme: light;
}

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

[hidden] {
  display: none !important;
}

html {
  background: var(--paper);
  scroll-padding-top: 4.5rem;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

h1,
h2 {
  font-weight: 700;
  letter-spacing: -.035em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.25rem, 1.2rem + 5.2vw, 3.5rem);
  line-height: 1.02;
}

h2 {
  font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem);
  line-height: 1.06;
}

h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1.25;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
  transition: background-color .15s ease, color .15s ease;
}

main a:not(.button):hover,
.site-footer a:hover {
  color: var(--ink);
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.wrap {
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin-inline: auto;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: var(--gap);
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Mono label: the only uppercase text on the site. */
.label,
.stage-tag,
.map-no,
.flow-no,
.flow-env,
.theme,
.footer-base {
  color: var(--ink-3);
  font: 400 .75rem/1.35 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.body {
  max-width: 38rem;
  color: var(--ink-2);
}

h2 + .body {
  margin-top: 1.25rem;
}

figcaption,
.note {
  margin-top: .75rem;
  color: var(--ink-3);
  font-size: .8125rem;
  line-height: 1.5;
}

/* Stage tag: a mono link from a page section back to its stage in the workflow diagram. */
.stage-tag {
  display: inline-block;
  text-decoration-thickness: 1px;
  text-underline-offset: .3em;
}

.tag + h2,
.tag + h3 {
  margin-top: .5rem;
}

dt .stage-tag {
  display: block;
  margin-top: .3rem;
  width: max-content;
}

.skip-link {
  position: absolute;
  top: -10rem;
  left: 1rem;
  z-index: 20;
  padding: .7rem 1rem;
  border: 1px solid var(--ink);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: .5rem;
}

/* ---- header ---- */
/* Sticky at every width, because under 64rem the Menu button is also the Close control and must stay in reach. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: .75rem;
  min-height: 3.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: .6rem;
  min-height: 3rem;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}

.brand-mark {
  flex: none;
}

.brand-mark rect {
  fill: var(--accent);
}

.brand-mark path {
  stroke: var(--on-accent);
}

.theme {
  display: flex;
  align-items: center;
}

.theme button {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0 .35rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.theme button:hover,
.theme button[aria-pressed="true"] {
  color: var(--ink);
}

.theme button[aria-pressed="true"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: .45em;
}

/* Menu button: script.js shows it, styles under 64rem hide the map until it opens, and the label reads Close while open. */
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-width: 5.75rem;
  min-height: 2.5rem;
  padding: 0 .7rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: 400 .75rem/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}

.menu-toggle[aria-expanded="true"] {
  background: var(--ink);
  color: var(--paper);
}

.menu-icon {
  flex: none;
}

.menu-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.menu-toggle[aria-expanded="true"] .menu-icon-open,
.menu-toggle:not([aria-expanded="true"]) .menu-icon-close {
  display: none;
}

/* Narrow phones: brand, theme control and Menu button share one row and must not touch (they overlapped at 360px and 320px before this). */
@media (max-width: 25.99rem) {
  .header-inner {
    column-gap: .5rem;
  }

  .theme button {
    padding: 0 .25rem;
  }

  /* Close is the wider label; the min-width still covers it, so the button never shifts between Menu and Close. */
  .menu-toggle {
    min-width: 5.25rem;
    padding: 0 .5rem;
  }
}

/* Below 360px only the mark fits; the link keeps its GenomeRx label. */
@media (max-width: 22.49rem) {
  .brand span {
    display: none;
  }
}

/* ---- hero ---- */
/* Text only: the delivery pipeline directly below is the explanatory device, so the hero carries no photograph. */
.hero-grid {
  row-gap: clamp(1.5rem, 3vw, 2rem);
  padding-top: clamp(2.5rem, 6vw, 3.5rem);
}

.hero-text h1 {
  max-width: 44rem;
  margin-top: 1.25rem;
}

.lede {
  max-width: 34rem;
  color: var(--ink-2);
  font-size: clamp(1.0625rem, .98rem + .4vw, 1.1875rem);
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 1.5rem;
  row-gap: .25rem;
  margin-top: 1.75rem;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  min-height: 3rem;
  padding: 0 1.15rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-size: .9375rem;
  font-weight: 700;
  text-decoration: none;
}

.button:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.arrow {
  flex: none;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  min-height: 3rem;
  color: var(--ink-2);
  font-size: .9375rem;
}

.map a[aria-current] .map-no {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---- system map ---- */
/* The only section navigation. In flow after the header without JavaScript; the panel behind the header Menu button under 64rem; a fixed panel in the right rail from 64rem (see below). */
.map {
  padding-block: .75rem .25rem;
  border-bottom: 1px solid var(--rule);
}

.map-list {
  display: flex;
  flex-wrap: wrap;
  column-gap: 1.25rem;
  margin-top: .15rem;
}

.map a {
  display: inline-flex;
  align-items: baseline;
  gap: .45rem;
  min-height: 2.5rem;
  color: var(--ink-2);
  font-size: .875rem;
  text-decoration: none;
}

.map-no {
  padding: .1em .25em;
  margin-left: -.25em;
}

main .map a:hover {
  text-underline-offset: .35em;
}

.map a[aria-current] {
  color: var(--ink);
  font-weight: 700;
}

/* Under 64rem with JavaScript the map is the Menu panel: hidden until opened, opaque, bordered, anchored under the button. */
@media (max-width: 63.99rem) {
  .has-js .map {
    display: none;
    position: fixed;
    top: 4rem;
    right: var(--gutter);
    z-index: 9;
    width: min(20rem, calc(100% - 2 * var(--gutter)));
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    padding: .7rem 1rem .6rem;
    border: 1px solid var(--ink);
    background: var(--paper);
  }

  @supports (height: 100dvh) {
    .has-js .map {
      max-height: calc(100dvh - 5rem);
    }
  }

  .has-js .map.is-open {
    display: block;
  }

  .has-js .map-list {
    flex-direction: column;
    margin-top: .35rem;
  }

  .has-js .map a {
    display: flex;
    min-height: 2.75rem;
    font-size: .9375rem;
  }
}

/* ---- sections ---- */
.section {
  padding-top: clamp(4.5rem, 10vw, 8rem);
}

/* The page closes on the footer rule with less air than a section opens with. */
.section-last {
  padding-bottom: clamp(3.5rem, 7vw, 5.5rem);
}

.section-head .body {
  margin-top: 1.25rem;
}

/* ---- illustrative 3D images: three still keyframes, one 1px rule around each and nothing else ---- */
/* The compute image sits beside the Build text from 56rem and under it below that; the analytics and research images
   sit under the Platform and Research intros. Each is shown as rendered in both themes: no filter, overlay, gradient,
   shadow, label or motion of its own. From 56rem each fills its five columns; stacked, the 34rem text measure caps it. */
.art {
  max-width: 34rem;
}

.art img {
  border: 1px solid var(--rule);
}

.art figcaption {
  margin-top: 1rem;
}

.side-art {
  margin-top: 1.5rem;
}

/* ---- build: two short text blocks and the compute image as one composition ---- */
.build {
  row-gap: 2.5rem;
  margin-top: clamp(2.5rem, 4vw, 3rem);
}

.build-part + .build-part {
  margin-top: 2rem;
}

.build-part h3 {
  font-size: 1.375rem;
  letter-spacing: -.02em;
}

.build-part p {
  max-width: 34rem;
  margin-top: .6rem;
  color: var(--ink-2);
}

/* ---- delivery pipeline ---- */
/* Five stages in one sequence, one detail per stage and one end state. Under 56rem the stages stack as full-width
   boxes with a short arrow between them, and a subgrid puts each stage's detail directly under its box, so the
   selected stage and its detail read as one block. From 56rem the stages share one row on one horizontal arrow and
   the selected stage's detail sits under the row, joined to it by the stage's accent underline. */
.section-flow {
  padding-top: clamp(2.5rem, 5vw, 3.5rem);
}

.flow {
  --flow-gap: 1.5rem;
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
}

.flow-stage {
  position: relative;
  display: grid;
}

.flow-stage + .flow-stage {
  margin-top: 2rem;
  scroll-margin-top: 2rem;
}

/* The whole stage is the link (the tab with scripts): number and name, action, environment or owner, output. */
.flow-stage a {
  display: grid;
  align-content: start;
  row-gap: .4rem;
  padding: .85rem 1rem 1rem;
  border: 1px solid var(--sel, var(--ink));
  color: inherit;
  text-decoration: none;
}

main .flow-stage a:hover {
  text-decoration: none;
}

/* Stacked layout: a short arrow from the block above down to this box, centred on the stage numbers. */
.flow-stage + .flow-stage::before,
.flow-stage + .flow-stage::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.flow-stage + .flow-stage::before {
  top: -2rem;
  left: 2rem;
  height: 2rem;
  border-left: 2px solid var(--ink);
}

.flow-stage + .flow-stage::after {
  top: -11px;
  left: calc(2rem - 3.5px);
  width: 9px;
  height: 9px;
  border-top: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
  transform: rotate(135deg);
}

.flow-title {
  display: flex;
  align-items: center;
  gap: .6rem;
}

/* Selected stage: its number takes the accent here and in the detail heading (variables set below).
   Positioned so that it paints over the arrow line drawn by the stage's pseudo-element. */
.flow-no {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 .35rem;
  border: 1px solid var(--sel, var(--ink));
  background: var(--sel-bg, var(--paper));
  color: var(--sel-fg, var(--ink));
}

.flow-name {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1.25;
}

.flow-stage a:hover .flow-name {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: .22em;
}

.flow-action {
  font-size: .9375rem;
  line-height: 1.4;
}

.flow-out {
  margin-top: .2rem;
  padding-top: .6rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: .875rem;
  line-height: 1.4;
}

/* The stage a reader jumped to from a section tag keeps a ring on its number until the next jump. */
.flow-stage:target .flow-no {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.flow-detail {
  padding: .25rem 1rem 1.1rem;
  border: 1px solid var(--sel, var(--ink));
  border-top: 0;
}

.flow-detail-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding-top: .85rem;
  font-size: 1.0625rem;
}

.flow-facts {
  margin-top: .75rem;
  border-top: 1px solid var(--rule);
}

.flow-facts > div {
  padding-block: .6rem .7rem;
  border-bottom: 1px solid var(--rule);
}

.flow-facts dt {
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.35;
}

.flow-facts dd {
  margin-top: .2rem;
  color: var(--ink-2);
  font-size: .875rem;
  line-height: 1.45;
}

.flow-goto {
  margin-top: .75rem;
  font-size: .875rem;
}

.flow-goto .label {
  margin-right: .5rem;
}

/* End state after the five stages: a boxed label and one sentence, no arrow and no claim of a live system. */
.flow-end {
  display: grid;
  row-gap: .7rem;
  margin-top: 2rem;
}

.flow-end-label {
  justify-self: start;
  padding: .5rem .65rem;
  border: 1px solid var(--ink);
  color: var(--ink);
}

.flow-end p:last-child {
  max-width: 34rem;
  color: var(--ink-2);
  font-size: .9375rem;
  line-height: 1.5;
}

.flow figcaption {
  max-width: 46rem;
  margin-top: 1.5rem;
}

/* Connect endpoint: the terminal row of the delivery section. */
.flow-connect {
  display: grid;
  row-gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ink);
}

.flow-connect-text p:last-child {
  max-width: 34rem;
  margin-top: .35rem;
  color: var(--ink-2);
}

[data-stage="s1"] .s1,
[data-stage="s2"] .s2,
[data-stage="s3"] .s3,
[data-stage="s4"] .s4,
[data-stage="s5"] .s5 {
  --sel: var(--accent);
  --sel-bg: var(--accent);
  --sel-fg: var(--on-accent);
}

/* Stacked layout: the stage list and the detail list share one grid, so each detail sits in the row after its stage. */
@supports (grid-template-columns: subgrid) {
  .flow-map {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(5, auto auto);
  }

  .flow-stages,
  .flow-details {
    display: grid;
    grid-column: 1;
    grid-row: 1 / -1;
    grid-template-rows: subgrid;
    pointer-events: none;
  }

  .flow-stage,
  .flow-detail {
    pointer-events: auto;
  }

  .flow-stage.s1 { grid-row: 1; }
  .flow-detail.s1 { grid-row: 2; }
  .flow-stage.s2 { grid-row: 3; }
  .flow-detail.s2 { grid-row: 4; }
  .flow-stage.s3 { grid-row: 5; }
  .flow-detail.s3 { grid-row: 6; }
  .flow-stage.s4 { grid-row: 7; }
  .flow-detail.s4 { grid-row: 8; }
  .flow-stage.s5 { grid-row: 9; }
  .flow-detail.s5 { grid-row: 10; }

  /* The stage box directly above already carries the number and name. */
  .flow-detail-head {
    display: none;
  }

  .flow-facts {
    margin-top: 0;
    border-top: 0;
  }
}

/* Row layout from 56rem: five equal columns on one horizontal arrow, detail and end state under the row. */
@media (min-width: 56rem) {
  .flow-map {
    display: block;
  }

  .flow-stages {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: none;
    column-gap: var(--flow-gap);
    pointer-events: auto;
  }

  .flow-details {
    display: block;
    grid-template-rows: none;
    pointer-events: auto;
  }

  .flow-stages .flow-stage,
  .flow-details .flow-detail {
    grid-row: auto;
    margin: 0;
    scroll-margin-top: 0;
  }

  /* Open cells: the selected stage's accent underline meets the detail's top rule. */
  .flow-stage a {
    row-gap: .45rem;
    padding: 0 0 1rem;
    border: 0;
    border-bottom: 2px solid var(--sel, transparent);
  }

  .flow-title {
    display: grid;
    align-content: start;
    justify-items: start;
    row-gap: .8rem;
  }

  /* One arrow through the row: each stage but the last draws the line from its number across the gap, and each
     stage but the first draws the arrowhead whose tip meets its number's left edge. */
  .flow-stages .flow-stage::before,
  .flow-stages .flow-stage::after {
    content: "";
    position: absolute;
    display: block;
    pointer-events: none;
  }

  .flow-stages .flow-stage::before {
    top: calc(1rem - 1px);
    right: calc(-1 * var(--flow-gap));
    left: 1rem;
    height: 0;
    border: 0;
    border-top: 2px solid var(--ink);
  }

  .flow-stages .flow-stage:last-child::before {
    display: none;
  }

  .flow-stages .flow-stage::after {
    top: calc(1rem - 4.5px);
    left: -11px;
    width: 9px;
    height: 9px;
    border: 0;
    border-top: 2px solid var(--ink);
    border-right: 2px solid var(--ink);
    transform: rotate(45deg);
  }

  .flow-stages .flow-stage:first-child::after {
    display: none;
  }

  .flow-detail {
    padding: 1.25rem 0 0;
    border: 0;
    border-top: 1px solid var(--ink);
  }

  .flow-detail-head {
    display: flex;
    padding-top: 0;
  }

  .flow-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--gap);
    margin-top: .75rem;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
  }

  .flow-facts > div {
    border-bottom: 0;
  }

  .flow-end {
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: var(--gap);
    align-items: start;
    margin-top: 2.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
  }

  .flow-connect {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--gap);
    align-items: center;
  }
}

/* ---- two-column matrix: platform, test, research ---- */
.matrix {
  margin-top: 2.5rem;
  border-top: 1px solid var(--ink);
}

.matrix > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: .35rem;
  padding-block: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--rule);
}

.matrix dt {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1.3;
}

.matrix dd {
  color: var(--ink-2);
  font-size: .9375rem;
  line-height: 1.5;
}

/* ---- governed improvement loop ---- */
/* One small figure under the Platform matrix, subordinate to the delivery pipeline: five boxed steps on one 1px arrow
   and a return path. Under 36rem the steps stack with a short arrow between them and the return is a final row with an
   icon; from 36rem the five share one row and the return path is drawn under them from Monitor back into Version.
   Review is the human gate: its entry is the accent node in place of an arrowhead. */
.loop {
  --loop-gap: 1.25rem;
  margin-top: 2.25rem;
}

/* Label row: the figure name at the left, when it runs at the right. */
.loop-label {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  column-gap: 1rem;
}

.loop-steps {
  position: relative;
  display: grid;
  row-gap: 1.25rem;
  margin-top: .85rem;
}

.loop-step,
.loop-return {
  position: relative;
  font: 400 .75rem/1.35 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.loop-step {
  justify-self: start;
  padding: .45rem .7rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
}

.loop-step + .loop-step::before,
.loop-step + .loop-step::after,
.loop-return::before {
  content: "";
  position: absolute;
  pointer-events: none;
}

/* Stacked layout: a short arrow from the box above down to this box, 1.25rem in from the left edge. */
.loop-step + .loop-step::before {
  top: calc(-1.25rem - 1px);
  left: 1.25rem;
  height: 1.25rem;
  border-left: 1px solid var(--ink);
}

.loop-step + .loop-step::after {
  top: -8px;
  left: calc(1.25rem - 2.5px);
  width: 6px;
  height: 6px;
  border-top: 1px solid var(--ink);
  border-right: 1px solid var(--ink);
  transform: rotate(135deg);
}

/* Human gate: the accent node sits on the line's end, centred on the box edge the line meets. */
.loop-step + .loop-gate::after {
  top: -5px;
  left: calc(1.25rem - 4.5px);
  width: 10px;
  height: 10px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--accent);
  transform: none;
}

.loop-return::before {
  display: none;
}

.loop-return {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--ink-3);
}

.loop-return-icon {
  flex: none;
}

.loop figcaption {
  max-width: 34rem;
  margin-top: 1.1rem;
}

/* Row layout from 36rem: five equal columns on one arrow, the return path under them. */
@media (min-width: 36rem) {
  .loop-steps {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    column-gap: var(--loop-gap);
    row-gap: 0;
    padding-bottom: 2.75rem;
  }

  .loop-step {
    justify-self: stretch;
    padding-inline: .3rem;
    text-align: center;
  }

  /* Each step but the first draws the line across the gap to its left and the head whose tip meets its left edge. */
  .loop-step + .loop-step::before {
    top: 50%;
    right: calc(100% + 1px);
    left: auto;
    width: var(--loop-gap);
    height: 0;
    border-left: 0;
    border-top: 1px solid var(--ink);
  }

  .loop-step + .loop-step::after {
    top: calc(50% - 2.5px);
    left: -8px;
    transform: rotate(45deg);
  }

  .loop-step + .loop-gate::after {
    top: calc(50% - 5px);
    left: -5px;
    transform: none;
  }

  /* Return path: down from under Monitor, along the bottom, up into Version; the label sits on the bottom line. */
  .loop-return {
    position: absolute;
    top: calc(100% - 2.75rem);
    right: calc((100% - 4 * var(--loop-gap)) / 10);
    left: calc((100% - 4 * var(--loop-gap)) / 10);
    display: block;
    height: 1.75rem;
    border: 1px solid var(--ink);
    border-top: 0;
  }

  .loop-return::before {
    display: block;
    top: 1px;
    left: -3.5px;
    width: 6px;
    height: 6px;
    border-top: 1px solid var(--ink);
    border-left: 1px solid var(--ink);
    transform: rotate(45deg);
  }

  .loop-return-icon {
    display: none;
  }

  .loop-return span {
    position: absolute;
    bottom: 0;
    left: 50%;
    padding: 0 .6rem;
    background: var(--paper);
    white-space: nowrap;
    transform: translate(-50%, 50%);
  }
}

/* ---- contact ---- */
.mail {
  margin-top: 1.75rem;
}

.mail a {
  display: inline-block;
  padding-block: .45rem;
  font-size: clamp(1.625rem, 1rem + 2.6vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-decoration-thickness: 2px;
  text-underline-offset: .18em;
}

.engage {
  margin-top: 3rem;
}

.engage .body {
  margin-top: .75rem;
  font-size: .9375rem;
}

.engage .body + .terms {
  margin-top: 1.25rem;
}

.terms {
  margin-top: .75rem;
  border-top: 1px solid var(--ink);
}

.terms > div {
  padding-block: .7rem .75rem;
  border-bottom: 1px solid var(--rule);
}

.terms dt {
  font-size: .9375rem;
  font-weight: 700;
  line-height: 1.35;
}

.terms dd {
  color: var(--ink-2);
  font-size: .875rem;
  line-height: 1.45;
}

.note {
  margin-top: 1rem;
}

/* ---- footer ---- */
.footer-inner {
  row-gap: 1rem;
  padding-block: 1.25rem 1rem;
  border-top: 1px solid var(--ink);
  color: var(--ink-2);
  font-size: .875rem;
}

.footer-name {
  color: var(--ink);
  font-weight: 700;
}

.footer-note {
  max-width: 30rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  column-gap: 1.5rem;
}

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

.footer-base {
  padding-bottom: 1.5rem;
}

/* ---- 40rem: wider gutter ---- */
@media (min-width: 40rem) {
  :root {
    --gutter: 2rem;
  }
}

/* ---- 56rem: the 12-column grid ---- */
@media (min-width: 56rem) {
  .grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .section-head {
    align-items: end;
  }

  .section-head h2,
  .contact-main {
    grid-column: 1 / span 7;
  }

  .section-head .body,
  .engage {
    grid-column: 9 / -1;
  }

  .section-head .body {
    margin-top: 0;
  }

  .section-head .tag {
    grid-column: 1 / -1;
  }

  .hero-text {
    grid-column: 1 / span 7;
  }

  /* Three lines at 1280, so the delivery pipeline starts inside an 800px first viewport. */
  h1 {
    font-size: clamp(2.5rem, 3.6vw, 3.25rem);
  }

  .hero-aside {
    grid-column: 9 / -1;
    align-self: end;
  }

  /* Build is a 6:5 split with one spacer column: the text in columns 1 to 6, the image in 8 to 12 under the head's
     supporting sentence, which takes the same five columns so the right column has one left edge. */
  .build-head .body {
    grid-column: 8 / -1;
  }

  .build-text {
    grid-column: 1 / span 6;
  }

  .build-art {
    grid-column: 8 / -1;
    align-self: start;
  }

  /* Intro column of five; the matrix keeps columns 6 to 12, so its rows and the loop are unchanged. */
  .side-head {
    grid-column: 1 / span 5;
  }

  .footer-brand {
    grid-column: 1 / span 4;
  }

  .matrix {
    grid-column: 6 / -1;
    margin-top: .5rem;
  }

  /* Row 2 of the Platform grid: the loop under the matrix. */
  .loop {
    grid-column: 6 / -1;
    grid-row: 2;
  }

  .matrix > div {
    grid-template-columns: minmax(0, 3fr) minmax(0, 4fr);
    column-gap: var(--gap);
  }

  .engage {
    margin-top: .5rem;
  }

  .footer-note {
    grid-column: 6 / span 4;
  }

  .footer-links {
    grid-column: 10 / -1;
    flex-direction: column;
  }

  .footer-links a {
    min-height: 1.75rem;
  }
}

/* ---- 64rem: the System map is a fixed panel in a right rail ---- */
/* Header, main and footer leave the rail free, so the panel never covers text, header controls or a focus ring. */
@media (min-width: 64rem) {
  :root {
    --map-w: 7rem;
    --rail: calc(var(--map-w) + 1.5rem);
  }

  .site-header,
  main,
  .site-footer {
    padding-right: var(--rail);
  }

  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .menu-toggle {
    display: none;
  }

  .map {
    position: fixed;
    top: 50%;
    right: .75rem;
    z-index: 5;
    width: var(--map-w);
    padding: .6rem .7rem .55rem;
    border: 1px solid var(--ink);
    background: var(--paper);
    transform: translateY(-50%);
  }

  .map-list {
    flex-direction: column;
    margin-top: .35rem;
  }

  .map a {
    min-height: 1.85rem;
    font-size: .8125rem;
  }
}

/* ---- motion ---- */
/* Everything here is one-time and only runs when the reader has not asked for reduced motion.
   The has-js class is set in script.js before first paint; without it nothing is hidden. */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .has-js .reveal {
    opacity: 0;
    transform: translateY(.6rem);
    transition: opacity .45s ease, transform .45s ease;
  }

  .has-js .reveal.is-in {
    opacity: 1;
    transform: none;
  }

  /* Delivery pipeline: the only motion is the selected stage taking the accent and its detail fading in. */
  .flow-no,
  .flow-stage a,
  .flow-detail {
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
  }

  .has-js .flow-detail {
    animation: flow-detail-in .25s ease;
  }

  @keyframes flow-detail-in {
    from {
      opacity: 0;
      transform: translateY(.3rem);
    }
  }

  /* Governed improvement loop: a one-time draw as it enters view. The figure rises like the other reveal targets, the
     five steps and their arrows fade in left to right, then the return path draws from Monitor back into Version. */
  .has-js .loop .loop-step,
  .has-js .loop .loop-return {
    opacity: 0;
    transition: opacity .3s ease;
  }

  .has-js .loop.is-in .loop-step,
  .has-js .loop.is-in .loop-return {
    opacity: 1;
  }

  .has-js .loop.is-in .loop-step:nth-child(2) {
    transition-delay: .1s;
  }

  .has-js .loop.is-in .loop-step:nth-child(3) {
    transition-delay: .2s;
  }

  .has-js .loop.is-in .loop-step:nth-child(4) {
    transition-delay: .3s;
  }

  .has-js .loop.is-in .loop-step:nth-child(5) {
    transition-delay: .4s;
  }

  .has-js .loop.is-in .loop-return {
    transition-delay: .55s;
  }

  @media (min-width: 36rem) {
    .has-js .loop .loop-return {
      opacity: 1;
      clip-path: inset(-.5rem -.5rem -1rem 100%);
      transition: clip-path .6s ease;
    }

    .has-js .loop.is-in .loop-return {
      clip-path: inset(-.5rem -.5rem -1rem 0);
    }
  }
}

/* ---- preferences ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media print {
  .reveal,
  .loop-step,
  .loop-return {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .loop-return {
    clip-path: none !important;
  }

  .flow-detail[hidden] {
    display: block !important;
  }

  .map,
  .menu-toggle {
    display: none;
  }

  .site-header,
  main,
  .site-footer {
    padding-right: 0;
  }
}

@media (forced-colors: active) {
  .map a[aria-current] .map-no {
    border: 1px solid CanvasText;
  }

  .flow [aria-selected="true"] .flow-no {
    outline: 2px solid CanvasText;
    outline-offset: 2px;
  }

  .loop-step + .loop-gate::after {
    border-color: Canvas;
    background: Highlight;
    forced-color-adjust: none;
  }
}
