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

html {
  font-size: 17px;
  scroll-behavior: smooth;
}

/* ===== 主题变量 ===== */
.theme-paper {
  --bg-color: #f8f5f0;
  --bg-secondary: #efe9e0;
  --bg-card: #f5f2ec;
  --text-color: #2c2c2c;
  --text-secondary: #5a5a5a;
  --text-muted: #8a8a8a;
  --accent-color: #8b4513;
  --accent-hover: #a0522d;
  --border-color: #d4ccc0;
  --shadow: rgba(0, 0, 0, 0.06);
  --shadow-deep: rgba(0, 0, 0, 0.12);
  --code-bg: #f0ebe4;
}

.theme-dark {
  --bg-color: #1a1a1a;
  --bg-secondary: #252525;
  --bg-card: #222222;
  --text-color: #e8e4df;
  --text-secondary: #a8a8a8;
  --text-muted: #6a6a6a;
  --accent-color: #c9a66b;
  --accent-hover: #d4b07a;
  --border-color: #3a3a3a;
  --shadow: rgba(0, 0, 0, 0.2);
  --shadow-deep: rgba(0, 0, 0, 0.4);
  --code-bg: #2a2a2a;
}

/* ===== 全局样式 ===== */
body {
  font-family: 'Sabon', 'EB Garamond', 'Noto Serif SC', Garamond, Georgia, serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.7;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* 数学符号专用字体 */
.math-symbol, .site-title, .hero-title {
  font-family: 'STIX Two Math', 'Sabon', 'EB Garamond', serif;
}

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

a:hover {
  color: var(--accent-color);
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  overflow: visible;
}

/* ===== 主题切换按钮 ===== */
.theme-toggle {
  position: fixed;
  top: 2rem;
  right: 2rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 0 2px 6px var(--shadow);
}

.theme-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 3px 10px var(--shadow-deep);
}

.theme-paper .theme-toggle .icon-moon { display: none; }
.theme-paper .theme-toggle .icon-sun { display: block; color: #8b4513; }
.theme-dark .theme-toggle .icon-sun { display: none; }
.theme-dark .theme-toggle .icon-moon { display: block; color: #c9a66b; }

/* ===== 页头 ===== */
.site-header {
  padding: 2rem 0 1.5rem;
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--border-color);
}

.site-title {
  font-size: 1.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}

.site-title a {
  color: var(--text-color);
}

.site-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-style: italic;
  letter-spacing: 0.02em;
}

.site-nav {
  margin-top: 1.5rem;
  display: flex;
  gap: 1.8rem;
}

.site-nav a {
  color: var(--text-secondary);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  position: relative;
  padding-bottom: 2px;
}

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

.site-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent-color);
  transition: width 0.25s ease;
}

.site-nav a:hover::after {
  width: 100%;
}

