/* ============================================================
   Luchen 的博客 · 纸上编辑部
   温暖文艺的中文编辑杂志风 — 零外部依赖（系统字体 + 原生 CSS/JS）
   ============================================================ */

:root {
  --paper:        #faf8f3;  /* 纸张底 */
  --card:         #fffdf8;
  --ink:          #2b2721;  /* 墨色 */
  --ink-soft:     #4c463c;
  --muted:        #8b8271;
  --faint:        #b3a992;
  --line:         #e7dfcf;
  --accent:       #33665e;  /* 石青 */
  --accent-deep:  #264d46;
  --seal:         #a63f2e;  /* 印泥红 */
  --code-bg:      #f1ece0;
  --quote-bg:     #f6f1e6;
  --shadow:       0 10px 28px rgba(74, 61, 38, .09);
  --radius:       10px;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "STKaiti", "KaiTi",
            "TW-Kai", Georgia, serif;
  --sans:  -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
            "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --paper:        #1b1813;
  --card:         #232019;
  --ink:          #e9e2d1;
  --ink-soft:     #cfc6b0;
  --muted:        #a2987f;
  --faint:        #6f6654;
  --line:         #383226;
  --accent:       #85b5a9;
  --accent-deep:  #abd0c6;
  --seal:         #c96448;
  --code-bg:      #2c2820;
  --quote-bg:     #25211a;
  --shadow:       0 10px 28px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.9;
  letter-spacing: .015em;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

::selection { background: var(--accent); color: var(--paper); }

a { color: var(--accent); text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--accent-deep); }

img { max-width: 100%; height: auto; }

/* ---------- 顶部阅读进度条 ---------- */
#progress {
  position: fixed; top: 0; left: 0; z-index: 100;
  height: 3px; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--seal));
}

/* ---------- 版心 ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 700px; margin: 0 auto; padding: 0 24px; }

/* ---------- 页眉 ---------- */
.masthead {
  border-bottom: 4px double var(--line);
}
.masthead-inner {
  max-width: 760px; margin: 0 auto; padding: 22px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { color: var(--ink); }
.seal-mark {
  flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--seal); color: var(--paper);
  font-family: var(--serif); font-size: 22px; line-height: 38px; text-align: center;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.28);
  transition: transform .25s ease;
}
.brand:hover .seal-mark { transform: rotate(-6deg); }
.brand-name { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: .06em; display: block; line-height: 1.3; }
.brand-tag { font-size: 12.5px; color: var(--muted); display: block; letter-spacing: .08em; }

.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a {
  color: var(--muted); font-size: 15px; padding: 6px 10px; border-radius: 6px;
  position: relative;
}
.site-nav a:hover { color: var(--ink); background: var(--code-bg); }
.site-nav a.active { color: var(--ink); font-weight: 600; }
.site-nav a.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 2px;
  height: 2px; background: var(--accent); border-radius: 2px;
}

/* 暗色模式切换 */
#theme-toggle {
  margin-left: 6px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .2s ease, color .2s ease, transform .2s ease;
}
#theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: rotate(15deg); }
#theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#theme-toggle svg { width: 18px; height: 18px; }
#theme-toggle .icon-sun { display: none; }
[data-theme="dark"] #theme-toggle .icon-sun { display: block; }
[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

/* ---------- 首页 Hero ---------- */
.hero { padding: 72px 0 20px; text-align: center; }
.hero-kicker {
  display: inline-flex; align-items: center; gap: 14px;
  color: var(--muted); font-size: 13px; letter-spacing: .5em; text-indent: .5em;
  margin: 0 0 22px;
}
.hero-kicker::before, .hero-kicker::after {
  content: ""; width: 42px; height: 1px; background: var(--faint);
}
.hero-title {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(30px, 6vw, 44px); line-height: 1.55; letter-spacing: .08em;
  margin: 0 0 18px;
}
.hero-title .dot { color: var(--seal); }
.hero-desc { color: var(--muted); font-size: 16px; margin: 0 auto; max-width: 34em; }

/* ---------- 分节标题 ---------- */
.section-head {
  display: flex; align-items: center; gap: 14px;
  margin: 56px 0 8px;
}
.section-head h2 {
  font-family: var(--serif); font-size: 19px; letter-spacing: .3em; text-indent: .1em;
  margin: 0; color: var(--ink); white-space: nowrap;
}
.section-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- 文章卡片 ---------- */
.post-cards { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 18px; }
.card-link {
  display: block; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 28px;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.card-link:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--accent); }
.card-link time {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); letter-spacing: .12em;
}
.card-link time::before { content: ""; width: 18px; height: 2px; background: var(--seal); border-radius: 2px; }
.card-link h2 {
  font-family: var(--serif); font-size: 23px; font-weight: 700; letter-spacing: .04em;
  margin: 10px 0 8px; color: var(--ink); line-height: 1.5;
  transition: color .2s ease;
}
.card-link:hover h2 { color: var(--accent-deep); }
.card-link .excerpt { margin: 0; color: var(--ink-soft); font-size: 15.5px; }
.card-link .more {
  display: inline-block; margin-top: 12px;
  font-size: 14px; letter-spacing: .1em; color: var(--accent); font-weight: 600;
}
.card-link .more .arrow { display: inline-block; transition: transform .25s ease; }
.card-link:hover .more .arrow { transform: translateX(5px); }

