/* stater.sh documentation layout. Loaded after site.css on /docs/ pages only.
   Colours, type, space and radii come from /css/tokens.css by name; never a literal value.
   Markup comes from tools/build_docs.py (layout, nav, TOC, pager) and js/docs.js (search). */

/* ---------- Layout ----------
   Below 860px: one column; the side nav is the "Documentation menu" <details>.
   860-1199px: side nav and content; the TOC is the "On this page" <details>.
   1200px and up: side nav, content and TOC. */
.docs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  padding-top: var(--space-5);
  padding-bottom: 80px;
  align-items: start;
}
@media (min-width: 860px) {
  .docs-layout { grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-7); padding-top: var(--space-6); }
}
@media (min-width: 1200px) {
  .docs-layout { grid-template-columns: 240px minmax(0, 760px) 200px; justify-content: space-between; }
}
.docs-main { min-width: 0; max-width: 760px; }

/* ---------- Side navigation ---------- */
.docs-sidebar { min-width: 0; }
.docs-nav { display: none; }
@media (min-width: 860px) {
  .docs-sidebar {
    position: sticky;
    top: calc(64px + var(--space-5));
    max-height: calc(100vh - 64px - var(--space-7));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: var(--space-2);
    padding-bottom: var(--space-5);
  }
  .docs-nav { display: block; }
  .docs-nav-mobile { display: none; }
}
.docs-nav ul, .docs-nav-list ul { list-style: none; margin: 0; padding: 0; }
.docs-nav-group {
  margin: var(--space-5) 0 var(--space-2);
  font: 700 12px/16px var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}
.docs-nav > .docs-nav-group:first-child, .docs-nav-list > .docs-nav-group:first-child { margin-top: 0; }
.docs-nav a, .docs-nav-list a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 6px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-size: 15px;
  line-height: 20px;
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard);
}
.docs-nav a:hover, .docs-nav-list a:hover { color: var(--ink); background: var(--surface); }
.docs-nav a[aria-current="page"], .docs-nav-list a[aria-current="page"] {
  color: var(--ink);
  background: var(--accent-soft);
  font-weight: 600;
}
.docs-nav .docs-nav-sub, .docs-nav-list .docs-nav-sub { margin-left: var(--space-3); padding-left: var(--space-2); border-left: 1px solid var(--line); }
.docs-nav-sub a { font-size: 14px; }

/* Mobile menu (works without JS: it is a <details>) */
.docs-nav-mobile, .docs-toc-mobile {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}
.docs-nav-mobile > summary, .docs-toc-mobile > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 48px;
  padding: 0 var(--space-4);
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-md);
}
.docs-nav-mobile > summary::-webkit-details-marker, .docs-toc-mobile > summary::-webkit-details-marker { display: none; }
.docs-nav-mobile > summary::after, .docs-toc-mobile > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink-muted);
  border-bottom: 2px solid var(--ink-muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--duration-fast) var(--ease-standard);
}
.docs-nav-mobile[open] > summary::after, .docs-toc-mobile[open] > summary::after { transform: rotate(225deg) translateY(-2px); }
.docs-nav-list { padding: 0 var(--space-3) var(--space-4); }
.docs-nav-list a { min-height: 44px; }

