/* =============================================================
   Dynamic TOC — Stylesheet
   v1.0.0
   ============================================================= */

/*
 * Desktop layout — CSS Grid trick:
 *   column 1 = 0px  → sidebar lives here but is translated LEFT
 *                      so it appears outside the content container
 *   column 2 = 1fr  → .dtoc-body keeps its FULL original width
 *
 * Requires ~244px of free space to the left of the content block.
 * Works on most themes at ≥ 992px when content has a centred max-width.
 */

/* --- Layout wrapper ----------------------------------------- */
.dtoc-wrapper {
    display: grid;
    grid-template-columns: 0 1fr;
    overflow: visible; /* let the sidebar bleed left */
}

/* --- Desktop sidebar ---------------------------------------- */
.dtoc-sidebar {
    /* Pull the sidebar to the LEFT of the content area.
       Total shift = sidebar width (220px) + gap (24px) = 244px */
    width: 220px;
    transform: translateX(-244px);

    position: sticky;
    top: 124px;
    align-self: start;          /* sticky requires align-self: start on grid items */

    max-height: calc(100vh - 48px);
    overflow-y: auto;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #c0c8d4 transparent;
}

.dtoc-sidebar::-webkit-scrollbar {
    width: 4px;
}
.dtoc-sidebar::-webkit-scrollbar-thumb {
    background: #c0c8d4;
    border-radius: 4px;
}

.dtoc-sidebar .dtoc-heading {
    width: 100%;
    height: 27px!important;
    line-height: 27px!important;
    background-color: #141516;
    border-radius: 4px!important;
    padding: 0 10px;
    text-transform: uppercase;
    margin: 0 0 16px 0!important;
    color: #fff!important;
    font-size: 13px;
    text-align: center;
    font-weight: 700!important;
}

section.page-content .body .dtoc-sidebar .dtoc-list {
    margin: 16px 0 0;
}
section.page-content .body ol.dtoc-list li{
    margin-bottom: 12px;
    padding: 0 0 0 20px;
    font-size: 1em;
    line-height: 1.2em;
    position: relative;
    a {
        color: #00000080;
        transition: .3s;
        font-size: 1em;
        padding-left: 4px;
        text-decoration: none;
        &.dtoc-active,
        &:hover{
            color: #000000;
        }
    }
}
section.page-content .body ol.dtoc-list li::before{
    content: " " counter(li) ". ";
    color: #000;
    position: absolute;
    left: 0;
    top: 0;
    margin-right: 0;
    font-weight: 400;
    font-size: 1em;
    background: none;
    padding: 0 6px 0 3px;
    height: 1em;
}

.dtoc-sidebar .dtoc-list a {
    color: #2c6fad;
    text-decoration: none;
    font-size: 13px;
    transition: color .15s ease;
}

.dtoc-sidebar .dtoc-list a:hover,
.dtoc-sidebar .dtoc-list a:focus,
.dtoc-sidebar .dtoc-list a.dtoc-active {
    color: #1a4a7a;
    text-decoration: underline;
}

/* Active item in mobile panel mirrors the hover style */
.dtoc-panel .dtoc-list a.dtoc-active {
    color: #000000;
    text-decoration: underline;
}

/* --- Content body — full original width --------------------- */
.dtoc-body {
    min-width: 0; /* prevent grid blowout */
}

/* --- Mobile TOC (hidden on desktop) ------------------------- */
.dtoc-mobile {
    display: none;
}

body .back-to-top{
    width: 43px;
    height: 43px;
    background: #d4d4d4;

    border-radius: 4px;
    &:before{
        color: #000000;
        line-height: 43px;
    }
}

/* =============================================================
   Responsive — below 1600 px (tablet + mobile)
   Sidebar hidden; sticky bottom panel shown instead.
   ============================================================= */
@media (max-width: 1599px) {

    /* Collapse flex layout */
    .dtoc-wrapper {
        display: block;
    }

    /* Hide desktop sidebar */
    .dtoc-sidebar {
        display: none;
    }

    /* ── Full-width sticky bar ──────────────────────────────── */
    .dtoc-mobile {
        max-width: 1110px;
        display: block;
        position: fixed;
        bottom: 0;
        left: 50%;
        right: 0;
        z-index: 9998;
        font-family: inherit;
        transform: translateX(-50%);
        width: calc(100% - 30px);
        margin-bottom: 20px;
    }

    /* Slide-up panel */
    .dtoc-panel {
        background: #f7f7f7;
        /*border-top: 3px solid #f7f7f7;*/
        max-height: 0;
        overflow: hidden;
        transition: max-height .35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .dtoc-panel.is-open {
        max-height: 58vh;
        overflow-y: auto;
        padding: 14px 20px;
    }

    .dtoc-panel .dtoc-list {
        margin: 0;
        padding: 14px 20px 18px 42px;
        list-style: decimal;
    }

    .dtoc-panel .dtoc-list li {
        margin-bottom: 10px;
        line-height: 1.5;
    }

    .dtoc-panel .dtoc-list a {
        color: #2c6fad;
        text-decoration: none;
        font-size: 15px;
    }

    .dtoc-panel .dtoc-list a:hover,
    .dtoc-panel .dtoc-list a:focus {
        text-decoration: underline;
    }

    /* Toggle button */
    .dtoc-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 14px 20px;
        background-color: #d4d4d4;
        color: #000;
        border: none;
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
        line-height: 1;
        font-family: inherit;
        text-align: left;
        border-radius: 4px;
    }

    .dtoc-toggle:focus-visible {
        outline: 2px solid #fff;
        outline-offset: -4px;
    }

    .dtoc-toggle__label {
        flex: 1;
    }

    /* Chevron icon drawn with CSS borders */
    .dtoc-toggle__icon {
        display: inline-block;
        flex-shrink: 0;
        width: 9px;
        height: 9px;
        margin-left: 10px;
        border-right: 2px solid #000000;
        border-top: 2px solid #000000;
        transform: rotate(-45deg);
        transition: transform .25s ease;
        position: relative;
        top: 2px;
    }

    .dtoc-toggle[aria-expanded="true"] .dtoc-toggle__icon {
        transform: rotate(135deg);
        top: -2px;
    }
}
@media (max-width: 1199px) {
    .dtoc-mobile {
        max-width: 930px;
    }
}

@media (max-width: 991px) {
    .dtoc-mobile {
        max-width: 690px;
    }
}

@media (max-width: 767px) {
    .dtoc-mobile {
        max-width: 530px;
    }
}
@media (max-width: 580px) {
    .dtoc-mobile {
        max-width: 530px;
        padding-right: 56px;
    }
}
