/* ===========================================
   历史天使书阁 · 升级主题
   Deployed on Cloudflare Pages
   =========================================== */

/* --- Import Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700;900&family=Noto+Sans+SC:wght@300;400;500&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

/* --- Reset & Variables --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Core */
  --font-serif: 'Noto Serif SC', 'Crimson Text', Georgia, 'Times New Roman', serif;
  --font-sans: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-eng: 'Crimson Text', Georgia, serif;
  --font-base: 1em;
  --line-height: 1.85;
  --max-width: 780px;

  /* Light palette */
  --bg: #f5f0e8;
  --bg-card: #ede5d8;
  --bg-hover: #e8ddd0;
  --bg-code: #ede5d8;
  --text: #2c2416;
  --text-heading: #3a2a1a;
  --text-muted: #8a7a6a;
  --text-link: #3a2a1a;
  --text-visited: #5a4a3a;
  --border: #d4c5a9;
  --border-light: #e0d5c5;
  --accent: #8a6a4a;
  --accent-light: #a08060;
  --accent-dim: #5a4a3a;
  --quote-bg: #f0e8dc;
}

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1612;
    --bg-card: #221c14;
    --bg-hover: #2a221a;
    --bg-code: #221c14;
    --text: #d4c8b8;
    --text-heading: #e0d5c5;
    --text-muted: #7a6a5a;
    --text-link: #d4c8b8;
    --text-visited: #b8a890;
    --border: #3a2a1a;
    --border-light: #2a221a;
    --accent: #6a5a4a;
    --accent-light: #5a4a3a;
    --accent-dim: #8a7a6a;
    --quote-bg: #221c14;
  }
}

/* --- Base --- */
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-serif);
  font-size: var(--font-base);
  line-height: var(--line-height);
  color: var(--text);
  background: var(--bg);
  padding: 0 20px;
  min-height: 100vh;
}

.wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: 2px;
  line-height: 1.5;
}

h1 { font-size: 2.2rem; }
h2 { font-size: 1.35rem; margin-top: 1.5em; margin-bottom: 0.6em; }
h3 { font-size: 1.1rem; margin-top: 1.2em; margin-bottom: 0.4em; }

p { margin-bottom: 0.8em; }

a {
  color: var(--text-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}

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

small, .text-small {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- Header --- */
.site-header {
  text-align: center;
  padding: 55px 0 30px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 40px;
  position: relative;
}

.site-header::after {
  content: "✦";
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  color: var(--accent-light);
  background: var(--bg);
  padding: 0 14px;
}

.site-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 10px;
  color: var(--text-heading);
  text-decoration: none !important;
  display: block;
  margin-bottom: 6px;
}

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

.site-title a {
  text-decoration: none;
  color: inherit;
}

.site-subtitle {
  font-family: var(--font-eng);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--text-muted);
  letter-spacing: 3px;
  margin-top: 2px;
}

/* --- Navigation --- */
.site-nav {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

.site-nav a {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 18px;
  border-radius: 20px;
  color: var(--text-muted);
  text-decoration: none !important;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.site-nav a:hover {
  background: var(--bg-hover);
  border-color: var(--border);
  color: var(--text-heading);
}

.site-nav a.active {
  background: var(--text-heading);
  color: var(--bg);
  border-color: var(--text-heading);
}

@media (prefers-color-scheme: dark) {
  .site-nav a.active {
    background: var(--text-heading);
    color: var(--bg);
  }
}

/* --- Hero --- */
.hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px 36px;
  margin-bottom: 40px;
  position: relative;
}

.hero::before {
  content: "「";
  position: absolute;
  top: 6px;
  left: 10px;
  font-size: 32px;
  color: var(--accent-light);
  opacity: 0.4;
  line-height: 1;
}

.hero::after {
  content: "」";
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-size: 32px;
  color: var(--accent-light);
  opacity: 0.4;
  line-height: 1;
}

.hero p {
  font-size: 0.95rem;
  color: var(--text);
  text-align: center;
  margin-bottom: 0;
}

.hero .notice {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 12px;
  font-family: var(--font-sans);
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  text-align: center;
  letter-spacing: 1px;
}

/* --- Stats Bar --- */
.site-stats {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 28px;
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Section Title --- */
.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 18px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  position: relative;
  margin-top: 0;
  letter-spacing: 3px;
}

.section-title::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--accent);
}

/* --- Blog Post List --- */
.post-list {
  list-style: none;
  margin-bottom: 40px;
}

.post-item {
  display: flex;
  gap: 20px;
  padding: 18px 12px;
  border-bottom: 1px solid var(--border-light);
  border-radius: 4px;
  transition: background 0.15s;
}

.post-item:first-child {
  border-top: none;
}

.post-item:hover {
  background: var(--bg-hover);
}

.post-date {
  flex: 0 0 100px;
  font-family: var(--font-eng);
  font-size: 0.82rem;
  color: var(--text-muted);
  padding-top: 4px;
  text-align: right;
}

.post-body {
  flex: 1;
  min-width: 0;
}

.post-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading);
  text-decoration: none;
  display: block;
  line-height: 1.5;
  transition: color 0.2s;
}

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

.post-tags {
  margin-top: 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.post-tag {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--border-light);
  color: var(--text-muted);
  letter-spacing: 1px;
}

.post-excerpt {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.6;
}

/* --- Collection Card --- */
.collection-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 28px;
  margin-bottom: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  transition: all 0.2s;
}

.collection-card:hover {
  border-color: var(--accent-light);
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
}

.collection-info h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 4px;
  margin-top: 0;
}

