/* =============================================================================
   TABLE OF CONTENTS STYLES
   ============================================================================= */

/* TOC Container - Positioned to the right of content */
#table-of-contents {
    position: fixed;
    right: 50px; /* ADJUSTED: better positioning for 699px content */
    top: 50%;
    transform: translateY(-41%);
    width: 320px; /* REDUCED: from 340px to 320px */
    max-height: 75vh; /* REDUCED: from 80vh to 75vh */
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    /*box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);*/
    z-index: 100;
    display: none; /* Hidden by default, shown by JavaScript */
    font-family: 'Space Grotesk', sans-serif;
}

/* TOC Header */
.toc-header {
    padding: 20px 24px 16px 24px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
    border-radius: 6px 6px 0 0;
}

.toc-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #171717;
    letter-spacing: -0.01em;
}

/* TOC Navigation */
.toc-nav {
    padding: 8px 0;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-item {
    margin: 0;
    padding: 0;
}

.toc-link {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 24px;
    text-decoration: none;
    color: #525252;
    font-size: 14px;
    line-height: 1.4;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.toc-link:hover {
    background: #f8f9fa;
    color: #171717;
    border-left-color: #e5e5e5;
}

.toc-link.active {
    background: #eff6ff;
    color: #2563eb;
    border-left-color: #2563eb;
    font-weight: 500;
}

.toc-link.active .toc-number {
    background: #2563eb;
    color: #ffffff;
}

/* TOC Number Badge */
.toc-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #e5e5e5;
    color: #737373;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.2s ease;
    margin-top: 1px; /* Slight visual alignment */
}

/* TOC Text */
.toc-text {
    flex: 1;
    line-height: 1.4;
    word-break: break-word;
}

/* Scrollbar Styling for TOC */
#table-of-contents::-webkit-scrollbar {
    width: 6px;
}

#table-of-contents::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#table-of-contents::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#table-of-contents::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* =============================================================================
   RESPONSIVE BEHAVIOR
   ============================================================================= */

/* Hide TOC on tablets and smaller screens */
@media (max-width: 1200px) {
    #table-of-contents {
        display: none !important;
    }
}

/* Adjust position for smaller desktop screens */
@media (max-width: 1400px) {
    #table-of-contents {
        right: 30px; /* ADJUSTED: from 20px to 30px */
        width: 300px; /* REDUCED: from 320px to 300px */
    }
}

/* Ensure TOC doesn't overlap with content on narrow screens */
@media (max-width: 1300px) {
    #table-of-contents {
        right: 20px; /* ADJUSTED: from 15px to 20px */
        width: 280px;
    }
    
    .toc-link {
        padding: 10px 18px; /* ADJUSTED: from 20px to 18px */
        font-size: 13px;
    }
    
    .toc-number {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }
    
    .toc-header {
        padding: 16px 18px 12px 18px; /* ADJUSTED: from 20px to 18px */
    }
    
    .toc-title {
        font-size: 15px;
    }
}

/* =============================================================================
   ALTERNATIVE COMPACT STYLE (if needed)
   ============================================================================= */

/* Add this class to TOC container for compact style */
#table-of-contents.toc-compact {
    width: 260px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

#table-of-contents.toc-compact .toc-header {
    padding: 16px 20px 12px 20px;
    background: rgba(250, 250, 250, 0.8);
}

#table-of-contents.toc-compact .toc-title {
    font-size: 14px;
}

#table-of-contents.toc-compact .toc-link {
    padding: 8px 20px;
    font-size: 13px;
}

#table-of-contents.toc-compact .toc-number {
    width: 18px;
    height: 18px;
    font-size: 10px;
}

/* =============================================================================
   ANIMATION ENHANCEMENTS
   ============================================================================= */

/* Subtle entrance animation */
#table-of-contents {
    opacity: 0;
    transform: translateY(-50%) translateX(20px);
    transition: all 0.3s ease;
}

#table-of-contents.toc-visible {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Hover animation for links */
.toc-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: #2563eb;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.toc-link.active::before {
    opacity: 1;
}

/* Number badge hover effect */
.toc-link:hover .toc-number {
    background: #d1d5db;
    color: #374151;
    transform: scale(1.05);
}

/* Smooth transitions for all interactive elements */
.toc-link,
.toc-number,
.toc-text {
    transition: all 0.2s ease;
}

/* =============================================================================
   HIGH CONTRAST MODE SUPPORT
   ============================================================================= */

@media (prefers-contrast: high) {
    #table-of-contents {
        border: 2px solid #000000;
        background: #ffffff;
    }
    
    .toc-link {
        color: #000000;
    }
    
    .toc-link:hover,
    .toc-link.active {
        background: #000000;
        color: #ffffff;
    }
    
    .toc-number {
        background: #000000;
        color: #ffffff;
    }
}

/* =============================================================================
   REDUCED MOTION SUPPORT
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
    #table-of-contents,
    .toc-link,
    .toc-number {
        transition: none;
    }
    
    .toc-link:hover .toc-number {
        transform: none;
    }
}