/* =========================================================
   Article TOC Dock
========================================================= */

.zxy-tocdock {
    --toc-dark: #06412f;
    --toc-dark-hover: #0a523d;
    --toc-green: #74d400;
    --toc-green-dark: #58b900;
    --toc-white: #ffffff;
    --toc-text: #23352e;
    --toc-muted: #6d7974;
    --toc-light: #f3f7f5;

    position: fixed;

    z-index: 95;

    top: 50%;
    left: 2%;

    width: 48px;

    transform: translateY(-50%);

    box-sizing: border-box;
}


/* 隐藏 */

.zxy-tocdock[hidden] {
    display: none !important;
}


/* =========================================================
   整体外壳
========================================================= */

.zxy-tocdock-shell {
    width: 48px;

    overflow: hidden;

    border-radius: 15px;

    background: var(--toc-dark);

    box-shadow:
        0 8px 25px
        rgba(0, 40, 28, 0.16);

    box-sizing: border-box;

    transition:
        width 0.3s ease,
        box-shadow 0.3s ease;
}


/* =========================================================
   OPEN 按钮
========================================================= */

.zxy-tocdock-toggle {
    display: flex;

    width: 100%;
    height: 32px;

    margin: 0;
    padding: 0 8px;

    align-items: center;
    justify-content: center;

    gap: 5px;

    border: 0;

    background: transparent;

    color: #fff;

    font-family: inherit;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;

    letter-spacing: 0.08em;

    cursor: pointer;

    box-sizing: border-box;

    transition:
        background-color 0.2s ease;
}


.zxy-tocdock-toggle:hover {
    background:
        rgba(255, 255, 255, 0.08);
}


.zxy-tocdock-toggle-text {
    font-size: inherit;
    line-height: 1;
}


/* 小箭头 */

.zxy-tocdock-toggle-arrow {
    display: none;

    width: 6px;
    height: 6px;

    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;

    transform: rotate(-45deg);

    transition:
        transform 0.25s ease;
}


/* =========================================================
   导航区域
========================================================= */

.zxy-tocdock-panel {
    width: 100%;

    /*
     * 导航再多也不会超过屏幕
     */
    max-height: calc(100vh - 180px);

    overflow-x: hidden;
    overflow-y: auto;

    padding: 4px;

    box-sizing: border-box;

    overscroll-behavior: contain;

    scrollbar-width: thin;
    scrollbar-color:
        rgba(255, 255, 255, 0.25)
        transparent;
}


/* Chrome 滚动条 */

.zxy-tocdock-panel::-webkit-scrollbar {
    width: 3px;
}


.zxy-tocdock-panel::-webkit-scrollbar-track {
    background: transparent;
}


.zxy-tocdock-panel::-webkit-scrollbar-thumb {
    border-radius: 10px;

    background:
        rgba(255, 255, 255, 0.25);
}


/* =========================================================
   UL
========================================================= */

.zxy-tocdock-list {
    display: flex;

    width: 100%;

    margin: 0;
    padding: 0;

    flex-direction: column;

    gap: 4px;

    list-style: none;

    box-sizing: border-box;
}


.zxy-tocdock-item {
    width: 100%;

    margin: 0;
    padding: 0;

    list-style: none;

    box-sizing: border-box;
}


/* =========================================================
   每个链接
========================================================= */

.zxy-tocdock-link {
    display: flex;

    width: 100%;
    min-height: 40px;

    margin: 0;
    padding: 0;

    align-items: center;

    overflow: hidden;

    border-radius: 10px;

    background:
        rgba(255, 255, 255, 0.055);

    color: #fff;

    text-decoration: none;

    box-sizing: border-box;

    transition:
        background-color 0.2s ease,
        transform 0.2s ease;
}


.zxy-tocdock-link:hover {
    background:
        rgba(255, 255, 255, 0.11);
}


/* =========================================================
   数字
========================================================= */

.zxy-tocdock-number {
    display: flex;

    width: 40px;
    min-width: 40px;
    height: 40px;

    flex: 0 0 40px;

    align-items: center;
    justify-content: center;

    margin: 0;

    border: 0;

    border-radius: 10px;

    background: transparent;

    color: #fff;

    font-size: 14px;
    font-weight: 700;
    line-height: 1;

    box-sizing: border-box;

    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}


