/**
 * 文章页面通用样式
 * Article Page Common Styles
 * 
 * 此文件包含所有文章页面的通用样式，避免在每个HTML文件中重复编写CSS代码
 */

/* ==================== 基础布局修正 ==================== */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

body {
    padding: 15px;
    box-sizing: border-box;
    font-family: "Noto Sans", "Arial", "Microsoft YaHei", "PingFang SC", sans-serif;
    line-height: 1.8;
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==================== 基础变量定义 ==================== */

:root {
    /* 亮色主题变量 */
    --bg-primary: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-title: #333333;
    --border-color: #e0e0e0;
    --accent-primary: #e53935;
    --accent-hover: #c62828;
    --quote-bg: #fff3e0;
    --hero-gradient-start: #e53935;
    --hero-gradient-end: #ff7043;
    --top-actions-bg: rgba(0,0,0,0.03);
}

/* 深色主题变量 */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-title: #ffffff;
    --border-color: #404040;
    --accent-primary: #ff7043;
    --accent-hover: #ff8a65;
    --quote-bg: #3e2723;
    --hero-gradient-start: #ff7043;
    --hero-gradient-end: #ff5722;
    --top-actions-bg: rgba(255,255,255,0.08);
}

/* 标题样式 */
h1 {
    font-size: 2em;
    color: var(--text-title);
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    border-bottom: 3px solid var(--accent-primary);
    padding-bottom: 0.3em;
}

/* 文章容器内的h1特殊样式 */
.article-container h1,
article > h1 {
    margin-top: 0;
    margin-bottom: 0.8em;
}

h2 {
    font-size: 1.5em;
    color: #d32f2f;
    margin-top: 1.5em;
    margin-bottom: 0.8em;
}

h3 {
    font-size: 1.2em;
    color: #333333;
    margin-top: 1.2em;
    margin-bottom: 0.6em;
}

[data-theme="dark"] h3 {
    color: #ffffff;
}

p {
    margin-bottom: 1.2em;
    text-align: justify;
}

/* ==================== 顶部功能区样式 ==================== */

/* 文章头部容器 */
.article-header {
    background: transparent !important;
    padding: 0;
    margin-bottom: 1em;
}

/* 顶部功能区容器 - 按钮区域 */
.top-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.5em;
    margin-bottom: 10px;
    background: transparent;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

