/* ========================================
   🎨 AI 知识宇宙 - 主题样式系统
   支持深色/明亮主题切换
   ======================================== */

/* ============ 深色主题（默认） ============ */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #1a2332;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --card-hover: #334155;
    --code-bg: #1e293b;
    --blockquote-bg: #1a2332;
    --table-border: #334155;
    --table-header-bg: #1e293b;
    --shadow: rgba(0, 0, 0, 0.3);
    --gradient-card: linear-gradient(135deg, #1e293b, #1a2332);
    --gradient-affiliate-dark: linear-gradient(135deg, #1e293b, #1a2332);
    --gradient-affiliate-jd: linear-gradient(135deg, #1a2332, #2a1a12);
}

/* ============ 明亮主题 ============ */
[data-theme="light"] {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --card-hover: #f1f5f9;
    --code-bg: #f1f5f9;
    --blockquote-bg: #f8fafc;
    --table-border: #e2e8f0;
    --table-header-bg: #f8fafc;
    --shadow: rgba(0, 0, 0, 0.08);
    --gradient-card: linear-gradient(135deg, #ffffff, #f8fafc);
    --gradient-affiliate-dark: linear-gradient(135deg, #ffffff, #f8fafc);
    --gradient-affiliate-jd: linear-gradient(135deg, #fef2f2, #ffffff);
}

/* ============ 基础样式 ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============ 主题切换按钮 ============ */
.theme-switcher {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
    box-shadow: 0 4px 12px var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 1000;
}

.theme-switcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px var(--shadow);
}

.theme-switcher:active {
    transform: scale(0.95);
}

/* ============ 头部样式 ============ */
header {
    padding: 30px 0;
    border-bottom: 1px solid var(--border);
    transition: border-color 0.3s ease;
}

header h1 {
    font-size: 1.8em;
    display: flex;
    align-items: center;
    gap: 12px;
}

header h1 a {
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-logo {
    height: 48px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
    transition: transform 0.2s ease;
}

header h1 a:hover .site-logo {
    transform: scale(1.05);
}

header h1 a:hover {
    opacity: 0.9;
}

header .desc {
    color: var(--text-secondary);
    font-size: 0.95em;
    margin-top: 5px;
}

nav {
    margin-top: 15px;
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    margin-right: 20px;
    font-size: 0.95em;
    transition: color 0.2s ease;
}

nav a:hover {
    color: var(--primary);
}

/* ============ Hero 区域 ============ */
.hero {
    padding: 60px 0 40px;
    text-align: center;
}

.hero h2 {
    font-size: 2.2em;
    margin-bottom: 15px;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.1em;
    max-width: 600px;
    margin: 0 auto;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 25px;
}

.stats a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: opacity 0.2s;
}

.stats a:hover {
    opacity: 0.7;
}

.stats strong {
    color: var(--primary);
    font-size: 1.3em;
    display: block;
}

/* ============ 文章列表 ============ */
.post-list {
    display: grid;
    gap: 25px;
    margin: 40px 0;
}

.post-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 25px;
    transition: transform 0.2s ease, background-color 0.3s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px var(--shadow);
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow);
}

.post-card .cat {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.8em;
    margin-bottom: 10px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.post-card .cat:hover {
    background: var(--primary-hover);
}

.post-card h3 {
    font-size: 1.3em;
    margin-bottom: 10px;
}

.post-card h3 a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-card h3 a:hover {
    color: var(--primary);
}

.post-card .meta {
    color: var(--text-secondary);
    font-size: 0.85em;
    margin-bottom: 10px;
}

.post-card p {
    color: var(--text-secondary);
    font-size: 0.95em;
}

.post-card .readmore {
    display: inline-block;
    margin-top: 12px;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9em;
}

/* ============ 加载更多 ============ */
.load-more {
    text-align: center;
    padding: 30px 0;
    color: var(--text-secondary);
    font-size: 0.9em;
    min-height: 60px;
}

.load-more .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-secondary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.load-more .done {
    color: var(--primary);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ 文章页面 ============ */
article {
    padding: 40px 0;
}

article h1 {
    font-size: 2em;
    margin-bottom: 15px;
    line-height: 1.3;
}

.post-meta {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    transition: border-color 0.3s ease;
}

.post-meta .cat {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    margin-right: 10px;
}

article h2 {
    font-size: 1.5em;
    margin: 30px 0 15px;
    color: var(--text);
}

article h3 {
    font-size: 1.2em;
    margin: 25px 0 10px;
}

article p {
    margin: 15px 0;
    color: var(--text-secondary);
}

article ul, article ol {
    margin: 15px 0;
    padding-left: 25px;
    color: var(--text-secondary);
}

article li {
    margin: 8px 0;
}

article a {
    color: var(--primary);
}

article blockquote {
    border-left: 4px solid var(--primary);
    padding: 15px 20px;
    margin: 20px 0;
    background: var(--blockquote-bg);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
    transition: background-color 0.3s ease;
}

article code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
}

article pre {
    background: var(--code-bg);
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
    transition: background-color 0.3s ease;
}

article pre code {
    background: none;
    padding: 0;
}

article img {
    max-width: 100%;
    border-radius: 8px;
    margin: 20px 0;
}

article table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

article th, article td {
    padding: 10px 15px;
    border: 1px solid var(--table-border);
    text-align: left;
    transition: border-color 0.3s ease;
}

article th {
    background: var(--table-header-bg);
    transition: background-color 0.3s ease;
}

/* ============ 推广盒子 ============ */
.affiliate-box {
    background: var(--gradient-affiliate-dark);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 25px;
    margin: 30px 0;
    text-align: center;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.affiliate-box p {
    margin: 5px 0;
}

.affiliate-box .btn {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 12px 30px;
    border-radius: 8px;
    text-decoration: none;
    margin-top: 10px;
    font-weight: bold;
    transition: opacity 0.2s ease;
}

.affiliate-box .btn:hover {
    opacity: 0.9;
}

.affiliate-box .note {
    color: var(--text-secondary);
    font-size: 0.8em;
    margin-top: 10px;
}

.affiliate-box.jd {
    border-color: #e8432a;
    background: var(--gradient-affiliate-jd);
}

.affiliate-box.jd .btn {
    background: #e8432a;
}

/* ============ 页脚 ============ */
footer {
    text-align: center;
    padding: 40px 0;
    color: var(--text-secondary);
    font-size: 0.85em;
    border-top: 1px solid var(--border);
    margin-top: 40px;
    transition: border-color 0.3s ease;
}

/* ============ 归档页面 ============ */
.archive-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    transition: border-color 0.3s ease;
}

.archive-filters a {
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9em;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.archive-filters a:hover,
.archive-filters a.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.archive-list {
    display: grid;
    gap: 15px;
}

.archive-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
    transition: border-color 0.3s ease;
}

.archive-item:last-child {
    border-bottom: none;
}

.archive-item .meta {
    display: flex;
    gap: 10px;
    align-items: center;
}

.archive-item .cat {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75em;
}

.archive-item h3 {
    font-size: 1.1em;
    margin: 0;
}

.archive-item h3 a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.archive-item h3 a:hover {
    color: var(--primary);
}

.archive-item .date {
    color: var(--text-secondary);
    font-size: 0.85em;
}

/* ============ 响应式设计 ============ */
@media (max-width: 600px) {
    .hero h2 {
        font-size: 1.6em;
    }
    
    .stats {
        gap: 20px;
        flex-wrap: wrap;
    }
    
    .theme-switcher {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 1.2em;
    }
    
    .archive-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    header h1 {
        flex-direction: column;
        gap: 8px;
    }
    
    .site-logo {
        height: 36px;
    }
}

/* ============ 平滑滚动 ============ */
html {
    scroll-behavior: smooth;
}

/* ============ 选中效果 ============ */
::selection {
    background: var(--primary);
    color: white;
}

::-moz-selection {
    background: var(--primary);
    color: white;
}
