/* ============================================================
   Docs page — layout, TOC sidebar, content typography
   ============================================================ */

/* ── Dark theme — scoped to docs page only ───────────────── */
/*
   Overriding the global CSS custom properties inside .docs-page
   causes every var(--xxx) reference in child rules to resolve to
   the dark values automatically — no other pages are affected.
*/
.docs-page {
  --bg:                    #0b0f1e;
  --bg-subtle:             #131929;
  --bg-card:               #131929;
  --border:                rgba(255,255,255,.09);
  --border-subtle:         rgba(255,255,255,.05);
  --text:                  #e8edf5;
  --text-muted:            #8899b4;
  --text-light:            #4f607a;
  --accent-on-light:       #00c7b7;
  --accent-on-light-soft:  rgba(0,199,183,.10);
  --accent-on-light-border:rgba(0,199,183,.28);
  --shadow-sm:             0 2px 12px rgba(0,0,0,.40);
  --shadow:                0 4px 24px rgba(0,0,0,.55);
}

/* ── Dark scrolled navbar (docs page only) ───────────────── */
.docs-dark-page .navbar.scrolled {
  background: rgba(11,15,30,.92);
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

/* ── Page wrapper ────────────────────────────────────────── */
.docs-page {
  min-height: calc(100vh - var(--nav-height));
  padding-top: var(--nav-height);
  background: var(--bg);
  color: var(--text);
}

/* ── Mobile TOC toggle button ────────────────────────────── */
.docs-toc-toggle {
  display: none;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .875rem 1.25rem;
  background: var(--bg-subtle);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.docs-toc-toggle:hover { background: var(--border); }
.docs-toc-toggle-chevron {
  margin-left: auto;
  transition: transform var(--transition);
}
.docs-toc-toggle[aria-expanded="true"] .docs-toc-toggle-chevron {
  transform: rotate(180deg);
}

/* ── Two-column layout ───────────────────────────────────── */
.docs-layout {
  display: grid;
  grid-template-columns: 272px 1fr;
  max-width: 1320px;
  margin: 0 auto;
  min-height: calc(100vh - var(--nav-height) - 56px);
}

/* ── Sidebar ─────────────────────────────────────────────── */
.docs-sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.docs-sidebar-inner {
  position: sticky;
  top: calc(var(--nav-height) + 1.5rem);
  max-height: calc(100vh - var(--nav-height) - 3rem);
  overflow-y: auto;
  padding: 1.75rem 1.25rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.docs-sidebar-inner::-webkit-scrollbar { width: 4px; }
.docs-sidebar-inner::-webkit-scrollbar-track { background: transparent; }
.docs-sidebar-inner::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.docs-toc-title {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 1rem;
  padding-left: .5rem;
}

/* ── TOC nav tree ────────────────────────────────────────── */
.docs-toc div { /* wrapper div from markdown toc extension */
  margin: 0;
}

.docs-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* depth-1 (h1) items */
.docs-toc > div > ul > li {
  margin-bottom: .125rem;
}

/* depth-2+ nested lists */
.docs-toc ul ul {
  padding-left: .875rem;
  border-left: 1px solid var(--border-subtle);
  margin: .125rem 0 .25rem;
}
.docs-toc ul ul ul {
  padding-left: .75rem;
}

.docs-toc a {
  display: block;
  padding: .3125rem .5rem;
  border-radius: var(--radius-xs);
  font-size: .875rem;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.45;
  word-break: break-word;
  transition: color var(--transition), background var(--transition);
}
.docs-toc a:hover {
  color: var(--text);
  background: var(--bg-subtle);
}
.docs-toc-link--active {
  color: var(--accent-on-light) !important;
  background: var(--accent-on-light-soft) !important;
  font-weight: 600;
}

/* h1 links slightly bolder */
.docs-toc > div > ul > li > a {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text);
}
.docs-toc > div > ul > li > a:hover {
  color: var(--accent-on-light);
}

/* ── Main content area ───────────────────────────────────── */
.docs-content {
  padding: 3rem 3.5rem 5rem;
  min-width: 0;
  max-width: 900px;
}

/* ── Heading styles inside docs ──────────────────────────── */
.docs-content h1,
.docs-content h2,
.docs-content h3,
.docs-content h4 {
  scroll-margin-top: calc(var(--nav-height) + 1.5rem);
  position: relative;
}

.docs-content h1 {
  font-size: clamp(1.625rem, 3vw, 2.25rem);
  margin: 3rem 0 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.docs-content h1:first-child { margin-top: 0; }

.docs-content h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.625rem);
  margin: 2.5rem 0 1rem;
  color: var(--text);
}

.docs-content h3 {
  font-size: 1.125rem;
  margin: 2rem 0 .75rem;
  color: var(--text);
}

.docs-content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 .625rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* heading anchor permalinks */
.docs-heading-anchor {
  display: inline-block;
  margin-left: .5rem;
  opacity: 0;
  color: var(--text-light) !important;
  text-decoration: none !important;
  font-weight: 400;
  font-size: .85em;
  transition: opacity var(--transition);
  vertical-align: middle;
}
.docs-content h1:hover .docs-heading-anchor,
.docs-content h2:hover .docs-heading-anchor,
.docs-content h3:hover .docs-heading-anchor,
.docs-content h4:hover .docs-heading-anchor { opacity: 1; }

/* ── Paragraphs & inline ─────────────────────────────────── */
.docs-content p {
  margin: 0 0 1rem;
  line-height: 1.8;
  color: var(--text);
}

.docs-content strong { color: var(--text); }

.docs-content em { color: var(--text-muted); }

.docs-content a {
  color: var(--accent-on-light);
  text-decoration: underline;
  text-decoration-color: var(--accent-on-light-border);
  text-underline-offset: 3px;
}
.docs-content a:hover { text-decoration-color: var(--accent-on-light); }

.docs-content code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: .875em;
  padding: .15em .4em;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  white-space: nowrap;
}

