/*
 * 文件：static/css/blog-detail.css
 * 作用：博客详情页样式（面包屑 + 头部 + 正文 + TOC + 分享 + 上下篇）
 * 解决什么问题：让单篇文章页有清晰导航、优雅排版、丰富阅读体验
 * 创建：2026-09-12
 * 作者：大军 + 小军
 *
 * 设计理念：克制的丰富 —— 每一个元素都有功能，不是装饰
 * - 面包屑：SEO + 导航
 * - 标题区：分类色 + 大字标题 + meta 信息
 * - 正文：最大可读宽度 720px，行高 1.8
 * - 右侧 TOC：sticky，电脑端固定
 * - 移动端 TOC：details/summary 折叠
 * - 代码块：Pygments 自动加 class="highlight" + 浅灰底
 * - 分享按钮：5 个主流平台
 * - 上下篇：grid 双列布局
 */

/* ========== 文章容器 ========== */
.post-detail {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px 64px;}

/* ========== 面包屑 ========== */
.breadcrumb {
    margin-bottom: 24px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}
.breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
}
.breadcrumb-item {
    display: inline-flex;
    align-items: center;
}
.breadcrumb-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}
.breadcrumb-link:hover {
    color: var(--color-accent);
}
.breadcrumb-sep {
    margin: 0 8px;
    color: var(--color-text-secondary);
    opacity: 0.5;
}
.breadcrumb-current {
    color: var(--color-text-primary);
    font-weight: 500;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (max-width: 768px) {
    /* 🆕 2026-09-21: mobile 上避免 400px 撑爆屏宽 */
    .breadcrumb-current {
        max-width: 100%;
    }
}

/* ========== 文章头部 ========== */
.post-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--color-border);
}
.post-category {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 12px;
}
/* 6 分类色（与列表页一致）*/
.post-category[data-color="efficiency"] { color: #0066cc; background: rgba(0,102,204,0.10); }
.post-category[data-color="environment"] { color: #228b22; background: rgba(34,139,34,0.10); }
.post-category[data-color="problem"] { color: #d97a00; background: rgba(217,122,0,0.10); }
.post-category[data-color="pitfall"] { color: #c91842; background: rgba(201,24,66,0.10); }
.post-category[data-color="thought"] { color: #7d22ce; background: rgba(138,43,226,0.10); }
.post-category[data-color="ai_creation"] { color: #e754a8; background: rgba(231,84,168,0.10); }

.post-title {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text-primary);
    margin: 0 0 16px;
}
.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}
.post-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.post-meta-icon {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}
.post-meta-dot {
    opacity: 0.4;
}

/* ========== 主体布局（正文 + 侧边 TOC）========== */
.post-body-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
}
/* 电脑端：正文 + 右侧 TOC */
@media (min-width: 1024px) {
    .post-body-wrapper {
        grid-template-columns: 1fr 240px;
        gap: 48px;
        align-items: start;
    }
}

/* ========== 正文 ========== */
/* =============================================================================
   V1 SEO 体检报告 P2-5：文章页移动端点击延迟优化（额外加固）
   site.css 全站 button / a 已覆盖；这里再加文章内链接专用规则
   原因：文章里链接密度高（内部链接/外链/锚点），单独加固
   ============================================================================= */
.post-content a {
    touch-action: manipulation;  /* 移动端点击立即触发，零延迟 */
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);  /* iOS 蓝色高亮改为主题色 */
}

.post-content a:active {
    background-color: rgba(99, 102, 241, 0.1);  /* 紫色背景反馈（主题色 #6366f1）*/
}

.post-content {
    max-width: 720px;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--color-text-primary);
}
/* 标题 */
.post-content h1, .post-content h2, .post-content h3, .post-content h4 {
    margin-top: 2em;
    margin-bottom: 0.75em;
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-text-primary);
    scroll-margin-top: 80px; /* 锚点跳转时不贴顶 */
}
.post-content h2 {
    font-size: 1.625rem;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}
