/* Neo-brutalism Table of Contents */

/* TOC Container */
.toc-container {
    background-color: #fff;
    border: 3px solid #000;
    border-radius: 0;
    margin: 30px 0;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.7);
    position: relative;
    overflow: hidden;
}

.dark .toc-container {
    background-color: var(--background-color-dark);
    border: 3px solid rgba(255, 255, 255, 0.7);
    box-shadow: 8px 8px 0 rgba(255, 255, 255, 0.15);
}

/* TOC title/toggle button */
.toc-toggle {
    display: block;
    width: 100%;
    font-size: 1.3rem;
    font-weight: bold;
    padding: 15px 20px;
    border: none;
    background-color: #FFD1DC;
    color: #000;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Rocket Thunder', sans-serif;
    cursor: pointer;
    position: relative;
    border-bottom: 2px solid #000;
    transition: all 0.3s ease;
}

.toc-toggle:hover {
    background-color: #ffbfcf;
}

.dark .toc-toggle {
    background-color: rgba(255, 209, 220, 0.3);
    color: #fff;
    border-bottom: 2px solid rgba(255, 255, 255, 0.7);
}

.dark .toc-toggle:hover {
    background-color: rgba(255, 209, 220, 0.4);
}

/* Toggle icon */
.toc-toggle::after {
    content: "▼";
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.toc-toggle.collapsed::after {
    transform: translateY(-50%) rotate(-90deg);
}

/* TOC content */
.toc-content {
    padding: 20px;
    display: block;
    transition: max-height 0.5s ease, opacity 0.3s ease;
    max-height: 1000px;
    opacity: 1;
    overflow: hidden;
}

.toc-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* TableOfContents styling */
#TableOfContents {
    width: 100%;
}

/* TOC list styling */
#TableOfContents ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

#TableOfContents ul ul {
    padding-left: 20px;
}

#TableOfContents li {
    margin-bottom: 10px;
    position: relative;
}

#TableOfContents li::before {
    content: "♥";
    color: #FF6B8B;
    margin-right: 8px;
    display: inline-block;
    font-size: 14px;
}

#TableOfContents li li::before {
    content: "→";
    color: #A2D2FF;
}

/* TOC links */
#TableOfContents a {
    color: #000;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-block;
    border-bottom: 2px solid transparent;
    padding-bottom: 2px;
}

#TableOfContents a:hover {
    color: #FF6B8B;
    border-bottom: 2px solid #FF6B8B;
    transform: translateX(5px);
}

.dark #TableOfContents a {
    color: #fff;
}

.dark #TableOfContents a:hover {
    color: #FF6B8B;
    border-bottom: 2px solid #FF6B8B;
}

/* Decorative elements */
#TableOfContents::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background-image:
        radial-gradient(#FFD1DC 6px, transparent 6px),
        radial-gradient(#FFD1DC 6px, transparent 6px);
    background-size: 30px 30px;
    background-position: 0 0, 15px 15px;
    opacity: 0.3;
    pointer-events: none;
}

.dark #TableOfContents::after {
    background-image:
        radial-gradient(rgba(255, 209, 220, 0.3) 6px, transparent 6px),
        radial-gradient(rgba(255, 209, 220, 0.3) 6px, transparent 6px);
}

/* Active TOC item */
#TableOfContents .active {
    background-color: #FFD1DC;
    padding: 5px 10px;
    border-radius: 0;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.7);
    border: 2px solid #000;
}

.dark #TableOfContents .active {
    background-color: rgba(255, 209, 220, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.7);
    box-shadow: 3px 3px 0 rgba(255, 255, 255, 0.15);
}

/* Mobile TOC styling */
.mobile-toc {
    display: block !important;
    width: 100% !important;
    margin-bottom: 20px !important;
}

/* Responsive TOC */
@media (max-width: 768px) {
    .toc-container {
        margin: 0 0 30px 0;
        box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.7);
        order: -1; /* Move to the top in flex containers */
        width: 100%;
    }

    .toc-toggle {
        font-size: 1.1rem;
        padding: 12px 15px;
        width: 100%;
    }

    .toc-content {
        padding: 15px;
    }

    #TableOfContents li {
        margin-bottom: 8px;
    }

    #TableOfContents li::before {
        font-size: 12px;
    }

    /* Make TOC sticky on mobile */
    .toc-container.sticky {
        position: sticky;
        top: 70px;
        z-index: 100;
        width: 100%;
        margin-top: 0;
    }

    /* Default collapsed state on mobile */
    .toc-content {
        max-height: 0;
        opacity: 0;
        padding-top: 0;
        padding-bottom: 0;
    }

    .toc-toggle {
        border-bottom: none;
    }

    .toc-toggle::after {
        transform: translateY(-50%) rotate(-90deg);
    }

    /* Active state classes */
    .toc-toggle.active {
        border-bottom: 2px solid #000;
    }

    .dark .toc-toggle.active {
        border-bottom: 2px solid rgba(255, 255, 255, 0.7);
    }

    .toc-toggle.active::after {
        transform: translateY(-50%) rotate(0);
    }

    .toc-content.active {
        max-height: 1000px;
        opacity: 1;
        padding: 15px;
    }

    /* Ensure mobile TOC is visible and desktop TOC is hidden */
    .d-none.d-lg-block .toc-container {
        display: none !important;
    }

    .d-block.d-lg-none .toc-container {
        display: block !important;
    }
}
