/* ===== 变量定义 ===== */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent: #4f46e5;
    --accent-light: #eef2ff;
    --border: #e2e8f0;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s ease;
    --sidebar-width: 300px;
    --container-width: 1200px;
    --gap: 2rem;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #818cf8;
    --accent-light: #1e1b4b;
    --border: #334155;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
    font-size: 16px;
}

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

a:hover {
    text-decoration: underline;
}

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

/* ===== 顶部横幅 ===== */
.page-banner {
    width: 100%;
    height: 250px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.page-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.1));
    border-radius: inherit;
    pointer-events: none;
}

/* ===== 导航栏（粘性定位，始终固定在顶部） ===== */
.navbar {
    position: sticky;
    top: 0;
    width: 100%;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    backdrop-filter: blur(8px);
    z-index: 100;
}

.nav-container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.5px;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 1rem;
    transition: color 0.2s;
    text-decoration: none;
}

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

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

/* ===== 布局容器 ===== */
.container {
    max-width: var(--container-width);
    margin: 2rem auto 0;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 1fr var(--sidebar-width);
    gap: var(--gap);
}

/* ===== 侧边栏通用卡片样式 ===== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.widget {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    /* 移除 overflow: hidden，让内容换行后正常显示 */
}

.widget-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 个人介绍卡片 */
.widget-profile {
    text-align: center;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto 1rem;
    border: 3px solid var(--accent);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.profile-bio {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.profile-social {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.profile-social a {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    background: var(--accent-light);
    border-radius: 20px;
    color: var(--accent);
}

/* 公告卡片（强制换行） */
.announcement-content {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    word-break: break-all;        /* 强制任意字符处换行，解决长数字问题 */
    overflow-wrap: break-word;
    white-space: normal;
    max-width: 100%;
}

.announcement-content p {
    margin-bottom: 0.5rem;
}

/* 标签云（可点击） */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-item {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 20px;
    font-size: 0.85rem;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
}

.tag-item:hover {
    background: var(--accent);
    color: white;
}

/* 精选推荐（可点击） */
.recommended-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recommended-list .recommended-item {
    display: block;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border);
    color: var(--text-primary);
    font-size: 0.95rem;
    text-decoration: none;
    transition: var(--transition);
    word-break: break-word;
}

.recommended-list .recommended-item:hover {
    color: var(--accent);
    padding-left: 0.5rem;
}

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

/* 友情链接 */
.friend-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.friend-links a {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    word-break: break-word;
}

.friend-links a:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== 文章卡片样式（交替左右布局，元信息位于图片对侧底部） ===== */
.posts-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.post-card {
    display: flex;
    gap: 2rem;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
    padding: 1.5rem;
}

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

/* 图片区域 */
.post-thumb {
    flex: 0 0 240px;
    border-radius: 8px;
    overflow: hidden;
}

.post-thumb img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

/* 内容区域（flex列，用于将元信息推到底部） */
.post-card-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* 偶数卡片图片在右边 */
.posts-grid .post-card:nth-child(even) {
    flex-direction: row-reverse;
}

/* 标题 */
.post-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
    word-break: break-word;
}

/* 摘要 */
.post-excerpt {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
    margin-bottom: 1rem;
}

/* 元信息（日期、分类、标签）- 默认靠右（用于图片在左边的情况） */
.post-meta {
    display: flex;
    gap: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    justify-content: flex-end;
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* 图片在右边（偶数卡片）时，元信息靠左，位于图片对侧 */
.posts-grid .post-card:nth-child(even) .post-meta {
    justify-content: flex-start;
}

.post-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* ===== 文章详情页 ===== */
.post-full {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid var(--border);
    overflow: hidden;
}

.post-full-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.post-full-title {
    font-size: 2.2rem;
    line-height: 1.3;
    margin-bottom: 1rem;
    color: var(--text-primary);
    word-break: break-word;
}

.post-full-meta {
    color: var(--text-secondary);
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

.post-full-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* 文章内容 */
.post-full-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-width: 100%;
}

.post-full-content h1,
.post-full-content h2,
.post-full-content h3,
.post-full-content h4 {
    margin: 2rem 0 1rem;
    color: var(--text-primary);
    word-break: break-word;
}

.post-full-content p {
    margin: 1.2rem 0;
    word-break: break-word;
}

.post-full-content img {
    max-width: 100%;
    border-radius: 12px;
    margin: 1.5rem 0;
}

.post-full-content code {
    background: var(--accent-light);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    color: var(--accent);
    font-size: 0.9rem;
    word-break: break-word;
}

.post-full-content pre {
    background: var(--bg-primary);
    padding: 1.5rem;
    border-radius: 12px;
    overflow-x: auto;
    border: 1px solid var(--border);
    margin: 1.5rem 0;
    white-space: pre-wrap;
    word-break: break-word;
}

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

/* 文章底部作者卡片 */
.post-author-card {
    margin-top: 4rem;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    border: 1px solid var(--border);
    word-break: break-word;
}

.author-thumb {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
}

.author-info h4 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.author-info p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.author-social-mini {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.author-social-mini a {
    font-size: 0.9rem;
}

/* ===== 底部 ===== */
.footer {
    max-width: var(--container-width);
    margin: 3rem auto 1rem;
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
}

/* ===== 分页控件 ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 3rem 0;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 0.5rem;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
    text-decoration: none;
}

.pagination a:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.pagination .page-current {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
}

.pagination .disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
    background: var(--bg-secondary);
}

.page-prev,
.page-next {
    padding: 0 1rem;
}

/* ===== 响应式优化 ===== */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .sidebar {
        order: 2;
    }

    .page-banner {
        height: 150px;
    }

    .post-full {
        padding: 1.5rem;
    }

    .post-full-title {
        font-size: 1.8rem;
    }

    .posts-grid {
        gap: 1.5rem;
    }

    .post-card,
    .posts-grid .post-card:nth-child(even) {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }

    .post-thumb {
        flex: none;
        width: 100%;
        margin-bottom: 1rem;
    }

    .post-thumb img {
        height: 200px;
    }

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

    /* 移动端所有卡片元信息统一靠左 */
    .post-meta,
    .posts-grid .post-card:nth-child(even) .post-meta {
        justify-content: flex-start;
    }

    .nav-links {
        gap: 1rem;
    }
}

@media (max-width: 640px) {
    .section-title {
        font-size: 1.75rem;
    }
}

@media (max-width: 480px) {
    .post-full-title {
        font-size: 1.5rem;
    }
    .post-full-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    .profile-avatar {
        width: 60px;
        height: 60px;
    }
    .widget {
        padding: 1rem;
    }
    .pagination a,
    .pagination span {
        min-width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }
    .page-prev,
    .page-next {
        padding: 0 0.75rem;
    }
    .friend-links {
        gap: 1rem;
    }
}