/**
 * Sydenham Clinic - Responsive Table of Contents (TOC) Styles
 */

/* ==========================================================================
   Desktop & Global Styles
   ========================================================================== */
.sydenham-blog-toc-sidebar {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 110px !important;
    z-index: 20 !important;
    max-height: calc(100vh - 130px);
    transition: top 0.3s ease;
}

.sydenham-toc-card {
    background: #FFFFFF;
    border: 1px solid #E6DDCB;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(14, 32, 42, 0.05);
    padding: 20px 18px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    max-height: inherit;
}

.sydenham-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #F0EAE1;
    user-select: none;
}

.sydenham-toc-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sydenham-toc-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #B38356;
    flex-shrink: 0;
}

.sydenham-toc-title {
    font-family: Georgia, "Playfair Display", serif;
    font-size: 15px;
    font-weight: 700;
    color: #0E1A23;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 0;
    line-height: 1.2;
}

.sydenham-toc-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: #718096;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}

.sydenham-toc-toggle-btn:hover {
    color: #0E1A23;
    background: #F8F5F0;
    border-color: #E6DDCB;
}

.sydenham-toc-chevron {
    transition: transform 0.25s ease;
}

.sydenham-toc-card.is-collapsed .sydenham-toc-chevron {
    transform: rotate(-90deg);
}

.sydenham-toc-card.is-collapsed .sydenham-toc-body {
    display: none;
}

.sydenham-toc-body {
    overflow-y: auto;
    padding-top: 12px;
    padding-right: 4px;
    margin-right: -4px;
}

/* Custom Sleek Scrollbar */
.sydenham-toc-body::-webkit-scrollbar {
    width: 4px;
}
.sydenham-toc-body::-webkit-scrollbar-track {
    background: #F9F7F4;
    border-radius: 4px;
}
.sydenham-toc-body::-webkit-scrollbar-thumb {
    background: #D9CEBE;
    border-radius: 4px;
}
.sydenham-toc-body::-webkit-scrollbar-thumb:hover {
    background: #B38356;
}

/* Nav list and items */
.sydenham-toc-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.sydenham-toc-item {
    list-style: none !important;
    margin: 4px 0 !important;
    padding: 0 !important;
}

.sydenham-toc-link {
    display: block !important;
    text-decoration: none !important;
    border-left: 2px solid transparent !important;
    border-radius: 0 4px 4px 0 !important;
    transition: all 0.2s ease !important;
    word-break: break-word !important;
}

/* Level 2 (H2) */
.sydenham-toc-item.level-2 > .sydenham-toc-link {
    font-size: 13.5px !important;
    font-weight: 600 !important;
    color: #2D3748 !important;
    line-height: 1.45 !important;
    padding: 6px 8px 6px 12px !important;
}

/* Level 3 (H3) */
.sydenham-toc-item.level-3 > .sydenham-toc-link {
    font-size: 12.5px !important;
    font-weight: 400 !important;
    color: #4A5568 !important;
    line-height: 1.4 !important;
    padding: 4px 8px 4px 22px !important;
}

/* Level 4 (H4) */
.sydenham-toc-item.level-4 > .sydenham-toc-link {
    font-size: 11.5px !important;
    font-weight: 400 !important;
    color: #718096 !important;
    line-height: 1.35 !important;
    padding: 3px 8px 3px 32px !important;
}

/* Hover and Active State */
.sydenham-toc-link:hover {
    color: #0E1A23 !important;
    background-color: #FAF7F2 !important;
    border-left-color: #C9A58A !important;
}

.sydenham-toc-link.is-active {
    color: #0E1A23 !important;
    font-weight: 700 !important;
    background-color: #F5EFE6 !important;
    border-left-color: #B38356 !important;
}

/* Empty state message */
.sydenham-toc-empty {
    font-size: 13px;
    color: #718096;
    padding: 10px 0;
    margin: 0;
    font-style: italic;
}


/* ==========================================================================
   Responsive Tablet & Mobile (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    /* Stack layout: TOC appears at the top before blog body */
    .single-post .qodef-grid.qodef-layout--template > .qodef-grid-inner {
        display: flex !important;
        flex-direction: column !important;
    }

    .single-post .qodef-grid.qodef-layout--template > .qodef-grid-inner > .qodef-col--sidebar {
        order: -1 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 28px !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .single-post .sydenham-blog-toc-sidebar {
        position: static !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .single-post .sydenham-toc-card {
        max-height: none !important;
        background: #FAF8F5;
        border: 1px solid #E6DDCB;
        box-shadow: none;
        padding: 16px;
    }

    .single-post .sydenham-toc-header {
        border-bottom: 1px solid #E8DFD3;
        padding-bottom: 10px;
    }

    .single-post .sydenham-toc-toggle-btn {
        background: #FFFFFF;
        border: 1px solid #D9CEBE;
        padding: 5px 10px;
        color: #0E1A23;
        font-weight: 600;
    }

    .single-post .sydenham-toc-body {
        max-height: 280px;
        overflow-y: auto;
    }
}

/* ==========================================================================
   Mobile Phone (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
    .single-post .sydenham-toc-title {
        font-size: 14px;
    }

    .single-post .sydenham-toc-card {
        padding: 14px 12px;
        border-radius: 6px;
    }

    .single-post .sydenham-toc-body {
        max-height: 250px;
    }

    .sydenham-toc-item.level-2 > .sydenham-toc-link {
        font-size: 13px !important;
        padding: 6px 6px 6px 10px !important;
    }

    .sydenham-toc-item.level-3 > .sydenham-toc-link {
        font-size: 12px !important;
        padding: 4px 6px 4px 18px !important;
    }
}

