/*
 * The documentation page's theme: ivory paper, dark brown ink, caramel, oxblood.
 *
 * Editorial rather than promotional. The rules this file keeps to, because the
 * two drafts before it broke all of them and read as a generic landing page:
 *
 *   no gradients as decoration, no glows, no drop shadows, no gradient text
 *   no pill badges, no glowing stat cards, no coloured panels for emphasis
 *   one accent, used for links and almost nothing else
 *   hairlines instead of borders, whitespace instead of boxes
 *
 * Emphasis comes from type and space. When something has to be set apart it
 * gets a rule or a margin, not a background. The exceptions are the two places
 * colour carries meaning rather than decoration, and they are the same two the
 * desktop window reserves: --danger is a live finding and --ok is a check that
 * ran and passed. Nothing else may use them.
 *
 * There are no gradients in the file at all. The strip the companion stood on
 * used to be one, fading the page out behind him with a translucent wash that
 * followed the reader down the document. He is parked in the corner now, with a
 * short drawn ledge under his feet and nothing else: the wash was there to make
 * an opaque speech bubble readable wherever he stopped, and the answer to that
 * was to stop putting him where the text is, not to fade the text out.
 *
 * The ornaments are the other thing this file places: an Ionic column, an arch,
 * a temple, a wreath. Janus is the god of doors and beginnings, and the page is
 * dressed as the building he would have been kept in. They fill space nothing
 * else reaches (the rail beside a 33rem measure, the outer margins) and none of
 * them is ever placed where a table or a code block can grow into it.
 */

:root {
  /* Ivory rather than white. A pure #fff page glares under a reading lamp, and
     this one has to sit under a brown ink and a caramel rule without either of
     them reading as a stain on it. */
  --paper: #faf5ea;
  --paper-2: #f2ead9;

  /* Dark brown, not black. The character's own outline is a near-black brown
     (#160f0a in argos.txt), so the page's ink is the same family: the dog looks
     drawn onto the document rather than pasted over it. */
  --ink: #2b1d13;
  --body: #4a3a2d;
  --muted: #7a6553;
  --faint: #a08b76;
  --rule: #e2d5bf;
  --rule-soft: #ece2d1;

  /* Caramel. Deep enough for body-size link text on ivory (about 4.9:1), which
     the lighter caramel below is not, so the light one is kept for rules and
     marks where nothing has to be read out of it. */
  --accent: #9a5d21;
  --caramel: #c08a4a;

  /* Oxblood is the live finding, and the only red on the page. */
  --danger: #6e1f26;
  --ok: #4f6137;
  --warn: #8a5a12;

  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Palatino Linotype",
    Palatino, Georgia, ui-serif, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* A reading measure, in the low sixties of characters. Anything wider and
     the eye loses the line return on a serif this size. */
  --measure: 33rem;
  --max: 76rem;

  /* The corner Argos occupies. The page reserves this much room on its right
     so that nothing is ever laid out underneath him: a speech bubble is opaque,
     and an opaque box over running text is the one thing it must never be. */
  --corner: 15rem;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

/* Serif for reading, sans for chrome. The body of a document that expects to be
   read for ten minutes is set in a serif; the navigation and the labels around
   it are furniture and stay out of the way in sans. */
body {
  margin: 0;
  background: var(--paper);
  color: var(--body);
  font: 19px/1.78 var(--serif);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(154, 93, 33, 0.3);
}

a:hover {
  border-bottom-color: var(--accent);
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.24;
  letter-spacing: -0.005em;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.06em 0.32em;
}

pre {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  font-size: 0.83rem;
  line-height: 1.7;
  margin: 1.4rem 0;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  color: #3a2a1c;
  font-size: 1em;
}

/* --- masthead ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 1rem 2rem;
  background: rgba(250, 245, 234, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}

.topbar .brand {
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
}

/* The second syllable in caramel, so the wordmark carries the palette without
   a logo file to keep in sync with anything. */
.topbar .brand em {
  font-style: normal;
  color: var(--accent);
}

.topbar .for {
  font-size: 0.8rem;
  color: var(--faint);
}

.topbar nav {
  margin-left: auto;
  display: flex;
  gap: 1.6rem;
  font-size: 0.85rem;
}

.topbar nav a {
  color: var(--muted);
  border-bottom: 0;
}

.topbar nav a:hover {
  color: var(--ink);
}

/* --- hero ---------------------------------------------------------------- */

.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: 6rem 2rem 3.5rem;
}

