/* Docs pages. Loaded after colonizer.css, which owns the tokens, the reset,
   .chip, .btn and the code styling this file builds on. Nothing here is used by
   the landing page. */

.docs-body { background: var(--bg); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 10;
  background: var(--chip); color: var(--ink); padding: 10px 16px; border-radius: 0 0 8px 0;
  font-family: var(--mono); font-size: 13px;
}
.skip:focus { left: 0; }

/* ------------------------------------------------------------------- chrome */

/* The header is the landing page's own (.top, from colonizer.css), copied in by tools/docs.js. */
.docs-body .top { border-bottom: 1px solid var(--line); max-width: none; padding-left: max(24px, calc((100vw - 1160px) / 2 + 24px)); padding-right: max(24px, calc((100vw - 1160px) / 2 + 24px)); }
/* Same side padding as the landing page's bar on phones, or the five menu items stop fitting on one row. */
@media (max-width: 1023px) { .docs-body .top { padding-left: 20px; padding-right: 20px; } }
@media (max-width: 380px) { .docs-body .top { padding-left: 14px; padding-right: 14px; } }
.nav a[aria-current="page"] { color: var(--accent); }

/* --------------------------------------------------------------- the column */

.docs-main {
  max-width: 1160px; margin: 0 auto; padding: 40px 24px 24px;
  display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 56px; align-items: start;
}

/* Module pages have no sidebar, so the article takes the whole row instead of
   landing in the sidebar's 240px track. */
.docs-main--noside { grid-template-columns: minmax(0, 1fr); }

/* The vertical docs menu: pages in reading order, the current page's sections under it. */
.side {
  /* Below the sticky site header, not under it. */
  position: sticky; top: calc(var(--top-h) + 12px);
  max-height: calc(100vh - var(--top-h) - 36px); overflow-y: auto; overscroll-behavior: contain;
  padding-right: 6px; font-size: 13px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.side__h {
  font-family: var(--mono); font-size: 11px; color: var(--accent);
  margin-bottom: 12px; letter-spacing: .02em;
}
.side__pages { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.side__page > a {
  display: block; padding: 7px 10px; border-radius: 8px;
  color: var(--muted); font-weight: 500; font-size: 14px;
  border-left: 2px solid transparent;
}
.side__page > a:hover { color: var(--ink); background: var(--chip); }
.side__page > a[aria-current="page"] { color: var(--ink); background: var(--chip); border-left-color: var(--accent); }
.side__toc {
  list-style: none; margin: 6px 0 10px 10px; padding: 0 0 0 12px;
  border-left: 1px solid var(--line); display: grid; gap: 6px;
}
.side__toc a { display: block; color: var(--muted); line-height: 1.4; }
.side__toc a:hover { color: var(--ink); }
.side__l3 { padding-left: 12px; font-size: 12.5px; }
.side__l3 a { color: var(--dim); }

.side-mobile { display: none; }

/* Previous / next, under each document. */
.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 56px !important; padding-top: 24px; border-top: 1px solid var(--line);
}
.pager a {
  display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none !important;
}
.pager a:hover { border-color: var(--accent); background: var(--chip); }
.pager__next { text-align: right; grid-column: 2; }
.pager__label { font-family: var(--mono); font-size: 11.5px; color: var(--dim); }
.pager__title { font-size: 16px; font-weight: 600; color: var(--ink); }


/* The docs are long-form: a measure, not the full grid width. */
.doc { min-width: 0; max-width: 78ch; }
.doc > * + * { margin-top: 18px; }

.doc h1 {
  font-size: clamp(32px, 4.4vw, 46px); line-height: 1.04; letter-spacing: -.035em;
  font-weight: 600; text-wrap: balance;
}
.doc h2 {
  font-size: 27px; letter-spacing: -.025em; font-weight: 600;
  margin-top: 54px; padding-top: 22px; border-top: 1px solid var(--line);
}
.doc h3 { font-size: 19px; font-weight: 600; margin-top: 36px; }
.doc h4 { font-size: 16px; font-weight: 600; margin-top: 28px; color: var(--muted); }
.doc h1, .doc h2, .doc h3, .doc h4 { position: relative; scroll-margin-top: 90px; }

.anchor {
  position: absolute; left: -22px; top: 0;
  color: var(--dim); opacity: 0; font-weight: 400; text-decoration: none;
  transition: opacity .12s ease;
}
.doc h2:hover .anchor, .doc h3:hover .anchor, .doc h4:hover .anchor,
.anchor:focus { opacity: 1; }

.doc p { font-size: 15.5px; line-height: 1.66; color: var(--muted); text-wrap: pretty; }
.doc strong { color: var(--ink); font-weight: 600; }
.doc a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }

