/*
  The HTML of the guide and of its reference, which docs/build.py writes:
  the tokens, dark mode, masthead and contents of the design pages and of
  the reference pages that were written by hand. The fonts are those of
  the computer: the HTML is installed, and opens without the network.
*/

:root {
  --ground: #f2f5f4;
  --surface: #ffffff;
  --ink: #16211e;
  --muted: #56655f;
  --rule: #d2dbd7;
  --rule-strong: #a9b7b1;
  --line: #71827b;
  --accent: #1b6880;
  --accent-soft: #ddebf0;
  --warn: #7a4800;
  --warn-soft: #faeed6;
  --risk: #982b22;
  --risk-soft: #f9e6e3;
  --ok: #2b6b3d;
  --ok-soft: #e1f0e4;
  --code-bg: #e8eeec;
  --code-ink: #1c2926;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Cantarell", sans-serif;
  --font-head: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0e1312;
    --surface: #141b19;
    --ink: #e0e7e4;
    --muted: #98a6a0;
    --rule: #29342f;
    --rule-strong: #43514b;
    --line: #83938d;
    --accent: #6dc3da;
    --accent-soft: #14303a;
    --warn: #edb45a;
    --warn-soft: #2a2112;
    --risk: #ef9a90;
    --risk-soft: #351b18;
    --ok: #85d29c;
    --ok-soft: #15301f;
    --code-bg: #172120;
    --code-ink: #d5dedb;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0e1312;
  --surface: #141b19;
  --ink: #e0e7e4;
  --muted: #98a6a0;
  --rule: #29342f;
  --rule-strong: #43514b;
  --line: #83938d;
  --accent: #6dc3da;
  --accent-soft: #14303a;
  --warn: #edb45a;
  --warn-soft: #2a2112;
  --risk: #ef9a90;
  --risk-soft: #351b18;
  --ok: #85d29c;
  --ok-soft: #15301f;
  --code-bg: #172120;
  --code-ink: #d5dedb;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.6 var(--font-body);
}
.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 16px 80px;
}
main { min-width: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
p, li, dd { max-width: 72ch; }
p { margin: 0 0 14px; }

/* the way back to the index */
.trail { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.trail p { margin: 0; }
.trail a { color: var(--muted); }

h1 {
  font: 600 clamp(1.9rem, 5vw, 2.6rem)/1.1 var(--font-head);
  margin: 0 0 18px;
  text-wrap: balance;
}
h2 {
  font: 600 1.55rem/1.2 var(--font-head);
  margin: 40px 0 14px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  text-wrap: balance;
}
h3 { font: 600 1.2rem/1.25 var(--font-head); margin: 28px 0 10px; }
h4 { font: 600 1.05rem/1.3 var(--font-head); margin: 22px 0 8px; }
h2, h3, h4 { scroll-margin-top: 16px; }

/* the marks of the guide */
code, kbd, pre {
  font-family: var(--font-mono);
}
code {
  font-size: 0.88em;
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 0.08em 0.32em;
  border-radius: 3px;
  overflow-wrap: anywhere;
}
code em { font-style: italic; }
.cmd em, code em { color: inherit; }
kbd {
  font-size: 0.82em;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.05em 0.4em;
  background: var(--surface);
  white-space: nowrap;
}
.gui { font-weight: 600; }
.guiseq { white-space: normal; }
.app { font-style: italic; }
span.cmd { font-family: var(--font-mono); font-size: 0.88em; }

/* blocks */
ul, ol { margin: 0 0 16px; padding-left: 1.4em; }
li { margin-bottom: 6px; }
li::marker { color: var(--muted); }
ol > li { padding-left: 0.2em; }
dl { margin: 0 0 18px; }
dt { font-weight: 600; margin-top: 12px; }
dd { margin: 4px 0 0 1.4em; }
dd > p:last-child { margin-bottom: 0; }
.terms > .title, .title { font-weight: 600; color: var(--muted); margin-bottom: 4px; }
pre {
  margin: 0 0 18px;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: 6px;
  font-size: 13.5px;
  line-height: 1.55;
}
pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.note {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
  padding: 12px 16px;
  margin: 0 0 18px;
}
.note.tip { border-color: var(--ok); background: var(--ok-soft); }
.note.warning { border-color: var(--warn); background: var(--warn-soft); }
.note > :last-child { margin-bottom: 0; }
figure { margin: 8px 0 24px; }
figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}
figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; }
table { border-collapse: collapse; margin: 0 0 18px; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 7px 14px 7px 0; border-bottom: 1px solid var(--rule); }
th { font-weight: 600; color: var(--muted); }

