/* ===========================================================================
   site/site.css — the whole visual system. One file, no imports, no webfonts,
   no external request of any kind. site/BRIEF.md §3 is the specification and
   this file is meant to be read beside it.

   Two typographic voices, because the repository has two kinds of content:
   PROSE is serif at book measure, WIRE is mono. Colour encodes exactly two
   things, each in its own kind of block: inside a ```console transcript it is
   byte direction (>> client, << server) and verdict (ok / FAIL); inside a
   code fence it is grammar — the eight muted tok-* classes below, on the
   same hues. The two never share a block: a transcript holds bytes, a code
   fence holds code, and colour never means both at once.
   =========================================================================== */

:root {
  --paper:   #FAF9F4;  --ink:  #1F1D17;  --ink-2: #676157;
  --rule:    #E4E0D3;  --code-bg: #F2EFE6;
  --tx:      #2F5A8C;  /* client >> ; also links */
  --rx:      #2E6B45;  /* server << ; also ok verdicts */
  --err:     #A23B2A;  /* FAIL verdicts, error vocabulary */
  --syn-num: #8A5A18;  /* syntax: numbers */
  --syn-ty:  #6E4E8E;  /* syntax: types, keys, directives */

  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia,
           "Liberation Serif", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas,
          "DejaVu Sans Mono", monospace;
}
@media (prefers-color-scheme: dark) { :root {
  --paper:   #15130E;  --ink:  #E5E0D4;  --ink-2: #9A9486;
  --rule:    #2C2920;  --code-bg: #1C1913;
  --tx:      #8FB6E4;  --rx:   #85C29B;  --err:  #E08D75;
  --syn-num: #D9B36C;  --syn-ty: #BFA1DC;
} }

/* --- page ---------------------------------------------------------------- */

/* color-scheme tells the browser that the two palettes above are the whole
   story, so anything it draws for itself follows prefers-color-scheme as the
   tokens do. It is necessary and not sufficient: the scrollbars needed saying
   twice, and are said again under `pre`. */
html { background: var(--paper); color-scheme: light dark;
       -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1.0625rem/1.55 var(--serif);
  font-variant-numeric: oldstyle-nums proportional-nums;
}

/* The type block is 42rem and everything is set in it — masthead, prose,
   footer. Plates (transcripts, wide tables, figures) hang 7rem into each
   margin, to 56rem, the way a technical book floats its figures past the
   measure. The breakout is a negative margin behind a width query, so a
   narrow window simply does not do it and the page never scrolls sideways. */
main, .masthead, .crumb, footer {
  max-width: 44.5rem; margin-left: auto; margin-right: auto; padding: 0 1.25rem;
}
/* A block only takes the wider measure when it needs it: tools/site.py marks
   a pre or a table `.plate` when its widest line does not fit the 42rem
   column. `V=1 make test` stretched to 56rem is not a plate, it is a shell
   command wearing a banner. */
@media (min-width: 61rem) {
  main > pre.plate, main > .scroll.plate, main > figure, main > .plate {
    margin-left: -7rem; margin-right: -7rem;
  }
}

/* --- masthead and footer ------------------------------------------------- */

.masthead {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem;
  align-items: baseline; justify-content: space-between;
  padding-top: 1.5rem; padding-bottom: .75rem;
  border-bottom: 1px solid var(--rule);
}
.wordmark { font: 700 1rem var(--serif); color: var(--ink); text-decoration: none; }
.masthead nav { font: .8125rem var(--mono); }
/* The separator carries its own space on the left only: a real space follows
   it in the markup, which is the nav's one break opportunity per item. */
.masthead .sep { color: var(--ink-2); padding-left: .3em; }

.crumb { font: .75rem var(--mono); color: var(--ink-2); margin: 1.5rem auto 0; }

footer {
  font: .75rem/1.6 var(--mono); color: var(--ink-2);
  border-top: 1px solid var(--rule); padding-top: 1.5rem;
  margin-top: 4.5rem; margin-bottom: 3rem;
}

/* --- headings ------------------------------------------------------------ */

h1 { font: 400 1.875rem/1.2 var(--serif); margin: 2.25rem 0 .75rem; }
h2 { font: 700 1.375rem/1.25 var(--serif); margin: 3rem 0 .75rem; }
h3 { font: 700 1.0625rem/1.35 var(--serif); margin: 1.5rem 0 .375rem; }
.kicker + h2 { margin-top: 0; }
h1 a, h2 a, h3 a { text-decoration-color: var(--rule); }

