/* Base colours come from art/sprites.json. Yellow and red mark the company,
   teal marks n8n, and clay marks the dispatcher. The branches use pale tints. */
:root {
  color-scheme: light;
  --ink: #1f1b16;
  --ink-soft: #463e33;
  --stone-dark: #7a6f60;
  --stone: #a89c88;
  --stone-light: #d6cbb3;
  --paper: #f6f0de;
  --white: #fffbf1;
  --sand: #d19a5b;
  --sand-light: #e8c48a;
  --sand-pale: #f3deb0;
  --clay-dark: #6b2a1d;
  --red-dark: #8f1d17;
  --red: #b3261e;
  --yellow: #f1c232;
  --yellow-pale: #fbeab0;
  --teal-dark: #1f4a4f;
  --teal-light: #a6d4c8;
  --green-dark: #2c6636;
  --asphalt-dark: #2e3138;
  --asphalt: #4d525c;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --u: 3px; /* one drawn pixel; whole numbers only */
  --edge: 2px;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--text);
}

::selection { background: var(--yellow); color: var(--ink); }

a { color: var(--red-dark); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: .14em; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
main:focus { outline: none; }

ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
p { margin: 0; }
code { font: .9em var(--mono); overflow-wrap: anywhere; }

.skip-link {
  position: absolute;
  z-index: 1;
  top: .5rem;
  left: var(--gutter);
  padding: .4rem .75rem;
  border: var(--edge) solid var(--ink);
  background: var(--white);
  transform: translateY(-300%);
}

.skip-link:focus { transform: none; }

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

/* Masthead */

.masthead { border-top: 6px solid var(--yellow); border-bottom: var(--edge) solid var(--ink); background: var(--white); }

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .25rem 2rem;
  padding-block: .7rem;
}

.wordmark { color: var(--ink); font-weight: 800; letter-spacing: -.01em; text-decoration: none; }
.wordmark span { color: var(--red-dark); }

nav ul { display: flex; flex-wrap: wrap; gap: 0 clamp(.9rem, 2.5vw, 1.6rem); }
nav a { display: inline-block; padding-block: .45rem; font-size: .9375rem; font-weight: 650; }

/* Type */

h1, h2, h3, h4 { margin: 0; line-height: 1.15; text-wrap: balance; }
h1 { max-width: 18ch; font-size: clamp(2.1rem, 6vw, 3.6rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
h2 { font-size: clamp(1.65rem, 4vw, 2.3rem); font-weight: 800; letter-spacing: -.02em; }
h3 { font-size: 1.125rem; font-weight: 750; }
h4 { font-size: 1.0625rem; font-weight: 700; }

.dek, .lead { max-width: 58ch; color: var(--ink-soft); font-size: clamp(1.1rem, 2.2vw, 1.25rem); line-height: 1.5; }
.dek { margin-top: .9rem; }
.lead { margin-top: .9rem; }
.lead strong { color: var(--ink); }

/* Intro and the route scene */

.intro { padding-block: clamp(2.25rem, 6vw, 4rem) clamp(2.5rem, 6vw, 4rem); }

.route { margin-top: clamp(1.75rem, 4vw, 2.5rem); }

.scene {
  position: relative;
  overflow: hidden;
  border: var(--edge) solid var(--ink);
  background-color: var(--sand-light);
  /* Dither: one sand pixel every eight, open ground only. */
  background-image:
    linear-gradient(transparent var(--u), var(--sand-light) var(--u)),
    linear-gradient(90deg, var(--sand) var(--u), transparent var(--u));
  background-size: calc(var(--u) * 8) calc(var(--u) * 8);
}

.spr { display: block; image-rendering: pixelated; }

.lot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: calc(var(--u) * 12) calc(var(--u) * 2) 0;
}

.building { width: calc(var(--u) * 20); height: calc(var(--u) * 16); }

.road {
  height: calc(var(--u) * 10);
  margin-bottom: calc(var(--u) * 3);
  border-block: var(--u) solid var(--asphalt-dark);
  background:
    linear-gradient(90deg, var(--sand-pale) 50%, transparent 50%)
    0 50% / calc(var(--u) * 8) var(--u) repeat-x
    var(--asphalt);
}

.truck, .alarm, .cactus { position: absolute; }

.truck {
  bottom: calc(var(--u) * 6);
  left: calc(50% - var(--u) * 12);
  width: calc(var(--u) * 24);
  height: calc(var(--u) * 13);
}

.alarm {
  bottom: calc(var(--u) * 20);
  left: calc(50% - var(--u) * 6);
  width: calc(var(--u) * 5);
  height: calc(var(--u) * 7);
}

.cactus { bottom: calc(var(--u) * 13); width: calc(var(--u) * 8); height: calc(var(--u) * 11); }
.cactus-a { left: 26%; }
.cactus-b { display: none; left: 71%; }

.stops {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
  margin-top: 1rem;
  color: var(--ink-soft);
  font-size: .875rem;
  line-height: 1.4;
}

.stops b { display: block; color: var(--ink); font-size: .9375rem; }
.stops li:nth-child(2) { text-align: center; }
.stops li:nth-child(2) b { color: var(--red-dark); }
.stops li:nth-child(3) { text-align: right; }

/* Sections */

main > section {
  border-top: var(--edge) solid var(--ink);
  padding-block: clamp(2.5rem, 6vw, 4.25rem);
  scroll-margin-top: 1rem;
}

.block { margin-top: clamp(2rem, 4.5vw, 3rem); }
.block > h3 { margin-bottom: .9rem; }
.block > p { max-width: 62ch; margin-top: .9rem; }

.roles, .options, .records, .lanes { display: grid; gap: .9rem; }

.options li {
  padding: .85rem 1rem;
  border: var(--edge) solid var(--ink);
  background: var(--white);
}

.roles li, .records > div, .lane { padding-top: .65rem; border-top: 1px solid var(--stone); }
.roles li, .records dd, .options p, .models span, .pilot li { color: var(--ink-soft); font-size: .9688rem; line-height: 1.45; }
.roles b, .pilot b { display: block; color: var(--ink); font-size: 1.0625rem; }

/* Option tracks: restaurant, breakdown, client. Yellow is new driving. */

.track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  height: 36px;
  margin: 0 6px .7rem;
}

