/* toc.css — table of contents: sticky sidebar + mobile collapse.
   Public --toc-* custom properties are THEME-owned: this file defines only
   private, scheme-aware `--_*-d` defaults, so theme overrides win at any
   stylesheet load order. */

:root {
  --_toc-fg-d:         #6b7280;
  --_toc-current-bg-d: rgba(0,0,0,0.06);
  --_toc-current-fg-d: #111827;
  --_toc-border-d:     #d1d5db;
  --_toc-mobile-bg-d:  rgba(0,0,0,0.03);
}

@media (prefers-color-scheme: dark) {
  :root {
    --_toc-fg-d:         #9ca3af;
    --_toc-current-bg-d: rgba(255,255,255,0.08);
    --_toc-current-fg-d: #e5e7eb;
    --_toc-border-d:     #2a2e37;
    --_toc-mobile-bg-d:  rgba(255,255,255,0.04);
  }
}

/* Hidden by default; the wide-screen media query below shows the desktop nav
   and the mobile box shows itself only under that breakpoint. */
.toc { display: none; }

/* Desktop: the nav renders wherever toc.js placed it (inside the article
   header rail in themes that have one). The plugin styles only the nav's own
   box — it never re-grids the article; themes own that layout. */
@media (min-width: 1000px) {
  .toc {
    display: block;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--toc-border, var(--_toc-border-d));
    font-family: var(--font-mono, monospace);
    font-size: 11.5px;
    line-height: 1.5;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    /* .toc a uses negative side margins for its hover pill; without this the
       few px of overflow draw a horizontal scrollbar in narrow rails. */
    overflow-x: hidden;
  }
  .toc-mobile { display: none !important; }
}

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

.toc ul ul {
  padding-left: var(--toc-indent, 1.2em);
  margin-top: 4px;
}

.toc li {
  margin-bottom: 4px;
}

.toc a {
  color: var(--toc-fg, var(--_toc-fg-d));
  border-bottom: none;
  display: block;
  transition: color .15s, background .15s;
  text-decoration: none;
  border-radius: var(--toc-radius, 3px);
  padding: 2px 4px;
  margin: -2px -4px;
}

.toc a:hover {
  color: var(--toc-current-fg, var(--_toc-current-fg-d));
  background: var(--toc-current-bg, var(--_toc-current-bg-d));
}

.toc a.toc-current {
  color: var(--toc-current-fg, var(--_toc-current-fg-d));
  background: var(--toc-current-bg, var(--_toc-current-bg-d));
  font-weight: 600;
}

/* Mobile: collapsed details box */
.toc-mobile {
  margin: 0 0 22px;
  border: 1px solid var(--toc-border, var(--_toc-border-d));
  border-radius: var(--toc-radius, 3px);
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  background: var(--toc-mobile-bg, var(--_toc-mobile-bg-d));
}

.toc-mobile summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  color: var(--toc-current-fg, var(--_toc-current-fg-d));
  list-style: none;
  user-select: none;
}

.toc-mobile summary::-webkit-details-marker {
  display: none;
}

.toc-mobile summary::before {
  content: "\25B6";
  display: inline-block;
  margin-right: 6px;
  font-size: 10px;
  transition: transform .15s;
}

.toc-mobile[open] > summary::before {
  transform: rotate(90deg);
}

.toc-mobile .toc {
  display: block;
  position: static;
  border: none;
  padding: 0 14px 10px;
  max-height: none;
  font-size: 11px;
}