/* The kicker row: the site's one piece of ornament, and it is quoted rather
   than invented — oe_probe prints `--- frame 1 ---` between frames. Baseline,
   not center: a label long enough to wrap (tests/README.md's § 3) would
   otherwise leave the rule floating between its two lines, attached to
   neither. On the baseline it sits on the first line, where a rule after a
   running head belongs. */
.kicker {
  display: flex; align-items: baseline; gap: .75rem;
  margin: 3rem 0 .75rem; max-width: 42rem;
}
.kicker .k {
  font: .75rem/1.4 var(--mono); text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-2);
}
.kicker i { flex: 1 0 2rem; border-top: 1px dashed var(--rule); }

/* --- prose --------------------------------------------------------------- */

p { margin: 0 0 .75rem; }
.standfirst { font-size: 1.125rem; line-height: 1.5; margin-bottom: .75rem; }
.standfirst strong { font-weight: 400; }
.byline { font: .8125rem var(--mono); color: var(--ink-2); margin-bottom: 1.5rem; }
blockquote.pull { font-size: 1.1875rem; line-height: 1.45; margin: 2.25rem 0; }
ul, ol { margin: 0 0 .75rem; padding-left: 1.5rem; }
li { margin: 0 0 .375rem; }
li > ul, li > ol { margin-top: .375rem; }
blockquote {
  margin: 1.5rem 0; padding-left: 1rem;
  border-left: 2px solid var(--ink-2); font-style: normal;
}
blockquote p:last-child { margin-bottom: 0; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.25rem auto; }

a { color: var(--tx); text-decoration: underline;
    text-underline-offset: 3px; text-decoration-color: var(--rule); }
a:hover { text-decoration-color: var(--tx); }

/* --- code and transcripts ------------------------------------------------ */

code { font: .875em var(--mono); background: var(--code-bg);
       padding: .1em .3em; border-radius: 2px; }
pre {
  font: .8125rem/1.5 var(--mono); background: var(--code-bg);
  padding: 1rem; border-radius: 2px; border-left: 2px solid var(--rule);
  margin: 1.5rem auto; overflow-x: auto;
}
pre code { font-size: inherit; background: none; padding: 0; border-radius: 0; }
/* `wrap` soft-wraps a transcript instead of scrolling it. The wire page uses
   it throughout: a terminal soft-wraps a long line too, so a reader comparing
   the page with their own run sees the same shape — and GET /schema's reply is
   a single 1,468-byte line no phone is going to scroll sideways. break-word,
   not anywhere: ordinary annotation still breaks between words, and only a run
   with no space in it (which is to say, JSON) is ever cut mid-token. */
pre.wrap { white-space: pre-wrap; overflow-wrap: break-word; }
/* The two blocks that scroll sideways, and the only browser furniture the site
   ever shows. Given the tokens rather than left to the UA: color-scheme above
   is not enough on its own in Firefox, and an unstyled thumb draws a white bar
   across a dark page — the one place dark mode looked like an oversight. */
pre, .scroll { scrollbar-color: var(--ink-2) var(--code-bg); }

/* The wire page's legend: the three-line grammar the transcripts are set in. */
.legend { margin: 1.5rem 0; font: .8125rem/1.7 var(--mono); }
.legend dt { float: left; clear: left; width: 2.5rem; font-weight: 700; }
.legend dd { margin: 0 0 0 2.5rem; color: var(--ink-2); }

.tx   { color: var(--tx); }             /* >> bytes the client sent          */
.rx   { color: var(--rx); }             /* << bytes the server sent          */
.note { color: var(--ink-2); font-style: italic; }  /* ~ never a byte        */
.ok   { color: var(--rx); font-weight: 700; }
.fail { color: var(--err); font-weight: 700; }
.err  { color: var(--err); }
.cmd .sig { color: var(--ink-2); }      /* the shell's $, not part of the cmd */

/* The code-fence palette (BRIEF §3.4): eight roles, five hues, all of them
   the site's own. Colour inside ```console is byte direction and verdict;
   inside a code fence there are no bytes, and the same hues mean grammar
   instead — blue keywords, green strings, ochre numbers, violet types and
   keys, brick variables, calls in bold ink. Comments take the `~` voice,
   --ink-2 italic, because that is what annotation already sounds like here. */
