/* Automatic Table of Contents */
.sanjesh-toc-link-icon {
  display: none;
}

.custom-automatic-toc {
    --toc-border-radius: 14px;
    --toc-scroll-offset: 100px;

    position: relative;
    display: block;
    width: 100%;

    margin: 32px 0;
    padding: 0;

    border: 1px solid #e7e7e7;
    border-radius: var(--toc-border-radius);

    background: #fafafa;

    box-sizing: border-box;

    scroll-margin-top: var(--toc-scroll-offset);

    overflow: hidden;
}

.custom-automatic-toc,
.custom-automatic-toc *,
.custom-automatic-toc *::before,
.custom-automatic-toc *::after {
    box-sizing: border-box;
}

/*
 * TOC header.
 */
.custom-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 16px;

    min-height: 58px;
    padding: 14px 20px;

    border-bottom: 1px solid #e7e7e7;
}

/*
 * Title wrapper.
 */
.custom-toc-title-wrap {
    display: flex;
    align-items: center;

    gap: 9px;

    min-width: 0;
}

/*
 * Title icon.
 */
.custom-toc-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    width: 20px;
    height: 20px;

    color: inherit;
}

/*
 * TOC title.
 */
.custom-toc-title {
    margin: 0;
    padding: 0;

    font-size: 18px;
    line-height: 1.7;
    font-weight: 700;
}

/*
 * Main toggle button.
 */
.custom-toc-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 36px;

    width: 36px;
    height: 36px;

    margin: 0;
    padding: 0;

    border: 0;
    border-radius: 8px;

    background: transparent;
    color: inherit;

    cursor: pointer;

    transition: background-color 180ms ease;
}

.custom-toc-toggle:hover {
    background: rgba(0, 0, 0, 0.06);
}

.custom-toc-toggle:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
}

/*
 * Header toggle icon.
 *
 * Default state: plus.
 */
.custom-toc-toggle-icon {
    position: relative;

    display: block;

    width: 14px;
    height: 14px;
}

.custom-toc-toggle-icon::before,
.custom-toc-toggle-icon::after {
    content: "";

    position: absolute;

    top: 50%;
    left: 50%;

    width: 12px;
    height: 2px;

    border-radius: 2px;

    background: currentColor;

    transform: translate(-50%, -50%);

    transition:
        transform 180ms ease,
        opacity 180ms ease;
}

.custom-toc-toggle-icon::after {
    transform:
        translate(-50%, -50%)
        rotate(90deg);
}

/*
 * Collapsed state: plus.
 */
.custom-automatic-toc.is-collapsed
.custom-toc-toggle-icon::after {
    opacity: 1;

    transform:
        translate(-50%, -50%)
        rotate(90deg);
}

/*
 * Expanded state: down arrow.
 */
.custom-automatic-toc:not(.is-collapsed)
.custom-toc-toggle-icon::before {
    width: 9px;
    height: 9px;

    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;

    background: transparent;

    transform:
        translate(-50%, -65%)
        rotate(45deg);
}

.custom-automatic-toc:not(.is-collapsed)
.custom-toc-toggle-icon::after {
    width: 2px;
    height: 12px;

    background: currentColor;

    transform:
        translate(-50%, -50%)
        rotate(0deg);
}

/*
 * TOC content.
 *
 * The height is controlled by JavaScript.
 * Padding is kept stable to prevent bottom-spacing issues.
 */
.custom-toc-content {
    display: block;

    width: 100%;

    padding: 10px 10px 10px;

    overflow: hidden;

    opacity: 1;

    transition:
        max-height 260ms ease,
        opacity 200ms ease,
        padding-top 260ms ease,
        padding-bottom 260ms ease;
}

/*
 * Collapsed content.
 */
.custom-automatic-toc.is-collapsed
.custom-toc-content {
    max-height: 0 !important;

    padding-top: 0;
    padding-bottom: 0;

    opacity: 0;

    visibility: hidden;
}

/*
 * Flat list.
 *
 * No numbering and no nested hierarchy.
 */
.custom-toc-list {
    display: flex;
    flex-direction: column;

    width: 100%;

    margin: 0;
    padding: 0;

    list-style: none !important;
}

/*
 * List item.
 */
.custom-toc-item {
    position: relative;

    display: block;

    width: 100%;

    margin: 0 !important;
    padding: 0 !important;

    list-style: none !important;
}

