/* ============================================================
   站点样式 —— 纸墨感 · 衬线标题 · 深色模式
   想换配色只改下面 :root 里的变量
   ============================================================ */

:root {
  --bg: #faf8f4;
  --bg-soft: #f3efe7;
  --surface: #fffdfa;
  --ink: #211d18;
  --ink-soft: #3c352d;
  --muted: #6d655b;
  --line: #e5dfd3;
  --accent: #a8412c;
  --accent-soft: #f0e3dd;
  --radius: 10px;
  --maxw: 44rem;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif CN", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #131210;
  --bg-soft: #1a1815;
  --surface: #1a1815;
  --ink: #e9e4da;
  --ink-soft: #d3ccc0;
  --muted: #918878;
  --line: #2c2823;
  --accent: #db8064;
  --accent-soft: #33231d;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.8;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* 极淡的纸张纹理 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image: radial-gradient(var(--line) .6px, transparent .6px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), transparent 40%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), transparent 40%);
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.35rem;
  position: relative;
  z-index: 1;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .22em; }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  padding: .6rem 1rem;
  z-index: 99;
}
.skip:focus { left: 1rem; top: .5rem; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ---------------- 顶栏 ---------------- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.site-head__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  color: var(--ink);
  min-width: 0;
}
.brand:hover { text-decoration: none; }

.brand__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff9f4;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1;
  padding-bottom: .1em;
}

.brand__name {
  display: flex;
  flex-direction: column;
  font-family: var(--serif);
  font-size: 1.16rem;
  font-weight: 600;
  letter-spacing: .04em;
  line-height: 1.25;
  white-space: nowrap;
}
.brand__name small {
  font-family: var(--sans);
  font-size: .68rem;
  font-weight: 400;
  letter-spacing: .02em;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .9rem;
  flex: none;
}
.nav a {
  color: var(--muted);
  padding: .35rem .6rem;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--ink); background: var(--bg-soft); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

.theme-toggle {
  margin-left: .3rem;
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, transform .15s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .i-moon { display: none; }
html[data-theme="dark"] .theme-toggle .i-moon { display: block; }
html[data-theme="dark"] .theme-toggle .i-sun { display: none; }

/* ---------------- 首页 ---------------- */
main.wrap { padding-top: 2.8rem; padding-bottom: 4rem; }

.hero { padding: .4rem 0 2.4rem; }
.hero__kicker {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.35rem, 4.6vw, 1.85rem);
  line-height: 1.6;
  letter-spacing: .02em;
  color: var(--ink-soft);
  max-width: 30ch;
}
.hero__kicker::after {
  content: "";
  display: block;
  width: 2.4rem;
  height: 2px;
  margin-top: 1.3rem;
  background: var(--accent);
  opacity: .85;
}

.post-list { list-style: none; margin: 0; padding: 0; }

.post-row { border-top: 1px solid var(--line); }
.post-row:last-child { border-bottom: 1px solid var(--line); }

.post-row__link {
  display: block;
  padding: 1.55rem .2rem 1.6rem;
  color: inherit;
  transition: padding .2s ease, background .2s ease;
}
.post-row__link:hover { text-decoration: none; background: color-mix(in srgb, var(--bg-soft) 55%, transparent); }

.post-row__date {
  display: block;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .35rem;
}

.post-row__title {
  margin: 0 0 .4rem;
  font-family: var(--serif);
  font-size: 1.28rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: .01em;
  transition: color .15s;
}
.post-row__link:hover .post-row__title { color: var(--accent); }

.post-row__summary {
  margin: 0;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-row__tags { margin: .7rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }

.tag {
  display: inline-block;
  font-size: .7rem;
  line-height: 1.6;
  padding: .05rem .5rem;
  border-radius: 999px;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  letter-spacing: .02em;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2rem;
  font-size: .88rem;
  color: var(--muted);
}
.pager__pos { font-family: var(--mono); font-size: .75rem; }

.page-title {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 600;
  margin: 0 0 .4rem;
}
.page-sub { color: var(--muted); font-size: .86rem; margin: 0 0 2rem; }
.empty { color: var(--muted); font-size: .9rem; }

/* ---------------- 文章 ---------------- */
.is-post main.wrap { padding-top: 2.2rem; }

.post__head { margin-bottom: 2rem; }

.post__title {
  font-family: var(--serif);
  font-size: clamp(1.62rem, 5.4vw, 2.1rem);
  font-weight: 700;
  line-height: 1.42;
  letter-spacing: .01em;
  margin: 0 0 .9rem;
}

.post__meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem;
  font-size: .78rem;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: .02em;
}
.dot { opacity: .55; }

.post__tags { margin: .85rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }

/* 正文排版 */
.prose {
  font-size: 1.02rem;
  line-height: 1.9;
  color: var(--ink-soft);
  overflow-wrap: break-word;
}
.prose > *:first-child { margin-top: 0; }

