/**
 * Blog detail — table of contents (desktop ≥1025px; JS gates init).
 * Sidebar variant: sticky in .blog-detail-sidebar; floating fallback if no sidebar.
 */

.blog-detail-page {
    /* Sync with scroll-margin-top on headings; blog-toc.js reads this for spy + click offset */
    --blog-toc-header-offset: 88px;
}

.blog-detail-page .blog-content .blog-toc-legacy-suppressed {
    display: none !important;
}

/* --- Floating (fallback, no sidebar) --- */
.blog-detail-page .blog-toc-widget.blog-toc-widget--floating {
    position: fixed;
    z-index: 90;
    width: min(280px, calc(100vw - 48px));
    max-height: min(72vh, 640px);
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    transition: opacity 0.22s ease, transform 0.22s ease;
    top: 50%;
    right: 20px;
}

.blog-detail-page .blog-toc-widget.blog-toc-widget--floating.blog-toc--concealed,
.blog-detail-page .blog-toc-widget.blog-toc-widget--floating.blog-toc--dismissed {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) translateX(12px);
}

/* --- Sticky in right column (primary) --- */
.blog-detail-page .blog-toc-widget.blog-toc-widget--sidebar {
    position: sticky;
    top: 88px;
    z-index: 2;
    width: 100%;
    max-width: 100%;
    margin-bottom: 24px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: min(72vh, 560px);
    transform: none;
    align-self: flex-start;
}

.blog-detail-page .blog-toc-widget.blog-toc-widget--sidebar.blog-toc--dismissed {
    display: none !important;
}

.blog-detail-page .blog-toc-widget.blog-toc-widget--sidebar.blog-toc--concealed {
    display: none !important;
}

/* --- Shared chrome --- */
.blog-detail-page .blog-toc-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    background: #0a3ca8;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.blog-detail-page .blog-toc-widget__close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.blog-detail-page .blog-toc-widget__close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.blog-detail-page .blog-toc-widget__body {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px 12px;
    font-size: 0.875rem;
    line-height: 1.35;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #e8eef5;
}

.blog-detail-page .blog-toc-widget__body::-webkit-scrollbar {
    width: 8px;
}

.blog-detail-page .blog-toc-widget__body::-webkit-scrollbar-track {
    background: #e8eef5;
    border-radius: 4px;
}

.blog-detail-page .blog-toc-widget__body::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 4px;
}

.blog-detail-page .blog-toc-widget__body::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.blog-detail-page .blog-toc-widget ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.blog-detail-page .blog-toc-widget ul ul {
    padding-left: 12px;
    margin-top: 4px;
}

.blog-detail-page .blog-toc-widget li {
    margin: 0 0 4px 0;
}

.blog-detail-page .blog-toc-widget a {
    display: block;
    padding: 6px 8px;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    word-break: break-word;
}

.blog-detail-page .blog-toc-widget a:hover {
    background: #f3f4f6;
    color: #111827;
}

.blog-detail-page .blog-toc-widget a.is-active {
    background: #2563eb;
    color: #ffffff;
    font-weight: 600;
}

.blog-detail-page .blog-toc-widget a:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.blog-detail-page .blog-content :is(h2, h3, h4, h5, h6) {
    scroll-margin-top: 88px;
}

@media (max-width: 1024px) {
    .blog-detail-page .blog-toc-widget {
        display: none !important;
    }

    .blog-detail-page .blog-content .blog-toc-legacy-suppressed {
        display: block !important;
    }
}