.track i { height: 6px; background: var(--stone-light); }
.track b { position: absolute; top: 12px; width: 12px; height: 12px; border: 2px solid var(--ink); background: var(--white); }
.track b:nth-of-type(1) { left: -6px; }
.track b:nth-of-type(2) { left: calc(50% - 6px); background: var(--red); }
.track b:nth-of-type(3) { right: -6px; }

.t-wait i:nth-of-type(2),
.t-divert i:nth-of-type(2),
.t-replace i { border-block: 2px solid var(--ink); background: var(--yellow); }

.t-divert::before {
  position: absolute;
  top: 0;
  left: calc(50% - 3px);
  width: 6px;
  height: 14px;
  border-inline: 2px solid var(--ink);
  background: var(--yellow);
  content: "";
}

.key { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; color: var(--ink-soft); font-size: .875rem; }
.key span::before { display: inline-block; width: 12px; height: 12px; margin-right: .45rem; border: 2px solid var(--ink); content: ""; vertical-align: -1px; }
.k-go::before { background: var(--yellow); }
.k-stop::before { background: var(--red); }

.records dt { font-weight: 700; }

.note {
  max-width: 62ch;
  margin-top: clamp(2rem, 4.5vw, 3rem);
  padding-top: .65rem;
  border-top: 1px solid var(--stone);
  color: var(--ink-soft);
  font-size: .9688rem;
}

.block > .note { margin-top: 1.25rem; }
.note b { display: block; color: var(--ink); }

/* Flow chart */

.flow-layout { display: grid; gap: 1.75rem; margin-top: clamp(1.75rem, 4vw, 2.5rem); }

.flow {
  --gap: clamp(.5rem, 2vw, 1rem);
  --wire: var(--ink-soft);
  --inset: calc((100% - var(--gap)) / 4);
  padding: clamp(.75rem, 3vw, 1.5rem);
  border: var(--edge) solid var(--ink);
  background: var(--white);
}

.flow figcaption { margin-bottom: 1.1rem; font-size: 1.125rem; font-weight: 750; text-align: center; text-wrap: balance; }
.flow ol { display: grid; justify-items: center; }

.node {
  width: min(100%, 27rem);
  padding: .65rem .8rem .75rem;
  border: var(--edge) solid var(--ink);
  background: var(--paper);
  font-size: .9375rem;
  line-height: 1.4;
}

.node > strong, .node > span:not(.who) { display: block; }
.node > strong { font-size: 1rem; line-height: 1.3; }
.node > span:not(.who) { margin-top: .25rem; color: var(--ink-soft); }
.node span b { color: var(--ink); }