/* 主题切换按钮 */
.theme-toggle {
    background: var(--accent-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

/* 分享按钮 - 推向右侧 */
.share-btn {
    margin-left: auto;
    background: var(--accent-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover,
.share-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

/* ==================== Hero区域样式（优化后） ==================== */

.hero-image {
    width: 100%;
    height: auto;
    min-height: 100px;
    background: linear-gradient(135deg, var(--hero-gradient-start) 0%, var(--hero-gradient-end) 100%);
    border-radius: 12px;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 1em;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    padding: 1.5em;
    box-sizing: border-box;
    overflow: hidden;
}

/* Hero内的H1标题 - 白色文字带阴影 */
.hero-image .article-title,
.hero-image > h1 {
    color: #ffffff;
    font-size: 1.8em;
    font-weight: bold;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.4);
    margin: 0;
    padding: 0;
    line-height: 1.3;
    border: none;
    display: block !important;
    word-wrap: break-word;
}

[data-theme="dark"] .hero-image .article-title,
[data-theme="dark"] .hero-image > h1 {
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.6);
}

/* ==================== 引用区块样式 ==================== */

.quote,
.quote-box {
    background: var(--quote-bg);
    border-left: 4px solid #ff9800;
    padding: 1em 1.5em;
    margin: 1.5em 0;
    font-style: italic;
}

/* ==================== 汉字链接样式 ==================== */

.han-character,
.internal-link {
    color: var(--accent-primary);
    font-weight: bold;
    text-decoration: none;
    border-bottom: 1px dashed var(--accent-primary);
    transition: all 0.3s ease;
}

.han-character:hover,
.internal-link:hover {
    color: var(--accent-hover);
    border-bottom-style: solid;
}

/* ==================== 文章容器和内容样式 ==================== */

/* 文章容器 */
.article-container {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 1em;
    transition: background-color 0.3s ease;
}

/* 文章内容区域 */
.article-content {
    line-height: 1.8;
}

/* article标签 */
article {
    margin-top: 1em;
}

/* ==================== 文章底部导航样式 ==================== */

.article-footer {
    margin-top: 0;
    padding-top: 1em;
    border-top: 1px solid var(--border-color);
}

.bottom-nav {
    display: flex;
    justify-content: center;
    gap: 1em;
    padding: 1em 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.5em 1em;
    background: var(--accent-primary);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-item:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.nav-icon {
    font-size: 1.2em;
}

.nav-text {
    font-weight: 500;
}

/* ==================== 语言提示样式 ==================== */

.lang-notice {
    background: #e3f2fd;
    padding: 0.5em 1em;
    border-radius: 4px;
    margin-bottom: 1em;
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* ==================== 返回按钮样式 ==================== */

.back-btn {
    display: inline-block;
    margin-bottom: 1em;
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.back-btn:hover {
    text-decoration: underline;
    color: var(--accent-hover);
}

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

.article-meta {
    margin-bottom: 1.5em;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.article-meta span {
    margin-right: 1em;
}

/* 删除伪元素，因为HTML中已包含标签文字 */
.author::before,
.date::before {
    content: "" !important;
}

/* ==================== 文章容器样式 ==================== */

.article-container {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 1em;
    transition: background-color 0.3s ease;
}

.article-content {
    line-height: 1.8;
}

/* 文章标题特殊样式 */
.article-title {
    color: var(--text-title);
}

[data-theme="dark"] .article-title {
    color: #ffffff;
}

/* ==================== 特性列表样式 ==================== */

.feature-list {
    list-style-type: none;
    padding-left: 0;
    margin: 1em 0;
}

.feature-list li {
    padding: 0.5em 0;
    padding-left: 1.5em;
    position: relative;
}

.feature-list li::before {
    content: "•";
    color: var(--accent-primary);
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* ==================== 表格样式 ==================== */

.timeline-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.95em;
}

.timeline-table th,
.timeline-table td {
    border: 1px solid var(--border-color);
    padding: 0.8em;
    text-align: left;
}

.timeline-table th {
    background: var(--accent-primary);
    color: white;
}

.timeline-table tr:nth-child(even) {
    background: rgba(0,0,0,0.02);
}

.timeline-table tr:hover {
    background: rgba(229, 57, 53, 0.05);
}

/* ==================== 相关文章区域样式 ==================== */

.related-articles {
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
    padding: 1.5em;
    margin: 2em 0;
    transition: background-color 0.3s ease;
}

[data-theme="dark"] .related-articles {
    background: rgba(255,255,255,0.05);
}

.related-articles h3 {
    margin-top: 0;
    color: var(--accent-primary);
}

.related-articles ul {
    list-style-type: none;
    padding-left: 0;
}

.related-articles li {
    padding: 0.5em 0;
    border-bottom: 1px solid var(--border-color);
}

.related-articles li:last-child {
    border-bottom: none;
}

.related-articles a {
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5em;
    transition: color 0.3s ease;
}

.related-articles a:hover {
    color: var(--accent-primary);
}

/* ==================== 行动号召区域样式 ==================== */

.cta-section {
    background: linear-gradient(135deg, var(--hero-gradient-start) 0%, var(--hero-gradient-end) 100%);
    padding: 1.5em;
    border-radius: 12px;
    text-align: center;
    margin: 1.5em 0 0.5em 0;
}

.cta-section p {
    color: white;
    margin-bottom: 1em;
    font-size: 1.1em;
    text-align: center;
}

.cta-btn {
    display: inline-block;
    padding: 0.8em 1.5em;
    background: white;
    color: var(--accent-primary);
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cta-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* ==================== 翻译待处理样式 ==================== */

.translation-pending {
    background: #fff9c4;
    border: 2px dashed #ffc107;
    border-radius: 8px;
    padding: 2em;
    text-align: center;
    margin: 2em 0;
}

.translation-pending h2 {
    color: #f57c00;
    margin-top: 0;
}

.translation-pending p {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
}

/* ==================== 外部链接样式 ==================== */

.article-content a.external-link {
    color: #1976d2;
    text-decoration: none;
    border-bottom: 1px dashed #1976d2;
    transition: all 0.3s ease;
}

.article-content a.external-link:hover {
    border-bottom-style: solid;
    color: #1565c0;
}

/* ==================== Toast提示样式 ==================== */

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9em;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toast.show {
    opacity: 1;
}

/* ==================== 时间线样式 ==================== */

.timeline {
    position: relative;
    padding-left: 2em;
    margin: 1.5em 0;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5em;
    padding-left: 1em;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -2em;
    top: 0.5em;
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    border-radius: 50%;
    border: 2px solid white;
}

.timeline-date {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 0.3em;
}

/* ==================== 代码块样式 ==================== */

pre {
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    padding: 1em;
    overflow-x: auto;
    margin: 1.5em 0;
}

[data-theme="dark"] pre {
    background: rgba(255,255,255,0.1);
}

code {
    font-family: "Consolas", "Monaco", monospace;
    font-size: 0.9em;
}

/* ==================== 图片样式 ==================== */

.article-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1em 0;
}

.image-caption {
    font-size: 0.9em;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.5em;
    font-style: italic;
}

/* ==================== 标签样式 ==================== */

.tag {
    display: inline-block;
    background: rgba(0,0,0,0.05);
    color: var(--accent-primary);
    padding: 0.2em 0.6em;
    border-radius: 4px;
    font-size: 0.85em;
    margin-right: 0.5em;
    margin-bottom: 0.5em;
}

[data-theme="dark"] .tag {
    background: rgba(255,255,255,0.1);
}

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

@media (max-width: 600px) {
    body {
        padding: 15px;
    }

    h1 {
        font-size: 1.6em;
    }

    h2 {
        font-size: 1.3em;
    }

    .top-actions {
        padding: 0;
    }

    .share-btn {
        margin-right: 2px;
    }

    .bottom-nav {
        flex-direction: column;
        align-items: center;
    }

    .nav-item {
        width: 100%;
        justify-content: center;
    }

    .hero-image {
        padding: 1.2em;
        height: auto;
        min-height: 80px;
    }

    .hero-image .article-title,
    .hero-image > h1 {
        font-size: 1.4em;
        text-align: left;
    }

    .cta-section {
        padding: 1.5em;
    }
}
