/* ============================================================
   纪遇的花园 · v2
   设计风格：借鉴 xiluluke.com（暖纸质感、编号板块、卡片微交互）
   文字排版：借鉴 demochen.com（霞鹜文楷、16px 正文、宽松行距）
   内容结构：借鉴 liangmouyin.com（精选 / 最近更新 / Sparks / 归档）
   ============================================================ */

:root {
  --bg: #faf9f5;
  --fg: #1b1a17;
  --muted: #76736a;
  --line: rgba(27, 26, 23, 0.08);
  --line-strong: rgba(27, 26, 23, 0.18);
  --code-bg: #f0eee7;
  --code-fg: #b23a30;
  --card: rgba(255, 255, 255, 0.55);
  --card-hover: rgba(27, 26, 23, 0.03);
  --green: #2e7d4f;
  --green-bg: rgba(46, 125, 79, 0.12);
  --sel: rgba(231, 196, 106, 0.5);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0b;
  --fg: #edece8;
  --muted: #8f8c83;
  --line: rgba(237, 236, 232, 0.1);
  --line-strong: rgba(237, 236, 232, 0.22);
  --code-bg: #1a1916;
  --code-fg: #e07b70;
  --card: rgba(255, 255, 255, 0.03);
  --card-hover: rgba(237, 236, 232, 0.05);
  --green: #7cc79b;
  --green-bg: rgba(124, 199, 155, 0.12);
  --sel: rgba(231, 196, 106, 0.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", "楷体", serif;
  font-size: 16px;
  line-height: 1.85;
  transition: background 0.25s ease, color 0.25s ease;
}
::selection { background: var(--sel); }
a { color: inherit; text-decoration: none; }

/* 纸张颗粒质感（xiluluke 风格） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}
html[data-theme="dark"] body::before { opacity: 0.07; }

.page { max-width: 37.5rem; margin: 0 auto; padding: 2.5rem 1.5rem 3rem; }

/* 顶部导航 */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1.75rem;
}
.brand {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.nav { display: flex; align-items: center; gap: 1.3rem; }
.nav a { font-size: 0.875rem; color: var(--muted); transition: color 0.15s; }
.nav a:hover { color: var(--fg); }
.nav a.active { color: var(--fg); font-weight: 600; }
.theme-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line-strong);
  background: none;
  color: var(--fg);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
  transition: border-color 0.15s;
}
.theme-btn:hover { border-color: var(--fg); }