.collection-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-sans);
  margin-bottom: 0;
}

.collection-link {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 8px 24px;
  background: var(--text-heading);
  color: var(--bg);
  border-radius: 20px;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background 0.2s;
}

.collection-link:hover {
  background: var(--accent-dim);
  color: var(--bg);
}

/* --- Article Page --- */
.article-meta {
  margin-bottom: 28px;
}

.article-meta .date {
  font-family: var(--font-eng);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.article-meta .source {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.article-meta .author-line {
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 10px;
}

.article-title {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

/* --- Article Content --- */
.article-content {
  font-size: 0.95rem;
  line-height: 1.85;
}

.article-content p {
  text-indent: 2em;
  margin-bottom: 0.7em;
}

.article-content h2,
.article-content h3,
.article-content h4,
.article-content ul,
.article-content ol,
.article-content blockquote,
.article-content pre,
.article-content figure,
.article-content .highlight {
  text-indent: 0;
}

.article-content blockquote {
  border-left: 3px solid var(--border);
  padding: 14px 22px;
  margin: 20px 0;
  background: var(--quote-bg);
  color: var(--text);
  border-radius: 0 4px 4px 0;
  font-style: normal;
  text-indent: 0;
}

.article-content blockquote p {
  text-indent: 0 !important;
}

.article-content .footnote-link {
  font-size: 0.75rem;
  vertical-align: super;
  color: var(--accent);
  text-decoration: none;
  margin: 0 1px;
}

.article-content hr {
  border: none;
  border-top: 1px dashed var(--border);
  margin: 30px 0;
  text-indent: 0;
}

.article-content img {
  max-width: 100%;
  border-radius: 4px;
  margin: 16px 0;
  text-indent: 0;
}

.article-content code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  padding: 2px 6px;
  background: var(--bg-code);
  color: var(--text);
  border-radius: 3px;
  font-size: 0.85em;
}

.article-content pre {
  background: var(--bg-code);
  border-radius: 6px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
}

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

.article-content ul,
.article-content ol {
  padding-left: 2em;
  margin: 12px 0;
}

.article-content li {
  margin-bottom: 4px;
}

/* Table of Contents */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 24px;
  margin-bottom: 28px;
}

.toc h3 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  letter-spacing: 2px;
}

.toc ol {
  padding-left: 1.5em;
  margin: 0;
}

.toc li {
  margin-bottom: 4px;
  font-size: 0.88rem;
}

.toc a {
  text-decoration: none;
  color: var(--text-muted);
}

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

/* --- TOC for Collection --- */
.collection-toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px 28px;
  margin-bottom: 32px;
}

.collection-toc h3 {
  margin: 0 0 14px;
  font-size: 1rem;
  letter-spacing: 3px;
}

.collection-toc ol {
  padding-left: 0;
  list-style: none;
  counter-reset: toc-counter;
}

.collection-toc ol li {
  counter-increment: toc-counter;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}

.collection-toc ol li:last-child {
  border-bottom: none;
}

.collection-toc ol li::before {
  content: "§" counter(toc-counter, trad-chinese-informal) "  ";
  font-weight: 600;
  color: var(--accent);
  margin-right: 6px;
}

@counter-style trad-chinese-informal {
  system: fixed;
  symbols: "零" "一" "二" "三" "四" "五" "六" "七" "八" "九";
}

/* --- Comments / Backlinks --- */
.backlinks {
  margin-top: 40px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
}

.backlinks a {
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

/* --- Footer --- */
.site-footer {
  margin-top: auto;
  text-align: center;
  padding: 32px 0 24px;
  border-top: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.73rem;
  color: var(--text-muted);
}

.site-footer p {
  margin-bottom: 4px;
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: underline;
}

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

/* --- RSS Feed Link --- */
.rss-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: all 0.2s;
}

.rss-link:hover {
  background: var(--bg-hover);
  border-color: var(--accent-light);
  color: var(--text-heading);
}

/* --- Reading Progress (JS) --- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  z-index: 9999;
  transition: width 0.1s linear;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .site-title { font-size: 1.5rem; letter-spacing: 5px; }
  .site-subtitle { font-size: 0.78rem; }
  .site-header { padding: 30px 0 24px; margin-bottom: 24px; }

  .post-item { flex-direction: column; gap: 4px; padding: 14px 8px; }
  .post-date { text-align: left; flex: none; }

  .hero { padding: 24px 18px; }

  .collection-card { flex-direction: column; text-align: center; padding: 20px; }

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

  .site-stats { gap: 10px; font-size: 0.7rem; }

  .section-title::after { width: 40px; }
}

@media (max-width: 400px) {
  .site-title { font-size: 1.2rem; letter-spacing: 3px; }
  nav a { padding: 4px 12px; font-size: 0.75rem; }
}

/* --- Print --- */
@media print {
  .site-header { border: none; }
  .site-header::after { display: none; }
  .site-nav { display: none; }
  .site-footer { display: none; }
  .reading-progress { display: none; }
  body { background: white; color: black; font-size: 0.85rem; }
  a { color: black !important; text-decoration: underline; }
  .hero { border: 1px solid #ccc; }
}

/* --- Utilities --- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
/* --- Download Button --- */
.download-btn {
  display: inline-block;
  padding: 4px 14px;
  background: var(--accent);
  color: var(--bg) !important;
  border-radius: 14px;
  font-size: 0.78rem;
  text-decoration: none !important;
  transition: opacity 0.2s;
  font-family: var(--font-sans);
}
.download-btn:hover { opacity: 0.8 !important; }
