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

:root {
    --primary: #16a34a;
    --primary-light: #22c55e;
    --primary-dark: #15803d;
    --bg: #f0fdf4;
    --card-bg: #ffffff;
    --text: #14532d;
    --text-secondary: #6b7280;
    --code-bg: #0f172a;
    --code-text: #e2e8f0;
    --accent: #10b981;
    --nav-bg: #14532d;
    --nav-text: #dcfce7;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.15);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

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

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

/* ===== 容器 ===== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== 导航栏 ===== */
.main-nav {
    background: var(--nav-bg);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.nav-brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff !important;
    letter-spacing: 0.5px;
}

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

.nav-link {
    color: var(--nav-text);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-link.active {
    background: var(--primary);
    color: #fff;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    margin: 5px 0;
    transition: 0.3s;
}

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

/* ===== 页面标题 ===== */
.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.page-header h1 {
    font-size: 2rem;
    color: var(--text);
    margin-bottom: 8px;
}

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

/* ===== 文章卡片 ===== */
.article-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
    transition: box-shadow 0.3s, transform 0.3s;
}

.article-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.article-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.img-fallback .article-card-image {
    display: none;
}

.article-card.img-fallback {
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    min-height: 200px;
}

.article-card-body {
    padding: 24px;
}

.article-card-body h2 {
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.article-card-body h2 a {
    color: var(--text);
}

.article-card-body h2 a:hover {
    color: var(--primary);
}

.article-meta {
    display: flex;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.article-excerpt {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-block;
    padding: 2px 10px;
    background: var(--primary-light);
    color: #fff;
    border-radius: 12px;
    font-size: 0.75rem;
    transition: background 0.2s;
}

.tag:hover {
    background: var(--primary-dark);
    color: #fff;
}

/* ===== 文章正文 ===== */
.post-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
    line-height: 1.8;
    font-size: 16px;
}

.post-content p {
    margin-bottom: 1.2em;
}

.post-content h2 {
    font-size: 1.5rem;
    margin: 2em 0 1em;
    padding-bottom: 0.3em;
    border-bottom: 2px solid var(--primary-light);
}

.post-content h3 {
    font-size: 1.25rem;
    margin: 1.5em 0 0.8em;
}

.post-content pre {
    background: var(--code-bg);
    color: var(--code-text);
    border-radius: var(--radius);
    padding: 20px;
    overflow-x: auto;
    margin: 1.5em 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.post-content code {
    font-family: "Fira Code", "JetBrains Mono", "Source Code Pro", Consolas, monospace;
}

.post-content :not(pre) > code {
    background: var(--primary-light);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
}

.post-content img {
    border-radius: var(--radius);
    margin: 1.5em 0;
    box-shadow: var(--shadow);
}

.post-content blockquote {
    border-left: 4px solid var(--primary);
    padding: 12px 20px;
    margin: 1.5em 0;
    background: var(--bg);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-secondary);
}

.post-content ul, .post-content ol {
    margin: 1em 0;
    padding-left: 2em;
}

.post-content li {
    margin-bottom: 0.5em;
}

/* ===== 文章导航（上下篇） ===== */
.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(128,128,128,0.2);
}

.post-nav-item {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    transition: box-shadow 0.3s;
}

.post-nav-item:hover {
    box-shadow: var(--shadow-hover);
}

.post-nav-item.next {
    text-align: right;
}

.post-nav-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.post-nav-title {
    font-weight: 600;
    color: var(--primary);
}

/* ===== 归档时间线 ===== */
.timeline {
    position: relative;
    padding-left: 30px;
}

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

.timeline-year {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin: 30px 0 16px;
    position: relative;
}

.timeline-year::before {
    content: "";
    position: absolute;
    left: -26px;
    top: 8px;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    border: 3px solid var(--bg);
}

.timeline-month {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 20px 0 10px;
}

.timeline-item {
    padding: 8px 0 8px 16px;
    border-left: 2px solid transparent;
    transition: border-color 0.2s;
}

.timeline-item:hover {
    border-left-color: var(--primary-light);
}

.timeline-item a {
    color: var(--text);
    font-size: 1rem;
}

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

.timeline-date {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-right: 12px;
}

/* ===== 分类网格 ===== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.category-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    transition: box-shadow 0.3s, transform 0.3s;
    border-top: 4px solid var(--primary);
}

.category-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

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

.category-card h3 a {
    color: var(--text);
}

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

.category-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.category-articles {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(128,128,128,0.15);
    list-style: none;
}

.category-articles li {
    padding: 4px 0;
    font-size: 0.9rem;
}

.category-articles li a {
    color: var(--text-secondary);
}

.category-articles li a:hover {
    color: var(--primary);
}

/* ===== 标签云 ===== */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    padding: 20px;
}

