/* Table of Contents Styles - OCD Anxiety Centers */
/* 
BRAND COLORS - OCD Anxiety Centers Official Colors:
Primary: #708FA6 (Blue-gray from logo text)
Primary Dark: #557085 (Darker blue-gray shade) 
Secondary: #D4B896 (Warm beige from logo curve)
Accent: #8FA6C1 (Light blue-gray accent)
*/

:root {
    --primary-color: #708FA6;        /* OCD Anxiety Centers blue-gray (from logo text) */
    --primary-dark: #557085;         /* Darker blue-gray shade */
    --secondary-color: #D4B896;      /* OCD Anxiety Centers warm beige (from logo curve) */
    --accent-color: #8FA6C1;         /* Light blue-gray accent */
    --text-primary: #333333;         /* Dark gray text */
    --text-secondary: #666666;       /* Medium gray text */
    --background-light: #f8f9fa;     /* Light background */
    --border-color: #e1e8ed;         /* Light border */
    --hover-bg: rgba(112, 143, 166, 0.08); /* Light primary color background */
}

.toc-container {
    background: #ffffff;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    margin: 25px 0;
    padding: 0;
    box-shadow: 0 4px 12px rgba(112, 143, 166, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
    position: relative; /* Added for chevron positioning */
}

.toc-container:hover {
    box-shadow: 0 6px 20px rgba(112, 143, 166, 0.2);
}

.toc-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 18px 22px;
    margin: 0;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.toc-header:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #152c4d 100%);
    transform: translateY(-1px);
}

.toc-toggle {
    font-size: 16px;
    transition: transform 0.3s ease;
    font-weight: bold;
    opacity: 0.9;
}

.toc-toggle.collapsed {
    transform: rotate(180deg);
}

.toc-content {
    padding: 18px;
    display: none;
    background: var(--background-light);
    border-top: 1px solid var(--border-color);
    max-height: 400px; /* Limit height for long articles */
    overflow-y: scroll; /* Always show vertical scrollbar */
}

.toc-content.show {
    display: block;
}

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

.toc-list li {
    margin: 0;
    padding: 0;
}

/* H2 items get outer bullets */
.toc-list .toc-h2 {
    list-style-type: disc;
    margin-left: 20px;
}

/* H3 items get indented with no bullets */
.toc-list .toc-h3 {
    list-style-type: none;
    margin-left: 40px;
}

.toc-list a {
    display: block;
    padding: 8px 0; /* Reduced from 12px */
    color: var(--text-primary);
    text-decoration: none;
    font-size: 15px; /* Slightly smaller */
    line-height: 1.4; /* Tighter line height */
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    border-radius: 4px;
}

.toc-list a:hover {
    color: var(--primary-color);
    padding-left: 15px;
    background: var(--hover-bg);
    transform: translateX(3px);
}

.toc-list a:last-child {
    border-bottom: none;
}

/* H2 items (main sections) - with outer bullets */
.toc-list .toc-h2 {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 15px;
    padding: 10px 0;
}

.toc-list .toc-h2:hover {
    color: var(--primary-color);
    background: var(--hover-bg);
}

.toc-list .toc-h2::before {
    content: "▸";
    position: absolute;
    left: 0;
    color: var(--secondary-color);
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toc-list .toc-h2:hover::before {
    opacity: 1;
}

/* H3 items (subsections) - indented with no bullets */
.toc-list .toc-h3 {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
    padding-top: 6px;
    padding-bottom: 6px;
    padding-left: 0; /* No extra padding since we use margin-left */
}

.toc-list .toc-h3:hover {
    color: var(--accent-color);
    padding-left: 10px; /* Small indent on hover */
}

/* Scrollbar styling for TOC content */
.toc-content::-webkit-scrollbar {
    width: 6px;
}

.toc-content::-webkit-scrollbar-track {
    background: var(--background-light);
}

.toc-content::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.toc-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Scroll indicator arrow - fixed position */
.toc-scroll-indicator {
    position: absolute;
    bottom: 8px;
    right: 12px;
    /* color: var(--accent-color); */
    color: #4c7995;
    opacity: 0.7;
    font-size: 18px; /* Increased from 12px */
    font-weight: 900; /* Made much bolder */
    cursor: pointer;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Initially not clickable */
    z-index: 10;
    background: var(--background-light); /* Background to ensure visibility */
    border-radius: 50%;
    width: 30px; /* Fixed size container */
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Subtle shadow for better visibility */
}

.toc-scroll-indicator:hover {
    opacity: 1;
}

.toc-scroll-indicator.visible {
    pointer-events: auto; /* Make clickable when visible */
}

/* Mobile Responsive - Smaller TOC on mobile */
@media (max-width: 768px) {
    .toc-container {
        margin: 20px 0;
        border-width: 1px;
    }
    
    .toc-header {
        padding: 14px 16px;
        font-size: 16px;
    }
    
    .toc-content {
        padding: 16px;
        max-height: 300px; /* Smaller on mobile */
        overflow-y: scroll; /* Always show scrollbar on mobile too */
    }
    
    .toc-scroll-indicator {
        bottom: 6px;
        right: 10px;
        font-size: 20px; /* Even larger on mobile */
        width: 32px; /* Larger touch target */
        height: 32px;
    }
    
    .toc-list a {
        font-size: 14px;
        padding: 6px 0; /* Even more compact on mobile */
    }
    
    .toc-list .toc-h2 {
        font-size: 14px;
        padding: 8px 0;
        margin-left: 16px; /* Smaller indent on mobile */
    }
    
    .toc-list .toc-h3 {
        font-size: 12px;
        padding-top: 4px;
        padding-bottom: 4px;
        margin-left: 32px; /* Proportional indent on mobile */
    }
    
    .toc-list .toc-h3:hover {
        padding-left: 8px;
    }
}

@media (max-width: 480px) {
    .toc-header {
        padding: 14px 16px;
        font-size: 15px;
    }
    
    .toc-content {
        padding: 16px;
    }
    
    .toc-list a {
        font-size: 14px;
        padding: 8px 0;
    }
    
    .toc-list .toc-h2 {
        padding: 10px 0;
    }
    
    .toc-list .toc-h3 {
        padding-top: 6px;
        padding-bottom: 6px;
    }
}

/* Dynamic offset with maximum padding for all viewports */
.toc-target {
    scroll-margin-top: 220px; /* Increased fallback - JavaScript will override this */
}

/* WordPress specific adjustments */
.single .toc-container {
    max-width: 100%;
}

/* Accessibility improvements */
.toc-header:focus {
    outline: 2px solid #ffffff;
    outline-offset: -2px;
}

.toc-list a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    background: var(--hover-bg);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .toc-container {
        border-width: 3px;
    }
    
    .toc-header {
        background: var(--primary-color);
    }
    
    .toc-list a {
        border-bottom-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .toc-header,
    .toc-toggle,
    .toc-list a,
    .toc-container {
        transition: none;
    }
    
    html {
        scroll-behavior: auto;
    }
}