.post-content h3 {
    font-size: 1.25rem;
}
.post-content h4 {
    font-size: 1.0625rem;
}
/* 段落 */
.post-content p {
    margin: 0 0 1em;
    text-indent: 2em;
}
/* 🆕 2026-10-05: FAQ 答案段落例外（通过后端加 class="faq-answer" 精确匹配）*/
.post-content p.faq-answer {
    text-indent: 0;
}
/* 🆕 2026-10-05: 通用顶格段落 —— 文章里给段落加 class="noindent" 即可不缩进 */
.post-content p.noindent,
.post-content .noindent p {
    text-indent: 0;
}
/* 链接 */
.post-content a {
    color: var(--color-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}
.post-content a:hover {
    border-bottom-color: var(--color-accent);
}
/* 列表 */
.post-content ul, .post-content ol {
    margin: 0 0 1em;
    padding-left: 1.5em;
}
.post-content li {
    margin: 0.25em 0;
}
/* 引用 */
.post-content blockquote {
    margin: 1.5em 0;
    padding: 12px 20px;
    border-left: 4px solid var(--color-accent);
    background: var(--color-accent-bg);
    color: var(--color-text-secondary);
    border-radius: 0 6px 6px 0;
}
.post-content blockquote p:last-child {
    margin-bottom: 0;
}
/* 行内代码 */
.post-content code {
    padding: 2px 6px;
    background: rgba(135,131,120,0.15);
    border-radius: 3px;
    font-size: 0.9em;
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
}
/* 代码块（Pygments 高亮）*/
.post-content pre {
    margin: 1.5em 0;
    padding: 16px 20px;
    background: #f6f8fa;
    border-radius: 8px;
    overflow-x: auto;
    line-height: 1.6;
    font-size: 0.875rem;
}
.post-content pre code {
    padding: 0;
    background: transparent;
    color: inherit;
    font-size: inherit;
}
.post-content .highlight {
    background: #f6f8fa;
    border-radius: 8px;
    margin: 1.5em 0;
}
.post-content .highlight pre {
    margin: 0;
}
/* 表格 */
.post-content table {
    width: 100%;
    margin: 1.5em 0;
    border-collapse: collapse;
    font-size: 0.9375rem;
}
.post-content th, .post-content td {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    text-align: left;
}
.post-content th {
    background: var(--color-accent-bg);
    font-weight: 600;
}
/* 图片 */
.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 1em 0;
}

/* ========== 标签云 ========== */
.post-tags {
    margin-top: 2em;
    padding-top: 1em;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.post-tags-icon {
    width: 16px;
    height: 16px;
    color: var(--color-text-secondary);
    margin-right: 4px;
}
.post-tag {
    padding: 4px 10px;
    background: var(--color-accent-bg);
    color: var(--color-accent);
    border-radius: 14px;
    font-size: 0.8125rem;
}

/* ========== 电脑端右侧 TOC ========== */
.post-toc-sidebar {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 16px;
    background: var(--color-bg-secondary, #f8f9fa);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.8125rem;
}
.post-toc-sidebar-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--color-text-secondary);
}
.post-toc-icon {
    width: 14px;
    height: 14px;
}
.post-toc-sidebar-content ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.post-toc-sidebar-content ul ul {
    padding-left: 12px;
    margin-top: 4px;
}
.post-toc-sidebar-content a {
    display: block;
    padding: 4px 8px;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}
.post-toc-sidebar-content a:hover {
    background: var(--color-accent-bg);
    color: var(--color-accent);
}
.post-toc-sidebar-content a.is-active {
    background: var(--color-accent-bg);
    color: var(--color-accent);
    border-left-color: var(--color-accent);
    font-weight: 500;
}

/* ========== 移动端 TOC（折叠）========== */
.post-toc-mobile {
    display: none;
    margin-bottom: 24px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}
