/* ========== 基础变量 ========== */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #888;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #dbeafe;
    --border: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --max-width: 1200px;
    --content-width: 800px;
    --header-height: 64px;
    --transition: all 0.25s ease;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --accent-light: #1e3a5f;
    --border: #334155;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.4);
}

/* ========== 重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    transition: var(--transition);
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; border-radius: var(--radius-md); }

/* ========== 阅读进度条 ========== */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    width: 0%;
    z-index: 1000;
    transition: width 0.1s;
}

/* ========== 导航栏 ========== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
}

[data-theme="dark"] .navbar { background: rgba(15,23,42,0.85); }

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-logo:hover { color: var(--accent); }

.nav-links {
    display: flex;
    align-items: center;
    gap: 28px;
    list-style: none;
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    position: relative;
}

.nav-links a:hover, .nav-links a.active { color: var(--accent); }

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: var(--transition);
}

.theme-toggle:hover { transform: scale(1.1); box-shadow: var(--shadow-md); }

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
}

/* ========== 容器 ========== */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

.content-container {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 24px;
}

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

.hero h1 {
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* ========== 搜索框 ========== */
.search-box {
    max-width: 560px;
    margin: 0 auto 40px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 14px 20px 14px 48px;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.search-box .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-muted);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: 8px;
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.search-results.active { display: block; }

.search-result-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-secondary); }
.search-result-item h4 { font-size: 0.95rem; margin-bottom: 4px; color: var(--text-primary); }
.search-result-item p { font-size: 0.85rem; color: var(--text-muted); }
.search-no-result { padding: 24px; text-align: center; color: var(--text-muted); }

/* ========== 主布局 ========== */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 40px;
    padding: 40px 0 60px;
}

/* ========== 文章列表 ========== */
.post-list { display: flex; flex-direction: column; gap: 24px; }

.post-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: var(--transition);
    cursor: pointer;
}

.post-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}

.post-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.post-card-category {
    background: var(--accent-light);
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
}

.post-card h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
    line-height: 1.4;
}

.post-card:hover h2 { color: var(--accent); }

.post-card-excerpt {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.post-tags { display: flex; gap: 8px; flex-wrap: wrap; }

.post-tag {
    font-size: 0.78rem;
    padding: 3px 10px;
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.post-meta { font-size: 0.85rem; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }

/* ========== 侧边栏 ========== */
.sidebar { display: flex; flex-direction: column; gap: 28px; }

.widget {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.widget-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

/* 作者卡片 */
.author-card { text-align: center; }
.author-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    font-weight: bold;
}
.author-name { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.author-bio { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 16px; }
.author-social { display: flex; justify-content: center; gap: 12px; }
.author-social a {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    border: 1px solid var(--border);
}
.author-social a:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* 分类列表 */
.category-list { list-style: none; }
.category-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.category-list li:last-child { border-bottom: none; }
.category-list a { color: var(--text-secondary); font-weight: 500; }
.category-list a:hover { color: var(--accent); }
.category-count {
    background: var(--bg-secondary);
    color: var(--text-muted);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
}

/* 标签云 */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud a {
    padding: 6px 14px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: var(--transition);
}
.tag-cloud a:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* 最新文章 */
.recent-posts { list-style: none; }
.recent-posts li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.recent-posts li:last-child { border-bottom: none; }
.recent-posts a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: block;
    line-height: 1.5;
}
.recent-posts a:hover { color: var(--accent); }
.recent-posts .date { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
}

.pagination a, .pagination span {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.pagination a:hover { background: var(--accent); color: white; border-color: var(--accent); }
.pagination .current { background: var(--accent); color: white; border-color: var(--accent); font-weight: 600; }
.pagination .disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== 文章详情页 ========== */
.post-header {
    padding: 60px 0 32px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 40px;
}

.post-header .post-category {
    display: inline-block;
    background: var(--accent-light);
    color: var(--accent);
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.post-header h1 {
    font-size: 2.4rem;
    font-weight: 800;
    margin-bottom: 20px;
    line-height: 1.3;
}

.post-header .post-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.post-content {
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--text-secondary);
}

.post-content h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 40px 0 20px;
    color: var(--text-primary);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}

.post-content h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 32px 0 16px;
    color: var(--text-primary);
}

.post-content p { margin-bottom: 20px; }

.post-content ul, .post-content ol {
    margin: 0 0 20px 24px;
}

.post-content li { margin-bottom: 8px; }

.post-content blockquote {
    border-left: 4px solid var(--accent);
    padding: 16px 24px;
    margin: 24px 0;
    background: var(--bg-secondary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
    color: var(--text-secondary);
}

.post-content code {
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: var(--accent);
}

.post-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 24px 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.post-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.post-content img {
    margin: 24px auto;
    display: block;
    box-shadow: var(--shadow-md);
}

.post-content a { text-decoration: underline; }

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
}

.post-content th, .post-content td {
    padding: 12px 16px;
    border: 1px solid var(--border);
    text-align: left;
}

.post-content th { background: var(--bg-secondary); font-weight: 600; }

/* 文章底部 */
.post-footer {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.post-footer-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 32px;
}

.post-footer-tags a {
    padding: 6px 16px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.post-footer-tags a:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* 上一篇下一篇 */
.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.post-nav-item {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.post-nav-item:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }

.post-nav-item .label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.post-nav-item .title { font-weight: 600; color: var(--text-primary); font-size: 0.95rem; line-height: 1.5; }
.post-nav-item.next { text-align: right; }

/* ========== 文章目录 ========== */
.toc-widget {
    position: sticky;
    top: calc(var(--header-height) + 24px);
}

.toc-list {
    list-style: none;
    font-size: 0.88rem;
}

.toc-list li { margin-bottom: 6px; }

.toc-list a {
    color: var(--text-muted);
    display: block;
    padding: 4px 0 4px 12px;
    border-left: 2px solid var(--border);
    transition: var(--transition);
    line-height: 1.5;
}

.toc-list a:hover, .toc-list a.active {
    color: var(--accent);
    border-left-color: var(--accent);
}

.toc-list .toc-h3 { padding-left: 28px; }

/* ========== 分类/标签页 ========== */
.page-header {
    padding: 60px 0 40px;
    text-align: center;
}

.page-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 12px;
}

.page-header p { color: var(--text-secondary); font-size: 1.05rem; }

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 40px 0 60px;
}