.tag-cloud .tag-item {
    display: inline-block;
    padding: 6px 16px;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    color: var(--text);
    transition: all 0.3s;
}

.tag-cloud .tag-item:hover {
    background: var(--primary);
    color: #fff;
    transform: scale(1.05);
}

/* ===== 友链卡片 ===== */
.friend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.friend-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    display: flex;
    gap: 16px;
    align-items: center;
    transition: box-shadow 0.3s, transform 0.3s;
}

.friend-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.friend-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.friend-info h3 {
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.friend-info h3 a {
    color: var(--text);
}

.friend-info h3 a:hover {
    color: var(--primary);
}

.friend-info p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ===== 关于页面 ===== */
.about-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
    max-width: 700px;
    margin: 0 auto;
}

.about-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto 20px;
    border: 4px solid var(--primary-light);
}

.about-name {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.about-bio {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.7;
}

.about-section {
    margin-bottom: 24px;
}

.about-section h3 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary-light);
}

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

.skill-tag {
    padding: 4px 14px;
    background: var(--primary-light);
    color: #fff;
    border-radius: 16px;
    font-size: 0.85rem;
}

.contact-list {
    list-style: none;
}

.contact-list li {
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.contact-list li::before {
    content: "\2192";
    color: var(--primary);
    font-weight: bold;
}

/* ===== 404 页面 ===== */
.not-found {
    text-align: center;
    padding: 80px 20px;
}

.not-found h1 {
    font-size: 6rem;
    color: var(--primary);
    margin-bottom: 16px;
}

.not-found p {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-bottom: 24px;
}

.not-found a {
    display: inline-block;
    padding: 12px 32px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    font-size: 1rem;
    transition: background 0.2s;
}

.not-found a:hover {
    background: var(--primary-dark);
    color: #fff;
}

/* ===== 页脚 ===== */
.site-footer {
    background: var(--nav-bg);
    color: var(--nav-text);
    text-align: center;
    padding: 20px;
    margin-top: auto;
}

.site-footer p {
    font-size: 0.9rem;
    opacity: 0.9;
}

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

.pagination a, .pagination span {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.pagination a {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    color: var(--text);
}

.pagination a:hover {
    background: var(--primary);
    color: #fff;
}

.pagination .current {
    background: var(--primary);
    color: #fff;
}

/* ===== 回到顶部 ===== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-hover);
    z-index: 99;
    transition: background 0.2s, transform 0.2s;
}
.back-to-top:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* ===== 文章正文图片 ===== */
.post-content figure {
    margin: 1.5em 0;
    text-align: center;
}
.post-content figure img {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 100%;
    height: auto;
}
.post-content figcaption {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5em;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--nav-bg);
        flex-direction: column;
        padding: 16px 20px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }

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

    .nav-link {
        padding: 12px 16px;
    }

    .post-content {
        padding: 20px;
    }

    .post-nav {
        flex-direction: column;
    }

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

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

    .about-card {
        padding: 24px;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }
}
