/* Every colour and every size the site uses, in one place. Nothing else in
   the stylesheet writes a colour: it names one of these. The contrast gate in
   tools/build.py reads THIS file and fails a pair below its ratio, so a token
   changed here is checked before anybody has to squint at it. */

@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4/source-serif-4-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4/source-serif-4-latin-wght-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* Fallbacks reshaped to the real fonts' metrics, so the swap moves nothing:
   the line that wraps before the font arrives wraps in the same place after. */
@font-face {
  font-family: "Serif Fallback";
  src: local("Georgia"), local("Times New Roman");
  size-adjust: 94%;
  ascent-override: 110%;
  descent-override: 35.6%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Sans Fallback";
  src: local("Arial"), local("Helvetica"), local("Liberation Sans");
  size-adjust: 107.1%;
  ascent-override: 90.4%;
  descent-override: 22.5%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Mono Fallback";
  src: local("Courier New"), local("Liberation Mono");
  size-adjust: 100%;
  ascent-override: 102%;
  descent-override: 30%;
  line-gap-override: 0%;
}

:root {
  --font-prose: "Source Serif 4", "Serif Fallback", Georgia, serif;
  --font-ui: "Inter", "Sans Fallback", system-ui, sans-serif;
  --font-code: "JetBrains Mono", "Mono Fallback", ui-monospace, monospace;

  --size-prose: 1.125rem;
  --leading-prose: 1.68;
  --measure: 70ch;
  --size-code: 0.86em;
  --weight-code: 700;
  --weight-keyword: 800;

  --radius: 6px;
  --gap: 1.5rem;
  --header-h: 3.5rem;
  --sidebar-w: 17rem;
  --toc-w: 15rem;
  --touch: 44px;

  color-scheme: light;
  /* LIGHT. Paper and ink. */
  --bg: #fbfaf7;
  --bg-raised: #ffffff;
  --bg-sunken: #f2efe8;
  --text: #22201c;
  --text-muted: #5d5850;
  --accent: #3a55c4;
  --accent-text: #ffffff;
  --border: #e3ded4;
  --border-strong: #c9c2b4;
  --focus: #3a55c4;
  --mark: #fff1b8;
  --note: #eef1fb;
  --note-edge: #3a55c4;
  --warn: #fbf0e6;
  --warn-edge: #b4560f;
  --danger: #fbecec;
  --danger-edge: #b3261e;

  /* Code, on --bg-sunken. */
  --code-text: #22201c;
  --code-k: #7a2a8c;
  --code-t: #0d6464;
  --code-f: #2f47ad;
  --code-s: #8a4508;
  --code-n: #a1305a;
  --code-c: #66625a;
  --code-p: #9b3a1f;
  --code-m: #7c5200;
  --code-a: #4f5f10;
  --code-v: #9a2f68;
}

/* DARK. #121216 is the framework's own theme_dark background, so the docs
   look like the UI the reader is about to build. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121216;
    --bg-raised: #1a1a20;
    --bg-sunken: #1c1c23;
    --text: #e8e6e1;
    --text-muted: #a8a49c;
    --accent: #8fa6ff;
    --accent-text: #121216;
    --border: #2b2b34;
    --border-strong: #3d3d48;
    --focus: #8fa6ff;
    --mark: #4a4220;
    --note: #1b1f30;
    --note-edge: #8fa6ff;
    --warn: #2a2018;
    --warn-edge: #f0a35e;
    --danger: #2c1818;
    --danger-edge: #f28b82;

    --code-text: #e8e6e1;
    --code-k: #d7a6ff;
    --code-t: #6fd6c6;
    --code-f: #9db8ff;
    --code-s: #e6b673;
    --code-n: #f09ab6;
    --code-c: #96949c;
    --code-p: #ff9d7a;
    --code-m: #e8c46a;
    --code-a: #b7d47a;
    --code-v: #f0a0d0;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121216;
  --bg-raised: #1a1a20;
  --bg-sunken: #1c1c23;
  --text: #e8e6e1;
  --text-muted: #a8a49c;
  --accent: #8fa6ff;
  --accent-text: #121216;
  --border: #2b2b34;
  --border-strong: #3d3d48;
  --focus: #8fa6ff;
  --mark: #4a4220;
  --note: #1b1f30;
  --note-edge: #8fa6ff;
  --warn: #2a2018;
  --warn-edge: #f0a35e;
  --danger: #2c1818;
  --danger-edge: #f28b82;

  --code-text: #e8e6e1;
  --code-k: #d7a6ff;
  --code-t: #6fd6c6;
  --code-f: #9db8ff;
  --code-s: #e6b673;
  --code-n: #f09ab6;
  --code-c: #96949c;
  --code-p: #ff9d7a;
  --code-m: #e8c46a;
  --code-a: #b7d47a;
  --code-v: #f0a0d0;
}

@media (max-width: 599px) {
  :root {
    --size-prose: 1.0625rem;
  }
}

/* Type and the elements of prose. */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-prose);
  font-size: var(--size-prose);
  line-height: var(--leading-prose);
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  font-family: var(--font-ui);
  line-height: 1.25;
  letter-spacing: -0.012em;
  margin: 2.2em 0 0.6em;
  text-wrap: balance;
}
h1 { font-size: 2.15rem; font-weight: 750; margin-top: 0.4em; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; font-weight: 700; padding-top: 0.6em; border-top: 1px solid var(--border); }
h3 { font-size: 1.2rem; font-weight: 680; }
h4 { font-size: 1.02rem; font-weight: 650; }

