/* ================================================================
   DataHints DS — Toc Component
   Requires: tokens.css
   ================================================================ */

/* ═══════════════════════════════════════════════════════════
   TOC COMPONENT
════════════════════════════════════════════════════════════ */
.dh-toc {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
}

/* ── Sticky sidebar ──────────────────────────────────────── */
.toc-sticky {
  position: sticky;
  top: calc(64px + var(--sp-6));
  max-height: calc(100vh - 64px - var(--sp-12));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-s) transparent;
  padding: var(--sp-5);
  background: var(--bg-card);
  border: 1px solid var(--border-s);
  border-radius: var(--r-md);
}

/* ── Inline ──────────────────────────────────────────────── */
.toc-inline {
  background: var(--bg-card);
  border: 1px solid var(--border-s);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  margin-bottom: var(--sp-8);
}

/* ── Title ───────────────────────────────────────────────── */
.toc-title {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-3);
  margin-bottom: var(--sp-4);
}

/* ── Collapsible (details/summary) ──────────────────────── */
.toc-collapsible .toc-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  margin: 0; padding: 0;
  user-select: none;
}
.toc-collapsible .toc-summary::-webkit-details-marker { display: none; }
.toc-collapsible .toc-summary .toc-title { margin-bottom: 0; }
.toc-collapsible .toc-summary .toc-chevron {
  width: 14px; height: 14px;
  color: var(--fg-3);
  flex-shrink: 0;
  transition: transform var(--ease-fast);
}
.toc-collapsible[open] .toc-summary .toc-chevron { transform: rotate(180deg); }
.toc-collapsible nav { margin-top: var(--sp-4); }

/* ── List reset ──────────────────────────────────────────── */
.toc-list, .toc-sublist {
  list-style: none;
  margin: 0; padding: 0;
}

/* ── Links ───────────────────────────────────────────────── */
.toc-link {
  display: block;
  padding: var(--sp-1) var(--sp-2);
  padding-left: var(--sp-3);
  border-left: 2px solid transparent;
  color: var(--fg-3);
  text-decoration: none;
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
  transition:
    color var(--ease-fast),
    border-color var(--ease-fast),
    background var(--ease-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toc-link:hover {
  color: var(--fg);
  border-left-color: var(--border-a);
  background: var(--bg-card-h);
}
.toc-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.toc-link.is-active {
  color: var(--accent-text);
  border-left-color: var(--accent);
  background: var(--accent-sub);
}

/* ── h3 sub-items ────────────────────────────────────────── */
.toc-sublist {
  margin-top: 1px;
  padding-left: var(--sp-3);
}
.toc-sublist .toc-link {
  font-size: 0.6875rem;
  padding-top: 1px;
  padding-bottom: 1px;
}

/* ── Item spacing ────────────────────────────────────────── */
.toc-item + .toc-item { margin-top: 1px; }

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .toc-link, .toc-chevron { transition: none; }
}

/* ═══════════════════════════════════════════════════════════
   TWO-COLUMN ARTICLE LAYOUT
════════════════════════════════════════════════════════════ */
.article-with-toc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: var(--sp-12);
  align-items: start;
}
.article-with-toc .dh-prose { order: 1; }
.article-with-toc .dh-toc   { order: 2; }

@media (max-width: 860px) {
  .article-with-toc { grid-template-columns: 1fr; }
  .article-with-toc .dh-toc.toc-sticky { display: none; }
}
