/* ==========================================================
   博客详情页（blog/:slug）
   依赖 new_blog.css 的变量与通用样式（面包屑、封面、日期、按钮、卡片、行动号召），
   所有样式限定在 .blog-detail 下
   ========================================================== */

/* mainV2.css 给 html、body 设置了 overflow-x: hidden，body 会因此成为滚动容器，右侧栏 sticky 失效；
   支持 clip 的浏览器改用 clip，同样裁掉横向溢出，但不会产生滚动容器 */
@supports (overflow-x: clip) {
    html,
    body {
        overflow-x: clip;
    }
}

.blog-detail .banner-Wrap {
    padding-top: 136px;
    padding-bottom: 120px;
}

.blog-detail .bd-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 324px;
    gap: 76px;
    align-items: start;
}

/* ---------- 左侧：面包屑、标题、描述、封面、作者 ---------- */

/* 文章标题过长时省略 */
.blog-detail .bd-breadcrumb {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.blog-detail .bd-breadcrumb .bc-breadcrumb-current {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.blog-detail .bd-title {
    margin: 60px 0 0;
    font-size: 36px;
    line-height: 46px;
    font-weight: 700;
    color: var(--bc-title);
    word-break: break-word;
}

.blog-detail .bd-desc {
    margin: 20px 0 0;
    font-size: 16px;
    line-height: 28px;
    color: var(--bc-muted);
    word-break: break-word;
}

.blog-detail .bd-cover {
    margin-top: 40px;
    padding-top: 50%;
    border-radius: 16px;
}

.blog-detail .bd-author {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 40px;
    padding-bottom: 40px;
    border-bottom: 1px solid var(--bc-border);
}

.blog-detail .bd-author-avatar {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    object-fit: cover;
    background: var(--bc-cover-bg);
    border-radius: 50%;
}

.blog-detail .bd-author-name {
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    color: var(--bc-title);
}

.blog-detail .bd-author .bc-date {
    margin-top: 2px;
}

/* ---------- 正文（CKEditor 编辑的 HTML，mainV2.css 已把所有元素的 margin、padding 清零） ---------- */

.blog-detail .bd-content {
    margin-top: 48px;
    font-size: 16px;
    line-height: 30px;
    color: var(--bc-text);
    word-break: break-word;
}

.blog-detail .bd-content h1,
.blog-detail .bd-content h2,
.blog-detail .bd-content h3,
.blog-detail .bd-content h4,
.blog-detail .bd-content h5,
.blog-detail .bd-content h6 {
    font-weight: 600;
    color: var(--bc-title);
    /* 通过地址栏锚点直接定位时让出固定顶栏 */
    scroll-margin-top: 104px;
}

.blog-detail .bd-content h1,
.blog-detail .bd-content h2 {
    margin: 40px 0 16px;
    font-size: 24px;
    line-height: 34px;
    font-weight: 700;
}

.blog-detail .bd-content h3 {
    margin: 32px 0 12px;
    font-size: 18px;
    line-height: 28px;
}

.blog-detail .bd-content h4,
.blog-detail .bd-content h5,
.blog-detail .bd-content h6 {
    margin: 24px 0 8px;
    font-size: 16px;
    line-height: 26px;
}

.blog-detail .bd-content p,
.blog-detail .bd-content ul,
.blog-detail .bd-content ol,
.blog-detail .bd-content figure {
    margin: 0 0 16px;
}

.blog-detail .bd-content ul,
.blog-detail .bd-content ol {
    padding-left: 24px;
}

.blog-detail .bd-content ul {
    list-style: disc;
}

.blog-detail .bd-content ol {
    list-style: decimal;
}

.blog-detail .bd-content li > ul,
.blog-detail .bd-content li > ol {
    margin: 0;
}

.blog-detail .bd-content a {
    color: var(--bc-primary);
}

.blog-detail .bd-content a:hover {
    text-decoration: underline;
}

.blog-detail .bd-content strong,
.blog-detail .bd-content b {
    font-weight: 600;
    color: var(--bc-title);
}

.blog-detail .bd-content img {
    max-width: 100%;
    /* 编辑器会写入行内宽高，宽度被限制时需要按比例缩放 */
    height: auto !important;
    vertical-align: middle;
    border-radius: 8px;
    cursor: zoom-in;
}

.blog-detail .bd-content a img {
    cursor: pointer;
}

.blog-detail .bd-content iframe,
.blog-detail .bd-content video {
    max-width: 100%;
}

.blog-detail .bd-content hr {
    margin: 32px 0;
    border: 0;
    border-top: 1px solid var(--bc-border);
}

/* 引用：用作「Rule of thumb」一类的提示框 */
.blog-detail .bd-content blockquote {
    margin: 24px 0;
    padding: 16px 20px;
    font-size: 14px;
    line-height: 22px;
    font-style: normal;
    color: var(--bc-text);
    background: #FBF7FF;
    border: 1px solid #EBD7FA;
    border-radius: 12px;
}

.blog-detail .bd-content blockquote > :last-child {
    margin-bottom: 0;
}

/* 表格：编辑器可能写入固定宽度和 border 属性，统一撑满正文并由单元格换行 */
.blog-detail .bd-content table {
    width: 100% !important;
    margin: 24px 0;
    font-size: 14px;
    line-height: 24px;
    border: 1px solid var(--bc-border);
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 12px;
    overflow: hidden;
}

.blog-detail .bd-content th,
.blog-detail .bd-content td {
    padding: 20px 16px;
    text-align: left;
    vertical-align: top;
    color: var(--bc-muted);
    border: 0;
    border-bottom: 1px solid var(--bc-border);
}

.blog-detail .bd-content th + th,
.blog-detail .bd-content th + td,
.blog-detail .bd-content td + th,
.blog-detail .bd-content td + td {
    border-left: 1px solid var(--bc-border);
}

.blog-detail .bd-content th {
    font-weight: 500;
    color: var(--bc-title);
}

.blog-detail .bd-content tr:last-child > th,
.blog-detail .bd-content tr:last-child > td {
    border-bottom: 0;
}

/* 表头与表体之间保留分隔线 */
.blog-detail .bd-content thead tr:last-child > th,
.blog-detail .bd-content thead tr:last-child > td {
    border-bottom: 1px solid var(--bc-border);
}

/* 代码：编辑器的「已编排格式」（pre），不做语法高亮 */
.blog-detail .bd-content pre {
    margin: 24px 0;
    padding: 16px 20px;
    font-size: 14px;
    line-height: 24px;
    color: #FFFFFF;
    white-space: pre-wrap;
    word-break: break-all;
    background: #19181B;
    border-radius: 12px;
}

.blog-detail .bd-content pre,
.blog-detail .bd-content code {
    font-family: Consolas, Monaco, "Courier New", monospace;
}

.blog-detail .bd-content pre * {
    font-family: inherit;
}

.blog-detail .bd-content code {
    padding: 2px 6px;
    font-size: 0.9em;
    color: var(--bc-title);
    background: var(--bc-cover-bg);
    border-radius: 4px;
}

.blog-detail .bd-content pre code {
    padding: 0;
    font-size: inherit;
    color: inherit;
    background: none;
}

/* 正文首尾元素不留外边距，需写在各元素规则之后 */
.blog-detail .bd-content-body > :first-child {
    margin-top: 0;
}

.blog-detail .bd-content-body > :last-child {
    margin-bottom: 0;
}

/* ---------- 右侧：内容索引、找文章卡片 ---------- */

.blog-detail .bd-aside {
    position: sticky;
    top: 104px;
}

.blog-detail .bd-toc-title {
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    color: var(--bc-title);
}

/* 章节很多时索引内部滚动，保证下方卡片仍在可视区域内 */
.blog-detail .bd-toc-list {
    max-height: calc(100vh - 480px);
    min-height: 132px;
    margin-top: 12px;
    overflow-y: auto;
    list-style: none;
}

.blog-detail .bd-toc-link {
    display: block;
    padding: 12px 0 12px 16px;
    font-size: 13px;
    line-height: 20px;
    color: var(--bc-light);
    text-decoration: none;
    border-left: 2px solid var(--bc-border);
    transition: color 0.2s, border-color 0.2s;
}

.blog-detail .bd-toc-link:hover {
    color: var(--bc-primary);
}

.blog-detail .bd-toc-item.active .bd-toc-link {
    font-weight: 500;
    color: var(--bc-title);
    border-left-color: var(--bc-primary);
}

.blog-detail .bd-guide {
    padding: 24px;
    background: #FFFFFF;
    border: 1px solid var(--bc-border);
    border-radius: 16px;
}

.blog-detail .bd-toc + .bd-guide {
    margin-top: 48px;
}

.blog-detail .bd-guide-title {
    font-size: 20px;
    line-height: 28px;
    font-weight: 600;
    color: var(--bc-title);
}

.blog-detail .bd-guide-desc {
    margin: 12px 0 0;
    font-size: 14px;
    line-height: 26px;
    color: var(--bc-muted);
}

.blog-detail .bd-guide .bc-btn {
    height: 44px;
    margin-top: 20px;
    padding: 0 24px;
    font-size: 14px;
    border-radius: 22px;
}

/* ---------- 更多文章 ---------- */

.blog-detail .bd-more {
    padding-bottom: 160px;
}

.blog-detail .bd-more-inner {
    padding-top: 120px;
    border-top: 1px solid var(--bc-border);
}

.blog-detail .bd-more-title {
    margin: 0 0 48px;
    font-size: 40px;
    line-height: 50px;
    font-weight: 700;
    color: var(--bc-title);
}

/* 分类标签：颜色按分类排序循环，数量与 HelpCenterLib::BLOG_TAG_COLOR_COUNT 一致 */
.blog-detail .bd-tag {
    align-self: flex-start;
    max-width: 100%;
    margin-top: 24px;
    padding: 0 8px;
    overflow: hidden;
    font-size: 12px;
    line-height: 22px;
    white-space: nowrap;
    text-overflow: ellipsis;
    border: 1px solid;
    border-radius: 4px;
    box-sizing: border-box;
}

.blog-detail .bd-tag-0 {
    color: #2F6BFF;
    background: #F0F5FF;
    border-color: #C9D9FF;
}

.blog-detail .bd-tag-1 {
    color: #16A06A;
    background: #EEF9F3;
    border-color: #BDE8D2;
}

.blog-detail .bd-tag-2 {
    color: #D6409F;
    background: #FDF0F8;
    border-color: #F5C6E3;
}

.blog-detail .bd-tag + .bc-card-title {
    margin-top: 16px;
}

/* 隐藏的 el-image，只用于打开图片查看器 */
.blog-detail .bd-img-viewer {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ---------- 响应式 ---------- */

@media (max-width: 1240px) {
    .blog-detail .bd-main {
        grid-template-columns: minmax(0, 1fr) 280px;
        gap: 40px;
    }
}

@media (max-width: 900px) {
    .blog-detail .banner-Wrap {
        padding-top: 104px;
        padding-bottom: 72px;
    }

    .blog-detail .bd-main {
        grid-template-columns: minmax(0, 1fr);
        gap: 48px;
    }

    /* 窄屏不显示内容索引，找文章卡片跟在正文后面 */
    .blog-detail .bd-aside {
        position: static;
    }

    .blog-detail .bd-toc {
        display: none;
    }

    .blog-detail .bd-toc + .bd-guide {
        margin-top: 0;
    }

    .blog-detail .bd-title {
        margin-top: 32px;
        font-size: 28px;
        line-height: 38px;
    }

    .blog-detail .bd-cover,
    .blog-detail .bd-author {
        margin-top: 28px;
    }

    .blog-detail .bd-author {
        padding-bottom: 28px;
    }

    .blog-detail .bd-content {
        margin-top: 32px;
    }

    .blog-detail .bd-more {
        padding-bottom: 80px;
    }

    .blog-detail .bd-more-inner {
        padding-top: 64px;
    }

    .blog-detail .bd-more-title {
        margin-bottom: 28px;
        font-size: 28px;
        line-height: 36px;
    }
}

@media (max-width: 600px) {
    .blog-detail .bd-title {
        margin-top: 24px;
        font-size: 24px;
        line-height: 32px;
    }

    .blog-detail .bd-desc {
        margin-top: 12px;
        font-size: 15px;
        line-height: 24px;
    }

    .blog-detail .bd-cover {
        margin-top: 20px;
        border-radius: 12px;
    }

    .blog-detail .bd-content {
        font-size: 15px;
        line-height: 26px;
    }

    .blog-detail .bd-content h1,
    .blog-detail .bd-content h2 {
        margin-top: 32px;
        font-size: 20px;
        line-height: 28px;
    }

    .blog-detail .bd-content h3 {
        font-size: 17px;
        line-height: 26px;
    }

    .blog-detail .bd-content th,
    .blog-detail .bd-content td {
        padding: 12px 10px;
    }

    .blog-detail .bd-guide {
        padding: 20px;
    }

    .blog-detail .bd-more-title {
        font-size: 24px;
        line-height: 32px;
    }
}