.doc ul, .doc ol { padding-left: 22px; display: grid; gap: 9px; }
.doc li { font-size: 15.5px; line-height: 1.6; color: var(--muted); }
.doc li::marker { color: var(--accent); font-size: 13px; }

.doc blockquote {
  border-left: 2px solid var(--accent); padding: 4px 0 4px 18px;
  color: var(--dim);
}

.doc hr { border: 0; border-top: 1px solid var(--line); margin: 38px 0; }

.doc-lede { font-size: 17px !important; line-height: 1.6; }
.doc-note { font-size: 14px !important; color: var(--dim) !important; }

/* ---------------------------------------------------------------- code, tables */

.doc .code {
  background: var(--hull); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7; color: var(--muted);
  position: relative;
}
.doc .code[data-lang]::after {
  content: attr(data-lang);
  position: absolute; top: 8px; right: 12px;
  font-size: 10px; color: var(--dim); letter-spacing: .06em; text-transform: uppercase;
}
.doc .code code { font: inherit; color: inherit; background: none; padding: 0; }

.c-key { color: var(--accent); }
.c-str { color: #a6e3a1; }
.c-num { color: #8fb7ff; }
.c-lit { color: #ffa066; }
.c-com { color: var(--dim); font-style: italic; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; }
.doc th, .doc td {
  text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line);
  vertical-align: top; line-height: 1.55;
}
.doc th {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500;
  color: var(--accent); letter-spacing: .03em; background: var(--hull);
  white-space: nowrap;
}
.doc td { color: var(--muted); }
/* A module kind like `interfaces` must not break across lines mid-word. */
.doc td code.inline, .doc th code.inline { white-space: nowrap; }
.doc tbody tr:last-child td { border-bottom: 0; }

/* -------------------------------------------------------------------- diagrams */

.diagram {
  margin: 26px 0; padding: 22px 18px;
  background: var(--hull); border: 1px solid var(--line); border-radius: 12px;
  overflow-x: auto;
}
/* Chrome hands back a pixel width; docs.js strips it so the diagram scales. */
.diagram svg.mermaid { display: block; width: 100%; height: auto; max-width: 100%; }
.diagram svg.mermaid text { font-family: var(--mono) !important; }

/* ----------------------------------------------------------------- doc index */

.doc-cards { list-style: none; padding: 0; display: grid; gap: 12px; margin-top: 30px; }
.doc-card a {
  display: grid; gap: 6px; padding: 20px;
  background: var(--hull); border: 1px solid var(--line); border-radius: 12px;
  text-decoration: none; transition: border-color .15s ease, background .15s ease;
}
.doc-card a:hover { border-color: var(--accent); background: var(--chip); }
.doc-card__t { font-size: 18px; font-weight: 600; color: var(--ink); letter-spacing: -.02em; }
.doc-card__d { font-size: 14.5px; line-height: 1.55; color: var(--muted); }
.doc-card__m { font-family: var(--mono); font-size: 11px; color: var(--dim); }

/* -------------------------------------------------------------------- footer */

.docs-foot {
  max-width: 1160px; margin: 60px auto 0; padding: 26px 24px 40px;
  border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; color: var(--dim);
  display: flex; flex-wrap: wrap; gap: 10px 26px; justify-content: space-between;
}
.docs-foot p { margin: 0; }
.docs-foot a { color: var(--muted); }
.docs-foot a:hover { color: var(--accent); }

@media (max-width: 900px) {
  .docs-main { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 20px; }
  .side { display: none; }
  .side-mobile {
    display: block; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
    position: sticky; top: calc(var(--top-h) + 8px); z-index: 3;
  }
  .side-mobile summary {
    list-style: none; cursor: pointer; padding: 12px 14px;
    display: flex; align-items: baseline; gap: 10px;
  }
  .side-mobile summary::-webkit-details-marker { display: none; }
  .side-mobile summary::after { content: "▾"; margin-left: auto; color: var(--dim); }
  .side-mobile[open] summary::after { content: "▴"; }
  .side-mobile .side__h { margin: 0; }
  .side-mobile__current { font-weight: 600; color: var(--ink); }
  .side-mobile nav { padding: 0 10px 12px; max-height: 60vh; overflow-y: auto; }
  .anchor { display: none; }
}
