/* ============================================================
   静态文档页（docs/*.html，CI 生成）专用组件样式
   布局与组件对齐交互式文档中心：顶栏 + 侧栏文档树（当前文档下嵌
   章节锚点）+ 内容玻璃卡 + 移动端吸顶章节条（<details> 原生交互，零 JS）。
   视觉语言沿用站点自身：玻璃卡片（--card-bg + blur）、主题蓝点缀、
   大圆角卡片；基础变量与正文字体由 main.css / markdown.css 提供。
   ============================================================ */

body.doc-static-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---------- 顶栏：玻璃吸顶 ---------- */
.ds-top {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem clamp(1rem, 3vw, 2rem);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.ds-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
}

.ds-brand-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
}

.ds-top-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.doc-langs {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.doc-lang-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
}

.doc-lang-link:hover {
    color: var(--text);
    background: rgba(var(--primary-rgb), 0.08);
}

.doc-lang-link.current {
    color: var(--primary);
    font-weight: 600;
}

.ds-interactive {
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    padding: 0.35rem 0.8rem;
    border: 1px solid rgba(var(--primary-rgb), 0.3);
    border-radius: 999px;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.ds-interactive:hover {
    background: var(--accent-soft);
}

/* ---------- 布局：侧栏树 + 内容卡 ---------- */
.ds-layout {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    gap: 1.6rem;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.6rem clamp(1rem, 3vw, 2rem) 2.5rem;
    align-items: start;
    flex: 1;
}

/* 侧栏：玻璃卡（同交互版 docs-sidebar 观感） */
.ds-sidebar {
    position: sticky;
    top: 84px;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 18px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    padding: 1.1rem;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--primary-rgb), 0.2) transparent;
}

.ds-sidebar::-webkit-scrollbar {
    width: 4px;
}

.ds-sidebar::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-rgb), 0.2);
    border-radius: 2px;
}

.ds-sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    padding: 0 0.5rem 0.7rem;
    margin-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
}

/* 分类折叠组 */
.ds-cat {
    margin-bottom: 0.35rem;
}

.ds-cat summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.7rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text);
    user-select: none;
    transition: background-color 0.2s ease;
}

.ds-cat summary::-webkit-details-marker {
    display: none;
}

.ds-cat summary:hover {
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary);
}

.ds-cat-name {
    flex: 1;
    min-width: 0;
}

.ds-cat-count {
    font-size: 0.72rem;
    color: var(--text-secondary);
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary);
    border-radius: 10px;
    padding: 0.05rem 0.45rem;
    font-weight: 600;
}

/* 折叠箭头（纯 CSS 三角，无图标依赖） */
.ds-cat-chev {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-secondary);
    transition: transform 0.25s ease;
}

.ds-cat[open] .ds-cat-chev {
    transform: rotate(180deg);
}

.ds-docs {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0.15rem 0 0.4rem;
}

.ds-doc {
    display: block;
    padding: 0.5rem 0.7rem 0.5rem 1.4rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.87rem;
    line-height: 1.5;
    transition: background-color 0.2s ease, color 0.2s ease;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.ds-doc:hover {
    color: var(--text);
    background: rgba(var(--primary-rgb), 0.1);
}

.ds-doc.current {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.15);
    font-weight: 500;
}

/* 当前文档下的章节锚点（同交互版章节 TOC 母题） */
.ds-chapters {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0.2rem 0 0.3rem 0.6rem;
    border-left: 1px solid var(--border);
    margin: 0.2rem 0 0.3rem 1rem;
}