.eyebrow {
  display: block;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 1.6rem;
}

.hero h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(2rem, 3.6vw, 2.7rem);
  font-weight: 600;
  letter-spacing: -0.012em;
  max-width: 19ch;
}

.hero .tagline {
  margin: 0 0 2.2rem;
  font-size: 1.07rem;
  line-height: 1.72;
  color: var(--body);
  max-width: var(--measure);
}

.cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.6rem;
  font-family: var(--sans);
  font-size: 0.9rem;
}

.cta .go {
  border-bottom-width: 2px;
  font-weight: 500;
}

.cta .quiet {
  color: var(--muted);
  border-bottom-color: var(--rule);
}

.cta .quiet:hover {
  color: var(--ink);
  border-bottom-color: var(--faint);
}

/* --- the numbers, as a line of type rather than cards -------------------- */

.figures {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2.5rem;
  border-top: 1px solid var(--rule);
  padding-top: 2.2rem;
}

.figure b {
  display: block;
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
}

.figure span {
  display: block;
  font-family: var(--sans);
  margin-top: 0.55rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}

/* --- terminal ------------------------------------------------------------ */

.term {
  max-width: var(--max);
  margin: 3.5rem auto 0;
  padding: 0 2rem;
}

.term-inner {
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}

.term-bar {
  padding: 0.55rem 1rem;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--faint);
}

.term pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #fffdf8;
  font-size: 0.78rem;
  line-height: 1.8;
}

/* Terminal output. Only the two reserved colours plus the ink: a finding is
   --danger, a pass is --ok, everything else is type weight and grey. */
.c-dim {
  color: var(--faint);
}
.c-cmd {
  color: var(--ink);
  font-weight: 600;
}
.c-bad {
  color: var(--danger);
  font-weight: 600;
}
.c-ok {
  color: var(--ok);
}
.c-warn {
  color: var(--warn);
}
.c-key {
  color: var(--ink);
  font-weight: 600;
}
.c-w {
  color: var(--ink);
}

/* --- layout -------------------------------------------------------------- */

/*
 * Three columns: the contents, the document, and the ornament rail.
 *
 * The rail is a real column rather than something floated into the text. The
 * prose is capped at a reading measure but the tables and the code blocks are
 * not, so an ornament placed in the gutter by hand would sit politely beside a
 * paragraph and then land on top of the next wide table. Given its own column
 * it cannot overlap anything, whatever the section is made of.
 */
.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 4.5rem 2rem 5rem;
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr) 11rem;
  gap: 3.4rem;
  align-items: start;
}

.toc {
  position: sticky;
  top: 4.5rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

.toc .group {
  margin: 1.6rem 0 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--faint);
}

.toc .group:first-child {
  margin-top: 0;
}

.toc a {
  display: block;
  padding: 0.22rem 0 0.22rem 0.85rem;
  margin-left: -1px;
  border-left: 1px solid var(--rule);
  border-bottom: 0;
  color: var(--muted);
}

.toc a:hover {
  color: var(--ink);
  border-left-color: var(--faint);
}

.toc a.here {
  color: var(--ink);
  border-left-color: var(--accent);
}

main {
  min-width: 0;
}

section {
  margin-bottom: 4.5rem;
  scroll-margin-top: 4.5rem;
}

section > p,
section > ul {
  max-width: var(--measure);
}

section h2 {
  font-size: 1.42rem;
  font-weight: 600;
  margin: 0 0 1.2rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--rule);
}

section h3 {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 2.4rem 0 0.7rem;
}

section ul {
  padding-left: 1.1rem;
}

section li {
  margin-bottom: 0.75rem;
}

blockquote {
  margin: 1.5rem 0;
  padding-left: 1.2rem;
  border-left: 2px solid var(--caramel);
  color: var(--muted);
  font-style: italic;
}

blockquote code {
  font-style: normal;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6rem 0;
  font-size: 0.92rem;
}

th {
  text-align: left;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 0.9rem 0.6rem 0;
  border-bottom: 1px solid var(--ink);
}

