/* Traction Pages, "signal" theme: the deck's light language as a site theme.
   Paper ground, ink type, signal-yellow accents. Condensed headings with a yellow-on-ink
   kicker chip above every h2, white hairline cards for code and tables, mono slug byline.
   Yellow is never text on paper: it is chips on ink, underlines, borders and washes.
   Dark scheme inverts to the deck's ink; yellow stays.
   Fonts: Barlow / Barlow Condensed / IBM Plex Mono (Google Fonts, linked in head.html). */

@property --measure { syntax: '<length>'; inherits: true; initial-value: 704px; }

:root {
  --bg: #eef0ed;          /* paper */
  --fg: #16181b;          /* ink: 15.5:1 on paper */
  --muted: #50565c;       /* 6.4:1 on paper, 7.3:1 on white */
  --card: #ffffff;        /* code, tables, figures */
  --hair: #cdd1cc;        /* card borders */
  --rule: #cdd1cc;
  --tint: #e4e7e3;        /* inline code ground */
  --edge: #e4e7e3;        /* big-screen page edges */
  --accent: #f5c400;      /* signal yellow */
  --wash: rgb(245 196 0 / 0.32);
  --chip-ink: #16181b;    /* the dark tab behind yellow labels */
  --chip-tab: #16181b;
  --chip-text: #f5c400;   /* yellow on ink: 10.8:1 */
  --on-accent: #16181b;
  --sans: 'Barlow', 'Helvetica Neue', 'Segoe UI', Arial, sans-serif;
  --cond: 'Barlow Condensed', 'Avenir Next Condensed', 'Roboto Condensed', 'Arial Narrow', sans-serif;
  --mono: 'IBM Plex Mono', 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;        /* ink */
    --fg: #eef0ed;        /* paper: 15.5:1 */
    --muted: #a4aaa3;     /* 7.5:1 on ink */
    --card: #1f2226;
    --hair: #353a40;
    --rule: #30353b;
    --tint: #24282c;
    --edge: #111315;
    --wash: rgb(245 196 0 / 0.22);
    --chip-ink: #16181b;
    --chip-tab: #2b2f33;  /* the tab still reads against the ink page */
    --chip-text: #f5c400;
    color-scheme: dark light;
  }
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.65;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: var(--on-accent); }

/* Links: ink text, yellow underline, yellow wash on hover */
a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
  border-radius: 2px;
  transition: background-color 0.12s;
}
a:hover { background-color: var(--wash); text-decoration-thickness: 3px; }
a:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; background-color: var(--wash); }

/* ---- Top navigation: condensed caps on a hairline ---- */

.topnav, .essay-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.85rem;
  max-width: 54rem;
  margin: 0 auto;
  padding: 1rem 1rem 0.8rem;
  font-family: var(--cond);
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.6;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
}
.essay-header { max-width: 50rem; }

.topnav a, .essay-header a { color: var(--muted); text-decoration: none; padding: 0 0.15em; }
.topnav a:hover, .essay-header a:hover { color: var(--fg); background: var(--wash); }

.brand {
  font-family: var(--cond);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.16em;
  color: var(--fg) !important;
}
.brand::before {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-right: 0.5em;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--chip-ink);
  border-radius: 1px;
  vertical-align: 0.04em;
}

.topnav nav, .essay-header nav { display: flex; flex: 1 1 0; min-width: 0; flex-wrap: wrap; gap: 0.1rem 0.7rem; }
.essay-header nav { flex: 0 0 auto; margin-left: auto; }
.topnav nav a.active { color: var(--fg); box-shadow: inset 0 -3px 0 var(--accent); }

/* ---- Page bodies ---- */

.content, .essay-body {
  max-width: 54rem;
  margin: 0 auto;
  padding: 1.75rem 1rem 3.5rem;
}
.content > :is(p, ul, ol, blockquote, h1, h2, h3, h4, hr) { max-width: 46rem; }
.essay-body { max-width: 48rem; padding-top: 2.75rem; }

