/* ============================================
   个人博客 - 主样式表
   ============================================ */

/* === CSS 变量 === */
:root {
    /* 颜色 - 亮色模式 */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --accent: #667eea;
    --accent-hover: #5a6fd6;
    --accent-light: rgba(102, 126, 234, 0.1);
    --border: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --card-bg: #ffffff;
    --nav-bg: rgba(255, 255, 255, 0.95);
    --code-bg: #f4f4f5;
    --gradient-start: #667eea;
    --gradient-end: #764ba2;

    /* 尺寸 */
    --max-width: 1200px;
    --nav-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;

    /* 字体 */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* 暗色模式 */
[data-theme="dark"] {
    --bg-primary: #1a1b26;
    --bg-secondary: #24253a;
    --bg-tertiary: #2f3046;
    --text-primary: #c0caf5;
    --text-secondary: #9aa5ce;
    --text-muted: #565f89;
    --accent: #7aa2f7;
    --accent-hover: #89b4fa;
    --accent-light: rgba(122, 162, 247, 0.1);
    --border: #3b3d57;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.5);
    --card-bg: #24253a;
    --nav-bg: rgba(26, 27, 38, 0.95);
    --code-bg: #2f3046;
    --gradient-start: #7aa2f7;
    --gradient-end: #bb9af7;
}

/* === 基础重置 === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    transition: var(--transition);
    overflow-x: hidden;
}

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

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    height: auto;
}

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

/* === 导航栏 === */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    transition: var(--transition);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

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

.logo-icon {
    font-size: 1.5rem;
    color: var(--accent);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--accent);
    background: var(--accent-light);
}

.nav-link.active {
    color: var(--accent);
    background: var(--accent-light);
}

.theme-toggle {
    background: none;
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    transition: var(--transition);
    font-size: 1.1rem;
}

.theme-toggle:hover {
    border-color: var(--accent);
    transform: rotate(15deg);
}

[data-theme="dark"] .sun-icon { display: inline; }
[data-theme="dark"] .moon-icon { display: none; }
.sun-icon { display: none; }
.moon-icon { display: inline; }

.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-btn span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