@media (max-width: 1023px) {
    .post-toc-mobile { display: block; }
}
.post-toc-mobile-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--color-bg-secondary, #f8f9fa);
    cursor: pointer;
    list-style: none;
    font-weight: 500;
}
.post-toc-mobile-summary::-webkit-details-marker {
    display: none;
}
.post-toc-toggle-icon {
    width: 16px;
    height: 16px;
    margin-left: auto;
    transition: transform 0.3s ease;
}
.post-toc-mobile[open] .post-toc-toggle-icon {
    transform: rotate(180deg);
}
.post-toc-mobile-content {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    font-size: 0.875rem;
}
.post-toc-mobile-content ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.post-toc-mobile-content ul ul {
    padding-left: 16px;
}
.post-toc-mobile-content a {
    display: block;
    padding: 6px 0;
    color: var(--color-text-secondary);
    text-decoration: none;
}

/* ========== 分享按钮 ========== */
.post-share {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 48px 0 32px;
    padding: 20px;
    background: var(--color-bg-secondary, #f8f9fa);
    border-radius: 8px;
}
.post-share-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-right: 4px;
}
.post-share-icon {
    width: 16px;
    height: 16px;
}
.post-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.8125rem;
    color: var(--color-text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.post-share-btn:hover {
    background: var(--color-accent-bg);
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: translateY(-1px);
}
.post-share-copy.is-copied {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

/* ========== 上一篇 / 下一篇 ========== */
.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}
.post-nav-link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    background: var(--color-bg-secondary, #f8f9fa);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}
.post-nav-link:hover {
    background: var(--color-accent-bg);
    border-color: var(--color-accent);
}
.post-nav-next {
    text-align: right;
}
.post-nav-direction {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.post-nav-title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}
.post-nav-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.post-nav-disabled:hover {
    background: var(--color-bg-secondary, #f8f9fa);
    border-color: var(--color-border);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .post-detail {
        padding: 24px 16px 48px;
    }

    /* 🆕 2026-09-21 01:40: 精准修复 mobile 撑爆 */
    /* H1 标题过长时缩小 + 强制换行 */
    .post-title {
        font-size: 1.375rem !important;
        line-height: 1.4;
        word-break: break-word;
        overflow-wrap: anywhere;
        hyphens: auto;
    }
    
    /* post-content 限宽 100%（不靠 hidden 截断） */
    .post-content {
        max-width: 100% !important;
        overflow-x: hidden;  /* 让内部超长内容不撑爆，但允许内部滚动 */
    }
    
    /* 表格 mobile 用 transform 缩放 + 横向滚动备选 */
    .post-content table {
        display: block;
        max-width: 100%;
        font-size: 0.8125rem;  /* 13px 表格字号 */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .post-content table th,
    .post-content table td {
        padding: 6px 8px !important;
        word-break: break-word;
        font-size: 0.8125rem;
    }
    .post-title {
        font-size: 1.75rem;
    }
    .post-content {
        font-size: 0.9375rem;
        max-width: 100%;  /* 🆕 2026-09-21: 不让 720px max-width 在小屏撑爆 */
    }
    .post-nav {
        grid-template-columns: 1fr;
    }
    .post-share {
        padding: 16px;
    }
    .post-share-btn {
        flex: 1;
        justify-content: center;
    }

    /* 🆕 C 保守版 (2026-09-21 00:16) */
    /* h2/h3 字号缩小 + 长标题强制换行 */
    .post-content h2 {
        font-size: 1.375rem;
        word-break: break-word;
    }
    .post-content h3 {
        font-size: 1.125rem;
        word-break: break-word;
    }

    /* 表格 mobile 横向滚动（不撑爆屏宽） */
    .post-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ========== 深色主题 ========== */
[data-theme="dark"] .post-content pre,
[data-theme="dark"] .post-content .highlight {
    background: #161b22;
    color: #c9d1d9;
}
[data-theme="dark"] .post-content code {
    background: rgba(135,131,120,0.25);
    color: #c9d1d9;
}
[data-theme="dark"] .post-toc-sidebar,
[data-theme="dark"] .post-share,
[data-theme="dark"] .post-toc-mobile-content,
[data-theme="dark"] .post-nav-link {
    background: #161b22;
}
[data-theme="dark"] .post-toc-mobile-summary {
    background: #0d1117;
}
