/* ========== 变量定义 ========== */
:root {
    --primary-color: #C27A3E;
    --primary-dark: #965F2E;
    --secondary-color: #5D4E37;
    --accent-color: #E0A24E;
    --text-color: #4A3828;
    --light-text: #7A6A58;
    --lighter-text: #AB9B8B;
    --bg-base-color: #FFFBF5;
    --card-bg: #FFFFFF;
    --header-bg: rgba(255, 251, 245, 0.7);
    --footer-bg: #F7F3EB;
    --gold-color: #E6B422;

    --bg-texture: none;
    --bg-texture-size: auto;
    --bg-gradient: none;
    --bg-image: none;
    --bg-image-opacity: 0.1;

    --text-base: 1rem;
    --text-sm: 0.875rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    --leading-normal: 1.8;
    --leading-relaxed: 1.8;
    --max-width: 1200px;
    --rhythm: 1.8rem;

    --font-main: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "WenQuanYi Micro Hei", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-quote: Georgia, serif;
    --font-serif: 'Noto Serif SC', 'Source Han Serif SC', 'STSong', 'SimSun', serif;
}

/* ========== 基础重置 ========== */
* { box-sizing: border-box; }
body {
    font-family: var(--font-main);
    color: var(--text-color);
    background-color: var(--bg-base-color);
    background-image: var(--bg-gradient), var(--bg-texture);
    background-size: 100%, var(--bg-texture-size, auto);
    background-position: center, center;
    background-attachment: fixed;
    margin: 0;
    padding: 0;
    line-height: var(--leading-normal);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    transition: background-color 0.3s, color 0.3s;
}

/* 图片背景模式 */
body.bg-image {
    background-image: none;
}
body.bg-image::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-image);
    background-size: cover;
    background-position: center;
    opacity: var(--bg-image-opacity);
    z-index: -1;
}

/* ========== 字体风格切换 ========== */
body.font-sans-serif {
    /* 默认已是无衬线，无需重复定义，但保留以应对未来覆盖 */
}
body.font-serif {
    --font-main: var(--font-serif);
}
body.font-monospace {
    --font-main: 'Consolas', 'Monaco', 'Courier New', monospace;
}
body.font-cursive {
    --font-main: 'Comic Sans MS', 'KaiTi', '楷体', cursive, sans-serif;
}
body.font-fantasy {
    --font-main: 'Impact', 'Papyrus', fantasy, sans-serif;
}
body.font-myself {
    /* 
       “自定”需要你在后台单独设置一个字体名称输入框，
       目前暂时回退为无衬线字体，如需自定义请告诉我，我可以为你增加这个选项。
    */
}

main { flex: 1; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }
a { color: var(--primary-color); text-decoration: none; transition: color 0.3s ease; }
a:hover { color: var(--gold-color); }

/* ========== 进度条 ========== */
.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 9999;
    pointer-events: none;
}
.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--gold-color));
    transition: width 0.1s linear;
    will-change: width;
}

/* ========== 头部 ========== */
/* ========== 头部 ========== */
.header {
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 30px rgba(0,0,0,0.06);
    padding: 15px 0;
    border-bottom: 1px solid rgba(212, 140, 60, 0.1);
    margin-bottom: var(--rhythm);
    z-index: 100;
    transition: background 0.3s, box-shadow 0.3s;
}
.sticky-header {
    position: sticky;
    top: 0;
}
.no-sticky {
    /* 正常文档流，可不写任何定位属性 */
}
.header-container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.header-brand { display: flex; align-items: center; }
.sun-symbol { display: flex; align-items: center; margin-right: 15px; }
.logo { display: flex; align-items: center; font-size: 1.5rem; font-weight: bold; color: var(--gold-color); }
.logo img { height: 40px; margin-right: 10px; }

/* 移动端菜单按钮 */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-color);
    cursor: pointer;
    padding: 0 10px;
}

