/* ── KB Table of Contents ── Fixed bar below main nav ── */

.kb-toc {
    position: fixed;
    top: 104px;
    left: 0;
    width: 100%;
    z-index: 800;
    font-family: 'Basier', Helvetica, Arial, sans-serif;
}

body.logged-in .kb-toc {
    top: 136px;
}

.kb-toc--hidden {
    opacity: 0;
    transform: translateY(-100%);
    animation: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.kb-toc--hidden.kb-toc--visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Bar ── */

.kb-toc__bar {
    background: #1E214D;
    position: relative;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.kb-toc__container {
    max-width: 1700px;
    margin: 0 auto;
    width: 90%;
}

.kb-toc__bar-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0;
}


/* ── Toggle (chevron only) ── */

.kb-toc__toggle {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0.6rem 0.8rem;
    display: flex;
    align-items: center;
    transition: color 0.15s ease;
}

.kb-toc__toggle:hover {
    color: #76E48B;
}

/* ── Chevron ── */

.kb-toc__chevron {
    flex-shrink: 0;
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.kb-toc--open .kb-toc__chevron {
    transform: rotate(180deg);
}

/* ── Timeline ── */

.kb-toc__timeline-wrapper {
    flex: 1;
    position: relative;
    min-width: 0;
    overflow: hidden;
}

/* Fade edges */
.kb-toc__timeline-wrapper::before,
.kb-toc__timeline-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2.5rem;
    z-index: 1;
    pointer-events: none;
}

.kb-toc__timeline-wrapper::before {
    left: 0;
    background: linear-gradient(to right, #1E214D, transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.kb-toc--sliding .kb-toc__timeline-wrapper::before {
    opacity: 1;
}

.kb-toc__timeline-wrapper::after {
    right: 0;
    background: linear-gradient(to left, #1E214D, transparent);
    transition: opacity 0.3s ease;
}

.kb-toc--at-end .kb-toc__timeline-wrapper::after {
    opacity: 0;
}

.kb-toc__timeline {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-behavior: smooth;
    list-style: none;
    margin: 0;
    padding: 0;
}

.kb-toc__timeline::-webkit-scrollbar {
    display: none;
}

.kb-toc__timeline-li {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* Separator between items */
.kb-toc__timeline-li + .kb-toc__timeline-li::before {
    content: '›';
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.12);
    font-size: 0.75rem;
}

.kb-toc__timeline-item {
    flex-shrink: 0;
    font-size: 0.8rem;
    color: #AEAFC6 !important;
    text-decoration: none !important;
    transition: color 0.3s ease;
    position: relative;
    padding-left: 14px;
    cursor: pointer;
}

.kb-toc__timeline-item:hover {
    color: #c5c6d6 !important;
}

/* Green dot — hidden by default, shown on active */
.kb-toc__timeline-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #76E48B;
    box-shadow: 0 0 6px rgba(118, 228, 139, 0.4);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.kb-toc__timeline-item--active {
    color: #fff !important;
}

.kb-toc__timeline-item--active::before {
    opacity: 1;
}

/* ── Progress bar ── */

.kb-toc__progress {
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
}

.kb-toc__progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #76E48B, #2cb55e);
    box-shadow: 0 0 6px rgba(118, 228, 139, 0.25);
    transition: width 0.12s linear;
    will-change: width;
}

/* ── Dropdown ── */

.kb-toc__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #1E214D;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: -1;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.kb-toc--open .kb-toc__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ── List ── */

.kb-toc__list {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0 0.75rem;
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.kb-toc__list::-webkit-scrollbar {
    width: 4px;
}

.kb-toc__list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

.kb-toc__item a {
    display: block;
    padding: 0.45rem 0.75rem;
    color: #b0b0c0 !important;
    text-decoration: none !important;
    font-size: 0.85rem;
    line-height: 1.4;
    transition: color 0.15s ease, border-color 0.15s ease;
    border-left: 2px solid transparent;
}

.kb-toc__item a:hover {
    color: #fff !important;
}

.kb-toc__item--active a {
    color: #76E48B !important;
    border-left-color: #76E48B;
}

/* ── Back to Top Button ── */

.kb-toc-top {
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 799;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #1E214D;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0px 0px 8px rgb(255 255 255 / 60%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, background-color 0.2s ease;
}

.kb-toc-top--visible {
    opacity: 1;
    pointer-events: auto;
}

body.is-review .kb-toc-top {
    bottom: 84px;
}

.kb-toc-top:hover {
    background-color: #171a3d;
}

/* ── Content offset when TOC bar is visible ── */
/* Adds 44px (TOC bar height) to every existing #site-wrapper margin-top rule */

/* Default desktop: 104px nav + 44px TOC */
body.has-toc:not(.logged-in) #site-wrapper {
    margin-top: 160px;
}

/* Desktop logged-in: 80px + 44px TOC */
body.has-toc.logged-in #site-wrapper {
    margin-top: 124px;
}

/* ≤1500px non-logged-in: 80px nav + 44px TOC */
@media screen and (max-width: 1500px) {
    body.has-toc:not(.logged-in) #site-wrapper {
        margin-top: 135px;
    }
}

/* ── Scroll offset for anchored headings (URL #hash fallback) ── */

body.has-toc h2[id],
body.has-toc #faq {
    scroll-margin-top: 160px;
}

body.has-toc.logged-in h2[id],
body.has-toc.logged-in #faq {
    scroll-margin-top: 192px;
}

@media screen and (max-width: 1500px) {
    body.has-toc:not(.logged-in) h2[id],
    body.has-toc:not(.logged-in) #faq {
        scroll-margin-top: 140px;
    }
}

@media (max-width: 980px) {
    body.has-toc h2[id],
    body.has-toc #faq {
        scroll-margin-top: 140px;
    }
    body.has-toc.logged-in h2[id],
    body.has-toc.logged-in #faq {
        scroll-margin-top: 168px;
    }
}

@media (max-width: 782px) {
    body.has-toc.logged-in h2[id],
    body.has-toc.logged-in #faq {
        scroll-margin-top: 182px;
    }
}

/* ── Responsive ── */

/* ≤1500px: nav switches to mobile height (80px) for non-logged-in */
@media screen and (max-width: 1500px) {
    body:not(.logged-in) .kb-toc {
        top: 80px;
    }
}

@media (max-width: 980px) {
    .kb-toc {
        top: 80px;
    }
    body.logged-in .kb-toc {
        top: 112px;
    }
}

@media (max-width: 782px) {
    body.logged-in .kb-toc {
        top: 126px;
    }
}
