/* The user guide's pages (/guide/), on top of style.css. */
.docs-wrap { max-width: 1320px; }
.docs {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 200px;
  gap: 48px;
  align-items: start;
  padding-top: 40px;
  padding-bottom: 64px;
}

/* Sidebar */
/* Only the link list scrolls: a scrolling sidebar would clip the search results, which
   spread over the page. */
.docs-side { position: sticky; top: 88px; z-index: 5; }
.docs-nav {
  max-height: calc(100vh - 160px); overflow-y: auto; margin-top: 8px;
  scrollbar-width: thin; scrollbar-color: var(--surface-hover) transparent;
}
.docs-nav ul, .docs-toc ul { list-style: none; margin: 0; padding: 0; }
.docs-group {
  margin: 24px 0 8px; padding-left: 12px;
  color: var(--text-muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
}
.docs-nav a {
  display: block; padding: 6px 12px; border-radius: var(--r-small);
  color: var(--text-muted); text-decoration: none; font-size: 15px;
}
.docs-nav a:hover { color: var(--text); background: var(--surface); }
.docs-nav a[aria-current="page"] { color: var(--text); background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.docs-menu { display: none; }

/* Search (Pagefind's UI, in the theme's colors) */
.docs-search {
  position: relative;
  --pagefind-ui-scale: .8;
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--text);
  --pagefind-ui-background: var(--surface);
  --pagefind-ui-border: var(--border);
  --pagefind-ui-tag: var(--surface-raised);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 8px;
  --pagefind-ui-font: var(--font);
}
.docs-search .pagefind-ui__form::before { top: 13px; left: 14px; }
.docs-search .pagefind-ui__search-input {
  height: 40px; padding: 0 64px 0 38px;
  color: var(--text); font: 400 15px var(--font);
  border-radius: var(--r-small);
  transition: border-color .15s;
}
.docs-search .pagefind-ui__search-input::placeholder { color: var(--text-muted); opacity: 1; }
.docs-search .pagefind-ui__search-input:focus { outline: none; border-color: var(--accent); }
.docs-search .pagefind-ui__search-clear {
  top: 6px; right: 6px; height: 28px; padding: 0 10px;
  border: 0; border-radius: var(--r-tiny);
  background: var(--surface-raised); color: var(--text-muted);
  font: 500 12px var(--font);
}
.docs-search .pagefind-ui__search-clear:hover { color: var(--text); background: var(--surface-hover); }
.docs-search .pagefind-ui__drawer {
  position: absolute; z-index: 5; top: calc(100% + 8px); left: 0;
  width: min(560px, calc(100vw - 32px)); max-height: 70vh; overflow-y: auto;
  gap: 0; padding: 4px 20px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-medium);
  box-shadow: 0 24px 60px -20px #000;
}
.docs-search .pagefind-ui__drawer:not(:has(.pagefind-ui__results-area)) { display: none; }
.docs-search .pagefind-ui__result-link { color: var(--text); }
.docs-search .pagefind-ui__result-excerpt, .docs-search .pagefind-ui__message { color: var(--text-muted); }
.docs-search mark { background: var(--accent-soft); color: var(--text); border-radius: 2px; }

/* On this page */
.docs-toc { position: sticky; top: 88px; }
.docs-toc .docs-group { margin-top: 0; padding-left: 13px; }
.docs-toc a {
  display: block; padding: 4px 12px; border-left: 1px solid var(--border);
  color: var(--text-muted); text-decoration: none; font-size: 14px; line-height: 1.4;
}
.docs-toc a:hover { color: var(--text); }
.docs-toc a.active { color: var(--accent); border-left-color: var(--accent); }
.docs-toc code { font-size: 12px; }

/* Page content */
.docs-main { max-width: 760px; }
.prose { font-size: 16px; line-height: 1.7; }
.prose h1 { font-size: clamp(32px, 4vw, 44px); font-weight: 800; margin: 0 0 20px; }
.prose h2 { font-size: 26px; font-weight: 700; margin: 48px 0 12px; padding-top: 24px; border-top: 1px solid var(--border); }
.prose h3 { font-size: 19px; margin: 32px 0 8px; }
.prose h2, .prose h3 { position: relative; scroll-margin-top: 88px; }
.prose .anchor {
  position: absolute; left: -24px; padding-right: 8px;
  color: var(--text-muted); text-decoration: none; opacity: 0; transition: opacity .15s;
}
.prose .anchor::before { content: "#"; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose .anchor:focus { opacity: 1; }
.prose p, .prose ul, .prose ol { margin: 0 0 16px; }
.prose ul, .prose ol { padding-left: 24px; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--text-muted); }
.prose li > ul, .prose li > ol { margin: 6px 0 0; }
.prose a { color: var(--accent); text-decoration: none; }
.prose a:hover { text-decoration: underline; }
.prose strong { color: #fff; font-weight: 600; }
.prose :not(pre) > code {
  padding: 2px 6px; border-radius: var(--r-tiny);
  background: var(--surface-raised); border: 1px solid var(--border);
  font-size: .86em; overflow-wrap: anywhere;
}
.prose .code { margin: 0 0 20px; }
.prose .code pre { font-size: 13.5px; }
.prose blockquote {
  margin: 0 0 16px; padding: 12px 18px;
  border-left: 3px solid var(--accent); border-radius: 0 var(--r-small) var(--r-small) 0;
  background: var(--surface); color: var(--text-muted);
}
.prose blockquote p:last-child { margin: 0; }

.table { margin: 0 0 20px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-medium); }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; }
.prose th, .prose td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.prose th { background: var(--surface); font-weight: 600; white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }

/* Previous and next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 56px; }
.pager a {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 20px;
  border: 1px solid var(--border); border-radius: var(--r-large);
  background: var(--surface); text-decoration: none; font-weight: 600;
  transition: border-color .2s;
}
.pager a:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.pager span { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.pager-next { text-align: right; grid-column: 2; }

.nav-links a[aria-current="page"] { color: var(--text); background: var(--surface); }

@media (max-width: 1200px) {
  .docs { grid-template-columns: 220px minmax(0, 1fr); gap: 40px; }
  .docs-toc { display: none; }
}
@media (max-width: 860px) {
  .docs { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-top: 24px; }
  .docs-side { position: static; max-height: none; overflow: visible; }
  .docs-menu {
    display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 12px;
    padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-medium);
    background: var(--surface); color: var(--text); font: 500 15px var(--font); cursor: pointer;
  }
  .docs-menu::after { content: "▾"; color: var(--text-muted); transition: transform .15s; }
  .docs-menu[aria-expanded="true"]::after { transform: rotate(180deg); }
  .docs-nav { display: none; max-height: none; padding: 4px 0 8px; }
  .docs-nav.open { display: block; }
  .prose .anchor { display: none; }
}
@media (max-width: 640px) {
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
}