/* 首页头图 */
.hero { padding: 2.5rem 0 3rem; }
.home-name { display: flex; align-items: center; gap: 0.6rem; }
.home-name h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.5;
}
.home-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-bg);
}
.home-introduction { margin-top: 1.1rem; color: var(--muted); font-size: 0.95rem; line-height: 1.75; }
.home-introduction p { margin: 0 0 0.75rem; }
.home-introduction a { text-decoration: underline dotted; text-underline-offset: 0.2em; }
.hero-count { margin-top: 1.2rem; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 板块标题（编号 + mono 标签） */
.section { margin: 2.75rem 0; }
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.section-tag {
  display: inline-flex;
  align-items: stretch;
  font-family: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-tag-index {
  border: 1px solid var(--line-strong);
  border-radius: 0.25rem;
  padding: 0.05rem 0.35rem;
  font-variant-numeric: tabular-nums;
  background: repeating-linear-gradient(-45deg, var(--line) 0 1px, transparent 1px 5px);
}
.section-tag-label { align-self: center; padding-left: 0.5rem; }
.view-all { font-size: 0.875rem; color: var(--muted); transition: color 0.15s; }
.view-all:hover { color: var(--fg); }

/* 精选卡片 */
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.post-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 0.75rem;
  padding: 1.25rem 1.25rem 1.1rem;
  transition: background-color 0.16s, transform 0.16s;
}
.post-card:hover { background: var(--card-hover); }
.post-card:active { transform: scale(0.985); }
.card-date { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-title { font-size: 1.05rem; font-weight: 600; line-height: 1.5; }
.card-summary { font-size: 0.85rem; color: var(--muted); line-height: 1.7; margin: 0; }
.card-tags { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.2rem; }

/* 文章行列表 */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-item {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  padding: 0.9rem 0;
  border-bottom: 1px dashed var(--line);
}
.post-item:first-child { padding-top: 0; }
.post-item:last-child { border-bottom: none; }
.post-date { flex: none; width: 5.2rem; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.post-info { min-width: 0; }
.post-title { font-size: 1rem; font-weight: 600; margin: 0; line-height: 1.5; }
.post-title a:hover { text-decoration: underline dotted; text-underline-offset: 0.25em; }
.post-summary { font-size: 0.85rem; color: var(--muted); margin: 0.15rem 0 0; }
.new-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.5rem;
  border: 1px solid rgba(46, 125, 79, 0.35);
  color: var(--green);
  background: var(--green-bg);
  border-radius: 999px;
  font-size: 0.68rem;
  line-height: 1.6;
  padding: 0 0.5rem;
}

/* Sparks 随想 */
.spark-item { display: flex; gap: 1rem; padding: 0.7rem 0; border-bottom: 1px dashed var(--line); }
.spark-item:last-child { border-bottom: none; }
.spark-date { flex: none; width: 5.2rem; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.spark-text { font-size: 0.95rem; line-height: 1.75; }

/* 文章页 / 关于页 / 归档页 */
.article { padding-top: 0.5rem; }
.article h1 {
  margin: 0 0 0.75rem;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.01em;
}
.article-lead { color: var(--muted); font-size: 0.9rem; margin: 0 0 1.75rem; }
.back-link { display: inline-block; font-size: 0.85rem; color: var(--muted); margin-bottom: 1.5rem; transition: color 0.15s; }
.back-link:hover { color: var(--fg); text-decoration: underline dotted; text-underline-offset: 0.2em; }
.back-link.bottom { margin: 2.5rem 0 0; }
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.post-tags { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.tag-mini { font-size: 0.75rem; color: var(--muted); }
.tag-mini::before { content: "#"; opacity: 0.6; margin-right: 0.1em; }

.post-content { margin-top: 2.25rem; font-size: 1.02rem; }
.post-content h2 { font-size: 1.5rem; font-weight: 600; margin: 2.4em 0 0.9em; }
.post-content h3 { font-size: 1.2rem; font-weight: 600; margin: 2em 0 0.8em; }
.post-content p { margin: 1.1em 0; }
.post-content ul, .post-content ol { padding-left: 1.8em; margin: 1em 0; }
.post-content li { margin: 0.4em 0; }
.post-content a { text-decoration: underline dotted; text-underline-offset: 0.2em; }
.post-content blockquote {
  margin: 1.6em 0;
  padding: 0.2em 0 0.2em 1.1em;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}
.post-content blockquote p { margin: 0.5em 0; }
.post-content img { max-width: 100%; border-radius: 0.5rem; }
.post-content hr { border: none; border-top: 1px dashed var(--line-strong); margin: 2.6em auto; width: 45%; }
.post-content code {
  font-family: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 0.12em 0.4em;
  border-radius: 0.3rem;
}
.post-content pre {
  background: #141412;
  color: #e6e4dd;
  border-radius: 0.75rem;
  padding: 1.4rem 1.6rem;
  overflow-x: auto;
  line-height: 1.7;
  margin: 1.5em 0;
  font-size: 0.9rem;
}
.post-content pre code { background: none; color: inherit; padding: 0; font-size: 1em; }

/* 上一篇 / 下一篇 */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}
.post-nav a { color: var(--muted); max-width: 48%; line-height: 1.6; transition: color 0.15s; }
.post-nav a:hover { color: var(--fg); }
.post-nav .next { text-align: right; }
.post-nav .dir {
  display: block;
  margin-bottom: 0.2rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* 归档页 */
.archive-year {
  margin: 2.5rem 0 0.9rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.archive-year .year {
  font-family: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.archive-year .count { font-size: 0.75rem; color: var(--muted); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.tag-chip {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.15rem 0.8rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: none;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.tag-chip:hover { color: var(--fg); border-color: var(--fg); }
.tag-chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tag-chip .cnt { opacity: 0.55; margin-left: 0.3rem; font-variant-numeric: tabular-nums; }

/* 页脚 */
.site-footer { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.footer-info { font-size: 0.8rem; color: var(--muted); line-height: 1.8; }
.footer-info p { margin: 0 0 0.5rem; }
.footer-info a { text-decoration: underline dotted; text-underline-offset: 0.2em; }
.footer-copy { margin: 1rem 0 0; font-size: 0.72rem; color: var(--muted); opacity: 0.8; }

.placeholder { color: var(--muted); }

/* 移动端 */
@media (max-width: 560px) {
  .page { padding: 1.75rem 1.25rem 2.5rem; }
  .hero { padding: 2rem 0 2.25rem; }
  .card-grid { grid-template-columns: 1fr; }
  .article h1 { font-size: 1.6rem; }
  .nav { gap: 1rem; }
  .post-date, .spark-date { width: 4.4rem; }
}