/* 右侧区域 */
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 导航菜单 */
.nav-menu { display: flex; list-style: none; margin: 0; padding: 0; }
.nav-menu li { margin-left: 25px; }
.nav-menu a { color: var(--text-color); font-weight: 500; position: relative; }
.nav-menu a:hover { color: var(--gold-color); }
.nav-menu a:hover::after { content: ''; position: absolute; bottom: -5px; left: 0; width: 100%; height: 2px; background: var(--gold-color); animation: underline 0.3s ease; }

/* 搜索框 */
.search-form { display: flex; align-items: center; }
.search-input {
    padding: 6px 12px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 20px;
    background: var(--card-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
    width: 160px;
    transition: width 0.3s, border-color 0.3s;
}
.search-input:focus { outline: none; border-color: var(--primary-color); width: 200px; }
.search-btn { background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 0 5px; }

/* ========== 首页标题与标语 ========== */
.header-quote { margin: calc(var(--rhythm)*2) 0 var(--rhythm); text-align: center; }
.site-logo {
    font-family: 'PingFang SC', sans-serif;
    font-size: 3rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 12px;
    letter-spacing: 3px;
    text-shadow: 0 0 10px rgba(230, 180, 34, 0.5), 2px 2px 4px rgba(0,0,0,0.2);
    animation: breatheGlow 4s ease-in-out infinite;
}
@keyframes breatheGlow {
    0%, 100% { text-shadow: 0 0 10px rgba(230, 180, 34, 0.5), 2px 2px 4px rgba(0,0,0,0.2); }
    50% { text-shadow: 0 0 25px rgba(230, 180, 34, 0.9), 2px 2px 12px rgba(230, 180, 34, 0.4); }
}
.site-motto { font-family: "Comic Sans MS", cursive, sans-serif; font-size: 1.2rem; color: var(--secondary-color); margin-bottom: 8px; line-height: var(--leading-normal); }
.site-submotto { font-size: 1.1rem; color: var(--light-text); font-style: italic; max-width: 80%; margin: 0 auto; }

/* ========== 格言卡片 ========== */
.quote-card {
    margin: calc(var(--rhythm)*1.5) 0;
    padding: calc(var(--rhythm)*1.5);
    border-left: 4px solid var(--primary-color);
    font-family: var(--font-quote);
    line-height: var(--leading-relaxed);
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 6px 30px rgba(0,0,0,0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.quote-card:hover { transform: translateY(-5px); box-shadow: 0 12px 40px rgba(0,0,0,0.1); }
.quote-card p { margin: 0 0 15px; font-size: 1.1rem; padding-left: 30px; position: relative; }
.quote-card p::before { content: ""; position: absolute; left: 0; top: 12px; width: 20px; height: 2px; background-color: var(--gold-color); }
.quote-card-footer { margin-top: 20px; text-align: right; font-style: italic; color: var(--light-text); font-size: 0.9rem; }
.quote-simple { margin: var(--rhythm) 0; font-family: var(--font-quote); white-space: pre-line; color: var(--secondary-color); }
.refresh-quote-btn { display: block; margin: 10px auto 0; background: none; border: 1px solid var(--primary-color); color: var(--primary-color); padding: 5px 15px; border-radius: 20px; cursor: pointer; font-size: 0.9rem; transition: background 0.3s, color 0.3s; }
.refresh-quote-btn:hover { background: var(--primary-color); color: #fff; }

/* ========== 文章列表 ========== */
.article-list { margin: calc(var(--rhythm)*1.5) 0; }
.month-header {
    font-size: 1.3rem;
    color: var(--secondary-color);
    margin: var(--rhythm) 0 calc(var(--rhythm)/2);
    font-weight: bold;
    position: relative;
    padding-bottom: 8px;
}
.month-header::after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 1px; background: linear-gradient(90deg, transparent, rgba(0,0,0,0.08), transparent); }
.article-item {
    margin-bottom: 18px;
    padding-left: 20px;
    position: relative;
    border-left: 3px solid transparent;
    transition: transform 0.2s ease, border-color 0.3s;
}
.article-item.sticky-item {
    background: rgba(230, 180, 34, 0.08);
    border-radius: 8px;
    padding: 10px 15px;
}
.sticky-badge {
    display: inline-block;
    background: var(--gold-color);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-right: 8px;
    vertical-align: middle;
}
/* 分类视觉区分 */
.cat-jingdian-jiedu,
.cat-classic-books { border-left-color: #B08968; }
.cat-guoxue-zhexue,
.cat-guo-xue { border-left-color: #7A9A7E; }
.cat-chengzhang-renzhi,
.cat-cognition { border-left-color: #D4A373; }
.cat-rensheng-ganwu,
.cat-life-thoughts { border-left-color: #C49B8A; }
.article-item:hover { transform: translateX(8px); }
.article-item::before {
    content: "●";
    position: absolute;
    left: -10px;
    top: 0;
    color: var(--gold-color);
    font-weight: bold;
}
.article-title { font-weight: bold; color: var(--primary-color); display: inline-block; margin-right: 10px; font-family: var(--font-serif); }
.article-meta { display: inline-block; font-size: 0.85rem; color: var(--light-text); margin-right: 10px; }
.article-meta .read-time { background: var(--footer-bg); padding: 2px 10px; border-radius: 12px; margin-right: 8px; color: var(--primary-dark); }
.article-meta a { color: var(--accent-color); background: rgba(201, 169, 110, 0.15); padding: 2px 10px; border-radius: 12px; font-size: 0.8rem; margin-right: 4px; }
.article-excerpt { display: block; color: var(--text-color); margin-top: 5px; font-family: var(--font-serif); }
.no-post { text-align: center; padding: 40px; color: var(--light-text); font-style: italic; }

/* ========== 文章页 ========== */
.post-wrapper { margin: calc(var(--rhythm)*1.5) 0; }
.post-title {
    color: var(--text-color);
    font-family: var(--font-serif);
    font-size: var(--text-3xl);
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: var(--rhythm);
}
.post-title.left { text-align: left; }
.post-title.center { text-align: center; }


.post-content {
    font-family: var(--font-serif);
    line-height: var(--leading-relaxed);
    font-size: var(--text-lg);
    letter-spacing: 0.02em;
    word-spacing: 0.05em;
    text-align: justify;
    max-width: 100ch;
    margin: 0 auto;
    word-break: break-word;  /* 防止长链接溢出 */
}


.post-content p { margin-bottom: var(--rhythm); }
.post-content h2, .post-content h3 { color: var(--primary-dark); margin-top: calc(var(--rhythm)*1.5); margin-bottom: var(--rhythm); position: relative; }
.post-content h2::after { content: ''; display: block; width: 40px; height: 3px; background: var(--gold-color); margin-top: 8px; }
.post-content img { max-width: 100%; height: auto; border-radius: 6px; margin: 20px 0; }
.post-content blockquote {
    border-left: 4px solid var(--gold-color);
    padding-left: 20px;
    margin-left: 0;
    color: var(--light-text);
    font-style: italic;
    background: rgba(230, 180, 34, 0.05);
    padding: var(--rhythm);
    border-radius: 0 8px 8px 0;
}
.post-content pre { background: var(--footer-bg); padding: 15px; border-radius: 4px; overflow-x: auto; }
.post-content code { font-family: Consolas, Monaco, monospace; background: var(--footer-bg); padding: 2px 6px; border-radius: 3px; font-size: 0.9em; }
.post-content strong {
    background: linear-gradient(120deg, rgba(230, 180, 34, 0.2) 0%, rgba(230, 180, 34, 0.2) 60%);
    padding: 0 2px;
    font-weight: inherit;
}

/* ========== 文章卡片样式 ========== */
.post-card {
    overflow: hidden;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 6px 30px rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.03);
}
.post-card .post-title,
.post-card .post-content {
    padding: 30px;
}
.post-card.gradient-border {
    position: relative;
    background: var(--bg-base-color);
}
.post-card.gradient-border::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 12px;
    padding: 2px;
    background: linear-gradient(45deg, var(--primary-color), var(--gold-color));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
}
.post-card.glass {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3);
}
.post-card.shadow-border {
    border: 2px solid transparent;
    box-shadow: 0 0 20px rgba(0,0,0,0.15);
}
.post-plain {
    margin: var(--rhythm) 0;
}

/* ========== 目录 TOC ========== */
.toc {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.toc-title { font-size: 1.1rem; font-weight: bold; margin-bottom: 12px; color: var(--primary-dark); }
.toc ul { list-style: none; padding-left: 0; margin: 0; }
.toc li { margin: 6px 0; }
.toc li.toc-level-3 { padding-left: 25px; font-size: 0.95em; }
.toc a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s;
    display: block;
    padding: 2px 0;
}
.toc a:hover, .toc a.active { color: var(--primary-color); font-weight: bold; }

/* ========== 导航与版权 ========== */

.post-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: calc(var(--rhythm)*2);
    padding-top: var(--rhythm);
    border-top: 1px solid rgba(0,0,0,0.05);
    gap: 20px;
}
.post-navigation > div {
    max-width: 48%;
}
.post-navigation a {
    font-weight: 500;
    color: var(--primary-color);
    transition: color 0.2s;
}
.post-navigation a:hover {
    color: var(--gold-color);
}
.no-nav {
    color: var(--lighter-text);
    font-style: italic;
    opacity: 0.6;
}
.copyright-notice {
    margin-top: calc(var(--rhythm)*1.5);
    padding: 15px;
    background: var(--footer-bg);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--light-text);
}

/* ========== 相关文章 ========== */
.related-posts { margin-top: calc(var(--rhythm)*2); padding-top: var(--rhythm); border-top: 1px solid rgba(212, 140, 60, 0.2); }
.related-title { font-size: 1.3rem; color: var(--secondary-color); margin-bottom: var(--rhythm); }
.related-list { display: flex; flex-wrap: wrap; gap: 15px; }
.related-item { flex: 1 1 200px; background: var(--card-bg); padding: 15px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); transition: transform 0.2s; text-decoration: none; color: inherit; }
.related-item:hover { transform: translateY(-3px); background: #FFFBF0; }
.related-post-title { display: block; font-weight: bold; color: var(--primary-color); margin-bottom: 5px; }
.related-post-date { font-size: 0.8rem; color: var(--light-text); }

/* ========== 分类页 ========== */
.category-header { margin: var(--rhythm) 0; font-size: 1.8rem; color: var(--primary-dark); }
.category-description { color: var(--light-text); margin-bottom: var(--rhythm); }
.category-stats { font-size: 0.9rem; color: var(--light-text); margin-bottom: var(--rhythm); }

/* ========== 搜索页 ========== */
.search-header { margin-bottom: var(--rhythm); }
.search-header h2 { font-size: 1.8rem; color: var(--primary-dark); }
.search-header p { color: var(--light-text); }

/* ========== 评论 ========== */
#comments { margin: var(--rhythm) 0; }
#comments h3 { font-size: 1.3rem; margin-bottom: var(--rhythm); color: var(--secondary-color); }
.comment-list { list-style: none; padding: 0; }
.comment-list li { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.respond input,
.respond textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #E8DDD0;
    border-radius: 6px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text-color);
}
.respond button {
    background: linear-gradient(135deg, var(--primary-color), var(--gold-color));
    color: #fff;
    border: none;
    padding: 12px 28px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    letter-spacing: 0.5px;
}
/* 表情面板 */
.emoji-panel { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.emoji-item { background: none; border: 1px solid rgba(0,0,0,0.1); border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 1.2rem; transition: background 0.2s; }
.emoji-item:hover { background: var(--footer-bg); }

/* ========== 返回顶部按钮 ========== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 999;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--gold-color); }

/* ========== 页脚 ========== */
.footer { text-align: center; color: var(--light-text); font-size: 0.9rem; background: var(--footer-bg); padding: 24px 0; margin-top: 60px; }
.footer a { color: var(--accent-color); }
.footer-motto { font-style: italic; margin-left: 15px; }

/* ========== 404 页面 ========== */
.error-page { text-align: center; padding: 80px 20px; }
.error-page h1 { font-size: 3rem; color: var(--primary-color); margin-bottom: 20px; }
.error-page p { font-size: 1.2rem; color: var(--light-text); margin-bottom: 30px; }
.error-search { max-width: 400px; margin: 0 auto 20px; }
.error-back { display: inline-block; padding: 10px 25px; background: var(--primary-color); color: #fff; border-radius: 25px; margin-top: 10px; }


/* ========== 文章元信息行 ========== */
.post-meta-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 16px;
    margin-bottom: 24px;
    padding: 12px 20px;
    background: var(--card-bg);
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--light-text);
    box-shadow: 0 2px 12px rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.04);
}
.post-meta-info time,
.post-meta-info span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.meta-sep {
    color: var(--lighter-text);
    font-weight: bold;
}
/* 标签链接延续主题风格 */
.post-meta-info a {
    color: var(--accent-color);
    background: rgba(201, 169, 110, 0.15);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    text-decoration: none;
    margin: 0 2px;
    transition: background 0.2s;
}
.post-meta-info a:hover {
    background: rgba(201, 169, 110, 0.3);
}
/* 响应式下保持易读 */
@media (max-width: 480px) {
    .post-meta-info {
        font-size: 0.85rem;
        padding: 10px 14px;
    }
}