p, ul, ol, dl, blockquote, figure, table, pre, .callout { margin: 0 0 1.1em; }
p { text-wrap: pretty; hanging-punctuation: first; }
ul, ol { padding-left: 1.4em; }
li + li { margin-top: 0.3em; }
li > ul, li > ol { margin: 0.3em 0 0; }
dt { font-family: var(--font-ui); font-weight: 650; margin-top: 0.8em; }
dd { margin: 0.2em 0 0 1.4em; }
strong { font-weight: 680; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5em 0; }

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-thickness: 0.14em; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

mark { background: var(--mark); color: inherit; padding: 0 0.15em; border-radius: 2px; }

blockquote {
  margin-left: 0;
  padding-left: 1.1em;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
  font-style: italic;
}

code, kbd, samp, pre {
  font-family: var(--font-code);
  font-weight: var(--weight-code);
  font-variant-ligatures: none;
}
code, kbd {
  font-size: var(--size-code);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.08em 0.3em;
  overflow-wrap: anywhere;
}
a code { color: var(--accent); }
h1 code, h2 code, h3 code, h4 code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 0.92em;
  font-weight: 800;
}
kbd { border-bottom-width: 2px; }

table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.5em 0.75em;
  border-bottom: 1px solid var(--border);
}
th { font-weight: 650; border-bottom: 2px solid var(--border-strong); }
td code, th code { font-size: 0.86em; }

img, svg { max-width: 100%; height: auto; }

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font-ui);
}
.skip-link:focus { top: 0.5rem; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* The frame around every page.

   >= 1240 px   sidebar | article | sticky "On this page"
   900 - 1239   sidebar | article, the TOC folded into the article's top
   <  900       article only; the navigation opens in a <dialog>          */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-ui);
}

