/* ============ base.css · 重置、排版、布局 ============ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--paper);
  transition: background-color 600ms ease, color 600ms ease;
  scroll-behavior: smooth;
}

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

/* 纸张噪点：内联 SVG，无外部纹理 */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* 页面暗角 */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%, transparent 42%, rgba(31, 29, 26, .045));
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.28;
  margin: 0;
  letter-spacing: .01em;
  text-wrap: pretty;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--cinnabar);
  text-decoration: none;
  border-bottom: 1px solid rgba(140, 28, 19, .25);
  transition: border-color 160ms ease, color 160ms ease;
}
a:hover { border-bottom-color: var(--cinnabar); }

img { max-width: 100%; display: block; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

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

::selection { background: rgba(140, 28, 19, .14); }

/* ---------- 布局 ---------- */
.shell {
  max-width: var(--w-wide);
  margin: 0 auto;
  padding: 0 48px;
}
.read {
  max-width: var(--w-read);
  margin: 0 auto;
}

/* 顶部 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s5);
  padding: 14px 48px;
  border-bottom: 1px solid var(--line);
  background: var(--paper); /* fallback：微信 X5 旧内核不支持 color-mix */
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
}
.brand {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  border: 0;
  letter-spacing: .04em;
  white-space: nowrap;
}
.brand .dot { color: var(--cinnabar); margin: 0 6px; }
.nav { display: flex; gap: var(--s5); align-items: center; }
.nav a {
  font-size: 14px;
  color: var(--ink-muted);
  border: 0;
  padding: 8px 0;
  position: relative;
  white-space: nowrap;
}
.nav a:hover { color: var(--ink); }
.nav a.is-active { color: var(--ink); }
.nav a.is-active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 2px;
  height: 2px;
  background: var(--cinnabar);
}

main { padding: var(--s8) 0 var(--s9); }
.view { animation: viewIn 320ms var(--ease) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* 页脚 */
.site-foot {
  border-top: 1px solid var(--line);
  padding: var(--s6) 48px var(--s8);
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.85;
}
.site-foot .shell { padding: 0; max-width: var(--w-wide); }
.site-foot .notice { max-width: 760px; }
.site-foot .meta { margin-top: var(--s3); color: var(--ink-muted); opacity: .8; }

/* 移动端 */
@media (max-width: 760px) {
  .shell, .topbar, .site-foot { padding-left: 20px; padding-right: 20px; }
  .topbar { padding-top: 12px; padding-bottom: 12px; }
  .brand { font-size: 15px; }
  .nav { gap: var(--s4); }
  .nav a { font-size: 13px; }
  main { padding: var(--s6) 0 var(--s8); }
  body { font-size: 16px; }
}

/* 减少动效 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