.tok-k { color: var(--tx); }      /* keywords: if, def, FROM, true, include  */
.tok-s { color: var(--rx); }      /* strings                                  */
.tok-n { color: var(--syn-num); } /* numbers                                  */
.tok-t { color: var(--syn-ty); }  /* types, builtins, JSON/TOML keys, oe_/OE_ */
.tok-v { color: var(--err); }     /* $variables, $(substitutions)             */
.tok-f { font-weight: 700; }      /* calls, commands, make targets            */
.tok-p { color: var(--syn-ty); }  /* #define and other #-directives, @decor   */
.tok-c { color: var(--ink-2); font-style: italic; }  /* comments              */

/* --- tables -------------------------------------------------------------- */

/* The right edge of a table that still has columns to the right of it. Two
   background layers: a crease fixed to the element, and a patch of paper
   attached to the CONTENT, which sits at the far end of the scroll and covers
   the crease when you reach it. So the mark appears only when there is more
   table, and a phone reader can tell a clipped column from a truncated one —
   which, on a 390px routes table, is the one place this site looked broken
   when it was not. No script, and nothing to reset: a block that does not
   scroll has its two layers exactly on top of each other. */
.scroll {
  overflow-x: auto; margin: 1.5rem auto;
  background:
    linear-gradient(var(--paper), var(--paper)) 100% 0 / 1.5rem 100% no-repeat local,
    linear-gradient(to right, transparent,
                    color-mix(in srgb, var(--ink-2) 30%, transparent))
      100% 0 / 1.5rem 100% no-repeat;
}
table {
  border-collapse: collapse; width: 100%;
  font: .8125rem/1.45 var(--mono);
  font-variant-numeric: tabular-nums;
}
th, td { text-align: left; padding: .45rem .75rem .45rem 0;
         border-bottom: 1px solid var(--rule); vertical-align: top; }