.who {
  display: inline-block;
  margin-bottom: .4rem;
  padding: .5rem;
  border: var(--edge) solid var(--ink);
  font: 700 .75rem/1.4 var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.who.dispatch { background: var(--yellow); color: var(--ink); }
.who.n8n { background: var(--teal-dark); color: var(--white); }
.who.person { background: var(--clay-dark); color: var(--white); }

.wire { position: relative; width: 100%; min-height: 1.5rem; }

.wire::before, .wire:not(.stem)::after { position: absolute; left: calc(50% - 1px); content: ""; }
.wire::before { top: 0; bottom: 0; width: 2px; background: var(--wire); }
.wire:not(.stem)::after { bottom: 0; left: calc(50% - 6px); border: 6px solid transparent; border-top-color: var(--wire); border-bottom: 0; }
.wire.stem { min-height: .9rem; }

.wire.labelled { display: grid; justify-items: center; padding-block: .65rem 1rem; }

.wire.labelled span {
  position: relative;
  max-width: 100%;
  padding: .5rem .65rem;
  border: var(--edge) dashed var(--wire);
  background: var(--white);
  color: var(--ink-soft);
  font-size: .8438rem;
  line-height: 1.35;
  text-align: center;
}

.wire.labelled b, .node span b { font-weight: 700; }
.wire.labelled b { color: var(--ink); }

.split { width: 100%; }

.branches {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  padding-block: .75rem;
}

.branches::before, .branches::after {
  position: absolute;
  inset-inline: var(--inset);
  height: .75rem;
  border: 2px solid var(--wire);
  content: "";
}

.branches::before { top: 0; border-bottom: 0; }
.branches::after { bottom: 0; border-top: 0; }
.branches .node { width: 100%; }

.node.auto { background: #e9f0dc; }
.node.human { background: #f6e1d6; }
.condition { margin-bottom: .45rem; font-size: .875rem; font-weight: 700; line-height: 1.3; }
.auto .condition { color: var(--green-dark); }
.human .condition { color: var(--red-dark); }

.results { display: grid; gap: .35rem; margin-top: .6rem; font-size: .875rem; }
.results li { padding: .5rem .65rem; border-top: 1px solid var(--stone); background: var(--white); }
.results b { margin-right: .35rem; }
.results .pass b { color: var(--green-dark); }
.results .hold b { color: var(--red-dark); }

.flow-notes { display: grid; gap: 1.4rem; align-content: start; }
.flow-notes > section { padding-top: .8rem; border-top: 1px solid var(--stone); }
.flow-notes h3 { margin-bottom: .45rem; font-size: 1.0625rem; }
.flow-notes p, .flow-notes li, .hooks dd { color: var(--ink-soft); font-size: .9375rem; line-height: 1.45; }
.hooks { display: grid; gap: .55rem; margin-top: .65rem; }
.hooks dt { color: var(--ink); font-weight: 700; }

.ticks { display: grid; gap: .35rem; }
.flow-notes p + .ticks { margin-top: .5rem; }
.ticks li { position: relative; padding-left: 1.1rem; }
.ticks li::before { position: absolute; top: .5em; left: 0; width: 6px; height: 6px; background: var(--ink); content: ""; }

/* Architecture */

.lane ul { display: grid; gap: .35rem; }
.lane li { font-size: .9688rem; line-height: 1.45; }
.lane.n8n { border-top: 6px solid var(--teal-dark); }
.lane.dispatch { border-top: 6px solid var(--yellow); }

.models { border-top: var(--edge) solid var(--ink); }
.models li { display: grid; gap: .15rem 1.5rem; padding: .875rem 0; border-bottom: 1px solid var(--stone); }

.sources { display: flex; flex-wrap: wrap; gap: .15rem 1.25rem; font-size: .9375rem; }
.block > .sources { margin-top: .5rem; }

.pilot { display: grid; gap: 1.1rem; counter-reset: stop; }

.pilot li { position: relative; padding-left: 2.6rem; counter-increment: stop; }

.pilot li::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 1.75rem;
  height: 1.75rem;
  border: var(--edge) solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  font: 700 .875rem/calc(1.75rem - 4px) var(--mono);
  text-align: center;
  content: counter(stop);
}

/* The road between pilot stops. */
.pilot li:not(:last-child)::after {
  position: absolute;
  top: 1.75rem;
  bottom: -1.1rem;
  left: calc(.875rem - 3px);
  width: 6px;
  background: var(--asphalt);
  content: "";
}

.pilot li:last-child::before { background: var(--white); }

@media (min-width: 40rem) {
  .roles, .options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .records, .lanes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .models li { grid-template-columns: 13rem minmax(0, 1fr); }
  .cactus-b { display: block; }
}

@media (min-width: 48rem) {
  :root { --u: 4px; }
  .stops { font-size: .9375rem; }
}

@media (min-width: 60rem) {
  .flow-layout { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
  .records { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pilot { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem; }
  .pilot li { padding: 2.5rem 0 0; }
  .pilot li:not(:last-child)::after { top: calc(.875rem - 3px); right: -1.25rem; bottom: auto; left: 1.75rem; width: auto; height: 6px; }
}

@media (max-width: 24rem) {
  .node { padding-inline: .55rem; }
  .branches .node { font-size: .875rem; }
  .options li { padding-inline: .8rem; }
}