h1, h2, h3, h4 {
  font-family: var(--cond);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0;
  margin: 2.2em 0 0.55em;
  text-wrap: balance;
}
h1 { font-size: 2.6rem; margin-top: 0.3em; }
h2 { font-size: 2rem; line-height: 1.08; }
h3 { font-size: 1.4rem; }
h4 {
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.essay-body h1 { font-size: 2.75rem; line-height: 1.02; }
h1 + p em:only-child { color: var(--muted); }
strong { font-weight: 600; color: var(--fg); }

/* Kicker chips: a bordered yellow label in a dark tab above every h2 (the deck's
   section label). Counter-driven, so it works on any MkDocs page with no markup. */
.essay-body article, .content { counter-reset: sec; }
.essay-body h2, .content h2 { counter-increment: sec; }
.essay-body h2::before, .content h2::before {
  content: "Part\2002" counter(sec, decimal-leading-zero);
  display: table;
  margin: 0 0 0.85rem 3px;
  padding: 0.12em 0.6em 0.05em;
  background: var(--chip-ink);
  border: 1.5px solid var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 0 3px var(--chip-tab);
  font-family: var(--cond);
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.5;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--chip-text);
}

/* Byline: a mono slug line */
.byline, .essay-body .byline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.9rem 0 2rem;
}
.byline::before {
  content: "";
  flex: 0 0 auto;
  width: 1.6rem;
  height: 3px;
  background: var(--accent);
}

p, ul, ol, blockquote, pre, table { margin: 0 0 1.1em; }
ul, ol { padding-left: 1.3em; }
li { margin: 0.3em 0; }
li::marker { color: var(--muted); }
ul > li::marker { content: "\25A0\2002"; font-size: 0.7em; color: var(--fg); }
li > ul, li > ol { margin-bottom: 0; }

blockquote {
  margin-left: 0;
  padding: 0.1em 0 0.1em 1em;
  border-left: 4px solid var(--accent);
  color: var(--muted);
}
blockquote > :last-child { margin-bottom: 0; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4em 0; }

/* ---- Code: white hairline cards, Plex Mono ---- */

code, pre { font-family: var(--mono); }
code {
  font-size: 0.84em;
  background: var(--tint);
  padding: 0.08em 0.35em;
  border-radius: 3px;
}
pre {
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}
pre code { background: none; padding: 0; border-radius: 0; font-size: inherit; }

/* Result lines as bordered chips. The measured-result block (the text block right
   before the dashboard figure) becomes an ink-bordered card with a kicker chip;
   status codes in table cells read as small bordered chips. */
.essay-body pre:has(+ p > img) {
  position: relative;
  padding-top: 2.9rem;
  border: 1.5px solid var(--fg);
  font-size: 0.88rem;
  line-height: 1.9;
}
.essay-body pre:has(+ p > img)::before {
  content: "Measured run";
  position: absolute;
  top: 0.8rem;
  left: calc(1.1rem + 3px);
  padding: 0.1em 0.6em 0.02em;
  background: var(--chip-ink);
  border: 1.5px solid var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 0 3px var(--chip-tab);
  font-family: var(--cond);
  font-weight: 600;
  font-size: 0.78rem;
  line-height: 1.5;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--chip-text);
}
td code {
  white-space: nowrap;
  background: var(--card);
  border: 1.5px solid var(--fg);
  border-radius: 3px;
  padding: 0.04em 0.45em;
}

/* ---- Tables: white hairline cards, scroll sideways on phones ---- */

