/**
 * 文档系统样式
 * 
 * @package WordPress
 * @subpackage Doc_System
 */

/* ==========================================
   基础样式
   ========================================== */

.doc-article {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* ==========================================
   面包屑导航
   ========================================== */

.doc-breadcrumb {
    margin-bottom: 20px;
    padding: 10px 0;
    font-size: 14px;
    color: #666;
}

.doc-breadcrumb a {
    color: #0073aa;
    text-decoration: none;
}

.doc-breadcrumb a:hover {
    color: #00a0d2;
    text-decoration: none;
}

.doc-breadcrumb .separator {
    margin: 0 8px;
    color: #999;
}

/* ==========================================
   树形目录
   ========================================== */

.doc-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.doc-tree-item {
    margin: 5px 0;
    padding: 5px 0;
}

.doc-tree-item a {
    color: #0073aa;
    text-decoration: none;
    padding: 5px 10px;
    display: block;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.doc-tree-item a:hover {
    background: #e9ecef;
    color: #005a87;
}

.doc-tree-item.current-item > a {
    background: #0073aa;
    color: #fff;
    font-weight: bold;
}

.doc-tree-item.has-children > .doc-tree {
    margin-left: 20px;
    border-left: 2px solid #e9ecef;
    padding-left: 10px;
}

.doc-tree-item.expanded > .doc-tree {
    display: block;
}

.doc-tree-item.collapsed > .doc-tree {
    display: none;
}

/* 折叠/展开按钮 */
.doc-tree-toggle {
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: inline-block;
    text-align: center;
    line-height: 20px;
    margin-right: 5px;
    color: #666;
    transition: transform 0.2s ease;
}

.doc-tree-toggle:hover {
    color: #333;
}

.doc-tree-item.expanded > .doc-tree-toggle {
    transform: rotate(90deg);
}

/* ==========================================
   文章元信息
   ========================================== */

.doc-meta {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
    font-size: 14px;
    color: #666;
}

/* ==========================================
   上下篇导航
   ========================================== */

.doc-nav-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.doc-nav-title {
    font-size: 16px;
    font-weight: bold;
}

.doc-nav-prev {
    margin-right: 20px;
}

.doc-nav-next {
    /*margin-left: 20px;*/
    text-align: right;
}

.doc-nav-placeholder {
    visibility: hidden;
}

/* ==========================================
   响应式设计
   ========================================== */

@media (max-width: 600px) {
    .doc-article {
        padding: 20px;
    }
    
    .doc-tree-item.has-children > .doc-tree {
        margin-left: 15px;
    }
    
    .doc-nav-next {
        text-align: left;
    }
}

/* ==========================================
   暗色模式支持
   ========================================== */

@media (prefers-color-scheme: dark) {
    .doc-article {
        background: #1e1e1e;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    
    .doc-tree-item a:hover {
        background: #404040;
    }
    
    .doc-tree-item.current-item > a {
        background: #0073aa;
    }
    
    .doc-meta {
        background: #2d2d2d;
    }
}

/* ==========================================
   根文章左右分栏布局
   ========================================== */

.doc-root-layout {
    display: flex;
    margin-top: 20px;
}

.doc-root-left {
    flex: 0 0 25%;
    max-width: 25%;
}

.doc-root-right {
    flex: 0 0 75%;
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.doc-featured-image {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.doc-featured-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* ==========================================
   根文档正文末尾的「分类 + 标签」

   位置在正文与下方 .doc-read-button-wrapper 的白线之间。
   分类沿用列表卡片的胶囊样式（与 doc-home.css 的 .doc-list-cats 同一套视觉），
   标签的配色与小块形状沿用彩色标签云（主题 style.css 里那份 8 色调色板，
   这里只补平铺 <a> 的排布，颜色由那边统一管）。
   ========================================== */

/* 字号统一 12px：与列表卡片的 .doc-list-meta、标签云容器保持同一档，
   分类胶囊与标签小块都从容器继承 */
.doc-root-terms {
    font-size: 12px;
    margin-top: 24px;
}

.doc-root-cats {
    margin-bottom: 10px;
}

#primary .doc-root-cats a {
    border: 1px solid var(--tb--main, #007bff);
    border-radius: 999px;
    color: var(--tb--main, #007bff);
    display: inline-block;
    padding: 1px 8px;
}

/* 标签云那边的小块靠 li 浮动排布，这里是平铺的 <a>，自己排一行 */
#primary .doc-root-tags a {
    display: inline-block;
    margin: 0 6px 6px 0;
}

.doc-read-button-wrapper {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.doc-read-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 30px;
    background: var(--tb--main, #0073aa);
    color: #fff;
    text-decoration: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* 暗色模式下主题注入的 html.darking a{color:var(--tb--main)} 特异性（0,1,2）
   高于 .doc-read-button（0,1,0），会把按钮文字染成与底色相同的主题色，
   只有鼠标经过时因 .doc-read-button:hover 才恢复白色。
   这里用更高的特异性把非 hover 状态的白字固定住。 */
.doc-read-button-wrapper .doc-read-button {
    color: #fff;
}

.doc-read-button:hover {
    transform: translateY(-2px);
    text-decoration: none;
    color: #fff;
}

.doc-read-arrow {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.doc-read-button:hover .doc-read-arrow {
    transform: translateX(5px);
}

/* 两列并排（>600px）：两列之间的间距改用右列的外边距做。
   原来用 flex 的 gap：两列是 25% + 75% 且 flex-shrink 为 0，
   而 gap 不计入百分比宽度，两列相加等于 100% + 间距，
   多出来的这段就把右侧文字区挤出了内容区右边界。
   右列改成 flex: 1，由它吃掉「扣掉左列与这段外边距后的剩余宽度」，
   相加恰好是 100%，不再溢出。
   ≤600px 是纵向单列，不存在这个问题，那里维持原样（gap 仍由下面的
   窄屏块给）。 */
@media (min-width: 601px) {
    .doc-root-right {
        flex: 1 1 0%;
        margin-left: 20px;
        max-width: none;
        min-width: 0;
    }
}

/* 响应式布局 */
@media (max-width: 600px) {
    .doc-root-layout {
        flex-direction: column;
        gap: 20px;
    }
    
    .doc-root-left {
        flex: 0 0 70%;
        max-width: 70%;
        margin: 0 auto;
    }
    
    .doc-root-right {
        flex: 1;
        max-width: 100%;
    }
}

/* ==========================================
   子文章列表样式
   ========================================== */

.doc-child-pages {
    margin-top: 30px;
    padding: 20px;
    background: var(--tb--tint, #f8f9fa);
    border-radius: 8px;
    border-left: 4px solid var(--tb--main, #0073aa);
}

.doc-child-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--tb--base, #333);
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--tb--line, #e1e1e1);
}

.doc-child-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.doc-child-list li {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--tb--line, #e1e1e1);
}

.doc-child-list li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.doc-child-list li a {
    font-size: 16px;
    font-weight: 500;
    color: var(--tb--base, #333);
    text-decoration: none;
    transition: color 0.2s ease;
}

.doc-child-list li a:hover {
    color: var(--tb--main, #0073aa);
    text-decoration: none;
}

.doc-child-excerpt {
    font-size: 14px;
    color: var(--tb--gray, #666);
    margin: 5px 0 0 0;
    line-height: 1.5;
}

/* ==========================================
   正文标题分级样式（仅 内容页）
   h1～h6 统一：左侧 2px 主题色竖条 + 10px 内边距
   各级的间距 / 字号 / 字色 / 前置装饰仍由下面各自的规则管
   ========================================== */

body.single-doc .article-content h1,
body.single-doc .article-content h2,
body.single-doc .article-content h3,
body.single-doc .article-content h4,
body.single-doc .article-content h5,
body.single-doc .article-content h6 {
    border-left: 8px solid var(--tb--main, #007bff);
    /* 主题给标题的上方留白用的是 padding: 1.5em 0 0，这段留白会计入边框盒，
       左侧竖条因此比文字高一截。这里把留白挪到外边距上：padding-top 归零，
       竖条就只覆盖文字高度。
       h2～h6 各自已有自己的 margin-top，会覆盖这条 1.5em；
       h1 没有单独规则，正好由它接住。 */
    margin-top: 1.5em;
    padding-left: 10px;
    padding-top: 0;
    /* 标题底色：主题色 15% 的低透明度铺一层。
       随 --tb--main 自动变（含明暗两套调色板），同时保证与文字色 --tb--base
       的对比度：亮色 #333 衬在 #ffebd9 上约 10.9:1，
       暗色 #ccc 衬在 #372717 上约 8.9:1，都远高于无障碍要求。 */
    background: color-mix(in srgb, var(--tb--main, #007bff) 5%, transparent);
}

/* h2 — 章节标题 */
body.single-doc .article-content h2 {
    margin: 36px 0 20px;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--tb--base, #ccc);
    scroll-margin-top: 70px;
}

body.single-doc .article-content h2:first-child {
    margin-top: 0;
}

/* h3 — 小节标题 */
body.single-doc .article-content h3 {
    margin: 28px 0 16px;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--tb--base, #ccc);
    scroll-margin-top: 70px;
}

/* 下一级文章列表的空标题不套用正文 h3 样式 */
body.single-doc .article-content h3.doc-child-title {
    margin: 0;
    padding: 0;
    border-left: 0;
    background: none;
}

/* h4 — 子节标题：前置主色小菱形 */
body.single-doc .article-content h4 {
    margin: 24px 0 14px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--tb--base, #ccc);
    scroll-margin-top: 70px;
}

body.single-doc .article-content h4::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 9px;
    vertical-align: 2px;
    background: var(--tb--main, #007bff);
    border-radius: 2px;
    transform: rotate(45deg);
}

/* h5 — 次级要点：前置短横线，字号略小 */
body.single-doc .article-content h5 {
    margin: 20px 0 12px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--tb--base, #ccc);
    scroll-margin-top: 70px;
}

body.single-doc .article-content h5::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 2px;
    margin-right: 8px;
    vertical-align: 3px;
    background: var(--tb--gray, #555);
    border-radius: 1px;
}

/* h6 — 备注级：小号、弱化、字距拉开 */
body.single-doc .article-content h6 {
    margin: 18px 0 10px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 1px;
    color: var(--tb--gray, #555);
    scroll-margin-top: 70px;
}

/* ==========================================
   宽表在正文列内横向滚动，不向外溢出

   表格是唯一会撑破列宽的正文元素。列装不下时它会溢出，
   而宽屏下 TOC 列在 DOM 中位于正文之后（非定位元素后者居上），
   会把表格右侧连同表头一起盖住；窄屏下则会把页面撑出横向滚动条。
   表格转成块级并自行滚动，两种情形一起解决。
   display:block 后浏览器仍按表格规则排版内部结构，
   装得下时宽度与原先一致，装不下时才出现横向滚动条。
   ========================================== */
body.single-doc .article-content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}

/* ==========================================
   宽屏双列布局：正文左列 + TOC 右列（sticky 随动）
   ≥1300px 时释放主题右侧小工具栏，双列间竖线分割
   仅作用于内容页（含 .doc-article-toc 的页面）
   ========================================== */
@media (min-width: 1300px) {
    /* 隐藏右侧分类/标签小工具栏，腾出 TOC 列空间。
       .sidebar 是原主题的类名；Twenty Seventeen 的小工具栏是
       <aside id="secondary" class="widget-area">，需一并列出。 */
    body.single-doc:has(.doc-article-toc) .sidebar,
    body.single-doc:has(.doc-article-toc) #secondary.widget-area {
        display: none;
    }

    body.single-doc:has(.doc-article-toc) .content-wrap .content {
        margin-right: 0;
    }

    /* 正文区两列：左列内容，右列 TOC */
    body.single-doc .article-content:has(.doc-article-toc) {
        display: flex;
        align-items: stretch;
    }

    body.single-doc .article-content .doc-article-body {
        flex: 1;
        min-width: 0;
    }

    body.single-doc .article-content .doc-article-toc {
        flex: 0 0 280px;
        margin-left: 24px;
        padding-left: 24px;
        border-left: 1px solid var(--tb--line, #1d2025);
    }

    body.single-doc .doc-article-toc-inner {
        position: sticky;
        top: 80px;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }

    body.single-doc .doc-article-toc #ez-toc-container {
        width: 100% !important;
    }
}

/* 窄屏：右列隐藏，TOC 保持顶部内联插入 */
@media (max-width: 1299px) {
    body.single-doc .doc-article-toc {
        display: none;
    }
}

/* ==========================================
   正文列表间距
   主题基类是 ul { margin: 0 0 1.5em }，上 0 下 1.5em 不对称，
   这里统一成上下各 1em。
   只挂正文容器：根文档是 .doc-root-right .article-content，
   内容页是 .doc-article-body。
   必须排除 .doc-child-list —— 内容页的子文档列表就在
   .doc-article-body 里面，它自带 margin:0，被顶掉会撑开
   上面那层 .doc-child-pages 卡片。
   ========================================== */

.doc-root-right .article-content ul:not(.doc-child-list),
.doc-root-right .article-content ol,
.doc-article-body ul:not(.doc-child-list),
.doc-article-body ol {
    margin: 1em 0;
    /* 主题基类给的是 padding: 0，而 list-style-position 默认是 outside，
       项目符号/序号会被画到内容盒左边之外、突到正文左边缘以外。
       补回左内边距，符号落进这段内边距里，与段落文字的左边齐平，
       列表文字则缩进 1.5em（与主题 li > ul 的缩进单位一致）。 */
    padding-left: 1.5em;
}

/* 嵌套列表：主题的 li > ul / li > ol { margin-left: 1.5em } 特异性低于上面那条，
   会被覆盖，这里把左缩进写回去 */
.doc-root-right .article-content li > ul,
.doc-root-right .article-content li > ol,
.doc-article-body li > ul,
.doc-article-body li > ol {
    margin: 1em 0 1em 1.5em;
}
