/* raft-nib — one stylesheet, no scripts, no requests.

   The page is drafting vellum and navy ink. Colour carries one meaning each:

     --n1 --n2 --n3   which node. Teal, amber, violet, in the order of the
                      hosts. Used for a node's lane, its leader bars, its
                      applies, and nowhere else.
     --refuse         where the monitor refused a run. Nothing else is red.
     --ink, --ink-2   text; --rule the hairlines and the timeline grid.

   The timelines are the one loud thing on the page; everything around them
   is a quiet column of serif text. Every token is redefined for dark mode, and
   the SVG carries classes, never colours, so the drawings follow. */

:root {
  --ground: #eef2f3;
  --plot: #f8fafa;
  --panel: #e2e9ec;
  --rule: #c9d3d8;
  --ink: #0e1a24;
  --ink-2: #44525e;
  --ink-3: #5f6d78;
  --navy: #1d3557;
  --n1: #00797a;
  --n2: #b35c00;
  --n3: #5b3fb5;
  --refuse: #c2261b;

  --c-keyword: #1d3557;
  --c-type: #5b3fb5;
  --c-function: #00696a;
  --c-string: #3c6a1c;
  --c-literal: #9a4f00;

  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Sitka Text",
    Cambria, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0f1a22;
    --plot: #13212b;
    --panel: #172833;
    --rule: #2c3f4b;
    --ink: #dfe7eb;
    --ink-2: #a9b8c1;
    --ink-3: #8b9ba5;
    --navy: #9fb8dc;
    --n1: #42bdb5;
    --n2: #e89b50;
    --n3: #a990f2;
    --refuse: #ff6f61;

    --c-keyword: #9fb8dc;
    --c-type: #b9a3f5;
    --c-function: #5cc7bf;
    --c-string: #9ccc78;
    --c-literal: #eaa865;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 1.125rem/1.62 var(--serif);
  font-variant-numeric: lining-nums;
}

a { color: var(--navy); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 2px; }

::selection { background: color-mix(in srgb, var(--n1) 28%, transparent); }

/* ---- the frame: a left-aligned column inside a wider page ---- */

.top, main, footer, .run {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 16px;
  padding-right: 16px;
}

@media (min-width: 720px) {
  .top, main, footer, .run { padding-left: 48px; padding-right: 48px; }
}

main > section > *, footer > p { max-width: 68ch; }
main > section > .run, main > section > .scroll { max-width: none; }

/* A run drawn inside a section is already inside main's padding. */
main .run { padding-left: 0; padding-right: 0; margin-top: 28px; margin-bottom: 24px; }

/* ---- header ---- */

.top { padding-top: 40px; }

.crumb {
  margin: 0 0 28px;
  color: var(--ink-3);
  font-size: 0.95rem;
}

.crumb a { color: var(--ink-2); }

