/* ==========================================================================
   Table of Contents
   ========================================================================== */

.toc {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.toc-title {
    padding: 0.75rem 1rem;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--green);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s ease;
}

.toc-title:hover {
    background: rgba(12, 213, 99, 0.05);
}

.toc-title::before {
    content: '▼';
    font-size: 0.6em;
    transition: transform 0.2s ease;
}

.toc-collapsed .toc-title::before {
    transform: rotate(-90deg);
}

.toc-list {
    padding: 0 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    max-height: 2000px;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
}

.toc-collapsed .toc-list {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.toc-link,
.toc-link:hover,
.toc-link:visited {
    display: block;
    padding: 0.25rem 0;
    color: var(--text-secondary);
    text-decoration: none !important;
    text-decoration-line: none !important;
    font-size: 0.88rem;
    line-height: 1.5;
    border-left: 2px solid transparent;
    border-bottom: none;
    padding-left: 0.75rem;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.toc-link:hover {
    color: var(--text-primary);
}

.toc-link--active {
    color: var(--green);
    border-left-color: var(--green);
}

.toc-link--sub {
    padding-left: 1.5rem;
    font-size: 0.82rem;
}

@media (max-width: 640px) {
    .toc-link--sub {
        display: none;
    }

    .toc-link {
        font-size: 0.82rem;
    }
}
