/* ============================================
   博客样式表 - 支持明暗主题切换
   ============================================ */

/* CSS 变量定义 - 浅色主题 */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #e9ecef;
    --accent-color: #3498db;
    --accent-hover: #2980b9;
    --success-color: #27ae60;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* 深色主题 */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-card: #252525;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --border-color: #404040;
    --accent-color: #5dade2;
    --accent-hover: #3498db;
    --success-color: #2ecc71;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* ============================================
   古典色主题（基于 work-mode 设计库）
   - 晋 (Jin): 青色 + 朱砂，米色卷轴
   - 宋 (Song): 靛蓝 + 灰绿，宣纸米黄
   - 唐 (Tang): 金 + 朱红，唐墨淡黄
   ============================================ */

/* 晋 · 浅色 */
[data-theme-pref="jin-light"] {
    --bg-primary: #f9f6f0;
    --bg-secondary: #f2ece2;
    --bg-card: #ffffff;
    --text-primary: #3e3730;
    --text-secondary: #6e5e50;
    --text-muted: #a28c76;
    --border-color: #e4dacf;
    --accent-color: #5298a3;
    --accent-hover: #3f7f8c;
    --success-color: #52ad7f;
    --shadow: 0 1px 3px rgba(62, 55, 48, 0.06);
    --shadow-hover: 0 2px 12px rgba(62, 55, 48, 0.10);
}
/* 晋 · 深色（用双属性选择器压过默认 dark） */
[data-theme-pref="jin-dark"] {
    --bg-primary: #3e3730;
    --bg-secondary: #5a4d42;
    --bg-card: #4a413a;
    --text-primary: #f2ece2;
    --text-secondary: #d2c3b4;
    --text-muted: #a28c76;
    --border-color: #6b5e50;
    --accent-color: #74b1ba;
    --accent-hover: #a0cad1;
    --success-color: #76c39c;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.45);
}

