/* Documentation: the chapter index, the chapter layout with its sidebar, and rendered Markdown.
   Every colour comes from tokens.css; the sidebar becomes a column at 900px. */

/* ---------- Index ---------- */
.docs-hero { padding-block: clamp(3rem, 8vw, 5rem) clamp(2.5rem, 6vw, 3.5rem); }
.docs-hero .lead { max-width: 40rem; margin-top: 1rem; }
.docs-hero .btn { flex-direction: column; align-items: flex-start; gap: 0.1rem; margin-top: 1.75rem; padding-block: 0.7rem; text-align: left; }
.docs-start-title { font-size: 0.85rem; font-weight: 500; opacity: 0.8; }

.docs-index { display: grid; gap: 3rem 2.5rem; align-items: start; }
.docs-toc { margin-top: 1.25rem; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--white); }
.docs-toc li + li { border-top: 1px solid var(--line); }
.docs-toc a { display: flex; gap: 0.9rem; padding: 1rem 1.25rem; text-decoration: none; }
.docs-toc a:hover { background: var(--surface); }
.docs-toc-number { flex: none; width: 1.5rem; padding-top: 0.1rem; font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent-deep); }
.docs-toc-text { font-size: 0.9rem; line-height: 1.55; color: var(--muted); }
.docs-toc-text b { display: block; margin-bottom: 0.15rem; font-size: 1rem; font-weight: 600; color: var(--ink); }
@media (min-width: 900px) { .docs-index { grid-template-columns: 1fr 1fr; } }

/* ---------- Chapter layout ---------- */
.docs-chapter { padding-block: 1.25rem 4rem; border-top: 0; }
.docs-layout { display: grid; gap: 1.75rem; align-items: start; }
.docs-article { min-width: 0; max-width: 46rem; }
.docs-title { margin-top: 0.6rem; font-size: clamp(2rem, 4.5vw, 2.75rem); }
@media (min-width: 900px) {
  .docs-chapter { padding-block: 3rem 5.5rem; }
  .docs-layout { grid-template-columns: 15.5rem minmax(0, 1fr); gap: 3.5rem; }
}

/* ---------- Sidebar: folded on phones, a sticky column from 900px ---------- */
.docs-nav-column { display: none; }
.docs-nav-fold { border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.docs-nav-fold summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 48px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
.docs-nav-fold summary::-webkit-details-marker { display: none; }
.docs-nav-fold summary::after {
  content: "";
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  margin-top: -0.25rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}
.docs-nav-fold[open] summary { border-bottom: 1px solid var(--line); }
.docs-nav-fold[open] summary::after { margin-top: 0.25rem; transform: rotate(-135deg); }
.docs-nav-fold .docs-nav-group { padding: 0.75rem; }
.docs-nav-fold .docs-nav-group + .docs-nav-group { padding-top: 0; }

.docs-nav-group + .docs-nav-group { margin-top: 1.25rem; }
.docs-nav-label {
  margin: 0 0 0.35rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.docs-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.75rem;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.93rem;
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
}
.docs-nav a:hover { background: var(--surface); color: var(--ink); }
.docs-nav a[aria-current] { border-left-color: var(--accent); background: var(--surface); font-weight: 600; color: var(--accent-deep); }

@media (min-width: 900px) {
  .docs-nav-fold { display: none; }
  .docs-nav-column { display: block; position: sticky; top: 5.5rem; max-height: calc(100vh - 6.5rem); overflow-y: auto; }
}

/* ---------- Rendered Markdown ---------- */
.prose { margin-top: 1.75rem; }
.prose > * + * { margin-top: 1.1rem; }
.prose h2 { margin-top: 2.75rem; font-size: clamp(1.35rem, 2.6vw, 1.6rem); scroll-margin-top: 5.5rem; }
.prose h3 { margin-top: 2rem; font-size: 1.15rem; scroll-margin-top: 5.5rem; }
.prose h2 + *, .prose h3 + * { margin-top: 0.75rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li { margin-top: 0.4rem; }
.prose li::marker { color: var(--accent-deep); }
.prose a { color: var(--accent-deep); text-underline-offset: 0.18em; }
.prose strong { font-weight: 700; }
.prose code {
  padding: 0.1em 0.35em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.84em;
  overflow-wrap: anywhere;
}
.prose .heading-permalink { margin-left: 0.4rem; font-weight: 400; color: var(--muted); text-decoration: none; opacity: 0; }
.prose h2:hover .heading-permalink, .prose h3:hover .heading-permalink { opacity: 1; }

/* A wide table scrolls inside its own box, never the page. */
.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-collapse: collapse;
  background: var(--white);
  font-size: 0.9rem;
  line-height: 1.5;
}
.prose th, .prose td { min-width: 10rem; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--surface); font-weight: 600; }
.prose tr:last-child td { border-bottom: 0; }
.prose td + td, .prose th + th { border-left: 1px solid var(--line); }

.prose figure { margin: 1.75rem 0 0; }
.prose figure img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }

/* A tip: a Markdown blockquote, e.g. "> **Tip:** …". */
.prose blockquote {
  margin: 1.5rem 0 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}
.prose blockquote > * + * { margin-top: 0.6rem; }

/* ---------- Previous / next ---------- */
.docs-pager { display: grid; gap: 0.75rem; margin-top: 3.5rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
.docs-pager a {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--white);
  text-decoration: none;
}
.docs-pager a:hover { border-color: var(--accent); }
.docs-pager span { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.docs-pager b { font-weight: 600; line-height: 1.35; }
.docs-pager-previous span::before { content: "← "; }
.docs-pager-next { text-align: right; }
.docs-pager-next span::after { content: " →"; }
@media (min-width: 640px) {
  .docs-pager { grid-template-columns: 1fr 1fr; }
  .docs-pager-next { grid-column: 2; }
}