/* ── Horizontal rule ─────────────────────────────────────── */
.docs-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ── Block quotes ────────────────────────────────────────── */
.docs-content blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--accent-on-light);
  background: var(--accent-on-light-soft);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  color: var(--text-muted);
}
.docs-content blockquote p { margin: 0; }

/* ── Lists ───────────────────────────────────────────────── */
.docs-content ul,
.docs-content ol {
  margin: 0 0 1rem 1.5rem;
  padding: 0;
}
.docs-content li {
  margin-bottom: .375rem;
  line-height: 1.75;
  color: var(--text);
}
.docs-content li > p { margin-bottom: .25rem; }
.docs-content ul ul,
.docs-content ol ol,
.docs-content ul ol,
.docs-content ol ul {
  margin: .375rem 0 .375rem 1.25rem;
}

/* ── Tables ──────────────────────────────────────────────── */
.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: .9375rem;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.docs-content thead {
  background: var(--bg-subtle);
}
.docs-content th {
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: .875rem;
  color: var(--text-muted);
  letter-spacing: .03em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.docs-content td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
.docs-content tr:last-child td { border-bottom: none; }
.docs-content tbody tr:hover { background: var(--bg-subtle); }

/* ── Images ──────────────────────────────────────────────── */
.docs-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: block;
  margin: 1.5rem auto;
  box-shadow: var(--shadow-sm);
}

/* ── Video embeds ────────────────────────────────────────── */
.docs-video {
  margin: 2rem 0;
}
.docs-video video {
  width: 100%;
  max-width: 720px;
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: #000;
}
.docs-video-caption {
  margin: .5rem 0 0;
  font-size: .875rem;
  color: var(--text-light);
  text-align: center;
}

/* ── Code blocks (fenced) ────────────────────────────────── */
.docs-content pre {
  background: var(--primary-dark);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border-dark);
}
.docs-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: .875rem;
  color: #e2e8f0;
  white-space: pre;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .docs-layout {
    grid-template-columns: 240px 1fr;
  }
  .docs-content {
    padding: 2.5rem 2rem 4rem;
  }
}

@media (max-width: 768px) {
  .docs-toc-toggle {
    display: flex;
  }

  .docs-layout {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    display: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .docs-sidebar--open {
    display: block;
  }

  .docs-sidebar-inner {
    position: static;
    max-height: none;
    overflow-y: visible;
    padding: 1.25rem 1.25rem 1.5rem;
  }

  .docs-content {
    padding: 1.75rem 1.25rem 3.5rem;
  }

  .docs-content h1 { font-size: 1.5rem; }
  .docs-content h2 { font-size: 1.25rem; }
}

@media (max-width: 480px) {
  .docs-content {
    padding: 1.5rem 1rem 3rem;
  }

  .docs-content table {
    font-size: .875rem;
  }
  .docs-content th,
  .docs-content td {
    padding: .5rem .75rem;
  }
}
