/* ================================================================
   TOC style, override TOC plugin css (desktop)
   ================================================================ */

.article__cta [data-sticky] {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-mini, 50px);
}

/* none the ori icon to use custom icon*/
#toc_container .toc_list li a::before {
    content: none;
}

/* Top-level row */
#toc_container > .toc_list > li {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
}

#toc_container > .toc_list > li > a {
    flex: 1;
}

/* Chevron toggle (appended by toc-accordion.js, only
   on items that have a nested sub-list)*/
#toc_container .toc-expand {
    order: -1;
    flex-shrink: 0;
    width: 10px;
    height: 6px;
    margin-top: 7px;
    background-color: var(--text-color, #1D1921);
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-mask-image: url("../img/icons/caret-down.svg");
    mask-image: url("../img/icons/caret-down.svg");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    transform: rotate(-90deg);
    transition: transform 200ms ease;
}

#toc_container .toc-expand[aria-expanded="true"] {
    transform: rotate(0deg);
}

/* Sub-heading list */
#toc_container .toc_list > li > ul {
    flex-basis: 100%;
    order: 3;
    box-sizing: border-box;
    max-height: 0;
    overflow: hidden;
    transition: max-height 200ms ease;
    padding-top: 12px;
    margin-top: 0;
    margin-left: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#toc_container .toc_list > li > ul > li {
    position: relative;
    padding-left: 16px;
}

#toc_container .toc_list > li > ul > li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--text-color, #1D1921);
}

/* Applied by toc-accordion.js. remove gap for collapsed sub-lists */
#toc_container .toc_list > li > ul.toc-sublist-hidden {
    display: none !important;
}
/* Always sticky on the article page (desktop only)
override the theme's JS-driven data-sticky ("true"/"false" based on measured height)
Only applies to the article sidebar (.article__cta)
make the sidebar sticky too*/
@media (min-width: 1025px) {
    .article__cta [data-sticky] {
        position: sticky;
        top: var(--sticky-distance, 120px);
        max-height: calc(100vh - var(--sticky-distance, 120px) - 20px);
        overflow-y: auto;
    }
}

/* Hide the sidebar's scrollbar scrollable (wheel/trackpad/touch). */
@media (min-width: 1025px) {
    .article__cta [data-sticky] {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .article__cta [data-sticky]::-webkit-scrollbar {
        display: none;
    }
}


/* --- TOC header / list tweaks --------------------------------------------- */

#toc_container .toc_title {
    align-items: center;
}

#toc_container .toc_list {
    margin-top: 30px;
}

#toc_container .toc_list li a {
    line-height: 1.1rem;
}

/* ================================================================
   Mobile (matches the theme's own existing breakpoint, max-width: 1024px)
   ================================================================ */
@media (max-width: 1024px) {
    .article__cta {
        order: -1 !important;
    }

    .article__cta [data-sticky] {
        position: static !important;
    }

    #toc_container .toc-expand {
        position: relative;
    }
    #toc_container .toc-expand::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 40px;
        height: 40px;
        transform: translate(-50%, -50%);
    }

    #toc_container .toc_list > li > ul {
        max-height: none !important;
        overflow: visible !important;
    }
    #toc_container .toc_list > li > ul.toc-sublist-hidden {
        display: flex !important;
    }
    #toc_container .toc-expand {
        display: none !important;
    }
}