th {
  font: .6875rem var(--mono); text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-2); border-bottom: 1px solid var(--ink-2); white-space: nowrap;
}
td:last-child, th:last-child { padding-right: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.right, th.right { text-align: right; }
td.center, th.center { text-align: center; }
td code, th code { background: none; padding: 0; font-size: 1em; }
/* The dimmed rows of plate 1: declining the Task API is conforming. */
tr.dim td { color: var(--ink-2); }
.nowrap { white-space: nowrap; }

/* --- figures ------------------------------------------------------------- */

figure { margin: 1.5rem auto; }
figure > pre, figure > .scroll, figure > table { margin-top: 0; }
figcaption {
  font: italic .9375rem/1.5 var(--serif); color: var(--ink-2);
  margin-top: .75rem;
}
figcaption .lead { font-style: normal; }
figcaption .from { font: .8125rem var(--mono); font-style: normal; }

/* --- generated-page contents --------------------------------------------- */

.contents {
  font: .8125rem/1.9 var(--mono); color: var(--ink-2);
  margin: 2.25rem auto; padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.contents .lbl {
  display: block; font-size: .6875rem; text-transform: uppercase;
  letter-spacing: .08em; margin-bottom: .25rem;
}
.contents a.sub { color: var(--ink-2); }
.contents code { background: none; padding: 0; font-size: 1em; }
h1 + .contents { margin-top: 1.5rem; }

/* The arcade's map (ARCADE-IA §1.3): the same contents idiom, one row per
   plate. The hanging indent keeps a row that wraps at 390px hung on its
   name, so the plate names stay a scannable column. */
.map ul { list-style: none; margin: 0 0 1.125rem; padding: 0; }
.map li { padding-left: 1.25rem; text-indent: -1.25rem; }
.map .also { margin: 0; }

/* The kicker's return path (ARCADE-IA §1.7): after the dashed rule, one mono
   link back to the map, so every plate can be left the way it was entered.
   --ink-2 with the hairline underline: navigation, never a second label. */
.kicker .up { font: .75rem/1.4 var(--mono); text-transform: uppercase;
              letter-spacing: .08em; color: var(--ink-2); text-decoration-color: var(--rule); }

/* --- the protocol cluster rail -------------------------------------------- */
/* Five documents, one subject, and each one's label is its own definition of
   itself. It sits under the document rather than over it, because it is the
   question a reader has when they have finished, not when they arrive. */

.rail { margin-top: 4.5rem; }
.rail .back {
  font: .75rem var(--mono); margin: 1.5rem 0 0;
  padding-top: 1.5rem; border-top: 1px dashed var(--rule);
}
.rail .kicker + .scroll + .back { margin-top: 0; }
.rail .kicker { margin-bottom: 0; }
.rail .scroll { margin-top: 0; }
/* Not the 100% every other table takes: five short rows of navigation should
   sit together at the left, not be spread across the measure by auto-layout. */
.rail table { width: auto; }
.rail td { border-bottom: 0; padding-top: .3rem; padding-bottom: .3rem;
           padding-right: 1.25rem; white-space: nowrap; }
.rail tr.here td { color: var(--ink-2); }
.rail .you {
  font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em;
  white-space: nowrap;
}

/* --- the contents page ---------------------------------------------------- */

.gen {
  font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-2); white-space: nowrap;
}
/* One width for the filename column across all six tables, so the descriptions
   start on one line down the whole page rather than on six. */
td.what { white-space: nowrap; width: 17rem; }

/* The lead: docs/TOUR.md, set apart because it is the document that orders the
   others. Dashed rules, the kicker's rule, not the blockquote's solid one. */
.lead {
  border-top: 1px dashed var(--rule); border-bottom: 1px dashed var(--rule);
  padding: 1.5rem 0; margin: 2.25rem 0;
}
.lead p.what { font: .8125rem var(--mono); margin-bottom: .75rem; }
.lead p.next { color: var(--ink-2); margin-bottom: 0; }
.lead p:last-child { margin-bottom: 0; }

@media (max-width: 34rem) {
  td.what { white-space: normal; width: auto; }
  /* A phone gets a wrapped rail rather than a nav it has to scroll sideways. */
  .rail td { white-space: normal; padding-right: .75rem; }
}

/* --- the door list (index) ------------------------------------------------ */
/* Five doors, labelled by who you are and not by what to click. Hairlines and
   a label column, never a card: the row is a line in a table of contents that
   happens to be addressed to a person. */

.doors { margin: 1.5rem 0 0; border-top: 1px solid var(--rule); }
.doors .door {
  display: grid; grid-template-columns: 14.5rem 1fr; gap: 0 1.5rem;
  padding: .75rem 0; border-bottom: 1px solid var(--rule);
}
.doors dt { font-weight: 700; }
.doors dd { margin: 0; }

/* --- the layer stack (index) ---------------------------------------------- */
/* README.md draws this in box characters. Here it is elements, so it reflows
   on a phone and reads aloud in order. The protocol layer is emphasised by
   weight and rule only: colour on this site is byte direction and verdict, and
   a diagram is neither. */

.stack .above, .stack .foot {
  font: .8125rem/1.5 var(--mono); color: var(--ink-2); margin: 0;
}
.stack .above {
  border: 1px dashed var(--rule); border-radius: 2px; padding: .625rem .875rem;
}
.stack .into {
  margin: 0; padding: .125rem 0; text-align: center;
  font: 1rem/1.4 var(--mono); color: var(--ink-2);
}
.stack .box {
  background: var(--code-bg); border: 1px solid var(--rule);
  border-radius: 2px; padding: .875rem;
}
.stack .tag, .stack .role {
  font: .6875rem/1.6 var(--mono); text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-2);
}
.stack .tag { margin: 0 0 .625rem; }
.stack .layers { list-style: none; margin: 0; padding: 0; }
.stack .layer {
  display: grid; grid-template-columns: 16rem 1fr; gap: 0 1.5rem;
  margin: 0; padding: .75rem .875rem;
  border-left: 2px solid var(--rule);
}
.stack .name { font: .875rem/1.5 var(--mono); margin: 0; }
.stack .role { display: block; }
.stack .body { margin: 0; font-size: .9375rem; color: var(--ink-2); }
.stack .body code { background: none; padding: 0; }
/* The middle layer is the subject of the whole repository, so it is the only
   one lifted onto the paper: emphasis by panel and weight, never by hue. */
.stack .core {
  background: var(--paper); border-left-color: var(--ink);
  padding-top: 1rem; padding-bottom: 1rem;
}
.stack .core .role { color: var(--ink); font-weight: 700; }
.stack .core .body { color: var(--ink); }
/* A seam is the name `make check` prints for the rule that holds it. */
.stack .seam {
  font: .6875rem/1.6 var(--mono); color: var(--ink-2);
  padding: .5rem .875rem; border-left: 2px dashed var(--rule);
}
.stack .seam .ok { font-weight: 400; }
.stack .foot {
  margin-top: .75rem; padding-top: .625rem;
  border-top: 1px dashed var(--rule);
}

/* --- narrow -------------------------------------------------------------- */

@media (max-width: 46rem) {
  .doors .door, .stack .layer { grid-template-columns: 1fr; gap: .25rem 0; }
}
@media (max-width: 34rem) {
  body { font-size: 1rem; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  pre { font-size: .75rem; padding: .75rem; }
  table { font-size: .75rem; }
  .masthead { display: block; }
  .masthead nav { margin-top: .375rem; display: block; }
}