/* 当前项 */

.zxy-tocdock-item.is-current
.zxy-tocdock-link {
    background: transparent;
}


.zxy-tocdock-item.is-current
.zxy-tocdock-number {
    background: var(--toc-green);

    color: #fff;

    box-shadow:
        0 4px 10px
        rgba(116, 212, 0, 0.25);
}


/* Hover */

.zxy-tocdock-item:not(.is-current)
.zxy-tocdock-link:hover
.zxy-tocdock-number {
    background:
        rgba(255, 255, 255, 0.1);
}


/* =========================================================
   标题
========================================================= */

.zxy-tocdock-label {
    display: none;

    min-width: 0;

    padding:
        0 10px
        0 8px;

    flex: 1 1 auto;

    overflow: hidden;

    color: var(--toc-text);

    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;

    box-sizing: border-box;
}


.zxy-tocdock-label-inner {
    display: -webkit-box;

    overflow: hidden;

    text-overflow: ellipsis;

    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;

    line-clamp: 2;

    overflow-wrap: anywhere;
}


/* =========================================================
   展开状态
========================================================= */

.zxy-tocdock.is-open {
    width: 190px;
}


.zxy-tocdock.is-open
.zxy-tocdock-shell {
    width: 190px;

    background: #fff;

    box-shadow:
        0 12px 38px
        rgba(0, 40, 28, 0.16);
}


/* 展开后的顶部 */

.zxy-tocdock.is-open
.zxy-tocdock-toggle {
    height: 38px;

    justify-content: flex-start;

    padding: 0 13px;

    background: var(--toc-dark);

    color: #fff;
}


.zxy-tocdock.is-open
.zxy-tocdock-toggle:hover {
    background: var(--toc-dark-hover);
}


.zxy-tocdock.is-open
.zxy-tocdock-toggle-arrow {
    display: block;

    margin-left: auto;

    transform: rotate(135deg);
}


/* 展开列表 */

.zxy-tocdock.is-open
.zxy-tocdock-panel {
    max-height: calc(100vh - 190px);

    padding: 7px;

    scrollbar-color:
        rgba(6, 65, 47, 0.22)
        transparent;
}


.zxy-tocdock.is-open
.zxy-tocdock-panel::-webkit-scrollbar-thumb {
    background:
        rgba(6, 65, 47, 0.22);
}


/* 展开后的每项 */

.zxy-tocdock.is-open
.zxy-tocdock-list {
    gap: 3px;
}


.zxy-tocdock.is-open
.zxy-tocdock-link {
    min-height: 48px;

    padding: 4px;

    background: transparent;

    color: var(--toc-text);
}


.zxy-tocdock.is-open
.zxy-tocdock-link:hover {
    background: var(--toc-light);
}


/* 展开后数字 */

.zxy-tocdock.is-open
.zxy-tocdock-number {
    width: 38px;
    min-width: 38px;
    height: 38px;

    flex-basis: 38px;

    border-radius: 9px;

    background: #edf3f0;

    color: var(--toc-dark);
}


/* 展开当前项 */

.zxy-tocdock.is-open
.zxy-tocdock-item.is-current
.zxy-tocdock-link {
    background: #f2f8ee;
}


.zxy-tocdock.is-open
.zxy-tocdock-item.is-current
.zxy-tocdock-number {
    background: var(--toc-green);

    color: #fff;
}


/* 展开显示文字 */

.zxy-tocdock.is-open
.zxy-tocdock-label {
    display: block;
}


/* =========================================================
   标题锚点偏移
========================================================= */

.long-single h2[id^="zxy-toc-section-"] {
    scroll-margin-top: 100px;
}


/* =========================================================
   中等尺寸屏幕
========================================================= */

@media (max-width: 1200px) {

    .zxy-tocdock {
        left: 12px;
    }

}


/* =========================================================
   手机端
========================================================= */

