/* ==================== 全局样式变量 ==================== */
:root {
    /* 明亮主题（默认） */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --accent-color: #3498db;
    --accent-hover: #2980b9;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --card-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    --card-hover-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    --border-color: #dee2e6;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* 性能优化：使用 transform 替代 top/left */
    --transition-speed: 0.3s;
    --border-radius: 12px;
    --container-width: 1200px;
    --header-height: 70px;
}

/* 暗黑主题 */
[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252542;
    --text-primary: #eaeaea;
    --text-secondary: #b0b0b0;
    --text-muted: #6c6c6c;
    --accent-color: #4fc3f7;
    --accent-hover: #29b6f6;
    --card-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
    --card-hover-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    --border-color: #3a3a5a;
    --gradient-primary: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* ==================== 基础重置 ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-speed), color var(--transition-speed);
    -webkit-tap-highlight-color: transparent;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-speed);
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition-speed);
    -webkit-appearance: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul {
    list-style: none;
}

/* ==================== 工具类 ==================== */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 30px;
    font-weight: 600;
    transition: all var(--transition-speed);
    text-align: center;
    will-change: transform;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-secondary {
    background: transparent;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
}

.btn-secondary:hover {
    background: var(--accent-color);
    color: white;
}

/* ==================== 导航栏 ==================== */
.header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg-primary);
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-speed);
    will-change: transform;
}

.header.scrolled {
    transform: translateY(-100%);
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: var(--container-width);
    margin: 0 auto;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-icon {
    font-size: 2rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 500;
    position: relative;
    padding: 5px 0;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    transition: width var(--transition-speed);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 10px;
    z-index: 1001;
}

.hamburger {
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition-speed);
}

.theme-toggle {
    padding: 8px 12px;
    border-radius: 20px;
    background: var(--bg-tertiary);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.icon-moon {
    display: none;
}

[data-theme="dark"] .icon-sun {
    display: none;
}

[data-theme="dark"] .icon-moon {
    display: inline;
}

.search-container {
    position: relative;
}

.search-box {
    padding: 8px 15px;
    border-radius: 20px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    width: 250px;
    transition: all var(--transition-speed);
}

.search-box:focus {
    outline: none;
    border-color: var(--accent-color);
    width: 300px;
}

.search-results {
    position: absolute;
    top: 100%;
    right: 0;
    width: 350px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--card-hover-shadow);
    margin-top: 10px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-speed);
    -webkit-overflow-scrolling: touch;
}

.search-results.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-history {
    padding: 1rem;
}

.history-item {
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition-speed);
}

.history-item:hover {
    background: var(--bg-tertiary);
}

.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--gradient-primary);
    width: 0;
    transition: width 0.1s;
    will-change: width;
}

/* ==================== Hero 区域 ==================== */
.hero {
    background: var(--gradient-primary);
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    margin-bottom: 4rem;
    position: relative;
    overflow: hidden;
    will-change: scroll;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320"><path fill="%23ffffff" fill-opacity="0.1" d="M0,96L48,112C96,128,192,160,288,160C384,160,480,128,576,122.7C672,117,768,139,864,138.7C960,139,1056,117,1152,106.7C1248,96,1344,96,1392,96L1392,320L1344,320C1296,320,1200,320,1104,320C1008,320,912,320,816,320C720,320,624,320,528,320C432,320,336,320,240,320C144,320,48,320,0,320Z"></path></svg>') no-repeat bottom;
    background-size: cover;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    animation: fadeInUp 0.8s ease;
}

.hero-subtitle {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    opacity: 0.9;
    animation: fadeInUp 0.8s ease 0.2s backwards;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    animation: fadeInUp 0.8s ease 0.4s backwards;
}

.hero-buttons .btn {
    background: white;
    color: #667eea;
}

.hero-buttons .btn-secondary {
    background: transparent;
    border-color: white;
    color: white;
}

/* ==================== 分类区域 ==================== */
.categories-section {
    padding: 4rem 0;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.category-card {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    text-align: center;
    transition: all var(--transition-speed);
    cursor: pointer;
    will-change: transform;
}

.category-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--card-hover-shadow);
}

.category-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.category-card h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.category-card p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.category-card .count {
    display: inline-block;
    background: var(--gradient-primary);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* ==================== 精选文章 ==================== */
.featured-section {
    padding: 4rem 0;
    background: var(--bg-tertiary);
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

/* ==================== 文章列表 ==================== */
.posts-section {
    padding: 4rem 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 20px;
    border-radius: 20px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    transition: all var(--transition-speed);
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
}

.post-list {
    display: grid;
    gap: 2rem;
}

.post-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    display: grid;
    grid-template-columns: 300px 1fr;
    transition: all var(--transition-speed);
    position: relative;
    will-change: transform;
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-hover-shadow);
}