/* ========== 简洁样式下的元信息 ========== */
.post-plain .post-meta-info {
    justify-content: flex-start;   /* 左对齐，跟随标题左对齐 */
    background: transparent;
    box-shadow: none;
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    border-radius: 0;
    padding: 0 0 12px 0;
    margin-bottom: 28px;
}

/* ========== 正文与评论区之间的过渡分隔线 ========== */
#comments::before {
    content: "";
    display: block;
    width: 120px;
    height: 1px;
    margin: calc(var(--rhythm) * 2) auto;
    background: linear-gradient(90deg, transparent, var(--gold-color) 40%, var(--gold-color) 60%, transparent);
    position: relative;
}
#comments::after {
    content: "◆";
    display: block;
    text-align: center;
    font-size: 0.6rem;
    color: var(--gold-color);
    margin-top: -0.65rem;
    margin-bottom: calc(var(--rhythm) * 2);
}

/* ========== 打印样式 ========== */
@media print {
    .header, .footer, .progress-container, .back-to-top, .toc, .related-posts, .comments, .post-navigation, .menu-toggle, .search-form { display: none !important; }
    body { background: #fff; color: #000; font-size: 12pt; }
    .post-content { max-width: 100%; }
    .post-title { font-size: 24pt; }
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .header-container { flex-wrap: nowrap; }
    .header-right { gap: 10px; }
    .search-input { width: 120px; }
}
@media (max-width: 767px) {
    .menu-toggle { display: block; }
    .header-right {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--header-bg);
        backdrop-filter: blur(20px);
        padding: 20px;
        box-shadow: 0 20px 30px rgba(0,0,0,0.1);
        border-top: 1px solid rgba(0,0,0,0.05);
    }
    .header-right.menu-open { display: flex; }
    .nav-menu { flex-direction: column; gap: 15px; }
    .nav-menu li { margin-left: 0; }
    .search-input { width: 100%; }
    .search-form { width: 100%; }
    .header {
        position: relative;
        top: auto;
    }
    .post-card {
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        border: none !important;
        padding: 0 !important;
        transform: none !important;
    }
    .post-card .post-title,
    .post-card .post-content { padding: 0 !important; }
    .post-card.gradient-border::before { display: none !important; }
    .post-card.glass {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: transparent !important;
        border: none !important;
    }
    .post-card.shadow-border { box-shadow: none !important; border: none !important; }
    .related-list { flex-direction: column; }
}
@media (max-width: 480px) {
    .site-logo { font-size: 2rem; }
    .site-motto { font-size: 1rem; }
    .site-submotto { font-size: 0.9rem; }
    .post-title { font-size: var(--text-2xl); }
}

@keyframes underline { from { width: 0; } to { width: 100%; } }