.brand {
  font-weight: 760;
  font-size: 1.02rem;
  letter-spacing: -0.015em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand span { color: var(--text-muted); font-weight: 560; }

.sections {
  display: flex;
  gap: 0.15rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.sections a {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0 0.7rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 560;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}
.sections a:hover { color: var(--text); background: var(--bg-sunken); }
.sections a[aria-current] { color: var(--text); background: var(--bg-sunken); font-weight: 650; }

.header-tools { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.25rem;
  min-width: 2.25rem;
  justify-content: center;
  padding: 0 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text-muted);
  font: 500 0.88rem var(--font-ui);
  cursor: pointer;
}
.icon-button:hover { color: var(--text); border-color: var(--border-strong); }
.icon-button svg { width: 1.05rem; height: 1.05rem; flex: none; }
.icon-button kbd { font-size: 0.75rem; padding: 0 0.3em; font-weight: 600; }

.nav-toggle { display: none; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 0 2.5rem;
  max-width: 92rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.sidebar, .toc {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 1.75rem 0 3rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  line-height: 1.45;
  scrollbar-width: thin;
}

.page { min-width: 0; padding: 2rem 0 4rem; }
.shell.single { grid-template-columns: minmax(0, var(--measure)); justify-content: center; }
.shell.single .sidebar, .shell.single .toc { display: none; }
.prose { max-width: var(--measure); }
.prose > :first-child { margin-top: 0; }

/* Section navigation. */
.nav-tree { list-style: none; margin: 0; padding: 0; }
.nav-tree ul { list-style: none; margin: 0.2rem 0 0.6rem; padding: 0 0 0 0.8rem;
               border-left: 1px solid var(--border); }
.nav-tree li { margin: 0; }
.nav-tree a {
  display: block;
  padding: 0.28rem 0.6rem;
  border-radius: 5px;
  color: var(--text-muted);
  text-decoration: none;
}
.nav-tree a:hover { color: var(--text); background: var(--bg-sunken); }
.nav-tree a[aria-current="page"] { color: var(--accent); background: var(--bg-sunken); font-weight: 620; }
.nav-group {
  display: block;
  margin: 1.1rem 0 0.25rem;
  padding: 0 0.6rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.nav-tree > li:first-child > .nav-group { margin-top: 0; }

/* On this page. */
.toc-title {
  margin: 0 0 0.6rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.toc ol, .toc-top ol { list-style: none; margin: 0; padding: 0; }
.toc ol ol, .toc-top ol ol { padding-left: 0.85rem; }
.toc a, .toc-top a {
  display: block;
  padding: 0.22rem 0 0.22rem 0.75rem;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
}
.toc a:hover { color: var(--text); }
.toc a[aria-current="true"] { color: var(--accent); border-left-color: var(--accent); }

.toc-top { display: none; margin: 0 0 1.75rem; font-family: var(--font-ui); font-size: 0.92rem; }
.toc-top summary {
  cursor: pointer;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  font-weight: 620;
  color: var(--text-muted);
}

.breadcrumbs {
  font-family: var(--font-ui);
  font-size: 0.84rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}
.breadcrumbs a { color: var(--text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--text); text-decoration: underline; }

.page-footer {
  max-width: var(--measure);
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
}
.page-footer a { color: var(--text-muted); }
.pager { display: flex; justify-content: space-between; gap: 1rem; max-width: var(--measure);
         margin-top: 3rem; font-family: var(--font-ui); }
.pager a {
  flex: 1;
  display: block;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
}
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--text-muted); font-size: 0.78rem; }
.pager .next { text-align: right; }

/* The navigation dialog, for narrow screens. */
.nav-dialog {
  margin: 0;
  width: min(22rem, 88vw);
  max-width: none;
  height: 100%;
  max-height: none;
  padding: 1rem 1rem 3rem;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.95rem;
}
.nav-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.nav-dialog .sections { flex-direction: column; margin-bottom: 1rem; overflow: visible; }
.nav-dialog .sections a, .nav-dialog .nav-tree a { min-height: var(--touch); display: flex; align-items: center; }
.dialog-close { float: right; }

@media (max-width: 1239px) {
  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
  .toc-top { display: block; }
}

@media (max-width: 479px) {
  .theme-toggle .label { display: none; }
}

@media (max-width: 899px) {
  .shell { display: block; padding: 0 1rem; }
  .sidebar { display: none; }
  .site-header .sections { display: none; }
  .nav-toggle { display: inline-flex; }
  .page { padding-top: 1.25rem; }
  .search-open .label, .search-open kbd { display: none; }
  .site-header { gap: 0.5rem; padding: 0 0.75rem; }
  .brand { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .icon-button { min-height: var(--touch); min-width: var(--touch); }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.32rem; }
}

@media print {
  .site-header, .sidebar, .toc, .toc-top, .pager, .skip-link, .nav-dialog,
  .copy-button, .heading-anchor, .takeaway { display: none !important; }
  .shell { display: block; padding: 0; }
  .prose { max-width: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: #000; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
  pre, .code-block { break-inside: avoid; border: 1px solid #999; }
}

/* The pieces pages are made of: code, callouts, tables, reference entries,
   cards, the search dialog. */

/* --- code blocks ---------------------------------------------------------- */
.code-block {
  position: relative;
  margin: 0 0 1.2em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}
.code-block figcaption, .code-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem 0.4rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font: 600 0.8rem var(--font-ui);
  color: var(--text-muted);
}
.code-head .file {
  min-width: 0;            /* a long path breaks inside the block, not past the screen */
  overflow-wrap: anywhere;
  font-family: var(--font-code);
  font-weight: 700;
  color: var(--text);
}
.code-head a { color: var(--text-muted); }
.code-head .spacer { margin-left: auto; }
pre {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--code-text);
  tab-size: 4;
}
.code-block pre { background: transparent; }
pre code { background: none; border: 0; padding: 0; font-size: inherit; }

.k { color: var(--code-k); font-weight: var(--weight-keyword); }
.t { color: var(--code-t); }
.f { color: var(--code-f); }
.s { color: var(--code-s); }
.n { color: var(--code-n); }
.c { color: var(--code-c); font-weight: 500; font-style: normal; }
.p { color: var(--code-p); font-weight: var(--weight-keyword); }
.m { color: var(--code-m); }
.a { color: var(--code-a); }
.v { color: var(--code-v); }

.copy-button {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.code-block:hover .copy-button, .copy-button:focus-visible { opacity: 1; }
.code-block:has(.code-head) .copy-button { position: static; opacity: 1; }
@media (hover: none) { .copy-button { opacity: 1; } }

.code-block.expect-error,
.code-block.expect-refused { border-color: var(--danger-edge); }
.code-block.expect-error .code-head,
.code-block.expect-refused .code-head { color: var(--danger-edge); }
/* Wrong, and compiles: what refuses it instead, said in the caption. */
.code-head .verdict { min-width: 0; overflow-wrap: anywhere; }
.code-head .verdict code { font-weight: 700; }
.compiler-output {
  margin: 0;
  padding: 0.6rem 1rem;
  border-top: 1px dashed var(--border-strong);
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}
/* What a tool printed about a block: its carets are columns of the line above
   them, so a line keeps its length and the block scrolls instead. */
.compiler-output[data-said] { white-space: pre; }

/* --- headings ------------------------------------------------------------- */
.heading-anchor {
  margin-left: 0.4em;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
}
h2:hover .heading-anchor, h3:hover .heading-anchor, h4:hover .heading-anchor,
.heading-anchor:focus-visible { opacity: 1; }

/* --- callouts ------------------------------------------------------------- */
.callout {
  padding: 0.85rem 1.1rem;
  border-left: 4px solid var(--note-edge);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--note);
}
.callout > :last-child { margin-bottom: 0; }
.callout-title {
  display: block;
  margin-bottom: 0.3rem;
  font: 700 0.8rem var(--font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.callout.warning { border-left-color: var(--warn-edge); background: var(--warn); }
.callout.danger { border-left-color: var(--danger-edge); background: var(--danger); }

/* The Guidelines' table of what checks what: the rule and its tool get the
   width, the three columns of where it holds only what a short answer needs.
   On a phone it keeps that much width and scrolls inside its wrap: squeezed to
   360 px, five columns of check names broke every nine characters. */
table[data-enforcement] { min-width: 40rem; }
table[data-enforcement] td:nth-child(1) { width: 32%; }
table[data-enforcement] td:nth-child(2) { width: 32%; }

/* --- tables that may be wider than the column ----------------------------- */
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; }
.table-wrap table { margin: 0; }

/* --- figures and diagrams ------------------------------------------------- */
figure { margin-left: 0; margin-right: 0; }
figure > figcaption {
  margin-top: 0.5rem;
  font: 0.84rem var(--font-ui);
  color: var(--text-muted);
}
.diagram svg { display: block; width: 100%; height: auto; }
/* A picture the build made from code (tools/rmpdocs/shots.py): a frame of the
   game, kept at its own shape; two of them side by side when they compare. */
.shot img { display: block; width: 100%; height: auto; border-radius: var(--radius);
            border: 1px solid var(--border); }
.shots { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
         gap: 0 1rem; margin: 0 0 1.1em; }
.shots > figure { min-width: 0; margin: 0; }

/* --- the same thing written two ways, side by side ------------------------ */
.modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 0 1rem;
  margin: 0 0 1.1em;
}
.modes > figure { min-width: 0; margin: 0; }
.modes > figure > pre { margin-bottom: 0; }

/* --- the reference -------------------------------------------------------- */
.entity {
  margin: 0 0 2.2rem;
  padding-top: 0.25rem;
}
.entity + .entity { border-top: 1px solid var(--border); padding-top: 1.4rem; }
.signature {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  font: var(--weight-code) 0.86rem/1.55 var(--font-code);
  overflow-x: auto;
  white-space: pre;
}
.signature + .signature { margin-top: -0.4rem; }
.entity h3, .entity h4 { margin-top: 0; font-family: var(--font-code); font-weight: 750;
                         letter-spacing: 0; }
.entity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: -0.25rem 0 0.9rem;
  font: 0.8rem var(--font-ui);
  color: var(--text-muted);
}
.entity-meta a { color: var(--text-muted); }
.badge {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font: 600 0.72rem var(--font-ui);
  color: var(--text-muted);
  vertical-align: middle;
}
.fields td:first-child, .fields td.type, .fields td:nth-child(3) { white-space: nowrap; }
.fields td code { overflow-wrap: normal; }
.fields td p { margin: 0 0 0.4em; }
.fields td p:last-child { margin-bottom: 0; }
.fields td:first-child code { font-weight: 750; }
.fields td.type code { color: var(--code-t); }

/* --- cards: the home page and the example gallery ------------------------ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
  max-width: none;
}
.card {
  display: block;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  line-height: 1.5;
}
.card:hover { border-color: var(--accent); }
.card strong { display: block; font-size: 1rem; margin-bottom: 0.25rem; }
.card span { color: var(--text-muted); }

.lede {
  font-size: 1.28rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin-bottom: 1.6rem;
}

/* --- search ---------------------------------------------------------------- */
.search-dialog {
  width: min(42rem, 94vw);
  max-height: 80vh;
  margin: 10vh auto auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--text);
  font-family: var(--font-ui);
}
.search-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.search-dialog input {
  width: 100%;
  min-height: 3.2rem;
  padding: 0 1rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: 500 1.05rem var(--font-ui);
}
.search-dialog input:focus { outline: none; }
.search-results { list-style: none; margin: 0; padding: 0.4rem; max-height: 60vh; overflow-y: auto; }
.search-results a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.search-results [aria-selected="true"] a, .search-results a:hover { background: var(--bg-sunken); }
.search-results .kind { font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
                        text-transform: uppercase; letter-spacing: 0.05em; }
