/* Table of Contents — desktop: sticky in margin column, mobile: collapsible details */

html {
    scroll-behavior: smooth;
}

h2, h3 {
    scroll-margin-top: 1.5rem;
}

/* Desktop: sticky sidebar TOC */
.article-toc {
    grid-column: 2 / 3;
    grid-row: 2 / 4; /* span content + footer rows */
    position: sticky;
    top: 2rem;
    align-self: start;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

.toc-nav {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    line-height: 1.6;
}

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

.toc-item {
    margin-bottom: 0.3em;
}

.toc-item a {
    color: var(--color-text-light);
    text-decoration: none;
    transition: color 0.15s;
}

.toc-item a:hover,
.toc-item a.is-active {
    color: var(--color-text);
}

.toc-item a.is-active {
    font-weight: 600;
}

.toc-item--sub {
    padding-left: 1em;
}

/* TOC heading label */
.toc-heading {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-light);
    margin-bottom: 0.75em;
}

/* Mobile: collapsible details inside content */
.toc-mobile {
    display: none;
    margin-bottom: 1.5em;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0;
}

.toc-mobile summary {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    padding: 0.75em 1em;
    cursor: pointer;
    list-style: none;
}

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

.toc-mobile summary::before {
    content: '\25B6\00a0'; /* ▶ */
    font-size: 0.7em;
}

.toc-mobile[open] summary::before {
    content: '\25BC\00a0'; /* ▼ */
}

.toc-mobile .toc-nav {
    padding: 0 1em 0.75em;
}

@media (max-width: 768px) {
    .article-toc {
        display: none;
    }

    .toc-mobile {
        display: block;
    }
}