table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 6px;
  font-size: 0.95rem;
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
}
th, td { padding: 0.55em 0.85em; border-bottom: 1px solid var(--hair); text-align: left; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th {
  font-family: var(--cond);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: var(--muted);
  border-bottom: 2px solid var(--accent);
  white-space: nowrap;
}
tbody tr:hover td { background: var(--wash); }

/* ---- Mermaid: the template's script picks warm colors; recolor to the deck ---- */

.mermaid {
  overflow-x: auto;
  margin: 1.4em 0;
  padding: 0.9rem;
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 6px;
  text-align: center;
  -webkit-overflow-scrolling: touch;
}
.mermaid svg { height: auto; max-width: none; }
.mermaid:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.mermaid svg :is(.node rect, .node polygon, .node circle, .node path) { fill: var(--bg) !important; stroke: var(--fg) !important; }
.mermaid svg .cluster rect { fill: var(--card) !important; stroke: var(--hair) !important; }
.mermaid svg :is(.flowchart-link, .edgePath .path) { stroke: var(--muted) !important; }
.mermaid svg :is(marker path, .arrowheadPath) { fill: var(--muted) !important; stroke: var(--muted) !important; }
.mermaid svg :is(.nodeLabel, .edgeLabel, .cluster-label, .label, text, span, p) { color: var(--fg); fill: var(--fg); }
.mermaid svg :is(.edgeLabel, .edgeLabel rect, .labelBkg) { background: var(--card) !important; fill: var(--card) !important; }

img { max-width: 100%; height: auto; }
/* A one-line caption under the dashboard screenshot */
.essay-body p:has(+ .shot-caption) { margin-bottom: 0.5rem; }
.essay-body .shot-caption { font-size: 0.85rem; line-height: 1.45; color: var(--muted); margin-bottom: 1.6em; }
.essay-body img { border: 1px solid var(--hair); border-radius: 6px; background: var(--card); }

.footer {
  max-width: 54rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.footer a { color: var(--muted); }

@media (max-width: 30rem) {
  body { font-size: 1.0625rem; }
  h1 { font-size: 2.2rem; }
  h2 { font-size: 1.75rem; }
  .essay-body h1 { font-size: 2.4rem; }
  .essay-body { padding-top: 1.75rem; }
}

/* ---- Big screens: fluid type, growing measure, breakout code and figures ---- */

@media (min-width: 48rem) {
  body {
    font-size: clamp(1.1875rem, 1.0625rem + 0.26vw, 1.375rem);
    --gutter: clamp(1.5rem, 4vw, 4rem);
    --measure: 64ch;
    --wide: min(calc(var(--measure) + 14rem), 100cqi - 2 * var(--gutter));
    container-type: inline-size;
    background:
      linear-gradient(to right,
        var(--edge) 0,
        var(--bg) calc(50% - var(--measure) / 2 - 10rem),
        var(--bg) calc(50% + var(--measure) / 2 + 10rem),
        var(--edge) 100%) fixed;
  }
  .content, .essay-body {
    max-width: calc(var(--measure) + 2 * var(--gutter));
    padding: 3rem var(--gutter) 5rem;
  }
  .essay-body { padding-top: 4rem; }
  .content > :is(p, ul, ol, blockquote, h1, h2, h3, h4, hr) { max-width: none; }
  .topnav, .essay-header, .footer {
    max-width: calc(var(--wide) + 2 * var(--gutter));
    padding-inline: var(--gutter);
  }
  .topnav, .essay-header { padding-top: 1.25rem; padding-bottom: 1rem; }

  h1, h2, h3, h4 { margin: 2.5em 0 0.6em; }
  h1 { font-size: clamp(2.6rem, 1.9rem + 1.3vw, 3.4rem); margin-top: 0.3em; }
  /* the article title: ~56px at 1280, ~60px at 1440, 64px from ~1600 up */
  .essay-body h1 { font-size: clamp(3.25rem, 1.75rem + 2.2vw, 4rem); max-width: 15em; }
  h2 { font-size: 1.85em; }
  h3 { font-size: 1.3em; }
  .essay-body .byline { margin-bottom: 2.8rem; }
  .essay-body .byline + h2 + p { font-size: 1.1em; }
  .essay-body .byline + h2 { margin-top: 1.4em; }

  pre, .mermaid, .essay-body img {
    width: var(--wide);
    max-width: none;
    margin-inline: calc((100% - var(--wide)) / 2);
  }
  pre { margin-block: 1.6em 1.8em; padding: 1.1rem 1.5rem; font-size: 0.78em; }
  .essay-body pre:has(+ p > img) { padding-top: 3.2rem; font-size: 0.88em; }
  .essay-body pre:has(+ p > img)::before { top: 0.95rem; left: calc(1.5rem + 3px); }
  .mermaid { margin-block: 2em; padding: 1.25rem; }
  .essay-body img { display: block; margin-block: 2.2em; }
  .essay-body p:has(> img:only-child) { margin: 0; }
  .essay-body p:has(+ .shot-caption) > img { margin-bottom: 0.6rem; }
  table {
    width: max-content;
    min-width: 100%;
    max-width: var(--wide);
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    margin-block: 1.6em 2em;
    font-size: 0.86em;
  }
}
@media (min-width: 80rem) { body { --measure: 68ch; } }
@media (min-width: 100rem) { body { --measure: 70ch; } }

/* ---- Diagrams: inline-SVG figures in the article. Colors and fonts come from the
   --d-* tokens defined per scheme below. ---- */

.diagram {
  margin: 1.8em 0 2em;
  padding: 1rem;
  background: var(--d-paper);
  border: 1px solid var(--d-hair);
  border-radius: 6px;
}
.diagram svg { display: block; width: 100%; height: auto; }
.diagram figcaption {
  margin-top: 0.8rem;
  font-family: var(--d-sans);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--d-muted);
}
.diagram .d-swatch {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.45em;
  vertical-align: -0.05em;
  background: var(--d-yellow);
  border: 1.5px solid var(--d-ink);
  border-radius: 2px;
}

/* 1. three sizes: three cards side by side, stacked on narrow screens */
.diagram .d-sizes { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.9rem; }
@media (min-width: 48rem) { .diagram .d-sizes { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.diagram .d-size {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.8rem 0.85rem 0.9rem;
  background: var(--d-card);
  border: 1px solid var(--d-hair);
  border-radius: 6px;
}
.diagram .d-size svg { max-width: 22rem; }
.diagram .d-kicker {
  align-self: flex-start;
  margin: 0;
  padding: 0.1em 0.55em 0.02em;
  border: 1.5px solid var(--d-ink);
  border-radius: 3px;
  font-family: var(--d-cond);
  font-weight: 600;
  font-size: 0.75rem;
  line-height: 1.5;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--d-ink);
}
.diagram .d-what {
  margin: 0;
  font-family: var(--d-sans);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--d-ink);
}
@media (min-width: 48rem) { .diagram .d-what { min-height: 2.6em; } }
.diagram dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.25rem 0.65rem;
  margin: 0;
  font-family: var(--d-sans);
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--d-ink);
}
.diagram dt {
  padding-top: 0.12em;
  font-family: var(--d-cond);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--d-muted);
}
.diagram dd { margin: 0; }
.diagram dd.d-move { font-weight: 600; }