.post-thumbnail {
    position: relative;
    overflow: hidden;
    height: 100%;
    min-height: 250px;
}

.post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-speed);
    will-change: transform;
}

.post-card:hover .post-thumbnail img {
    transform: scale(1.1);
}

.post-category {
    position: absolute;
    top: 15px;
    left: 15px;
    background: var(--gradient-primary);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    z-index: 1;
}

.post-content {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.post-content h2 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.post-content h2 a:hover {
    color: var(--accent-color);
}

.summary {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 1rem;
}

.post-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tag {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
}

.meta {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.author {
    display: flex;
    align-items: center;
    gap: 8px;
}

.author-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.post-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.post-card:hover .post-actions {
    opacity: 1;
}

.btn-share,
.btn-bookmark {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--bg-primary);
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.btn-share:hover,
.btn-bookmark:hover {
    background: var(--accent-color);
    color: white;
}

/* ==================== 加载更多 ==================== */
.load-more {
    text-align: center;
    margin-top: 3rem;
}

.btn-load-more {
    padding: 12px 40px;
    background: var(--bg-primary);
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    transition: all var(--transition-speed);
}

.btn-load-more:hover {
    background: var(--accent-color);
    color: white;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-secondary);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== 骨架屏 ==================== */
.skeleton-loader {
    display: none;
    gap: 2rem;
}

.skeleton-card {
    height: 300px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-color) 50%, var(--bg-tertiary) 75%);
    background-size: 200px 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--border-radius);
}

@keyframes skeleton-loading {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

/* ==================== 标签云 ==================== */
.tags-section {
    padding: 4rem 0;
    background: var(--bg-tertiary);
}

.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.tag-cloud-item {
    padding: 8px 20px;
    background: var(--bg-primary);
    border-radius: 25px;
    color: var(--text-secondary);
    transition: all var(--transition-speed);
    cursor: pointer;
}

.tag-cloud-item:hover {
    background: var(--gradient-primary);
    color: white;
    transform: scale(1.1);
}

/* ==================== 关于区域 ==================== */
.about-section {
    padding: 4rem 0;
}

.about-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 4rem;
    align-items: center;
    background: var(--bg-primary);
    padding: 3rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

.about-avatar img {
    width: 100%;
    border-radius: var(--border-radius);
    box-shadow: var(--card-hover-shadow);
}

.about-info h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.about-info p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 2rem;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-link {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all var(--transition-speed);
}

.social-link:hover {
    background: var(--gradient-primary);
    transform: translateY(-5px);
}

/* ==================== 联系表单 ==================== */
.contact-section {
    padding: 4rem 0;
    background: var(--bg-tertiary);
}

.contact-form {
    max-width: 600px;
    margin: 0 auto;
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition-speed);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn-submit {
    width: 100%;
    padding: 15px;
    font-size: 1rem;
}

/* ==================== 页脚 ==================== */
.footer {
    background: #1a1a2e;
    color: white;
    padding: 3rem 0 1rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3,
.footer-section h4 {
    margin-bottom: 1rem;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section a:hover {
    color: var(--accent-color);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==================== 返回顶部 ==================== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-speed);
    z-index: 999;
    will-change: transform;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-5px);
}

/* ==================== Toast 提示 ==================== */
.toast-container {
    position: fixed;
    top: 100px;
    right: 30px;
    z-index: 1001;
}

.toast {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 15px 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--card-hover-shadow);
    margin-bottom: 10px;
    animation: slideInRight 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==================== 动画 ==================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }
    
    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: var(--bg-primary);
        flex-direction: column;
        padding: 5rem 2rem;
        box-shadow: var(--card-shadow);
        transition: right var(--transition-speed);
    }
    
    .nav-links.active {
        right: 0;
    }
    
    .search-box {
        width: 180px;
    }
    
    .search-box:focus {
        width: 200px;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1.2rem;
    }
    
    .hero-buttons {
        flex-direction: column;
    }
    
    .post-card {
        grid-template-columns: 1fr;
    }
    
    .post-thumbnail {
        min-height: 200px;
    }
    
    .about-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .about-avatar {
        max-width: 300px;
        margin: 0 auto;
    }
    
    .social-links {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .section-title {
        font-size: 1.5rem;
    }
    
    .categories-grid,
    .featured-grid {
        grid-template-columns: 1fr;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filter-buttons {
        width: 100%;
        overflow-x: auto;
    }
}

/* ==================== 性能优化 ==================== */
/* GPU 加速 */
.post-card,
.category-card,
.social-link,
.back-to-top {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* 减少重绘 */
.theme-transition,
.theme-transition * {
    transition-property: background-color, color !important;
}

/* 打印优化 */
@media print {
    .header,
    .hero,
    .filter-buttons,
    .post-actions,
    .back-to-top,
    .contact-section,
    .footer {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .post-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* 减少动画模式 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