.search-results small { display: block; color: var(--text-muted); }
.search-empty { padding: 1rem; color: var(--text-muted); }

/* --- forced colours (Windows high contrast) -------------------------------- */
@media (forced-colors: active) {
  .callout, .card, .code-block, .signature { border: 1px solid CanvasText; }
  .nav-tree a[aria-current="page"], .sections a[aria-current] { outline: 2px solid Highlight; }
  .k, .p { font-weight: 800; }
}

/* --- an example, played in the page -------------------------------------- */
.player {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: 0 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  overflow: hidden;
}
.player img { display: block; width: 100%; height: 100%; object-fit: cover; }
.player iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; }
.play-button {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-height: var(--touch);
  padding: 0 1.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font: 650 1rem var(--font-ui);
  cursor: pointer;
}
.play-button:hover { filter: brightness(1.08); }
details.source { margin: 0 0 0.75rem; }
details.source > summary { cursor: pointer; font-family: var(--font-ui); padding: 0.4rem 0; }
details.source > summary small { color: var(--text-muted); margin-left: 0.5rem; }
.example-card img { display: block; width: 100%; height: auto; margin: -1rem -1.1rem 0.75rem;
                    width: calc(100% + 2.2rem); max-width: none; border-radius: var(--radius) var(--radius) 0 0; }

/* Download, at the bottom right of every page: this page or the whole manual
   as a PDF (the browser prints it), or as plain text for an AI. */
.takeaway {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.takeaway-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--text) 14%, transparent);
}
.takeaway-toggle svg { width: 18px; height: 18px; }
.takeaway-toggle:hover, .takeaway-toggle[aria-expanded="true"] { border-color: var(--accent); }
.takeaway-menu {
  order: -1;
  display: flex;
  flex-direction: column;
  min-width: 15rem;
  max-width: calc(100vw - 32px);
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-raised);
  box-shadow: 0 6px 24px color-mix(in srgb, var(--text) 20%, transparent);
}
.takeaway-menu[hidden] { display: none; }
.takeaway-title {
  margin: 6px 8px 2px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.takeaway-menu a, .takeaway-menu button {
  display: block;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.takeaway-menu a:hover, .takeaway-menu button:hover { background: var(--bg-sunken); }
@media (max-width: 40rem) { .takeaway-toggle .label { display: none; } }