.ds-chapter {
    padding: 0.38rem 0.6rem;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.83rem;
    line-height: 1.5;
    transition: background-color 0.2s ease, color 0.2s ease;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.ds-chapter:hover {
    color: var(--text);
    background: rgba(var(--primary-rgb), 0.06);
}

.ds-chapter.level-3 {
    padding-left: 1.2rem;
    font-size: 0.8rem;
}

/* ---------- 内容卡：玻璃大卡（同 docs-main 观感） ---------- */
.ds-main {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 18px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    padding: 2.2rem 2.5rem 2.5rem;
    min-width: 0;
}

.doc-breadcrumbs {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
    overflow-wrap: anywhere;
}

.doc-breadcrumbs a {
    color: var(--primary);
    text-decoration: none;
}

.doc-breadcrumbs a:hover {
    text-decoration: underline;
}

.doc-crumb-sep {
    margin: 0 0.4rem;
    opacity: 0.6;
}

.doc-interactive {
    margin: 0 0 1.8rem;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(var(--primary-rgb), 0.03);
    font-size: 0.84rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.doc-interactive a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.doc-interactive a:hover {
    text-decoration: underline;
}

.doc-pager {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2.5rem;
}

.doc-pager a {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.88rem;
    background: var(--card-bg);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.doc-pager a:hover {
    border-color: rgba(var(--primary-rgb), 0.4);
    background: rgba(var(--primary-rgb), 0.05);
}

.doc-pager a small {
    color: var(--text-secondary);
}

.doc-pager-next {
    text-align: right;
}

/* ---------- 移动端吸顶章节条（≤991px，原生 <details>，零 JS） ---------- */
.ds-chapter-bar {
    display: none;
}

@media (max-width: 991px) {
    .ds-layout {
        grid-template-columns: 1fr;
        gap: 1.1rem;
        padding-top: 1.1rem;
    }

    /* 侧栏（分类/文档树）保留在顶部；长列表内滚动 */
    .ds-sidebar {
        position: relative;
        top: 0;
        max-height: min(60vh, 540px);
    }

    .ds-main {
        padding: 1.6rem 1.4rem 2rem;
    }

    .ds-chapter-bar {
        display: block;
        position: sticky;
        top: 66px;
        z-index: 85;
        background: var(--glass-bg);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid var(--border);
        border-radius: 14px;
        box-shadow: var(--shadow-sm);
        overflow: hidden;
    }

    .ds-chapter-bar summary {
        list-style: none;
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0.7rem 1rem;
        cursor: pointer;
        color: var(--text);
        font-size: 0.9rem;
        font-weight: 500;
        min-height: 48px;
        transition: background-color 0.2s ease;
    }

    .ds-chapter-bar summary::-webkit-details-marker {
        display: none;
    }

    .ds-chapter-bar summary:hover {
        background: rgba(var(--primary-rgb), 0.06);
    }

    .ds-chapter-bar-icon {
        width: 14px;
        height: 12px;
        border-top: 2px solid var(--primary);
        border-bottom: 2px solid var(--primary);
        flex-shrink: 0;
    }

    .ds-chapter-bar-label {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ds-chapter-bar-chev {
        width: 0;
        height: 0;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-top: 6px solid var(--text-secondary);
        transition: transform 0.25s ease;
        flex-shrink: 0;
    }

    .ds-chapter-bar[open] .ds-chapter-bar-chev {
        transform: rotate(180deg);
    }

    .ds-chapter-bar-panel {
        border-top: 1px solid var(--border);
        max-height: min(60vh, 480px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    /* 竖线导轨母题（与交互版一致） */
    .ds-chapter-rail {
        position: relative;
        display: flex;
        flex-direction: column;
        gap: 1px;
        padding: 0.55rem 0.75rem 0.75rem;
    }

    .ds-chapter-rail::before {
        content: '';
        position: absolute;
        left: 1.55rem;
        top: 0.9rem;
        bottom: 1rem;
        width: 1px;
        background: var(--border);
    }

    .ds-chapter-rail .ds-chapter {
        position: relative;
        padding: 0.5rem 0.6rem 0.5rem 1.9rem;
        border-left: 0;
        font-size: 0.88rem;
        min-height: 44px;
        display: flex;
        align-items: flex-start;
    }

    .ds-chapter-rail .ds-chapter.level-3 {
        padding-left: 2.4rem;
    }
}

@media (max-width: 767px) {
    .ds-sidebar {
        max-height: min(60vh, 520px);
    }

    .ds-main {
        padding: 1.3rem 1.1rem 1.75rem;
    }

    .ds-chapter-bar {
        top: 60px;
    }

    .ds-top {
        padding: 0.6rem 1rem;
    }

    .ds-interactive {
        display: none;   /* 顶栏太窄时让位语言切换；正文内还有入口 */
    }
}

/* ---------- 页脚 ---------- */
.ds-footer {
    text-align: center;
    padding: 2rem 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.ds-footer a {
    color: var(--primary);
    text-decoration: none;
}
