/* Documentation pages. Same Swiss/technical direction as the home page:
   paper, ink, engineering blue, hairlines. The article sits on a raised
   sheet so long text does not fight the page grid. */

:root {
  --doc-measure: 46rem;
  --doc-code-size: .84rem;
  --tok-number: oklch(80% 0.11 70);
}

.doc-shell {
  display: grid; gap: 0 2.5rem; align-items: start;
  grid-template-columns: minmax(0, 1fr);
  padding-block: 0 4rem;
}
@media (min-width: 60rem) {
  .doc-shell { grid-template-columns: 14rem minmax(0, 1fr); }
}
@media (min-width: 84rem) {
  .doc-shell { grid-template-columns: 14rem minmax(0, 1fr) 13rem; }
}

/* ---------- navigation ---------- */
.doc-nav, .doc-toc {
  position: sticky; top: 3.75rem; max-height: calc(100vh - 3.75rem);
  overflow-y: auto; padding-block: 2.5rem 2rem; font-size: .9rem;
}
.doc-nav { display: none; }
@media (min-width: 60rem) { .doc-nav { display: block; } .doc-nav-mobile { display: none; } }
.doc-toc { display: none; }
@media (min-width: 84rem) { .doc-toc { display: block; } }

.doc-group, .doc-toc p {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .08em;
  color: var(--safety-text); margin: 1.4rem 0 .5rem;
}
.doc-group:first-child, .doc-toc p { margin-top: 0; }
.doc-nav ul, .doc-toc ul, .doc-nav-mobile ul { list-style: none; }
.doc-nav a, .doc-toc a, .doc-nav-mobile a {
  display: block; padding: .28rem .75rem; margin-left: -1px;
  color: var(--ink-soft); text-decoration: none;
  border-left: 2px solid var(--line);
}
.doc-nav a:hover, .doc-toc a:hover, .doc-nav-mobile a:hover { color: var(--blue); border-left-color: var(--line-strong); }
.doc-nav a[aria-current="page"], .doc-nav-mobile a[aria-current="page"] {
  color: var(--ink); font-weight: 600; border-left-color: var(--safety);
}
.doc-toc a { font-size: .84rem; line-height: 1.35; padding-block: .3rem; }

.doc-nav-mobile { margin-top: 1.25rem; border: 1px solid var(--line-strong); background: var(--paper-raised); }
.doc-nav-mobile summary {
  cursor: pointer; padding: .8rem 1rem; font-family: var(--mono); font-size: .8rem;
}
.doc-nav-mobile nav { padding: 0 1rem 1rem; }
.site-header .nav a[aria-current] { color: var(--ink); font-weight: 600; }
@media (max-width: 56rem) {
  .docs .site-header .nav a[href="/docs/"] { display: inline; }
}

/* ---------- article ---------- */
.doc-main { min-width: 0; padding-top: 2.5rem; }
.doc {
  background: var(--paper-raised); border: 1px solid var(--line-strong);
  padding: clamp(1.25rem, 1rem + 2.5vw, 3rem);
  box-shadow: 8px 8px 0 var(--line);
}
.doc > * { max-width: var(--doc-measure); }
.doc > figure.code, .doc > table, .doc > .table-scroll { max-width: none; }
/* Screenshots from the repository docs are larger than the column: never wider than it. */
.doc img { max-width: 100%; height: auto; }

.doc h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.4vw, 3rem); line-height: 1.04;
  letter-spacing: -0.03em; text-wrap: balance; margin-bottom: 1.5rem;
}
.doc h2 {
  font-size: clamp(1.3rem, 1.1rem + .8vw, 1.7rem); letter-spacing: -0.02em; line-height: 1.15;
  margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--line-strong);
  scroll-margin-top: 4.5rem;
}
.doc h3 { font-size: 1.12rem; letter-spacing: -0.01em; margin-top: 2rem; scroll-margin-top: 4.5rem; }
.doc h4 {
  font-family: var(--mono); font-size: .95rem; font-weight: 600; margin-top: 1.75rem;
  scroll-margin-top: 4.5rem;
}
.doc p, .doc ul, .doc ol, .doc figure.code, .doc table, .doc blockquote { margin-top: 1rem; }
.doc h1 + p { font-size: 1.1em; color: var(--ink-soft); }
.doc ul, .doc ol { padding-left: 1.3rem; }
.doc li + li { margin-top: .35rem; }
.doc li > ul { margin-top: .35rem; }
.doc a { color: var(--blue); text-underline-offset: .18em; text-decoration-thickness: 1px; }
.doc a:hover { color: var(--blue-bright); }
.doc strong { font-weight: 650; }
.doc :not(pre) > code {
  font-family: var(--mono); font-size: .86em; padding: .08em .35em;
  background: var(--paper); border: 1px solid var(--line); overflow-wrap: anywhere;
}
.doc blockquote { border-left: 3px solid var(--safety); padding-left: 1rem; color: var(--ink-soft); }