/* ===== 页脚 ===== */
.site-footer {
  margin-top: 5rem;
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.site-footer a {
  color: var(--text-secondary);
}

/* ===== 主页全屏英雄区 ===== */
.hero-full {
  position: relative;
  min-height: 70vh;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-bottom: 3rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.hero-full.has-background {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.hero-overlay {
  width: 100%;
  padding: 3rem 2rem 2rem;
  background: linear-gradient(to top, rgba(248, 245, 240, 0.92) 0%, rgba(248, 245, 240, 0.7) 60%, transparent 100%);
}

.theme-dark .hero-overlay {
  background: linear-gradient(to top, rgba(26, 26, 26, 0.92) 0%, rgba(26, 26, 26, 0.7) 60%, transparent 100%);
}

.hero-poem {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.poem-line {
  font-size: 1rem;
  color: var(--text-color);
  line-height: 2;
  letter-spacing: 0.02em;
}

.poem-author {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
  font-style: italic;
}

/* ===== 最新文章 ===== */
.latest-section {
  margin-bottom: 3rem;
}

.latest-section .section-header {
  margin-bottom: 1.5rem;
}

.latest-card {
  padding: 1.5rem;
  background: var(--bg-card);
  border-radius: 2px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  margin-bottom: 1rem;
}

.latest-card:last-child {
  margin-bottom: 0;
}

.latest-card:hover {
  border-color: var(--accent-color);
}

.latest-title {
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.latest-title a {
  color: var(--text-color);
}

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

.latest-excerpt {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ===== 分类区 ===== */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border-color);
}

.section-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-color);
  letter-spacing: 0.03em;
}

.section-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== 文章列表 ===== */
.posts-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-item {
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

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

.post-item-title {
  font-size: 1rem;
  font-weight: 400;
  flex: 1;
}

.post-item-title a {
  color: var(--text-color);
}

.post-item-title a:hover {
  color: var(--accent-color);
}

.post-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===== 文章列表页 ===== */
.list-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.list-title {
  font-size: 1.6rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.list-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* 分类筛选 */
.category-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 2rem;
}

.category-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-btn:hover,
.category-btn.active {
  color: var(--accent-color);
  border-color: var(--accent-color);
  background: transparent;
}

/* ===== 单篇文章 ===== */
.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.article-body {
  display: flex;
  gap: 2rem;
}

.article-content {
  flex: 1;
  min-width: 0;
  max-width: 700px;
}

.article-toc {
  width: 200px;
  flex-shrink: 0;
  margin-right: -220px;
}

.article-title {
  font-size: 1.8rem;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 0.8rem;
  letter-spacing: 0.02em;
}

.article-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.article-content {
  font-size: 1rem;
  line-height: 1.85;
}

.article-content h2,
.article-content h3,
.article-content h4 {
  margin: 2.5rem 0 1rem;
  line-height: 1.4;
  font-weight: 500;
}

.article-content h2 {
  font-size: 1.35rem;
}

.article-content h3 {
  font-size: 1.15rem;
}

.article-content p {
  margin-bottom: 1.2rem;
}

.article-content code {
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 2px;
  font-size: 0.88em;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.article-content pre {
  background: var(--code-bg);
  padding: 1rem 1.2rem;
  border-radius: 2px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.9em;
}

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

.article-content blockquote {
  border-left: 2px solid var(--accent-color);
  padding-left: 1.2rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
}

.article-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2.5rem 0;
}

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 2px;
  margin: 1.5rem 0;
}

.article-content ul,
.article-content ol {
  margin: 1rem 0 1.5rem 1.2rem;
}

.article-content li {
  margin-bottom: 0.4rem;
}

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

.article-content th,
.article-content td {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-color);
  font-size: 0.95em;
}

.article-content th {
  background: var(--bg-secondary);
  font-weight: 500;
}

/* ===== KaTeX 数学公式 ===== */
.katex {
  font-size: 1.05em;
}
.katex-display {
  margin: 1.5rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* ===== 关于页面 ===== */
.about-content {
  max-width: 650px;
}

/* ===== 文章目录侧边栏 ===== */
.article-toc {
  position: relative;
}

.toc-sticky {
  position: sticky;
  top: 2rem;
  padding: 1rem 0;
}

.toc-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

/* Hugo 生成的目录结构样式 */
.toc-sticky ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-sticky li {
  margin: 0;
  padding: 0.3rem 0;
}

.toc-sticky > ul > li > a {
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: block;
  padding: 0.25rem 0;
  transition: color 0.2s ease;
}

.toc-sticky > ul > li > a:hover {
  color: var(--accent-color);
}

/* 二级目录 */
.toc-sticky ul ul {
  padding-left: 0.8rem;
  margin: 0.2rem 0;
}

.toc-sticky ul ul li a {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.toc-sticky ul ul li a:hover {
  color: var(--accent-color);
}

/* 当前激活的目录项 */
.toc-sticky a.active {
  color: var(--accent-color) !important;
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .article-body {
    flex-direction: column;
  }

  .article-toc {
    display: none;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 1.5rem 1rem;
  }

  .hero-full {
    min-height: 50vh;
    margin-left: -1rem;
    width: calc(100% + 2rem);
  }

  .hero-overlay {
    padding: 2rem 1rem 1.5rem;
  }

  .poem-line {
    font-size: 0.9rem;
  }

  .theme-toggle {
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .latest-card {
    padding: 1.5rem;
  }

  .latest-title {
    font-size: 1.2rem;
  }

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

  .post-item {
    flex-direction: column;
    gap: 0.3rem;
  }

  .section-header {
    flex-direction: column;
    gap: 0.3rem;
  }
}

/* ===== 小说卡片（总览页 & 主页） ===== */
.novels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.novel-card {
  padding: 1.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.novel-card:hover {
  border-color: var(--accent-color);
}

.novel-card-title {
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.novel-card-title a {
  color: var(--text-color);
}

.novel-card-title a:hover {
  color: var(--accent-color);
}

.novel-card-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.novel-card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 1rem;
}

/* ===== 主页创作区 ===== */
.creative-section {
  margin: 3rem 0;
  padding: 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  text-align: center;
}

.creative-section .section-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

.creative-section .creative-novel-title {
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.creative-section .creative-novel-title a {
  color: var(--text-color);
}

.creative-section .creative-novel-title a:hover {
  color: var(--accent-color);
}

.creative-section .creative-chapter-info {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.creative-section .creative-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.creative-section .creative-all-link {
  font-size: 0.82rem;
}

.creative-section .creative-all-link a {
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1px;
}

.creative-section .creative-all-link a:hover {
  color: var(--accent-color);
  border-color: var(--accent-color);
}

/* ===== 章节导航 ===== */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
  margin: 2rem 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.88rem;
}

.chapter-nav .nav-prev,
.chapter-nav .nav-next {
  flex: 1;
}

.chapter-nav .nav-next {
  text-align: right;
}

.chapter-nav .nav-toc {
  flex: 0 0 auto;
  padding: 0 1.5rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.chapter-nav a {
  color: var(--text-secondary);
}

.chapter-nav a:hover {
  color: var(--accent-color);
}

.chapter-nav .nav-placeholder {
  color: var(--text-muted);
  opacity: 0.4;
}

/* ===== 小说信息头 ===== */
.novel-info {
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.novel-info a {
  color: var(--text-secondary);
}

.novel-info a:hover {
  color: var(--accent-color);
}

/* ===== 响应式（小说） ===== */
@media (max-width: 768px) {
  .novels-grid {
    grid-template-columns: 1fr;
  }

  .creative-section {
    padding: 1.8rem;
  }

  .chapter-nav {
    font-size: 0.82rem;
  }

  .chapter-nav .nav-toc {
    padding: 0 0.8rem;
  }
}