/* the index, and See also: pages with their lines */
.links { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 32px; margin: 0 0 8px; }
h2.columns + .links { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.link { padding: 6px 0; }
.link p { margin: 0; }
.link > p a { font-weight: 500; text-decoration: none; }
.link > p a:hover { text-decoration: underline; }
.link .desc { font-size: 14px; color: var(--muted); }
.seealso h2 { font-size: 1.2rem; }

/* a page of the reference */
.lede p { font-size: 1.12rem; line-height: 1.55; margin-bottom: 8px; }
.meta { font: 13px/1.4 var(--font-mono); color: var(--muted); margin-bottom: 8px; }
.meta p { margin: 0; }
.synopsis {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 0 0 18px;
}
.synopsis p { margin: 0; max-width: none; }
.page.reference { max-width: 1180px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.toc { font-size: 14px; }
.toc-label { font: 500 11.5px/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.toc li { margin: 0; }
.toc a { display: block; padding: 3px 0; color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--accent); }
@media (max-width: 1019px) {
  .toc { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 14px 16px; }
  .toc ol { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); column-gap: 18px; }
}
@media (min-width: 1020px) {
  .page.reference { grid-template-columns: 210px minmax(0, 1fr); gap: 48px; }
  .toc { position: sticky; top: 24px; align-self: start; max-height: calc(100vh - 48px); overflow-y: auto; padding-top: 34px; }
}

/* the drawings of the reference, inline, in the colours of the page */
figure.diagram { margin: 18px 0 30px; min-width: 0; }
figure.diagram .canvas { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 16px 14px; overflow-x: auto; }
figure.diagram svg { display: block; width: 100%; min-width: 660px; height: auto; }
figure.diagram figcaption { font-size: 14px; line-height: 1.5; color: var(--muted); margin-top: 10px; max-width: 80ch; }
.dg { color: var(--ink); }
.dg text { fill: currentColor; font-family: var(--font-body); font-size: 13px; }
.dg .mono { font-family: var(--font-mono); font-size: 12px; }
.dg .small { font-size: 11.5px; }
.dg .title { font-family: var(--font-head); font-weight: 600; font-size: 15px; }
.dg .strong { font-weight: 600; }
.dg .muted { fill: var(--muted); }
.dg .t-accent { fill: var(--accent); }
.dg .t-warn { fill: var(--warn); }
.dg .box { fill: var(--ground); stroke: var(--rule-strong); stroke-width: 1.2; }
.dg .box-accent { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.2; }
.dg .box-ghost { fill: none; stroke: var(--rule-strong); stroke-width: 1.2; stroke-dasharray: 5 4; }
.dg .ln { fill: none; stroke: var(--line); stroke-width: 1.5; }
.dg .ln-accent { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.dg .ln-warn { fill: none; stroke: var(--warn); stroke-width: 1.5; }
.dg .dash { stroke-dasharray: 5 4; }
.dg .life { fill: none; stroke: var(--rule-strong); stroke-width: 1.2; stroke-dasharray: 3 4; }
.dg .tip { fill: var(--line); }
.dg .tip-accent { fill: var(--accent); }
.dg .tip-warn { fill: var(--warn); }
.dg .badge { fill: var(--accent); }
.dg .badge-text { fill: var(--surface); font: 600 11px var(--font-mono); }
.dg .ln-bytes { fill: none; stroke: var(--accent); stroke-width: 3; }

/* the keys of the reference */
table.keys { width: 100%; font-size: 14.5px; }
table.keys th { font-family: var(--font-head); font-size: 13px; letter-spacing: 0.02em; border-bottom-width: 1.5px; }
table.keys td:first-child { white-space: nowrap; }
table.keys td:nth-child(2) { color: var(--muted); }
table.keys td p { margin: 0 0 6px; }
table.keys td p:last-child { margin: 0; }
@media (max-width: 719px) { table.keys { display: block; overflow-x: auto; } }
table.keys code { overflow-wrap: normal; }