/* ---------- code ---------- */
.doc figure.code {
  background: var(--code-bg); color: var(--code-ink);
  border-left: 3px solid var(--blue-bright);
}
.doc figure.code.term { border-left-color: var(--ok); }
.doc figure.code.text, .doc figure.code.sh, .doc figure.code.ebnf { border-left-color: var(--line-strong); }
.doc figure.code figcaption {
  font-family: var(--mono); font-size: .72rem; padding: .5rem 1.1rem 0;
  color: color-mix(in oklab, var(--code-ink) 60%, transparent);
}
.doc figure.code pre {
  font-family: var(--mono); font-size: var(--doc-code-size); line-height: 1.6;
  padding: .95rem 1.1rem; overflow-x: auto; white-space: pre; tab-size: 2;
}
.doc figure.code pre:focus-visible { outline-offset: -2px; }
.doc .tok-n { color: var(--tok-number); }
.doc .tok-p { color: color-mix(in oklab, var(--code-ink) 45%, transparent); user-select: none; }
.doc .tok-cmd { color: #fff; font-weight: 600; }

/* ---------- tables ---------- */
.doc table { border-collapse: collapse; font-size: .9rem; display: block; overflow-x: auto; max-width: 100%; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: .5rem .9rem .5rem 0; border-bottom: 1px solid var(--line); }
.doc th { font-family: var(--mono); font-size: .74rem; letter-spacing: .04em; color: var(--ink-faint); border-bottom-color: var(--line-strong); white-space: nowrap; }
.doc td code { white-space: nowrap; }

/* ---------- footer of a page ---------- */
.doc-source { margin-top: 1.5rem; font-size: .84rem; color: var(--ink-faint); max-width: var(--doc-measure); }
.doc-source a { color: var(--ink-soft); }
.doc-pager { margin-top: 2rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.doc-pager a {
  display: block; padding: 1rem 1.2rem; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line-strong); background: var(--paper-raised); font-weight: 600;
  transition: box-shadow .18s var(--ease), transform .18s var(--ease);
}
.doc-pager a:hover, .doc-pager a:focus-visible { transform: translateY(-2px); box-shadow: 4px 4px 0 var(--blue); }
.doc-pager a[rel="next"] { text-align: right; }
.doc-pager small { display: block; font-family: var(--mono); font-size: .7rem; font-weight: 400; color: var(--ink-faint); margin-bottom: .2rem; }
.docs .site-footer { background: var(--paper); }

@media print {
  .site-header, .doc-nav, .doc-nav-mobile, .doc-toc, .doc-pager, .site-footer { display: none; }
  .doc { border: 0; box-shadow: none; padding: 0; }
}

/* The documentation uses a wider frame than the marketing pages: three
   columns need the room. */
.docs .wrap { max-width: 88rem; }

/* Narrow phones: brand, Docs and Playground must share one row. */
@media (max-width: 24rem) {
  .docs .site-header .nav { gap: .6rem; }
  .docs .site-header .nav .cta { padding-inline: .7rem; }
  .docs .brand { font-size: 1.2rem; gap: .4rem; }
}

/* Compiler messages are the point of a terminal block: wrap them instead of
   hiding their end behind a scrollbar. */
.doc figure.code.term pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Exercises: the solution folded under its question. */
.doc details { margin: .6rem 0 1.6rem; border: 1px solid var(--line-strong); border-left: 3px solid var(--blue); padding: 0 1rem; background: var(--paper-raised); }
.doc details > summary { cursor: pointer; font-weight: 600; padding: .55rem 0; color: var(--blue); }
.doc details > summary:hover { text-decoration: underline; }
.doc details[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: .75rem; }
.doc details > summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
