/* 文章页样式 - 沉浸式阅读体验 */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.back-link:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* ===== 文章主体 ===== */
article {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 44px;
    box-shadow: var(--shadow);
}
article h1 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: var(--text);
    margin-bottom: 14px;
    line-height: 1.25;
    letter-spacing: -0.02em;
    font-weight: 750;
}

.meta {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.meta .reading-time, .meta .view-count { font-size: 0.85em; color: var(--text-faint); }

/* ===== 正文排版 ===== */
.article-content {
    font-size: 1.02rem;
    line-height: 1.8;
    color: var(--text);
}
.article-content > *:first-child { margin-top: 0; }
.article-content h2 {
    color: var(--text);
    margin: 32px 0 14px;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.article-content h3 {
    color: var(--text);
    margin: 26px 0 10px;
    font-size: 1.18rem;
    font-weight: 650;
}
.article-content h4 { color: var(--text); margin: 22px 0 8px; font-size: 1.05rem; font-weight: 600; }
.article-content p { margin-bottom: 16px; }
.article-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.article-content a:hover { color: var(--accent-hover); }

.article-content code {
    background: var(--inline-code-bg);
    color: var(--text);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.88em;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    border: 1px solid var(--border);
}
.article-content pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 18px 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 18px 0;
    font-size: 0.88rem;
    line-height: 1.6;
    border: 1px solid var(--border);
}
.article-content pre code { background: none; padding: 0; color: inherit; border: none; font-size: inherit; }

/* 代码块容器（复制按钮 + 横向滚动） */
.code-block { position: relative; margin: 18px 0; }
.code-block pre { margin: 0; }
.code-block .code-copy {
    position: absolute; top: 10px; right: 10px;
    padding: 4px 12px; font-size: 0.75rem; font-weight: 500;
    color: var(--code-text); background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15); border-radius: var(--radius-sm);
    cursor: pointer; opacity: 0; transition: opacity var(--transition), background var(--transition);
}
.code-block:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-block .code-copy:hover { background: rgba(255,255,255,0.16); }
.code-block .code-copy.copied { background: var(--success); border-color: var(--success); color: #fff; }
@media (max-width: 768px) { .code-block .code-copy { opacity: 1; } }

.article-content blockquote {
    border-left: 4px solid var(--blockquote-border);
    padding: 12px 22px;
    margin: 18px 0;
    background: var(--blockquote-bg);
    color: var(--text-muted);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.article-content blockquote p:last-child { margin-bottom: 0; }

.article-content ul, .article-content ol { margin: 14px 0; padding-left: 26px; }
.article-content li { margin-bottom: 8px; }
.article-content ul li::marker { color: var(--accent); }

.article-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 18px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}
.article-content th, .article-content td { border-bottom: 1px solid var(--border); padding: 10px 14px; text-align: left; }
.article-content th { background: var(--bg-subtle); font-weight: 600; font-size: 0.92em; }
.article-content tr:last-child td { border-bottom: none; }
.article-content img { max-width: 100%; border-radius: var(--radius); margin: 16px 0; }
.article-content hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

/* 图片懒加载淡入（无 JS 时默认可见） */
.article-content img[data-src] { opacity: 0; transition: opacity 0.4s ease; }
.article-content img.loaded { opacity: 1; }

/* ===== 目录（桌面端侧边吸顶） ===== */
.toc {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}
.toc h4 {
    color: var(--text-faint);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    font-weight: 600;
}
.toc ul { list-style: none; padding-left: 0; }
.toc li { padding: 4px 0; }
.toc a { color: var(--text-muted); font-size: 0.9rem; transition: color var(--transition), padding-left var(--transition); position: relative; }
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc a.active { color: var(--accent); font-weight: 600; }
.toc a.active::before {
    content: ""; position: absolute; left: -22px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 16px; border-radius: 2px; background: var(--accent);
}
.toc .toc-h3 { padding-left: 18px; }
.toc .toc-h3 a.active::before { left: -4px; }

@media (min-width: 1024px) {
    .article-layout { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
    .article-layout .toc { position: sticky; top: calc(var(--nav-height) + 20px); margin-bottom: 0; }
}

/* ===== 相关文章 ===== */
.related {
    margin-top: 36px;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.related h3 { color: var(--text); margin-bottom: 14px; font-size: 1.1rem; font-weight: 700; }
.related-list { list-style: none; }
.related-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.related-list li:last-child { border-bottom: none; }
.related-list li a { color: var(--text); font-weight: 500; transition: color var(--transition); }
.related-list li a:hover { color: var(--accent); text-decoration: none; }

/* ===== 事实核查脚注 ===== */
.fact-check-footnotes {
    margin-top: 22px;
    padding: 18px 20px;
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    border-radius: 0 var(--radius) var(--radius) 0;
}
[data-theme="dark"] .fact-check-footnotes { background: #422006; border-left-color: #f59e0b; }
.fact-check-footnotes h4 { margin-bottom: 10px; color: var(--text); }
.fact-check-footnotes ol { padding-left: 22px; }
.fact-check-footnotes li { margin-bottom: 8px; font-size: 0.9rem; line-height: 1.6; }
.low-confidence { color: #c2410c; font-weight: 600; }

/* ===== 阅读进度条 ===== */
.reading-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    background: var(--gradient-brand);
    width: 0;
    z-index: 999;
    transition: width 0.1s linear;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

/* 移动端缩小内边距 */
@media (max-width: 768px) {
    article { padding: 26px 22px; }
    .article-layout { grid-template-columns: 1fr; }
    .article-layout .toc { position: static; }
}