/* ---------- 文章页 ---------- */
.post { padding: 56px 0 8px; }
.post-kicker {
  color: var(--seal); font-size: 13px; letter-spacing: .5em; text-indent: .1em;
  margin: 0 0 16px; font-weight: 600;
}
.post-header h1 {
  font-family: var(--serif); font-size: clamp(27px, 5vw, 36px);
  line-height: 1.5; letter-spacing: .05em; margin: 0 0 14px; font-weight: 700;
}
.post-meta { color: var(--muted); font-size: 14px; letter-spacing: .08em; margin-bottom: 34px; }
.post-meta .sep { margin: 0 10px; color: var(--faint); }
.post-rule { border: none; border-top: 1px solid var(--line); margin: 0 0 34px; }

.post-body { font-size: 17.5px; }
.post-body p { margin: 0 0 1.25em; text-align: justify; }
.post-body p.lead { font-size: 1.14em; color: var(--ink); }
.post-body p.lead::first-letter {
  font-family: var(--serif); font-size: 1.9em; color: var(--seal);
  padding-right: .08em; line-height: 1;
}
.post-body h2 {
  font-family: var(--serif); font-size: 23px; letter-spacing: .06em;
  margin: 2em 0 .9em; display: flex; align-items: center; gap: 12px;
}
.post-body h2::before {
  content: ""; flex: 0 0 auto; width: 9px; height: 9px;
  background: var(--accent); transform: rotate(45deg);
}
.post-body blockquote {
  margin: 1.8em 0; padding: 18px 22px;
  background: var(--quote-bg);
  border-left: 3px solid var(--seal); border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink-soft); font-family: var(--serif); font-size: 1.02em;
}
.post-body blockquote p:last-child { margin-bottom: 0; }
.post-body code {
  background: var(--code-bg); color: var(--accent-deep);
  padding: 2px 7px; border-radius: 5px; font-size: .88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono", monospace;
}
.post-body pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; overflow-x: auto; line-height: 1.7; font-size: 14.5px;
}
.post-body pre code { background: none; padding: 0; color: var(--ink); }
.post-body hr { border: none; text-align: center; margin: 2.4em 0; color: var(--faint); letter-spacing: 1em; }
.post-body hr::after { content: "···"; }

.post-back { margin-top: 48px; }
.post-back a {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 20px;
  font-size: 14.5px; color: var(--muted); background: var(--card);
  transition: border-color .2s ease, color .2s ease, transform .2s ease;
}
.post-back a:hover { border-color: var(--accent); color: var(--accent-deep); transform: translateX(-3px); }

/* ---------- 关于页 ---------- */
.about { padding: 56px 0 8px; }
.about h1 {
  font-family: var(--serif); font-size: clamp(27px, 5vw, 34px);
  letter-spacing: .12em; margin: 0 0 8px;
}
.about .about-sub { color: var(--muted); font-size: 14.5px; letter-spacing: .1em; margin: 0 0 30px; }
.about-body p { margin: 0 0 1.25em; text-align: justify; }
.about-body p.lead { font-size: 1.14em; }
.about-sign {
  margin-top: 40px; text-align: right;
  font-family: var(--serif); color: var(--muted); letter-spacing: .2em;
}
.about-sign .seal-inline {
  display: inline-block; width: 30px; height: 30px; border-radius: 7px;
  background: var(--seal); color: var(--paper);
  font-size: 17px; line-height: 30px; text-align: center; vertical-align: -7px; margin-left: 8px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.28);
}

/* ---------- 页脚 ---------- */
.site-footer { margin-top: 72px; border-top: 4px double var(--line); }
.footer-inner { max-width: 760px; margin: 0 auto; padding: 30px 24px 44px; text-align: center; }
.footer-brand { font-family: var(--serif); font-size: 17px; letter-spacing: .3em; text-indent: .3em; margin: 0 0 10px; }
.footer-nav { margin: 0 0 12px; font-size: 14px; }
.footer-nav a { color: var(--muted); margin: 0 10px; }
.footer-nav a:hover { color: var(--accent-deep); }
.footer-note { color: var(--faint); font-size: 13px; margin: 0; letter-spacing: .06em; }

/* ---------- 回到顶部 ---------- */
#to-top {
  position: fixed; right: 22px; bottom: 26px; z-index: 90;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font-size: 18px; cursor: pointer; line-height: 1;
  opacity: 0; pointer-events: none; transform: translateY(10px);
  transition: opacity .3s ease, transform .3s ease, color .2s ease, border-color .2s ease;
  box-shadow: var(--shadow);
}
#to-top.show { opacity: 1; pointer-events: auto; transform: none; }
#to-top:hover { color: var(--accent); border-color: var(--accent); }
#to-top:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .masthead-inner { padding: 16px 18px; }
  .brand-tag { display: none; }
  .hero { padding: 52px 0 12px; }
  .card-link { padding: 22px 20px; }
  .post, .about { padding-top: 40px; }
  .post-body { font-size: 16.5px; }
  #to-top { right: 16px; bottom: 18px; }
}

/* ---------- 减少动态效果偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