td {
  padding: 0.7rem 0.9rem 0.7rem 0;
  border-bottom: 1px solid var(--rule-soft);
  color: var(--body);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: 0;
}

/* A wide table on a narrow screen scrolls in its own box rather than pushing
   the whole document sideways. */
.scroller {
  overflow-x: auto;
}

/* --- notes --------------------------------------------------------------- */

.note {
  margin: 1.6rem 0;
  padding-left: 1.2rem;
  border-left: 2px solid var(--rule);
  font-size: 0.94rem;
  color: var(--muted);
  max-width: var(--measure);
}

.note strong {
  color: var(--ink);
  font-weight: 600;
}

/* --- the join diagram ---------------------------------------------------- */

.viz {
  margin: 2.2rem 0;
}

.viz svg {
  display: block;
  width: 100%;
  height: auto;
}

.viz .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem;
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.viz .legend i {
  display: inline-block;
  width: 20px;
  height: 0;
  margin-right: 0.45rem;
  vertical-align: middle;
  border-top: 1.5px solid var(--faint);
}

.viz .legend i.dashed {
  border-top: 1.5px dashed var(--accent);
}

.viz .legend i.bad {
  border-top: 1.5px solid var(--danger);
}

/* A diagram's own one-line note, set tighter than a caption under a figure. */
.viz .note-line {
  margin-top: 0.7rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
  max-width: var(--measure);
}

/* --- benchmark ----------------------------------------------------------- */

.bench {
  margin: 1.8rem 0;
  max-width: 40rem;
}

.bench-row {
  display: grid;
  grid-template-columns: 13rem 1fr 3rem;
  gap: 1.2rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 0.88rem;
}

.bench-row:last-child {
  border-bottom: 0;
}

.bench-row .who {
  color: var(--ink);
}

.bench-row .who small {
  display: block;
  color: var(--faint);
  font-size: 0.76rem;
}

.bench-bar {
  height: 3px;
  background: var(--rule);
}

.bench-bar i {
  display: block;
  height: 100%;
  background: var(--ink);
}

.bench-row.weak .bench-bar i,
.bench-row.none .bench-bar i {
  background: var(--faint);
}

.bench-row .val {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--ink);
  text-align: right;
}

.bench-row.weak .val,
.bench-row.none .val {
  color: var(--faint);
}

.caption {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--faint);
  max-width: var(--measure);
  margin-top: 0.2rem;
}

/* --- the checks ---------------------------------------------------------- */

.checks {
  margin: 1.8rem 0;
  border-top: 1px solid var(--rule);
}

.check {
  padding: 1.3rem 0;
  border-bottom: 1px solid var(--rule-soft);
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 1.5rem;
  align-items: baseline;
}

.check h4 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
}

.check p {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
  color: var(--body);
}

.check .needs {
  font-family: var(--sans);
  font-size: 0.79rem;
  color: var(--faint);
}

/* --- copy button --------------------------------------------------------- */

.copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.2rem 0.55rem;
  font: 600 0.7rem var(--sans);
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease;
}

/* Keyboard users never hover, so focus has to reveal it or it is mouse-only. */
pre:hover .copy,
.copy:focus-visible {
  opacity: 1;
}

.copy:hover {
  color: var(--ink);
  border-color: var(--faint);
}

.copy.done {
  opacity: 1;
  color: var(--ok);
  border-color: var(--ok);
}

/* --- the companion ------------------------------------------------------- */

/*
 * Argos sits in the bottom right corner and stays there.
 *
 * He used to walk a strip across the full width of the window, which put his
 * speech bubble wherever he happened to stop, and a bubble is opaque, so it
 * covered whatever paragraph was behind it. Parking him solves half of that;
 * the other half is `body`'s reserved right-hand gutter below, without which a
 * corner is still somewhere the document is laid out.
 *
 * He is still not a decoration on a timer: the pose and the line both come from
 * the section being read, so he changes as the reader moves down the page.
 *
 * pointer-events: none is load-bearing. He sits over the page, so without it he
 * would eat the clicks on whatever is under him.
 */
.companion {
  position: fixed;
  right: 0;
  bottom: 0;
  width: var(--corner);
  height: var(--corner);
  z-index: 40;
  pointer-events: none;
}

