/* Auto TOC v4 - Fixed sidebar for articles */

/* Fixed TOC - desktop */
.auto-toc-fixed {
    position: fixed;
    top: 80px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    font-size: 0.82rem;
    padding: 20px;
    background: #18181b;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    z-index: 50;
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.auto-toc-fixed::-webkit-scrollbar { width: 3px; }
.auto-toc-fixed::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}
.auto-toc-fixed.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* Title */
.auto-toc-title {
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.35;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* List */
.auto-toc-fixed ol {
    list-style: none;
    margin: 0;
    padding: 0;
}
.auto-toc-fixed > ol > li {
    margin-bottom: 1px;
}

/* Links */
.auto-toc-fixed a {
    text-decoration: none;
    color: rgba(255,255,255,0.85);
    opacity: 0.4;
    transition: all 0.15s ease;
    display: block;
    padding: 5px 10px 5px 12px;
    border-left: 2px solid transparent;
    border-radius: 0 6px 6px 0;
    line-height: 1.35;
}
.auto-toc-fixed a:hover {
    opacity: 0.75;
    background: rgba(255,255,255,0.04);
}
.auto-toc-fixed a.active {
    opacity: 1;
    font-weight: 600;
    border-left-color: #DC2626;
    background: rgba(220, 38, 38, 0.08);
    color: #fff;
}

/* Sub-items H3 */
.auto-toc-fixed .auto-toc-sub {
    margin: 0;
    padding: 0;
}
.auto-toc-fixed .auto-toc-sub a {
    padding-left: 24px;
    font-size: 0.9em;
    opacity: 0.3;
}
.auto-toc-fixed .auto-toc-sub a:hover {
    opacity: 0.6;
}
.auto-toc-fixed .auto-toc-sub a.active {
    opacity: 0.85;
    border-left-color: #DC2626;
}

/* Light theme overrides via cascade */
body:not([class*="dark"]) .auto-toc-fixed {
    background: #fafafa;
    border-color: #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
body:not([class*="dark"]) .auto-toc-title {
    border-bottom-color: #e5e7eb;
}
body:not([class*="dark"]) .auto-toc-fixed a {
    color: #1f2937;
}
body:not([class*="dark"]) .auto-toc-fixed a:hover {
    background: rgba(0,0,0,0.02);
}
body:not([class*="dark"]) .auto-toc-fixed a.active {
    background: rgba(220, 38, 38, 0.04);
    color: #111;
}
body:not([class*="dark"]) .auto-toc-fixed::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.08);
}

/* Mobile: collapsible */
.auto-toc-mobile {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 16px 20px;
    margin: 16px 0 24px;
}
.auto-toc-mobile summary {
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.auto-toc-mobile summary::before { content: "\2630"; font-size: 1.1em; }
.auto-toc-mobile summary::marker { display: none; }
.auto-toc-mobile summary::-webkit-details-marker { display: none; }
.auto-toc-mobile ol {
    margin: 12px 0 0;
    padding-left: 18px;
    list-style: none;
    counter-reset: toc;
}
.auto-toc-mobile li {
    margin-bottom: 6px;
    counter-increment: toc;
}
.auto-toc-mobile li::before {
    content: counter(toc) ".";
    font-weight: 600;
    margin-right: 6px;
    opacity: 0.5;
}
.auto-toc-mobile a {
    text-decoration: none;
    opacity: 0.85;
}
.auto-toc-mobile a:hover {
    opacity: 1;
    text-decoration: underline;
}
.auto-toc-mobile .auto-toc-sub {
    margin: 6px 0 2px 12px;
    padding-left: 12px;
    border-left: 2px solid rgba(128,128,128,0.15);
}
.auto-toc-mobile .auto-toc-sub li { font-size: 0.9em; margin-bottom: 4px; }
.auto-toc-mobile .auto-toc-sub li::before { content: "\2013"; margin-right: 6px; }

body:not([class*="dark"]) .auto-toc-mobile {
    background: #f8f9fa;
    border-color: #e2e8f0;
}

/* Responsive: hide fixed on small screens */
@media (max-width: 1199px) {
    .auto-toc-fixed { display: none; }
}

/* Position via CSS custom properties (set by JS on :root) */
.auto-toc-fixed {
    left: var(--toc-left, auto);
    width: var(--toc-width, 220px);
}
.auto-toc-fixed.toc-hidden {
    display: none;
}