/* ---------- Search (built by js/docs.js, only with JS) ---------- */
.docs-search { position: relative; margin-bottom: var(--space-4); }
@media (min-width: 860px) { .docs-search { margin-bottom: var(--space-5); } }
.docs-search label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--ink);
}
.docs-search-field { position: relative; }
.docs-search input {
  width: 100%;
  min-height: 44px;
  padding: 0 64px 0 var(--space-3);
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: 400 16px/24px var(--font-sans);
}
.docs-search input::placeholder { color: var(--ink-subtle); }
.docs-search input::-webkit-search-cancel-button { display: none; }
.docs-search-key {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  font: 500 12px/20px var(--font-mono);
  color: var(--ink-subtle);
  pointer-events: none;
}
.docs-search-results {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: var(--space-1);
  max-height: min(70vh, 480px);
  overflow-y: auto;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
@media (min-width: 860px) {
  .docs-search-results { position: absolute; left: 0; z-index: 20; width: min(440px, calc(100vw - 48px)); }
}
.docs-search-results li { border-radius: var(--radius-sm); }
.docs-search-results li + li { margin-top: 2px; }
.docs-search-results a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  line-height: 20px;
}
.docs-search-results a:hover, .docs-search-results [aria-selected="true"] a { background: var(--accent-soft); }
.docs-search-results [aria-selected="true"] a { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.docs-result-title { display: block; font-weight: 600; }
.docs-result-excerpt { display: block; margin-top: 2px; color: var(--ink-muted); overflow-wrap: anywhere; }
.docs-search-results mark { background: var(--accent-soft); color: var(--ink); border-radius: 2px; }
.docs-search-empty { padding: var(--space-2) var(--space-3); font-size: 14px; color: var(--ink-muted); }

/* ---------- Page head ---------- */
.docs-main > .breadcrumbs { padding-top: 0; margin-bottom: var(--space-4); }
.docs-main > h1 { font: 700 32px/40px var(--font-display); letter-spacing: -0.01em; }
.docs-main > .lead { margin-top: var(--space-3); max-width: 64ch; }
.docs-main > .btn-row { margin-top: var(--space-5); }
.docs-tour {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-4);
  margin-top: var(--space-4);
  font-size: 15px;
  line-height: 22px;
}
.docs-tour-label { color: var(--ink-muted); }
.docs-tour .link-more { min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- Table of contents ---------- */
.docs-toc { display: none; }
.docs-toc-mobile { margin-top: var(--space-5); }
.docs-toc-mobile nav { padding: 0 var(--space-4) var(--space-4); }
@media (min-width: 1200px) {
  .docs-toc {
    display: block;
    position: sticky;
    top: calc(64px + var(--space-5));
    max-height: calc(100vh - 64px - var(--space-7));
    overflow-y: auto;
    padding-bottom: var(--space-5);
  }
  .docs-toc-mobile { display: none; }
}
.docs-toc-title {
  margin-bottom: var(--space-2);
  font: 700 12px/16px var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}
.docs-toc ul, .docs-toc-mobile ul { list-style: none; margin: 0; padding: 0; }
.docs-toc ul ul, .docs-toc-mobile ul ul { padding-left: var(--space-3); }
.docs-toc a, .docs-toc-mobile a {
  display: block;
  padding: 4px var(--space-2);
  border-radius: var(--radius-xs);
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 20px;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.docs-toc-mobile a { display: flex; align-items: center; min-height: 40px; }
.docs-toc a:hover, .docs-toc-mobile a:hover { color: var(--ink); }
.docs-toc a[aria-current="true"] { color: var(--ink); background: var(--accent-soft); font-weight: 600; }

/* ---------- Content ---------- */
.docs-content { margin-top: var(--space-6); }
.docs-content > h2:first-child { margin-top: 0; }
.docs-content h2, .docs-content h3, .docs-content h4 { scroll-margin-top: calc(64px + var(--space-4)); }
.heading-anchor {
  margin-left: var(--space-2);
  padding: 0 4px;
  border-radius: var(--radius-xs);
  color: var(--ink-subtle);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-standard);
}
.heading-anchor:hover { color: var(--accent); }
.docs-content :is(h2, h3, h4):hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1; }
@media (hover: none) { .heading-anchor { opacity: 1; } }
.docs-content .table-wrap { margin-top: var(--space-4); }
.docs-content li > .codeblock, .docs-content li > p { margin-top: var(--space-2); }
.docs-content td code, .docs-content th code { overflow-wrap: anywhere; }

/* ---------- Docs home groups ---------- */
.docs-groups { margin-top: 64px; }
.docs-groups > h2 { font: 700 24px/32px var(--font-display); margin-bottom: var(--space-5); scroll-margin-top: calc(64px + var(--space-4)); }
.docs-group .card-title { margin-bottom: var(--space-3); }
.docs-group-list { list-style: none; margin: 0; padding: 0; }
.docs-group-list li + li { margin-top: var(--space-3); }
.docs-group-list a { font-weight: 600; text-decoration: none; }
.docs-group-list a:hover { text-decoration: underline; }
.docs-group-desc { display: block; margin-top: 2px; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.docs-group-sub { padding-left: var(--space-4); border-left: 1px solid var(--line); }

/* ---------- Pager ---------- */
.docs-pager {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
  margin-top: 64px;
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}
@media (min-width: 600px) { .docs-pager { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.docs-pager a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 64px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  text-decoration: none;
  transition: border-color var(--duration-fast) var(--ease-standard);
}
.docs-pager a:hover { border-color: var(--line-strong); }
.docs-pager-next { text-align: right; grid-column: -2; }
.docs-pager-dir { font-size: 13px; line-height: 18px; color: var(--ink-subtle); }
.docs-pager-title { font-weight: 600; color: var(--accent); }
@media (max-width: 599px) { .docs-pager-next { grid-column: auto; } }
@media (max-width: 859px), (hover: none) { .docs-search-key { display: none; } }
