/* ===== Table of Contents plugin =====
   All selectors scoped under [data-cb-type="table-of-contents"] so nothing leaks.
   Colors run through CSS variables so dark mode is a variable override. */
[data-cb-type="table-of-contents"] {
    position: relative;
    width: 100%;
    --toc-accent: #3b82f6;
    --toc-text: #1a1a1a;
    --toc-muted: #6b7280;
    --toc-border: #e5e7eb;
    --toc-surface: #f9fafb;
}

/* ── Dark mode (opt-in — commented out) ───────────────────────────────────
   Dark mode for a rendered block is the SITE's responsibility, not the plugin's.
   Every color above is a CSS variable, so to enable dark mode you only need to
   redefine the palette below under whatever trigger your site uses — a class,
   [data-theme="dark"], @media (prefers-color-scheme: dark), etc. Uncomment and
   change the selector to match your site's theme system.
   NOTE: `.dark` is also the ContentBuilder editor's own UI theme, so on a page
   that runs the editor, prefer a different class here to avoid the editor
   repainting your content while you edit.

.dark [data-cb-type="table-of-contents"] {
    --toc-text: #f3f4f6;
    --toc-muted: #9ca3af;
    --toc-border: #3a3a3a;
    --toc-surface: #1e1e1e;
}
*/

[data-cb-type="table-of-contents"] {
    padding: 18px 20px;
    background: var(--toc-surface);
    border: 1px solid var(--toc-border);
    border-radius: 12px;
}

[data-cb-type="table-of-contents"] .toc-title {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--toc-muted);
}

[data-cb-type="table-of-contents"] .toc-list {
    list-style: none;
    margin: 0 !important;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-inline-start: 0px !important;
}

[data-cb-type="table-of-contents"] .toc-item.toc-h3 { padding-left: 16px; }
[data-cb-type="table-of-contents"] .toc-item.toc-h4 { padding-left: 32px; }

[data-cb-type="table-of-contents"] .toc-link {
    display: block;
    padding: 5px 10px;
    border-left: 2px solid transparent;
    font-size: 15px;
    line-height: 1.4;
    color: var(--toc-text);
    text-decoration: none;
    border-radius: 0 6px 6px 0;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

[data-cb-type="table-of-contents"] .toc-item.toc-h3 .toc-link,
[data-cb-type="table-of-contents"] .toc-item.toc-h4 .toc-link {
    font-size: 14px;
    color: var(--toc-muted);
}

[data-cb-type="table-of-contents"] .toc-link:hover {
    color: var(--toc-accent);
    background: color-mix(in srgb, var(--toc-accent) 8%, transparent);
}

[data-cb-type="table-of-contents"] .toc-link.is-active {
    color: var(--toc-accent);
    border-left-color: var(--toc-accent);
    font-weight: 600;
    background: color-mix(in srgb, var(--toc-accent) 8%, transparent);
}

[data-cb-type="table-of-contents"] .toc-link:focus-visible {
    outline: 2px solid var(--toc-accent);
    outline-offset: -2px;
}

/* Empty state (no headings found) */
[data-cb-type="table-of-contents"] .toc-list:empty::after {
    content: "No headings found on the page yet.";
    display: block;
    padding: 4px 10px;
    font-size: 14px;
    color: var(--toc-muted);
}

@media (prefers-reduced-motion: reduce) {
    [data-cb-type="table-of-contents"] .toc-link { transition: none; }
}