.category-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: var(--transition);
    cursor: pointer;
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}

.category-card-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

.category-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.category-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.category-card .count {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

/* ========== 关于页 ========== */
.about-section {
    padding: 60px 0;
}

.about-hero {
    text-align: center;
    margin-bottom: 48px;
}

.about-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
    font-weight: bold;
}

.about-hero h1 { font-size: 2.4rem; font-weight: 800; margin-bottom: 12px; }
.about-hero p { color: var(--text-secondary); font-size: 1.1rem; }

.about-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    margin-bottom: 32px;
}

.about-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 32px 0 16px;
    color: var(--text-primary);
}

.about-content h2:first-child { margin-top: 0; }

.about-content p { margin-bottom: 16px; color: var(--text-secondary); line-height: 1.8; }

.about-skills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.skill-item {
    padding: 8px 18px;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.about-contact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.contact-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    text-align: center;
    transition: var(--transition);
}

.contact-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.contact-card .icon { font-size: 2rem; margin-bottom: 12px; }
.contact-card h3 { font-size: 1.1rem; margin-bottom: 6px; }
.contact-card p { color: var(--text-secondary); font-size: 0.9rem; }

/* ========== 页脚 ========== */
.footer {
    border-top: 1px solid var(--border);
    padding: 40px 0 32px;
    background: var(--bg-secondary);
    margin-top: 60px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-left { color: var(--text-muted); font-size: 0.9rem; }
.footer-left a { color: var(--text-muted); }
.footer-left a:hover { color: var(--accent); }

.footer-links { display: flex; gap: 24px; }
.footer-links a { color: var(--text-muted); font-size: 0.9rem; }
.footer-links a:hover { color: var(--accent); }

/* ========== 回到顶部 ========== */
.back-to-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 99;
}

.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { transform: translateY(-3px); background: var(--accent-hover); }

/* ========== 动画 ========== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in { animation: fadeInUp 0.5s ease-out forwards; opacity: 0; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }

/* ========== 响应式 ========== */
@media (max-width: 968px) {
    .main-layout { grid-template-columns: 1fr; }
    .sidebar { order: -1; }
    .toc-widget { position: static; display: none; }
    .post-nav { grid-template-columns: 1fr; }
    .post-nav-item.next { text-align: left; }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--bg-card);
        flex-direction: column;
        padding: 20px;
        gap: 16px;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
    }
    .nav-links.open { display: flex; }
    .mobile-menu-btn { display: block; }
    .hero h1 { font-size: 2rem; }
    .post-header h1 { font-size: 1.8rem; }
    .post-card { padding: 20px; }
    .post-card h2 { font-size: 1.2rem; }
    .about-content { padding: 24px; }
    .footer-content { flex-direction: column; text-align: center; }
    .back-to-top { bottom: 20px; right: 20px; width: 42px; height: 42px; }
}

@media (max-width: 480px) {
    .hero h1 { font-size: 1.7rem; }
    .post-header h1 { font-size: 1.5rem; }
    .category-grid { grid-template-columns: 1fr; }
}