/* === 头部横幅 === */
.hero {
    margin-top: var(--nav-height);
    padding: 80px 24px;
    text-align: center;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: #ffffff;
    position: relative;
    overflow: hidden;
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 16px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    animation: fadeInUp 0.8s ease;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 40px;
    animation: fadeInUp 0.8s ease 0.2s both;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    animation: fadeInUp 0.8s ease 0.4s both;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

.hero-decoration {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.circle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    animation: float 6s ease-in-out infinite;
}

.circle-1 {
    width: 200px;
    height: 200px;
    top: -50px;
    left: -50px;
    animation-delay: 0s;
}

.circle-2 {
    width: 150px;
    height: 150px;
    bottom: -30px;
    right: 10%;
    animation-delay: 2s;
}

.circle-3 {
    width: 100px;
    height: 100px;
    top: 20%;
    right: -20px;
    animation-delay: 4s;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === 主内容区 === */
.main-content {
    padding: 48px 0;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 40px;
    align-items: start;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.title-icon {
    font-size: 1.3rem;
}

/* === 文章卡片 === */
.post-card {
    display: grid;
    grid-template-columns: 200px 1fr;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--shadow-hover);
    border-color: var(--accent);
}

.post-card.featured {
    grid-template-columns: 1fr;
}

.post-card-image {
    position: relative;
    overflow: hidden;
}

.post-placeholder-img {
    width: 100%;
    height: 100%;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.post-card.featured .post-placeholder-img {
    min-height: 200px;
    font-size: 4rem;
}

.post-tag {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.post-card-content {
    padding: 20px 24px;
}

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

.post-category {
    background: var(--accent-light);
    color: var(--accent);
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.post-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.4;
}

.post-title a {
    color: var(--text-primary);
}

.post-title a:hover {
    color: var(--accent);
}

.post-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-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.read-time {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.read-more {
    font-weight: 600;
    font-size: 0.9rem;
}

/* === 分页 === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.page-current, .page-link, .page-next {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition);
}

.page-current {
    background: var(--accent);
    color: #fff;
}

.page-link {
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.page-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.page-next {
    color: var(--accent);
    font-weight: 600;
}

/* === 侧边栏 === */
.sidebar {
    position: sticky;
    top: calc(var(--nav-height) + 24px);
}

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

.widget:hover {
    box-shadow: 0 4px 12px var(--shadow);
}

.widget-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-light);
}

/* 个人信息 */
.profile-widget {
    text-align: center;
}

.profile-avatar {
    margin-bottom: 16px;
}

.avatar-placeholder {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.profile-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.profile-bio {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.6;
}

.profile-social {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.social-link {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transition: var(--transition);
}

.social-link:hover {
    background: var(--accent);
    color: #fff;
    transform: translateY(-2px);
}

/* 搜索 */
.search-box {
    display: flex;
    gap: 8px;
}

.search-box input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

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

.search-btn {
    padding: 10px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.search-btn:hover {
    background: var(--accent-hover);
}

/* 分类列表 */
.category-list {
    list-style: none;
}

.category-list li {
    margin-bottom: 8px;
}

.category-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
}

.category-list a:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.category-list .count {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* 标签云 */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 4px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.tag:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* 最近更新 */
.recent-list {
    list-style: none;
}

.recent-list li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.recent-list li:last-child {
    border-bottom: none;
}

.recent-list a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    flex: 1;
}

.recent-list a:hover {
    color: var(--accent);
}

.recent-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

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

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 32px;
}

.footer-section h4 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.footer-section p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 8px;
}

.footer-section ul a {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-section ul a:hover {
    color: var(--accent);
}

.footer-bottom {
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* === 回到顶部 === */
.back-to-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 44px;
    height: 44px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 999;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-hover);
}

/* === 关于页面 === */
.about-page {
    margin-top: var(--nav-height);
    padding: 60px 24px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.about-page h1 {
    font-size: 2.5rem;
    margin-bottom: 24px;
    text-align: center;
}

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

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

.about-content p {
    margin-bottom: 16px;
}

.about-content .skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.skill-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    transition: var(--transition);
}

.skill-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.skill-item .skill-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.skill-item .skill-name {
    font-weight: 600;
    color: var(--text-primary);
}

/* === 归档页面 === */
.archive-page {
    margin-top: var(--nav-height);
    padding: 60px 24px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.archive-page h1 {
    font-size: 2.5rem;
    margin-bottom: 32px;
    text-align: center;
}

.archive-timeline {
    position: relative;
    padding-left: 32px;
}

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

.archive-year {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 32px 0 16px;
    color: var(--accent);
    position: relative;
}

.archive-year::before {
    content: '';
    position: absolute;
    left: -28px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
}

.archive-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.archive-item:hover {
    padding-left: 8px;
}

.archive-item-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 80px;
}

.archive-item-title a {
    color: var(--text-primary);
    font-weight: 500;
}

.archive-item-title a:hover {
    color: var(--accent);
}

/* === 文章详情页 === */
.article-page {
    margin-top: var(--nav-height);
    padding: 48px 24px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.article-header {
    text-align: center;
    margin-bottom: 40px;
}

.article-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 16px;
    line-height: 1.3;
}

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

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

.article-body h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin: 32px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.article-body p {
    margin-bottom: 16px;
}

.article-body code {
    background: var(--code-bg);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.article-body pre {
    background: var(--code-bg);
    padding: 20px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 20px 0;
    border: 1px solid var(--border);
}

.article-body pre code {
    background: none;
    padding: 0;
}

.article-body blockquote {
    border-left: 4px solid var(--accent);
    padding: 16px 20px;
    margin: 20px 0;
    background: var(--accent-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-primary);
}

.article-body ul, .article-body ol {
    padding-left: 24px;
    margin-bottom: 16px;
}

.article-body li {
    margin-bottom: 8px;
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.95rem;
}

.article-body th,
.article-body td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
}

.article-body th {
    background: var(--code-bg);
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
}

.article-body tbody tr:nth-child(even) {
    background: var(--accent-light);
}

/* === 系列文章 === */
.series-box {
    background: var(--accent-light);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    margin-bottom: 32px;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.series-box .series-label {
    font-weight: 700;
    color: var(--accent);
    margin-right: 8px;
}

.series-box a {
    color: var(--accent);
    font-weight: 600;
}

.series-box a:hover {
    text-decoration: underline;
}

.series-page-desc {
    color: var(--text-secondary);
    text-align: center;
    max-width: 640px;
    margin: 0 auto 8px;
    line-height: 1.9;
}

.archive-item.planned .archive-item-title {
    color: var(--text-muted);
}

.archive-item.planned .archive-item-date {
    font-style: italic;
}

/* === 响应式设计 === */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .widget {
        margin-bottom: 0;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--nav-bg);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 16px;
        border-bottom: 1px solid var(--border);
    }

    .nav-links.active {
        display: flex;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .hero-stats {
        gap: 24px;
    }

    .post-card {
        grid-template-columns: 1fr;
    }

    .post-card-image {
        height: 160px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .sidebar {
        grid-template-columns: 1fr;
    }

    .about-page h1, .archive-page h1 {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 48px 16px;
    }

    .hero-title {
        font-size: 1.6rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .container {
        padding: 0 16px;
    }
}