@media (max-width: 768px) {

    .zxy-tocdock {
        top: auto;

        right: 12px;
        bottom: 14px;
        left: 12px;

        width: auto;

        transform: none;
    }


    /*
     * 手机默认变成底部横向条
     */
    .zxy-tocdock-shell {
        display: flex;

        width: 100%;
        height: 48px;

        align-items: stretch;

        border-radius: 14px;

        background: var(--toc-dark);

        box-shadow:
            0 8px 28px
            rgba(0, 35, 25, 0.2);
    }


    /*
     * OPEN 放左侧
     */
    .zxy-tocdock-toggle {
        width: 52px;
        min-width: 52px;
        height: 48px;

        flex: 0 0 52px;

        border-radius:
            14px 0 0 14px;

        border-right:
            1px solid
            rgba(255, 255, 255, 0.1);
    }


    /*
     * 手机默认横向滚动
     */
    .zxy-tocdock-panel {
        width: auto;
        max-height: none;

        padding: 4px;

        flex: 1 1 auto;

        overflow-x: auto;
        overflow-y: hidden;

        scrollbar-width: none;
    }


    .zxy-tocdock-panel::-webkit-scrollbar {
        display: none;
    }


    .zxy-tocdock-list {
        display: flex;

        width: max-content;
        min-width: 100%;

        height: 40px;

        flex-direction: row;

        gap: 3px;
    }


    .zxy-tocdock-item {
        width: 40px;

        flex: 0 0 40px;
    }


    .zxy-tocdock-link {
        width: 40px;
        min-height: 40px;

        border-radius: 9px;
    }


    .zxy-tocdock-number {
        width: 40px;
        min-width: 40px;
        height: 40px;

        flex-basis: 40px;

        font-size: 12px;
    }


    /*
     * ==============================
     * 手机展开
     * ==============================
     */

    .zxy-tocdock.is-open {
        width: auto;
    }


    .zxy-tocdock.is-open
    .zxy-tocdock-shell {
        display: block;

        width: 100%;
        height: auto;

        border-radius: 16px;

        background: #fff;
    }


    .zxy-tocdock.is-open
    .zxy-tocdock-toggle {
        width: 100%;
        height: 40px;

        border: 0;

        border-radius:
            16px 16px 0 0;

        padding: 0 14px;

        flex: none;
    }


    .zxy-tocdock.is-open
    .zxy-tocdock-panel {
        width: 100%;

        max-height: min(
            48vh,
            360px
        );

        padding: 7px;

        overflow-x: hidden;
        overflow-y: auto;
    }


    .zxy-tocdock.is-open
    .zxy-tocdock-list {
        display: flex;

        width: 100%;
        height: auto;

        flex-direction: column;

        gap: 3px;
    }


    .zxy-tocdock.is-open
    .zxy-tocdock-item {
        width: 100%;

        flex: none;
    }


    .zxy-tocdock.is-open
    .zxy-tocdock-link {
        width: 100%;
        min-height: 48px;
    }


    .zxy-tocdock.is-open
    .zxy-tocdock-number {
        width: 38px;
        min-width: 38px;
        height: 38px;

        flex-basis: 38px;
    }

}


/* =========================================================
   超小屏幕
========================================================= */

@media (max-width: 480px) {

    .zxy-tocdock {
        right: 8px;
        bottom: 10px;
        left: 8px;
    }


    .zxy-tocdock-toggle {
        width: 48px;
        min-width: 48px;

        flex-basis: 48px;

        font-size: 8px;
    }


    .zxy-tocdock-item {
        width: 38px;

        flex-basis: 38px;
    }


    .zxy-tocdock-link {
        width: 38px;
    }


    .zxy-tocdock-number {
        width: 38px;
        min-width: 38px;

        flex-basis: 38px;
    }

}


/* =========================================================
   Reduce Motion
========================================================= */

@media (prefers-reduced-motion: reduce) {

    .zxy-tocdock-shell,
    .zxy-tocdock-link,
    .zxy-tocdock-number,
    .zxy-tocdock-toggle,
    .zxy-tocdock-toggle-arrow {
        transition: none;
    }

}