/* Copyright 2026, Niklas Hauser
 * SPDX-License-Identifier: MPL-2.0
 *
 * The documentation page: a narrow text column with a table of contents beside it
 * (above it on narrow screens). Colours only from the theme tokens.
 */
body.doc-page { height: auto; }
body.doc-page > .site { padding-inline: clamp(16px, 3vw, 32px); }

.doc {
  display: grid; gap: 40px; align-items: start; justify-content: center;
  grid-template-columns: minmax(180px, 220px) minmax(0, 75ch);
  padding: 32px clamp(16px, 3vw, 32px) 80px;
}
.doc main { min-width: 0; font-size: 15px; line-height: 1.6; }

/* ----------------------------------------------------------------- contents */
.toc { position: sticky; top: 20px; max-height: calc(100dvh - 40px); overflow: auto; font-size: 13px; }
.doc .toc h2 { padding: 0; border: 0; line-height: 1.4; margin: 0 0 8px; color: var(--faint); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc ol ol { padding-left: 12px; margin: 2px 0 6px; border-left: 1px solid var(--rule); }
.toc a { display: block; padding: 2px 6px; border-radius: 5px; color: var(--muted); text-decoration: none; }
.toc a:hover { background: var(--hover); color: var(--ink); }
.toc > ol > li > a { color: var(--ink); font-weight: 500; }

/* -------------------------------------------------------------------- text */
.doc h1 { margin: 0 0 10px; font-size: 30px; line-height: 1.2; letter-spacing: -0.015em; }
.doc h2 {
  margin: 52px 0 12px; padding-top: 14px; border-top: 1px solid var(--rule);
  font-size: 22px; line-height: 1.3; letter-spacing: -0.01em;
}
.doc h3 { margin: 32px 0 8px; font-size: 17px; line-height: 1.35; }
.doc h4 { margin: 22px 0 6px; font-size: 15px; }
.doc :is(h2, h3, h4) { scroll-margin-top: 16px; }
.doc p, .doc ul, .doc ol:not(.toc ol), .doc dl { margin: 0 0 14px; }
.doc li { margin-bottom: 4px; }
.doc li > ul { margin: 4px 0 0; }
.doc a { color: var(--accent); text-underline-offset: 2px; }
.doc .lead { font-size: 17px; color: var(--muted); }
.doc .note {
  padding: 10px 14px; border-left: 3px solid var(--accent); border-radius: 0 var(--radius-s) var(--radius-s) 0;
  background: var(--accent-soft); color: var(--ink);
}
.doc .note.warn { border-left-color: var(--warn); background: var(--band); }

.doc :not(pre) > code {
  font-size: 0.88em; padding: 1px 5px; border-radius: 4px;
  background: var(--band); border: 1px solid var(--rule); overflow-wrap: anywhere;
}
.doc kbd {
  font-size: 0.85em; padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--rule-strong); border-bottom-width: 2px; background: var(--surface);
}

/* Code: commands with a copy button, output below them in a muted block */
.doc pre.code { font-size: 12.5px; line-height: 1.5; padding: 10px 12px; margin: 0 0 14px; }
.doc pre.code.out { color: var(--muted); background: var(--surface); }
.code-wrap:has(+ pre.code.out) > pre.code { margin-bottom: 6px; }
.code-wrap { position: relative; }
.code-wrap .copy { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity 0.1s; }
.code-wrap:hover .copy, .code-wrap .copy:focus-visible { opacity: 1; }
@media (hover: none) { .code-wrap .copy { opacity: 1; } }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--rule); border-radius: var(--radius-s); }
.doc table { border-collapse: collapse; width: 100%; font-size: 13.5px; line-height: 1.45; }
.doc th, .doc td { padding: 6px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.doc tr:last-child > td { border-bottom: 0; }
.doc th { background: var(--band); color: var(--muted); font-weight: 600; font-size: 12px; }
.doc tr.group > td {
  background: var(--band); color: var(--faint); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; padding-block: 4px;
}
.doc td:first-child code { white-space: nowrap; }
.doc .tag { white-space: nowrap; }
.doc .tag.private { color: var(--warn); background: var(--band); border: 1px solid var(--rule); }

@media (max-width: 860px) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-top: 20px; }
  .toc {
    position: static; max-height: none; padding: 12px 14px;
    border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface);
  }
  /* only the chapters, in a row, so the text starts on the first screen */
  .toc ol ol { display: none; }
  .toc > ol { display: flex; flex-wrap: wrap; gap: 2px 4px; }
  .doc h1 { font-size: 25px; }
}