/* 2. containment: one picture, capped so its labels stay near natural size */
.diagram-vocab svg { max-width: 34rem; margin: 0 auto; }

/* 3. life of a flight: wide; on phones it keeps a legible size and scrolls sideways */
.diagram .d-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.diagram .d-scroll:focus-visible { outline: 2px solid var(--d-ink); outline-offset: 2px; }
@media (max-width: 40rem) { .diagram-flow svg { width: 760px !important; max-width: none; } }
/* phones get a stacked version of the containment picture (only one is ever displayed,
   so assistive tech sees one image) */
.diagram-vocab svg.d-narrow { display: none; max-width: 22rem; }
@media (max-width: 40rem) {
  .diagram-vocab svg.d-wide { display: none; }
  .diagram-vocab svg.d-narrow { display: block; }
  .diagram { padding: 0.75rem; }
  .diagram .d-size { padding: 0.75rem; }
}

:root {
  --d-sans: var(--sans); --d-cond: var(--cond); --d-mono: var(--mono);
  --d-ink: #16181b; --d-muted: #50565c; --d-paper: #ffffff; --d-card: #ffffff;
  --d-box: #fafaf8; --d-cell: #ffffff; --d-panel: #f4f5f3; --d-frame: #8e9398;
  --d-cell-line: #9aa0a5; --d-hair: #cdd1cc; --d-band: #e4e7e3;
  --d-red: #c4302b; --d-red-wash: #f7e1de; --d-red-text: #9e2520;
  --d-yellow: #f5c400; --d-on-yellow: #16181b;
  --d-tower: #16181b; --d-tower-text: #f1f2ef; --d-tower-accent: #f5c400;
  --d-green: #1b7a4c; --d-blue: #2a5caa; --d-blue-wash: #e4ecf7; --d-blue-text: #2a5caa;
  --d-gray: #5a6066; --d-pill-text: #ffffff; --d-runway: #2b2f33; --d-runway-mark: #fafaf8;
}
@media (prefers-color-scheme: dark) {
  :root {
  --d-ink: #eef0ed; --d-muted: #a4aaa3; --d-paper: #1c1f22; --d-card: #22262a;
  --d-box: #1b1e21; --d-cell: #2b2f33; --d-panel: #2a2e33; --d-frame: #6b7177;
  --d-cell-line: #5f666c; --d-hair: #3a3f45; --d-band: #191b1e;
  --d-red: #e5534b; --d-red-wash: #3d2422; --d-red-text: #f4a39d;
  --d-yellow: #f5c400; --d-on-yellow: #16181b;
  --d-tower: #2b2f33; --d-tower-text: #eef0ed; --d-tower-accent: #f5c400;
  --d-green: #1b7a4c; --d-blue: #2a5caa; --d-blue-wash: #1e2a3d; --d-blue-text: #8db1ee;
  --d-gray: #5a6066; --d-pill-text: #ffffff; --d-runway: #101214; --d-runway-mark: #a4aaa3;
  }
}

@media (min-width: 48rem) {
  .essay-body .diagram:not(.diagram-vocab) { width: var(--wide); max-width: none; margin-inline: calc((100% - var(--wide)) / 2); }
}
