/* ============================================
   详情页长文章阅读体验优化
   包含：阅读进度条、返回顶部、目录导航、排版优化
   移动端和PC端通用
   ============================================ */

/* ===== 1. 阅读进度条 ===== */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #C9A96E, #8B6914);
    z-index: 99999;
    transition: width 0.1s ease-out;
    box-shadow: 0 0 8px rgba(201, 169, 110, 0.5);
}

/* ===== 2. 返回顶部按钮 ===== */
.back-to-top-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #C9A96E;
    color: #C9A96E;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.back-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top-btn:hover {
    background: #C9A96E;
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(201, 169, 110, 0.4);
}

/* ===== 3. 目录导航优化 ===== */
.article-toc {
    background: #FAF7F2;
    border: 1px solid #e8d8c0;
    border-radius: 12px;
    padding: 20px 24px;
    margin: 30px 0;
}
.article-toc-title {
    font-size: 16px;
    font-weight: bold;
    color: #3d2820;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.article-toc-title::before {
    content: "📑";
    font-size: 18px;
}
.article-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.article-toc-list li {
    margin-bottom: 6px;
}
.article-toc-list a {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    display: block;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.article-toc-list a:hover {
    background: #f0e8d8;
    color: #3d2820;
    border-left-color: #C9A96E;
}
.article-toc-list a.active {
    background: #e8d8c0;
    color: #3d2820;
    font-weight: bold;
    border-left-color: #8B6914;
}
.article-toc-list .toc-h3 {
    padding-left: 20px;
    font-size: 13px;
}
.article-toc-list .toc-h4 {
    padding-left: 40px;
    font-size: 12px;
}

/* 移动端目录折叠按钮 */
.toc-toggle-btn {
    display: none;
    width: 100%;
    padding: 10px 16px;
    background: #FAF7F2;
    border: 1px solid #e8d8c0;
    border-radius: 8px;
    color: #3d2820;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    margin: 20px 0 10px;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.toc-toggle-btn .toc-arrow {
    transition: transform 0.3s;
}
.toc-toggle-btn.open .toc-arrow {
    transform: rotate(180deg);
}

/* ===== 4. 文章内容排版优化 ===== */
.article-content,
.post-content,
.entry-content,
.pdetail-content,
.bd-content {
    /* 字体优化 */
    font-size: 16px;
    line-height: 1.85;
    color: #333;
    /* 字间距优化 */
    letter-spacing: 0.3px;
    /* 单词间距优化（英文） */
    word-spacing: 1px;
}

/* 标题优化 */
.article-content h2,
.post-content h2,
.entry-content h2,
.pdetail-content h2,
.bd-content h2 {
    font-size: 22px;
    color: #2d1f12;
    margin: 36px 0 18px;
    padding: 12px 16px;
    background: linear-gradient(90deg, #FAF7F2 0%, transparent 100%);
    border-left: 4px solid #C9A96E;
    border-radius: 0 8px 8px 0;
    font-weight: 600;
    scroll-margin-top: 80px;
}
.article-content h3,
.post-content h3,
.entry-content h3,
.pdetail-content h3,
.bd-content h3 {
    font-size: 18px;
    color: #8B6914;
    margin: 28px 0 14px;
    font-weight: 600;
    scroll-margin-top: 80px;
}
.article-content h3::before,
.post-content h3::before,
.entry-content h3::before,
.pdetail-content h3::before,
.bd-content h3::before {
    content: "▸";
    color: #C9A96E;
    margin-right: 8px;
}
.article-content h4,
.post-content h4,
.entry-content h4,
.pdetail-content h4,
.bd-content h4 {
    font-size: 16px;
    color: #3d2820;
    margin: 22px 0 12px;
    font-weight: 600;
    scroll-margin-top: 80px;
}

/* 段落优化 */
.article-content p,
.post-content p,
.entry-content p,
.pdetail-content p,
.bd-content p {
    margin-bottom: 18px;
    text-align: justify;
    text-justify: inter-ideograph;
}

/* 列表优化 */
.article-content ul,
.post-content ul,
.entry-content ul,
.pdetail-content ul,
.bd-content ul,
.article-content ol,
.post-content ol,
.entry-content ol,
.pdetail-content ol,
.bd-content ol {
    margin: 18px 0;
    padding-left: 28px;
}
.article-content li,
.post-content li,
.entry-content li,
.pdetail-content li,
.bd-content li {
    margin-bottom: 10px;
    line-height: 1.8;
}
.article-content ul li::marker,
.post-content ul li::marker,
.entry-content ul li::marker,
.pdetail-content ul li::marker,
.bd-content ul li::marker {
    color: #C9A96E;
}

/* 引用块优化 */
.article-content blockquote,
.post-content blockquote,
.entry-content blockquote,
.pdetail-content blockquote,
.bd-content blockquote {
    margin: 24px 0;
    padding: 16px 20px;
    background: #FAF7F2;
    border-left: 4px solid #C9A96E;
    border-radius: 0 8px 8px 0;
    color: #5a4a3a;
    font-style: italic;
}
.article-content blockquote p,
.post-content blockquote p,
.entry-content blockquote p,
.pdetail-content blockquote p,
.bd-content blockquote p {
    margin-bottom: 0;
}

/* 代码块优化 */
.article-content pre,
.post-content pre,
.entry-content pre,
.pdetail-content pre,
.bd-content pre {
    background: #2d1f12;
    color: #e8d8c0;
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
    font-size: 14px;
    line-height: 1.6;
}
.article-content code,
.post-content code,
.entry-content code,
.pdetail-content code,
.bd-content code {
    background: #f0e8d8;
    color: #8B6914;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}
.article-content pre code,
.post-content pre code,
.entry-content pre code,
.pdetail-content pre code,
.bd-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* 表格优化 */
.article-content table,
.post-content table,
.entry-content table,
.pdetail-content table,
.bd-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 14px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.article-content th,
.post-content th,
.entry-content th,
.pdetail-content th,
.bd-content th {
    background: #3d2820;
    color: #fff;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
}
.article-content td,
.post-content td,
.entry-content td,
.pdetail-content td,
.bd-content td {
    padding: 10px 16px;
    border-bottom: 1px solid #e8d8c0;
}
.article-content tr:nth-child(even) td,
.post-content tr:nth-child(even) td,
.entry-content tr:nth-child(even) td,
.pdetail-content tr:nth-child(even) td,
.bd-content tr:nth-child(even) td {
    background: #FAF7F2;
}

/* 图片优化 */
.article-content img,
.post-content img,
.entry-content img,
.pdetail-content img,
.bd-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 20px auto;
    display: block;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: zoom-in;
    transition: transform 0.3s;
}
.article-content img:hover,
.post-content img:hover,
.entry-content img:hover,
.pdetail-content img:hover,
.bd-content img:hover {
    transform: scale(1.02);
}
.article-content figcaption,
.post-content figcaption,
.entry-content figcaption,
.pdetail-content figcaption,
.bd-content figcaption {
    text-align: center;
    color: #888;
    font-size: 13px;
    margin-top: -10px;
    margin-bottom: 20px;
}

/* 图片灯箱 */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.image-lightbox.active {
    display: flex;
}
.image-lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.image-lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    background: none;
    border: none;
    z-index: 100001;
}

/* ===== 5. 文章导读摘要 ===== */
.article-summary {
    background: linear-gradient(135deg, #FAF7F2 0%, #f5efe6 100%);
    border: 1px solid #e8d8c0;
    border-radius: 12px;
    padding: 20px 24px;
    margin: 24px 0 30px;
    position: relative;
}
.article-summary::before {
    content: "📝 本文导读";
    position: absolute;
    top: -12px;
    left: 20px;
    background: #C9A96E;
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}
.article-summary p {
    margin: 8px 0 0;
    color: #5a4a3a;
    font-size: 14px;
    line-height: 1.7;
}

/* ===== 6. 相关文章推荐 ===== */
.related-articles {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 2px solid #e8d8c0;
}
.related-articles-title {
    font-size: 20px;
    color: #2d1f12;
    margin-bottom: 20px;
    font-weight: 600;
}
.related-articles-title::before {
    content: "🔗";
    margin-right: 8px;
}
.related-articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.related-article-card {
    background: #fff;
    border: 1px solid #e8d8c0;
    border-radius: 10px;
    padding: 16px;
    transition: all 0.3s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.related-article-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    border-color: #C9A96E;
}
.related-article-card h4 {
    font-size: 14px;
    color: #2d1f12;
    margin: 0 0 8px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.related-article-card .ra-meta {
    font-size: 12px;
    color: #999;
}

/* ===== 7. 移动端优化（768px以下）===== */
@media (max-width: 768px) {
    /* 阅读进度条 */
    .reading-progress-bar {
        height: 2px;
    }
    
    /* 返回顶部按钮 */
    .back-to-top-btn {
        bottom: 70px;
        right: 12px;
        width: 42px;
        height: 42px;
        font-size: 18px;
    }
    
    /* 目录导航 */
    .article-toc {
        padding: 16px;
        margin: 20px 0;
    }
    .article-toc-title {
        font-size: 15px;
    }
    .article-toc-list a {
        font-size: 13px;
        padding: 6px 8px;
    }
    
    /* 移动端目录折叠 */
    .article-toc .article-toc-list {
        display: none;
    }
    .article-toc.open .article-toc-list {
        display: block;
    }
    .article-toc .article-toc-title {
        cursor: pointer;
        justify-content: space-between;
    }
    .article-toc .article-toc-title::after {
        content: "▼";
        font-size: 12px;
        color: #C9A96E;
        transition: transform 0.3s;
    }
    .article-toc.open .article-toc-title::after {
        transform: rotate(180deg);
    }
    
    /* 文章内容排版 */
    .article-content,
    .post-content,
    .entry-content,
    .pdetail-content,
    .bd-content {
        font-size: 15px;
        line-height: 1.9;
    }
    
    /* 标题 */
    .article-content h2,
    .post-content h2,
    .entry-content h2,
    .pdetail-content h2,
    .bd-content h2 {
        font-size: 19px;
        margin: 28px 0 14px;
        padding: 10px 14px;
    }
    .article-content h3,
    .post-content h3,
    .entry-content h3,
    .pdetail-content h3,
    .bd-content h3 {
        font-size: 17px;
        margin: 22px 0 12px;
    }
    .article-content h4,
    .post-content h4,
    .entry-content h4,
    .pdetail-content h4,
    .bd-content h4 {
        font-size: 15px;
        margin: 18px 0 10px;
    }
    
    /* 段落 */
    .article-content p,
    .post-content p,
    .entry-content p,
    .pdetail-content p,
    .bd-content p {
        margin-bottom: 16px;
    }
    
    /* 列表 */
    .article-content ul,
    .post-content ul,
    .entry-content ul,
    .pdetail-content ul,
    .bd-content ul,
    .article-content ol,
    .post-content ol,
    .entry-content ol,
    .pdetail-content ol,
    .bd-content ol {
        padding-left: 22px;
    }
    .article-content li,
    .post-content li,
    .entry-content li,
    .pdetail-content li,
    .bd-content li {
        margin-bottom: 8px;
    }
    
    /* 引用块 */
    .article-content blockquote,
    .post-content blockquote,
    .entry-content blockquote,
    .pdetail-content blockquote,
    .bd-content blockquote {
        padding: 14px 16px;
        margin: 20px 0;
    }
    
    /* 代码块 */
    .article-content pre,
    .post-content pre,
    .entry-content pre,
    .pdetail-content pre,
    .bd-content pre {
        padding: 12px 14px;
        font-size: 13px;
    }
    
    /* 表格 - 移动端横向滚动 */
    .article-content table,
    .post-content table,
    .entry-content table,
    .pdetail-content table,
    .bd-content table {
        font-size: 13px;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    .article-content th,
    .post-content th,
    .entry-content th,
    .pdetail-content th,
    .bd-content th,
    .article-content td,
    .post-content td,
    .entry-content td,
    .pdetail-content td,
    .bd-content td {
        padding: 8px 12px;
    }
    
    /* 图片 */
    .article-content img,
    .post-content img,
    .entry-content img,
    .pdetail-content img,
    .bd-content img {
        margin: 16px auto;
        border-radius: 6px;
    }
    
    /* 文章导读 */
    .article-summary {
        padding: 16px 18px;
        margin: 20px 0 24px;
    }
    .article-summary p {
        font-size: 13px;
    }
    
    /* 相关文章 - 移动端单列 */
    .related-articles-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .related-articles-title {
        font-size: 18px;
    }
}

/* ===== 8. 小屏幕手机（480px以下）===== */
@media (max-width: 480px) {
    .article-content,
    .post-content,
    .entry-content,
    .pdetail-content,
    .bd-content {
        font-size: 14px;
        line-height: 1.95;
    }
    .article-content h2,
    .post-content h2,
    .entry-content h2,
    .pdetail-content h2,
    .bd-content h2 {
        font-size: 18px;
    }
    .article-content h3,
    .post-content h3,
    .entry-content h3,
    .pdetail-content h3,
    .bd-content h3 {
        font-size: 16px;
    }
}

/* ===== 9. PC端专属优化（769px以上）===== */
@media (min-width: 769px) {
    /* 文章内容最大宽度限制（避免行宽过大） */
    .article-content,
    .post-content,
    .entry-content,
    .pdetail-content,
    .bd-content {
        max-width: 820px;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* 英文内容行宽更窄 */
    .article-content:lang(en),
    .post-content:lang(en),
    .entry-content:lang(en),
    .pdetail-content:lang(en),
    .bd-content:lang(en) {
        max-width: 720px;
        line-height: 1.75;
    }
}

/* ===== 10. 打印样式 ===== */
@media print {
    .reading-progress-bar,
    .back-to-top-btn,
    .article-toc,
    .related-articles,
    .image-lightbox {
        display: none !important;
    }
    .article-content,
    .post-content,
    .entry-content,
    .pdetail-content,
    .bd-content {
        max-width: 100%;
        font-size: 12pt;
        line-height: 1.6;
        color: #000;
    }
    .article-content h2,
    .post-content h2,
    .entry-content h2,
    .pdetail-content h2,
    .bd-content h2 {
        page-break-after: avoid;
        background: none;
        border-left: 3px solid #000;
        color: #000;
    }
    .article-content img,
    .post-content img,
    .entry-content img,
    .pdetail-content img,
    .bd-content img {
        max-width: 100%;
        page-break-inside: avoid;
        box-shadow: none;
    }
}

/* ============================================
   PC端双栏布局已移除（用户要求还原单栏布局）
   ============================================ */

/* 隐藏手机端多余的旧footer（案例详情页等页面的.footer类，不影响统一的.zy-footer） */
@media (max-width: 768px) {
    footer.footer {
        display: none !important;
    }
}

/* 隐藏多余的返回顶部按钮，保留原有的浮动按钮组中的返回顶部按钮 #backToTopBtn */
.back-to-top-btn,
#floatTop {
    display: none !important;
}

/* 修复产品详情页底部咨询卡片居中问题和按钮变形问题（PC端） */
@media (min-width: 769px) {
    .pdetail-cta {
        max-width: 1200px !important;
        margin: 0 auto 40px !important;
        padding: 0 20px !important;
        width: 100% !important;
    }
    .pdetail-cta .cta-bg {
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .cta-inner {
        justify-content: space-around !important;
        flex-wrap: nowrap !important;
    }
    .cta-btn {
        white-space: nowrap !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* 阅读时间显示 */
.reading-time-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #FAF7F2;
    border: 1px solid #e8d8c0;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    color: #8B6914;
    margin-bottom: 20px;
}
.reading-time-badge::before {
    content: "⏱️";
    font-size: 14px;
}

/* 章节锚点分享按钮 */
.heading-anchor-link {
    display: inline-block;
    margin-left: 8px;
    color: #C9A96E;
    text-decoration: none;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
}
.article-content h2:hover .heading-anchor-link,
.post-content h2:hover .heading-anchor-link,
.entry-content h2:hover .heading-anchor-link,
.pdetail-content h2:hover .heading-anchor-link,
.bd-content h2:hover .heading-anchor-link {
    opacity: 1;
}
.heading-anchor-link:hover {
    color: #8B6914;
}

/* 复制成功提示 */
.anchor-copy-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(45, 31, 18, 0.9);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 100000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.anchor-copy-toast.show {
    opacity: 1;
}