/* 宋 · 浅色 */
[data-theme-pref="song-light"] {
    --bg-primary: #f7f3ec;
    --bg-secondary: #ece6dc;
    --bg-card: #ffffff;
    --text-primary: #2c2c2c;
    --text-secondary: #4a4458;
    --text-muted: #6b6354;
    --border-color: #ddd5c6;
    --accent-color: #4a6b8a;
    --accent-hover: #385370;
    --success-color: #7a8a5a;
    --shadow: 0 1px 3px rgba(74, 107, 138, 0.08);
    --shadow-hover: 0 2px 12px rgba(74, 107, 138, 0.14);
}
/* 宋 · 深色 */
[data-theme-pref="song-dark"] {
    --bg-primary: #1a1814;
    --bg-secondary: #2a2520;
    --bg-card: #221f1a;
    --text-primary: #e8e2d8;
    --text-secondary: #c4bca8;
    --text-muted: #8a8270;
    --border-color: #3a342a;
    --accent-color: #6f8aa8;
    --accent-hover: #9aabc4;
    --success-color: #a0b07a;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* 唐 · 浅色 */
[data-theme-pref="tang-light"] {
    --bg-primary: #f5f0e6;
    --bg-secondary: #ebe3d2;
    --bg-card: #fdf9f0;
    --text-primary: #1a1612;
    --text-secondary: #5a4a2a;
    --text-muted: #6b5a3a;
    --border-color: #d9cfb8;
    --accent-color: #c4981a;
    --accent-hover: #9a7a14;
    --success-color: #b5372b;
    --shadow: 0 1px 3px rgba(196, 152, 26, 0.10);
    --shadow-hover: 0 2px 12px rgba(196, 152, 26, 0.18);
}
/* 唐 · 深色 */
[data-theme-pref="tang-dark"] {
    --bg-primary: #141210;
    --bg-secondary: #2a2418;
    --bg-card: #1c1812;
    --text-primary: #f5f0e6;
    --text-secondary: #c4b894;
    --text-muted: #8a7a4a;
    --border-color: #3a3424;
    --accent-color: #e5b830;
    --accent-hover: #f5cf5a;
    --success-color: #e55a4f;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.6);
}

/* 古典色主题：标题用 Noto Serif SC（通过 .theme-serif-heading 加在 h1-h3 上） */
[data-theme-pref^="jin-"] h1,
[data-theme-pref^="jin-"] h2,
[data-theme-pref^="jin-"] h3,
[data-theme-pref^="jin-"] .post-title,
[data-theme-pref^="jin-"] .site-title {
    font-family: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
    letter-spacing: 0.04em;
}
[data-theme-pref^="song-"] h1,
[data-theme-pref^="song-"] h2,
[data-theme-pref^="song-"] h3,
[data-theme-pref^="song-"] .post-title,
[data-theme-pref^="song-"] .site-title {
    font-family: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
    letter-spacing: 0.04em;
}
[data-theme-pref^="tang-"] h1,
[data-theme-pref^="tang-"] h2,
[data-theme-pref^="tang-"] h3,
[data-theme-pref^="tang-"] .post-title,
[data-theme-pref^="tang-"] .site-title {
    font-family: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
    letter-spacing: 0.04em;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
                 'Ubuntu', 'Cantarell', sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 导航栏 */
.navbar {
    background-color: var(--bg-primary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

.nav-brand a {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s;
}

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

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.5rem;
    transition: transform 0.3s;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* ============================================
   主题下拉菜单（浅色/深色/跟随系统）
   ============================================ */
.theme-menu-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.theme-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    max-height: 70vh;
    overflow-y: auto;
    margin: 0;
    padding: 6px;
    list-style: none;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    z-index: 1100;
    /* 默认隐藏；加 .open 才显示 */
    display: none;
    /* 避免菜单撑大触发 reflow */
    transform-origin: top right;
    transition: opacity 0.15s ease, transform 0.15s ease;
    opacity: 0;
    transform: scale(0.95);
}

.theme-menu.open {
    display: block;
    opacity: 1;
    transform: scale(1);
}

.theme-menu li {
    margin: 0;
    padding: 0;
}

.theme-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.15s;
    font-family: inherit;
}

.theme-menu-item:hover {
    background-color: var(--bg-secondary);
}

.theme-menu-item.active {
    color: var(--accent-color);
    font-weight: 500;
}

.theme-menu-icon {
    font-size: 1.1rem;
    width: 1.4rem;
    text-align: center;
}

.theme-menu-label {
    flex: 1;
}

.theme-menu-check {
    width: 1rem;
    text-align: right;
    color: var(--accent-color);
}

/* 分组标题（默认 / 晋 / 宋 / 唐） */
.theme-menu-group {
    padding: 0;
    margin: 0;
}

.theme-menu-group + .theme-menu-group {
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
    padding-top: 4px;
}

.theme-menu-group > ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.theme-menu-header {
    padding: 6px 12px 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0.05em;
    user-select: none;
}

/* 主内容区 */
.main-content {
    padding: 2rem 20px;
    min-height: calc(100vh - 200px);
}

.blog-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

/* 搜索栏 */
.search-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-bar input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
}

.search-bar button {
    padding: 0.75rem 1.5rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.search-bar button:hover {
    background-color: var(--accent-hover);
}

/* 文章卡片 */
.posts-container {
    display: grid;
    gap: 1.5rem;
}

.post-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

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

.post-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.post-card h2 a {
    color: inherit;
    text-decoration: none;
}

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

.post-meta {
    display: flex;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.post-excerpt {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.8;
}

.post-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: var(--bg-secondary);
    color: var(--accent-color);
    border-radius: 20px;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background-color 0.3s;
}

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

/* 侧边栏 */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.widget {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.widget-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
}

.category-list,
.archive-list {
    list-style: none;
}

.category-list li,
.archive-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.category-list li:last-child,
.archive-list li:last-child {
    border-bottom: none;
}

.category-list a,
.archive-list a {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    justify-content: space-between;
    transition: color 0.3s;
}

.category-list a:hover,
.archive-list a:hover {
    color: var(--accent-color);
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rss-link {
    display: block;
    padding: 0.75rem;
    background-color: var(--bg-secondary);
    color: var(--accent-color);
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    transition: background-color 0.3s;
}

.rss-link:hover {
    background-color: var(--accent-color);
    color: white;
}

/* 文章详情页 */
.post-detail {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.post-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.post-info {
    display: flex;
    gap: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.post-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.post-content h1,
.post-content h2,
.post-content h3 {
    margin: 1.5rem 0 1rem;
    color: var(--text-primary);
}

.post-content p {
    margin-bottom: 1rem;
}

.post-content code {
    background-color: var(--bg-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.post-content pre {
    background-color: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}

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

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    display: block;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

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

.post-content th {
    background-color: var(--bg-secondary);
}

/* 评论区 */
.comments-section {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.comment-form {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
}

.btn-submit {
    padding: 0.75rem 2rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

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

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.comment-item {
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.comment-author {
    font-weight: bold;
    color: var(--text-primary);
}

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

.comment-content {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.3s;
}

.pagination button:hover,
.pagination button.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* 加载状态 */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* 页脚 */
.footer {
    background-color: var(--bg-primary);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
    margin-top: 3rem;
}

.footer-about {
    max-width: 720px;
    margin: 0 auto 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}
.footer-about .footer-title {
    font-size: 1.15rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}
.footer-about p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 0.5rem;
}
.footer-about a {
    color: var(--accent-color);
    text-decoration: none;
}
.footer-about a:hover {
    text-decoration: underline;
}

.footer-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
}
.footer-meta p {
    margin: 0.25rem 0;
}
.footer-meta .beian a {
    color: var(--text-muted);
    text-decoration: none;
}
.footer-meta .beian a:hover {
    color: var(--accent-color);
}
.beian-icon {
    margin-right: 0.25rem;
}

@media (max-width: 768px) {
    .footer-about {
        text-align: left;
    }
}

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

    .sidebar {
        order: -1;
    }

    .nav-menu {
        gap: 1rem;
        font-size: 0.9rem;
    }

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

    .search-bar {
        flex-direction: column;
    }
}

/* 封面图样式 */
.post-cover {
    margin-bottom: 1rem;
    border-radius: 8px;
    overflow: hidden;
}

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

/* ============================================
   用户认证 UI
   ============================================ */

/* Navbar 上的用户菜单（已登录态） */
.user-menu {
    position: relative;
}
.user-menu-toggle {
    cursor: pointer;
}
.user-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 130px;
    list-style: none;
    margin: 0;
    padding: 8px 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 100;
}
.user-menu:hover .user-menu-dropdown,
.user-menu:focus-within .user-menu-dropdown {
    display: block;
}
.user-menu-dropdown li a {
    display: block;
    padding: 8px 16px;
    color: var(--text-primary);
    text-decoration: none;
}
.user-menu-dropdown li a:hover {
    background: var(--bg-secondary);
}

/* 登录 / 注册页 */
.auth-page {
    display: flex;
    justify-content: center;
    padding: 48px 16px;
    min-height: calc(100vh - 200px);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.auth-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    margin-bottom: 20px;
}
.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 0;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-secondary, #888);
}
.auth-tab.active {
    color: var(--accent, #2563eb);
    border-bottom-color: var(--accent, #2563eb);
    font-weight: 600;
}
.auth-panel {
    display: none;
}
.auth-panel.active {
    display: block;
}
.auth-form .form-group {
    margin-bottom: 14px;
}
.auth-form label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--text-secondary, #888);
}
.auth-form input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #222);
    box-sizing: border-box;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--accent, #2563eb);
}
.auth-error {
    color: #c0392b;
    font-size: 13px;
    min-height: 18px;
    margin-bottom: 8px;
}

/* 评论作者条（已登录态） */
.comment-author-bar {
    font-size: 13px;
    color: var(--text-secondary, #888);
    margin-bottom: 10px;
}

/* 未登录态评论提示 */
.login-prompt {
    padding: 24px;
    text-align: center;
    background: var(--bg-secondary, #f8f9fa);
    border: 1px dashed var(--border-color, #ddd);
    border-radius: 8px;
    color: var(--text-secondary, #666);
}
.login-prompt a {
    color: var(--accent, #2563eb);
    font-weight: 600;
    text-decoration: none;
}
.login-prompt a:hover {
    text-decoration: underline;
}
