/* pages.css - the site's plain reading pages (about.html, 404.html, learn/index.html and every learn/<slug>.html):
   colour tokens, type, the library's background, the logo header, one button family, links and focus.
   learn/learn.css loads after it and adds only what the guides need (diagrams, the glance box, badges, questions).

   The three token blocks below are copied value for value from index.html, which is the source of truth for
   colours (light on bare :root, then the two dark blocks). tests/seo.test.js fails if any value here drifts
   from index.html. Only tokens these pages use are copied. */
:root {
  --bg: #e9f0ea;
  --bg-glow: #f6faf5;
  --contour: rgba(21, 41, 43, 0.085);
  --ink: #15292b;
  --ink-2: #41585a;
  --ink-3: #647a7a;
  --sheet-solid: #f7faf7;
  --card-bg: #fbfdfb;
  --line: rgba(21, 41, 43, 0.15);
  --line-strong: rgba(21, 41, 43, 0.32);
  --control: rgba(21, 41, 43, 0.06);
  --control-hover: rgba(21, 41, 43, 0.1);
  --control-on: #1b3336;
  --control-sel: rgba(21, 41, 43, 0.11);
  --control-sel-hover: rgba(21, 41, 43, 0.16);
  --control-on-ink: #f1f6f2;
  --focus: #0b6b8f;
  --shadow: rgba(24, 48, 46, 0.14);
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Avenir Next", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1b1d;
    --bg-glow: #182c2f;
    --contour: rgba(230, 239, 234, 0.06);
    --ink: #e6efea;
    --ink-2: #aebfbb;
    --ink-3: #829794;
    --sheet-solid: #16272a;
    --card-bg: #182b2e;
    --line: rgba(230, 239, 234, 0.15);
    --line-strong: rgba(230, 239, 234, 0.34);
    --control: rgba(230, 239, 234, 0.08);
    --control-hover: rgba(230, 239, 234, 0.14);
    --control-on: #e6efea;
    --control-sel: rgba(230, 239, 234, 0.14);
    --control-sel-hover: rgba(230, 239, 234, 0.2);
    --control-on-ink: #0f1b1d;
    --focus: #7fd6e6;
    --shadow: rgba(0, 0, 0, 0.42);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1b1d;
  --bg-glow: #182c2f;
  --contour: rgba(230, 239, 234, 0.06);
  --ink: #e6efea;
  --ink-2: #aebfbb;
  --ink-3: #829794;
  --sheet-solid: #16272a;
  --card-bg: #182b2e;
  --line: rgba(230, 239, 234, 0.15);
  --line-strong: rgba(230, 239, 234, 0.34);
  --control: rgba(230, 239, 234, 0.08);
  --control-hover: rgba(230, 239, 234, 0.14);
  --control-on: #e6efea;
  --control-sel: rgba(230, 239, 234, 0.14);
  --control-sel-hover: rgba(230, 239, 234, 0.2);
  --control-on-ink: #0f1b1d;
  --focus: #7fd6e6;
  --shadow: rgba(0, 0, 0, 0.42);
  color-scheme: dark;
}

/* ---------- base ---------- */
html { box-sizing: border-box; background: var(--bg); }
*, *::before, *::after { box-sizing: inherit; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink);
  font: 400 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
/* The library's atmosphere, standing still behind the page: the soft glow, and over it the twelve faint contour
   lines (contours.svg, used as a mask so their colour is var(--contour) in either theme). Both layers are fixed to
   the window and take no clicks; the text sits on the plain page colour between the lines. */
body::before, body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none;
}
body::before {
  z-index: -2;
  background: radial-gradient(ellipse 120% 90% at 50% 30%, var(--bg-glow), var(--bg) 70%) var(--bg);
}
@supports ((mask-image: url("x.svg")) or (-webkit-mask-image: url("x.svg"))) {
  body::after {
    z-index: -1; background-color: var(--contour);
    -webkit-mask: url("/contours.svg") center / cover no-repeat;
    mask: url("/contours.svg") center / cover no-repeat;
  }
}
::selection { background: var(--control-sel-hover); color: var(--ink); }
@supports (background-color: color-mix(in srgb, red, blue)) {
  ::selection { background: color-mix(in srgb, var(--focus) 26%, transparent); }
}

/* the reading column: about 70 characters a line */
main {
  max-width: calc(32rem + 40px); margin: 0 auto;
  padding: 20px max(20px, env(safe-area-inset-right, 0px)) 72px max(20px, env(safe-area-inset-left, 0px));
}

h1 { margin: 0 0 8px; font: 700 34px/1.1 var(--font-display); letter-spacing: -0.02em; text-wrap: balance; }
h2 { margin: 44px 0 10px; font: 700 22px/1.2 var(--font-display); letter-spacing: -0.01em; text-wrap: balance; }
h3 { margin: 26px 0 6px; font: 700 17px/1.3 var(--font-display); }
p, li, dd { text-wrap: pretty; }
p { margin: 0 0 14px; }
.lead { font-size: 18px; line-height: 1.5; color: var(--ink-2); }
ul { margin: 0 0 14px; padding-left: 22px; }
li { margin: 0 0 6px; }
sub, sup { line-height: 0; }
hr { margin: 44px 0 18px; border: 0; border-top: 1px solid var(--line); }
small, .fine { font-size: 14px; color: var(--ink-2); }

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

/* ---------- the logo header: the library's (index.html .lib-head) ---------- */
.site-head { display: flex; align-items: center; gap: 16px; margin: 0 0 22px; }
.logo { display: block; flex: none; margin-left: -4px; line-height: 0; border-radius: 8px; }
.logo img { display: block; height: 46px; width: auto; aspect-ratio: 681 / 176; }
.site-nav { margin-left: auto; display: flex; gap: 4px; font: 500 13px/1.3 var(--font-body); }
.site-nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; border-radius: 7px;
  color: var(--ink-2); text-decoration: none; white-space: nowrap;
  transition: color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}
.site-nav a:hover { color: var(--ink); background: var(--control); }
.site-nav a[aria-current="page"] { color: var(--ink); }

/* ---------- one button family (index.html .btn and .btn.primary) ----------
   .btn is the outlined one; .btn.primary the filled one, at most one a page. */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: transparent; color: var(--ink);
  font: 600 14px/1.25 var(--font-body); text-align: center; text-decoration: none;
  -webkit-user-select: none; user-select: none;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}
.btn:hover { background: var(--control); }
.btn:active { transform: scale(0.985); }
.btn.primary { border-color: transparent; background: var(--control-on); color: var(--control-on-ink); }
.btn.primary:hover { background: var(--control-on); background: color-mix(in srgb, var(--control-on) 88%, var(--bg)); }
p > .btn { margin: 4px 8px 4px 0; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .btn:hover:not(:active), .site-nav a:hover:not(:active) { transform: translateY(-1px); }
  /* the strip the lift uncovers still counts as the control, so its bottom edge cannot flicker */
  .btn:hover::after, .site-nav a:hover::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 3px; }
  .site-nav a { position: relative; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .site-nav a { transition: none; }
  .btn:active { transform: none; }
}

@media (max-width: 760px) {
  main { padding-top: 12px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .site-head { gap: 10px; margin-bottom: 18px; }
  .logo img { height: 38px; }
  .site-nav { gap: 0; font-size: 12px; }
  .site-nav a { padding: 0 7px; }
  h1 { font-size: 30px; }
}