.prose p { margin: 0 0 1.25em; }
.prose h2, .prose h3, .prose h4 {
  font-family: var(--serif);
  color: var(--ink);
  line-height: 1.5;
  scroll-margin-top: 5rem;
}
.prose h2 {
  font-size: 1.38rem;
  font-weight: 600;
  margin: 2.4em 0 .8em;
  padding-bottom: .35em;
  border-bottom: 1px solid var(--line);
}
.prose h3 { font-size: 1.14rem; font-weight: 600; margin: 1.9em 0 .6em; }
.prose h4 { font-size: 1rem; margin: 1.6em 0 .5em; }

.anchor {
  float: left;
  margin-left: -1.1em;
  padding-right: .3em;
  color: var(--accent);
  opacity: 0;
  font-weight: 400;
  text-decoration: none;
  transition: opacity .15s;
}
.prose h2:hover .anchor,
.prose h3:hover .anchor { opacity: .55; }

.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: .2em; }
.prose a:hover { text-decoration-color: var(--accent); }

.prose blockquote {
  margin: 1.6em 0;
  padding: .3em 0 .3em 1.1em;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: normal;
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose ul, .prose ol { padding-left: 1.35em; margin: 0 0 1.25em; }
.prose li { margin: .3em 0; }
.prose li::marker { color: var(--muted); }

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
  margin: 1.8em auto;
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 28px -12px rgba(0,0,0,.18);
}

.prose code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .12em .38em;
  color: var(--ink);
  word-break: break-word;
}

.prose pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 1.6em 0;
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}
.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: .83rem;
  color: var(--ink-soft);
  white-space: pre;
}

.prose hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 2.6em auto;
  width: 40%;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: .9rem;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td { border: 1px solid var(--line); padding: .5rem .7rem; text-align: left; }
.prose th { background: var(--bg-soft); font-weight: 600; color: var(--ink); }

/* 目录 */
.toc {
  margin: 0 0 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-soft) 60%, transparent);
  padding: .7rem 1rem;
  font-size: .88rem;
}
.toc summary {
  cursor: pointer;
  color: var(--muted);
  font-size: .78rem;
  letter-spacing: .08em;
  list-style: none;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary::before { content: "▸ "; color: var(--accent); }
.toc[open] summary::before { content: "▾ "; }
.toc__list { margin: .6rem 0 .2rem; padding-left: 1.1rem; }
.toc__item { margin: .3rem 0; }
.toc__item--h3 { margin-left: .9rem; font-size: .94em; }
.toc a { color: var(--muted); }
.toc a:hover { color: var(--accent); }

/* 上一篇 / 下一篇 */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3.4rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
}
.post-nav__item {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  color: var(--ink);
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, background .15s;
}
.post-nav__item:hover { text-decoration: none; border-color: var(--muted); background: var(--bg-soft); }
.post-nav__item--right { text-align: right; }
.post-nav__dir { font-size: .72rem; color: var(--muted); letter-spacing: .05em; }
.post-nav__title { font-family: var(--serif); font-size: .96rem; line-height: 1.5; }

/* ---------------- 归档 ---------------- */
.year { margin-bottom: 2.2rem; }
.year__label {
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 400;
  letter-spacing: .12em;
  color: var(--muted);
  margin: 0 0 .8rem;
  display: flex;
  align-items: center;
  gap: .8rem;
}
.year__label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.year__list { list-style: none; margin: 0; padding: 0; }
.year__list li { border-bottom: 1px dashed var(--line); }
.year__list a {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  padding: .7rem .15rem;
  color: var(--ink);
}
.year__list a:hover { text-decoration: none; color: var(--accent); }
.year__list time {
  flex: none;
  width: 3.4rem;
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--muted);
}

/* ---------------- 其它 ---------------- */
.post--page .post__head { margin-bottom: 1.4rem; }

.empty-page { text-align: center; padding: 4rem 0 3rem; color: var(--muted); }
.empty-page__code {
  font-family: var(--serif);
  font-size: 4rem;
  line-height: 1;
  color: var(--accent);
  margin: 0 0 .6rem;
  opacity: .8;
}
.btn {
  display: inline-block;
  margin-top: 1rem;
  padding: .5rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: .88rem;
}
.btn:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }

.site-foot {
  border-top: 1px solid var(--line);
  padding: 1.6rem 0 2.2rem;
  font-size: .78rem;
  color: var(--muted);
}
.site-foot__inner { display: flex; align-items: center; gap: .5rem; justify-content: center; }
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--accent); }

/* 阅读进度条 */
.progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  background: transparent;
  z-index: 30;
  pointer-events: none;
}
.progress__bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .1s linear;
}

/* 手机 */
@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { padding: 0 1.1rem; }
  .site-head__inner { min-height: 3.6rem; }
  .brand__name small { display: none; }
  .nav { gap: 0; }
  .nav a { padding: .35rem .45rem; font-size: .85rem; }
  main.wrap { padding-top: 2rem; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav__item--right { text-align: left; }
  .year__list time { width: 3rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

@media print {
  .site-head, .site-foot, .toc, .post-nav, .progress { display: none; }
  body { background: #fff; }
}
