/* Docs pages under /docs/. Builds on site.css (tokens, nav, buttons, footer). */

.docs-badge {
  color: var(--fg-2); font-size: 14px; font-weight: 500; padding: 3px 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2);
}
.docs-badge:hover { color: var(--fg); text-decoration: none; border-color: var(--border-strong); }

.docs {
  display: grid; grid-template-columns: 220px minmax(0, 1fr) 200px; gap: 48px;
  align-items: start; padding-top: 40px; padding-bottom: 88px;
}

/* ---------- Sidebar ---------- */
.docs-side { position: sticky; top: 88px; max-height: calc(100vh - 112px); overflow-y: auto; padding-bottom: 16px; }
.docs-group + .docs-group { margin-top: 22px; }
.docs-group-label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); margin: 0 0 6px 10px; }
.docs-group a {
  display: block; padding: 5px 10px; border-radius: var(--radius-sm);
  color: var(--fg-2); font-size: 14.5px; line-height: 1.45;
}
.docs-group a:hover { color: var(--fg); background: var(--surface-2); text-decoration: none; }
.docs-group a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 500; }

/* The sidebar as a menu on narrow screens. */
.docs-menu { display: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.docs-menu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; font-weight: 500; font-size: 15px;
}
.docs-menu summary::-webkit-details-marker { display: none; }
.docs-menu[open] summary .ico { transform: rotate(180deg); }
.docs-menu nav { padding: 4px 6px 12px; border-top: 1px solid var(--border); }
.docs-menu .docs-group-label { margin-top: 12px; }

/* ---------- On this page ---------- */
.docs-toc { position: sticky; top: 88px; font-size: 13.5px; }
.docs-toc p { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); margin-bottom: 8px; }
.docs-toc ul { border-left: 1px solid var(--border); }
.docs-toc a { display: block; padding: 4px 0 4px 12px; margin-left: -1px; border-left: 1px solid transparent; color: var(--fg-2); line-height: 1.4; }
.docs-toc a:hover { color: var(--fg); text-decoration: none; }
.docs-toc a.active { color: var(--accent); border-left-color: var(--accent); }

/* ---------- Content ---------- */
.docs-main { min-width: 0; }
.prose { max-width: 760px; font-size: 16px; line-height: 1.7; color: var(--fg); }
.prose h1 { font-size: clamp(32px, 3vw, 40px); line-height: 1.12; letter-spacing: -0.032em; margin-bottom: 18px; }
.prose h2 {
  font-size: 24px; line-height: 1.25; letter-spacing: -0.02em; margin: 52px 0 14px;
  padding-top: 28px; border-top: 1px solid var(--border);
}
.prose h3 { font-size: 18px; margin: 32px 0 10px; }
.prose h1 + p { font-size: 18px; color: var(--fg-2); }
.prose h2, .prose h3 { position: relative; scroll-margin-top: 88px; }
.prose .anchor {
  position: absolute; left: -0.9em; width: 0.9em; color: var(--fg-3); font-weight: 400; opacity: 0;
  transition: opacity .12s;
}
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose .anchor:focus { opacity: 1; text-decoration: none; }
.prose p, .prose ul, .prose ol, .prose .code, .prose .table-scroll, .prose blockquote { margin: 0 0 18px; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { margin: 4px 0; padding-left: 2px; }
.prose li::marker { color: var(--fg-3); }
.prose strong { font-weight: 600; }
.prose a { text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--accent); }
.prose blockquote { padding: 2px 16px; border-left: 3px solid var(--accent-line); color: var(--fg-2); }

/* Code blocks are dark in both themes, like the landing page's windows. */
.prose .code {
  position: relative; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--radius-sm);
}
.prose pre {
  margin: 0; padding: 14px 48px 14px 16px; overflow-x: auto; color: var(--code-fg);
  font-size: 13.5px; line-height: 1.6; tab-size: 2;
}
.prose pre code { font-family: var(--font-mono); }
.code-copy {
  position: absolute; top: 5px; right: 6px; width: 30px; height: 26px; display: grid; place-items: center; padding: 0;
  border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--code-dim);
}
.code-copy:hover { color: var(--code-fg); border-color: var(--code-border); background: var(--code-bar); }
.code-copy.done { color: var(--code-green); }

/* Tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.55; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 9px 14px; border-bottom: 1px solid var(--border); }
.prose th { background: var(--surface-2); font-weight: 600; font-size: 13.5px; color: var(--fg-2); white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose td :not(pre) > code { white-space: normal; overflow-wrap: anywhere; }
.prose td:first-child :not(pre) > code { white-space: nowrap; }

/* ---------- Figures ---------- */
/* Console screenshots, light or dark to match the reader. */
.prose .shot { margin: 8px 0 26px; }
.prose .shot img {
  display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.prose figcaption { margin-top: 10px; font-size: 13.5px; color: var(--fg-3); text-align: center; }

/* Flow diagrams: steps in a row that light up in turn; "loop" adds the way back. */
.prose .flow { margin: 8px 0 28px; }
.prose .flow ol {
  list-style: none; padding: 0; margin: 0; display: grid; gap: 28px;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
}
.prose .flow li {
  position: relative; margin: 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  font-size: 13.5px; line-height: 1.45; color: var(--fg-2);
}
.prose .flow li b { color: var(--fg); font-size: 14.5px; font-weight: 600; }
.prose .flow li:not(:last-child)::after {
  content: "\2192"; position: absolute; right: -22px; top: 50%; transform: translateY(-50%);
  color: var(--fg-3); font-size: 15px;
}
.prose .flow.flow-loop ol { position: relative; padding-bottom: 30px; }
.prose .flow.flow-loop ol::after {
  content: ""; position: absolute; left: calc(100% / var(--n) / 2); right: calc(100% / var(--n) / 2); bottom: 8px; height: 22px;
  border: 1.5px dashed var(--accent-line); border-top: 0; border-radius: 0 0 10px 10px;
}
.prose .flow-back { margin-top: -6px; font-size: 12.5px; color: var(--accent); text-align: center; }
@media (prefers-reduced-motion: no-preference) {
  .prose .flow li { animation: flow-on calc(var(--n) * 1.4s) calc(var(--i) * 1.4s) infinite both; }
}
@keyframes flow-on {
  0%, 24%, 100% { border-color: var(--border); background: var(--surface); box-shadow: none; }
  6%, 16% { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
}
@media (max-width: 860px) {
  .prose .flow ol { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .prose .flow li:not(:last-child)::after { content: "\2193"; right: auto; left: 50%; top: auto; bottom: -21px; transform: translateX(-50%); }
  .prose .flow.flow-loop ol { padding-bottom: 0; }
  .prose .flow.flow-loop ol::after { display: none; }
  .prose .flow-back { margin-top: 10px; }
  .prose .flow-back::before { content: "\21BA  "; }
}

/* The deploy demo on the Quickstart uses the landing page's terminal, without its overlapping cards. */
.prose .demo.doc-demo { padding-bottom: 0; margin: 8px 0 28px; }
.prose .doc-demo .demo-body { min-height: 300px; }
.prose .doc-demo ol, .prose .doc-demo li { list-style: none; padding: 0; margin: 0; }
.prose .doc-demo p { margin: 0; }
.prose .doc-demo .demo-live { margin-top: 16px; }

/* ---------- Previous / next ---------- */
.pager { max-width: 760px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 56px; }
.pager a {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--fg); font-weight: 500;
}
.pager a:hover { border-color: var(--accent-line); text-decoration: none; }
.pager small { color: var(--fg-3); font-weight: 400; font-size: 13px; }
.pager-next { text-align: right; grid-column: 2; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1120px) {
  .docs { grid-template-columns: 210px minmax(0, 1fr); gap: 40px; }
  .docs-toc { display: none; }
}
@media (max-width: 860px) {
  .docs { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-top: 20px; }
  .docs-side { display: none; }
  .docs-menu { display: block; }
  .prose h2 { margin-top: 40px; padding-top: 24px; }
  .prose .anchor { display: none; }
}
@media (max-width: 640px) {
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager-next { grid-column: 1; }
}