.companion canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* --- the ornaments ------------------------------------------------------- */

/*
 * The rail beside the prose. Body copy is set to a 33rem measure inside a
 * column wider than that, so every section left a vertical band of nothing
 * down its right side; this is what now stands in it. One piece at a time,
 * changing with the section, for the same reason there is one dog.
 */
.relic {
  position: sticky;
  top: 6rem;
  height: 26rem;
  pointer-events: none;
}

.relic canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* An ornament arrives rather than appearing: it rises a little and settles.
   Cheap, and it is the same idea as the dog walking to his next stop. */
.relic canvas.arrive {
  animation: settle 520ms ease-out;
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(0.6rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* A band of the running key, where a hairline used to separate two regions of
   the page. Fixed height, because the art has one and scaling it would blur
   the only thing a pixel border has going for it. */
.frieze {
  max-width: var(--max);
  margin: 2.6rem auto 0;
  padding: 0 2rem;
  height: 2.6rem;
  overflow: hidden;
}

.frieze canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/*
 * The outer margins, which no content ever reaches on a wide screen. A single
 * column repeated down each side, turned on only once the viewport is wide
 * enough that the strips cannot touch the text.
 */
.colonnade {
  display: none;
}

@media (min-width: 104rem) {
  .colonnade {
    display: block;
    position: fixed;
    top: 0;
    bottom: 0;
    width: 6rem;
    z-index: 1;
    pointer-events: none;
    opacity: 0.5;
  }

  .colonnade.left {
    left: 0;
  }

  .colonnade.right {
    right: 0;
    /* Stops above the corner Argos occupies, so he is not standing in front of
       a column with his ledge cutting across it. The colonnade is a tile
       repeated from the top and is clipped by the window anyway, so ending it
       early reads no differently. */
    bottom: var(--corner);
  }

  .colonnade canvas {
    display: block;
    width: 100%;
    height: 100%;
  }
}

/* The hero's own set piece: the temple and the god, in the space the tagline's
   measure leaves beside it. Absolute rather than a grid cell, because the hero
   is one block of type and a second column would re-wrap the headline. */
.hero {
  position: relative;
}

.hero .standing {
  position: absolute;
  right: 2rem;
  bottom: 2.5rem;
  width: 21rem;
  height: 15rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: end;
  pointer-events: none;
}

.hero .standing canvas {
  display: block;
  width: 100%;
  height: 100%;
}

@media (max-width: 62rem) {
  .hero .standing {
    display: none;
  }
}

/* --- footer -------------------------------------------------------------- */

footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2.5rem 2rem 3rem;
  border-top: 1px solid var(--rule);
  color: var(--faint);
  font-size: 0.84rem;
}

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 60rem) {
  .hero {
    padding-top: 4rem;
  }

  .figures {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.8rem;
  }

  .page {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  /* No room for a rail beside the text once the contents has folded to a row
     of links: the ornament would be a third of the width of the document. */
  .relic {
    display: none;
  }

  .toc {
    position: static;
    max-height: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 1.1rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--rule);
  }

  .toc .group {
    display: none;
  }

  .toc a {
    border-left: 0;
    padding: 0.15rem 0;
    margin: 0;
  }

  .toc a.here {
    border-bottom: 1px solid var(--accent);
  }

  .check {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .bench-row {
    grid-template-columns: 1fr 3rem;
  }

  .bench-row .bench-bar {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media (max-width: 34rem) {
  body {
    font-size: 16px;
  }

  .topbar,
  .hero,
  .figures,
  .term,
  .page,
  footer {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .topbar nav {
    display: none;
  }

  .figures {
    grid-template-columns: 1fr;
  }
}

/*
 * The reserved gutter, and the width below which there is no reserving it.
 *
 * Above the breakpoint the page is laid out inside `body`'s content box, which
 * stops short of the corner, so the bubble has somewhere to be that is not on
 * top of a paragraph. Below it, reserving a sixth of a narrow window would cost
 * the document more than the companion is worth, so he goes rather than the
 * text: the script also stops animating once the canvas has no box.
 */
@media (min-width: 70rem) {
  body {
    padding-right: var(--corner);
  }

  .topbar {
    padding-right: 2rem;
  }
}

@media (max-width: 70rem) {
  .companion {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