h1 {
  margin: 0;
  max-width: 16ch;
  font-size: clamp(2.3rem, 6.4vw, 4.1rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.lede {
  max-width: 62ch;
  margin: 24px 0 0;
  font-size: 1.22rem;
  line-height: 1.55;
  color: var(--ink-2);
}

/* ---- the run drawings ---- */

.run { margin-top: 40px; margin-bottom: 8px; }
.run.hero { margin-top: 44px; }

.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.timeline {
  display: block;
  width: 100%;
  min-width: 640px;
  height: auto;
  background: var(--plot);
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  font-family: var(--serif);
}

.timeline .grid { stroke: var(--rule); stroke-width: 1; }
.timeline .tick { fill: var(--ink-3); font-size: 12px; }
.timeline .host { fill: var(--ink); font-size: 13.5px; }
.timeline .lane { stroke-width: 1.5; stroke-opacity: 0.55; }
.timeline .lane.n1, .timeline .apply.n1 { stroke: var(--n1); }
.timeline .lane.n2, .timeline .apply.n2 { stroke: var(--n2); }
.timeline .lane.n3, .timeline .apply.n3 { stroke: var(--n3); }
.timeline .apply { stroke-width: 1.5; }
.timeline .leader.n1 { fill: var(--n1); }
.timeline .leader.n2 { fill: var(--n2); }
.timeline .leader.n3 { fill: var(--n3); }
.timeline .candidate { fill: var(--plot); stroke-width: 1.5; }
.timeline .candidate.n1 { stroke: var(--n1); }
.timeline .candidate.n2 { stroke: var(--n2); }
.timeline .candidate.n3 { stroke: var(--n3); }
.timeline .role { fill: var(--plot); font-size: 13px; font-weight: 700; }
.timeline .down { stroke: var(--rule); stroke-width: 1; }
.timeline .hatch { stroke: var(--ink-3); stroke-width: 1.2; stroke-opacity: 0.6; }
.timeline .downlabel { fill: var(--ink-3); font-size: 12px; font-style: italic; }
.timeline .refuse { stroke: var(--refuse); stroke-width: 2; }
.timeline .refuse-dot { fill: var(--plot); stroke: var(--refuse); stroke-width: 2.5; }
.timeline .refuselabel { fill: var(--refuse); font-size: 13px; font-weight: 700; }
.timeline .unread { fill: var(--plot); fill-opacity: 0.72; }
.timeline .unreadlabel { fill: var(--ink-3); font-size: 12px; font-style: italic; }

.run figcaption { max-width: 68ch; margin-top: 14px; font-size: 1rem; color: var(--ink-2); }
.run figcaption p { margin: 0 0 8px; }
.ok { color: var(--n1); }

.key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.sw {
  display: inline-block;
  width: 22px;
  height: 11px;
  margin-right: 4px;
  vertical-align: -1px;
  border-radius: 2px;
}
.sw.leader { background: linear-gradient(90deg, var(--n1) 33%, var(--n2) 33% 66%, var(--n3) 66%); }
.sw.candidate { border: 1.5px solid var(--ink-2); }
.sw.down {
  background: repeating-linear-gradient(45deg, var(--ink-3) 0 1.2px, transparent 1.2px 4.2px);
  opacity: 0.7;
}

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

main { padding-top: 24px; padding-bottom: 32px; }

section { margin-top: 64px; }

h2 {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0 0 18px;
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* The numeral is a step of the pipeline, so it is drawn as one: the same
   numbers as the list in "How a run becomes a verdict". */
h2 .n {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.55em;
  height: 1.55em;
  border: 2px solid var(--ink);
  border-radius: 50%;
  font-size: 0.72em;
  transform: translateY(-0.12em);
}

p { margin: 0 0 1em; }

.small { font-size: 0.95rem; color: var(--ink-3); }

/* ---- the pipeline: five steps, read left to right ---- */

.pipeline {
  list-style: none;
  counter-reset: step;
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  gap: 0;
}

.pipeline li {
  counter-increment: step;
  position: relative;
  padding: 10px 0 14px 46px;
  border-left: 2px solid var(--rule);
  margin-left: 15px;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink-2);
}

.pipeline li::before {
  content: counter(step);
  position: absolute;
  left: -16px;
  top: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--ground);
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
}

.pipeline li:last-child { border-left-color: transparent; }
.pipeline b { color: var(--ink); }
.pipeline a { text-decoration: none; }
.pipeline a:hover b { text-decoration: underline; }

/* ---- code ---- */

figure { margin: 0; }

figure.code { margin: 22px 0 26px; }

pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--panel);
  border-left: 3px solid var(--navy);
  font: 0.84rem/1.55 var(--mono);
  tab-size: 2;
}

pre.journal { font-size: 0.76rem; white-space: pre; }
pre.shell { margin: 16px 0 22px; }

figure.code figcaption {
  margin-top: 8px;
  font-size: 0.93rem;
  color: var(--ink-3);
}

code { font-family: var(--mono); font-size: 0.88em; }
pre code { font-size: inherit; }

.keyword { color: var(--c-keyword); font-weight: 600; }
.type { color: var(--c-type); font-weight: 600; }
.type.builtin { font-style: italic; font-weight: 500; }
.constructor { color: var(--c-literal); font-weight: 600; }
.string, .string.special { color: var(--c-string); }
.number, .constant, .constant.builtin { color: var(--c-literal); }
.comment { color: var(--ink-3); font-style: italic; }
.function, .function.builtin { color: var(--c-function); }
.property, .property.builtin, .attribute, .operator { color: var(--ink-2); }
.variable, .variable.builtin { color: var(--ink); }
.variable.parameter { color: var(--ink-2); font-style: italic; }
.punctuation, .punctuation.bracket, .punctuation.delimiter, .punctuation.special { color: var(--ink-3); }

/* ---- definitions: the five properties, the four decisions ---- */

.props { margin: 20px 0 24px; }
.props dt { font-weight: 700; margin-top: 14px; }
.props dd { margin: 2px 0 0; color: var(--ink-2); }

/* ---- the sweep table ---- */

table {
  width: 100%;
  min-width: 520px;
  margin: 18px 0 10px;
  border-collapse: collapse;
  font-size: 0.98rem;
}

th, td { text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 700; border-bottom: 2px solid var(--ink); }
td.held { color: var(--ink); }
td.broke { color: var(--refuse); font-weight: 700; }

ul { padding-left: 1.2em; }
li { margin-bottom: 0.5em; }

footer {
  margin-top: 40px;
  padding-top: 20px;
  padding-bottom: 48px;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
  color: var(--ink-3);
}

@media (max-width: 560px) {
  body { font-size: 1.05rem; }
  .lede { font-size: 1.1rem; }
  section { margin-top: 48px; }
  h2 { font-size: 1.5rem; }
}

.crumb-src { margin: 14px 0 0; font-size: 1rem; color: var(--ink-3); }