.custom-toc-item + .custom-toc-item {
    margin-top: 3px !important;
}

/*
 * TOC link.
 */
.custom-toc-link {
    position: relative;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 14px;

    width: 100%;
    min-height: 44px;

    margin: 0;
    padding: 8px 12px;

    border-radius: 8px;

    color: inherit;
    text-decoration: none !important;

    line-height: 1.8;

    transition:
        background-color 180ms ease,
        color 180ms ease;
}

/*
 * Link text.
 */
.custom-toc-link-text {
    display: block;

    flex: 1 1 auto;

    min-width: 0;

    font-size: 14px;
    line-height: 1.8;
}

/*
 * Link icon.
 *
 * The icon itself is generated with CSS.
 * This prevents a plus icon from becoming an X.
 */
.custom-toc-link-icon {
    position: relative;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 28px;

    width: 28px;
    height: 28px;

    border: 1px solid #dedede;
    border-radius: 50%;

    color: inherit;

    background: transparent;

    transition:
        background-color 180ms ease,
        border-color 180ms ease;
}

/*
 * Hide any inline SVG supplied by the markup.
 */
.custom-toc-link-icon svg {
    display: none !important;
}

/*
 * Default icon: plus.
 */
.custom-toc-link-icon::before,
.custom-toc-link-icon::after {
    content: "";

    position: absolute;

    top: 50%;
    left: 50%;

    width: 11px;
    height: 1.5px;

    border-radius: 2px;

    background: currentColor;

    transform: translate(-50%, -50%);
}

/*
 * Vertical line of plus.
 */
.custom-toc-link-icon::after {
    transform:
        translate(-50%, -50%)
        rotate(90deg);
}

/*
 * Hover state.
 */
.custom-toc-link:hover {
    background: rgba(0, 0, 0, 0.045);
}

.custom-toc-link:hover
.custom-toc-link-icon {
    background: rgba(0, 0, 0, 0.04);
}

/*
 * Focus state.
 */
.custom-toc-link:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 2px;
}

/*
 * Active item.
 *
 * Active state uses a down arrow instead of rotating plus.
 */
.custom-toc-link.is-active {
    background: rgba(0, 0, 0, 0.06);

    font-weight: 700;
}

.custom-toc-link.is-active
.custom-toc-link-icon::before {
    width: 8px;
    height: 8px;

    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;

    background: transparent;

    transform:
        translate(-50%, -65%)
        rotate(45deg);
}

.custom-toc-link.is-active
.custom-toc-link-icon::after {
    width: 1.5px;
    height: 11px;

    background: currentColor;

    transform:
        translate(-50%, -50%)
        rotate(0deg);
}

/*
 * Heading scroll offset.
 */
.custom-automatic-toc + h2 {
    scroll-margin-top: var(--toc-scroll-offset);
}

/*
 * Also apply offset to H2 elements anywhere inside the content.
 */
.custom-automatic-toc ~ h2 {
    scroll-margin-top: var(--toc-scroll-offset);
}

/*
 * Keep a consistent bottom gap after the TOC.
 */
.custom-automatic-toc {
    margin-bottom: 32px !important;
}

/*
 * Mobile.
 */
@media (max-width: 767px) {

    .custom-automatic-toc {
        margin-top: 24px !important;
        margin-bottom: 24px !important;

        --toc-scroll-offset: 80px;
    }

    .custom-toc-header {
        min-height: 20px;

        padding: 4px 10px;
    }

    .custom-toc-title {
        font-size: 16px;
    }

    .custom-toc-content {
        padding: 12px 14px 14px;
    }

    .custom-toc-link {
        min-height: 42px;

        padding: 7px 8px;
    }

    .custom-toc-link-text {
        font-size: 14px;
        line-height: 1.8;
    }

    .custom-toc-link-icon {
        flex-basis: 26px;

        width: 26px;
        height: 26px;
    }

    .custom-toc-toggle {
        flex-basis: 34px;

        width: 34px;
        height: 34px;
    }
}

/*
 * Reduced motion accessibility.
 */
@media (prefers-reduced-motion: reduce) {

    .custom-toc-toggle,
    .custom-toc-toggle-icon::before,
    .custom-toc-toggle-icon::after,
    .custom-toc-content,
    .custom-toc-link,
    .custom-toc-link-icon,
    .custom-toc-link-icon::before,
    .custom-toc-link-icon::after {
        transition: none;
    }
}