/* ==========================================================================
   一页 · 考而不死是为神
   静态单篇阅读页：纸感、宋体、朱印；无外部字体与脚本依赖。
   ========================================================================== */

:root {
  --font-serif: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", "宋体", serif;
  --font-kai: "Kaiti SC", "STKaiti", "KaiTi", "楷体", serif;
  --font-ui: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", sans-serif;
  --font-num: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;

  --paper: #f6eedf;
  --paper-deep: #efe3cf;
  --ink: #241f19;
  --ink-soft: #3f382e;
  --muted: #73624c;
  --rule: rgba(63, 48, 30, 0.16);
  --rule-strong: rgba(63, 48, 30, 0.34);
  --seal: #a83a2b;
  --seal-ink: #f8f0e1;
  --seal-wash: rgba(168, 58, 43, 0.14);
  --topbar-bg: rgba(246, 238, 223, 0.86);
  --selection: rgba(168, 58, 43, 0.18);
  --glow-a: rgba(255, 255, 255, 0.52);
  --glow-b: rgba(122, 82, 34, 0.07);
  --vignette: rgba(56, 40, 20, 0.12);

  --reading: 1.1875rem;
  --measure: 36em;
  --ease: cubic-bezier(0.22, 0.72, 0.24, 1);

  color-scheme: light;
}

html[data-theme="night"] {
  --paper: #15130f;
  --paper-deep: #1d1913;
  --ink: #e9dfcc;
  --ink-soft: #d3c6b0;
  --muted: #96866e;
  --rule: rgba(233, 223, 204, 0.14);
  --rule-strong: rgba(233, 223, 204, 0.28);
  --seal: #cf6450;
  --seal-ink: #171410;
  --seal-wash: rgba(207, 100, 80, 0.2);
  --topbar-bg: rgba(21, 19, 15, 0.86);
  --selection: rgba(207, 100, 80, 0.26);
  --glow-a: rgba(255, 236, 206, 0.045);
  --glow-b: rgba(0, 0, 0, 0.4);
  --vignette: rgba(0, 0, 0, 0.35);

  color-scheme: dark;
}

html[data-size="sm"] { --reading: 1.0625rem; }
html[data-size="md"] { --reading: 1.1875rem; }
html[data-size="lg"] { --reading: 1.3125rem; }

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

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

body {
  margin: 0;
  min-height: 100svh;
  background-color: var(--paper);
  background-image:
    radial-gradient(90rem 52rem at 50% -22rem, var(--glow-a) 0%, transparent 62%),
    radial-gradient(68rem 46rem at 88% 112%, var(--glow-b) 0%, transparent 58%);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--reading);
  line-height: 2;
  letter-spacing: 0.01em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.45s var(--ease), color 0.45s var(--ease);
}

/* 纸纤维颗粒 + 四角暗角，均不参与交互 */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

body::before {
  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' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: multiply;
  opacity: 0.2;
}

body::after {
  background: radial-gradient(ellipse 120% 88% at 50% 42%, transparent 55%, var(--vignette) 100%);
}

html[data-theme="night"] body::before {
  mix-blend-mode: screen;
  opacity: 0.055;
}

::selection {
  background: var(--selection);
}

a {
  color: inherit;
}

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

.skip {
  position: fixed;
  top: -6rem;
  left: 1rem;
  z-index: 100;
  padding: 0.55rem 1rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  border-radius: 2px;
  transition: top 0.2s var(--ease);
}

.skip:focus {
  top: 0.8rem;
}

/* --------------------------------------------------------------- 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  transition: background-color 0.45s var(--ease), border-color 0.45s var(--ease), box-shadow 0.3s var(--ease);
}

.topbar.is-scrolled {
  box-shadow: 0 12px 32px -28px rgba(0, 0, 0, 0.6);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100%, 1180px);
  height: 4rem;
  margin: 0 auto;
  padding: 0 clamp(1.15rem, 4vw, 2.4rem);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  background: var(--seal);
  color: var(--seal-ink);
  font-family: var(--font-kai);
  font-size: 1rem;
  line-height: 1;
  border-radius: 2px;
  outline: 1px solid color-mix(in srgb, var(--seal-ink) 45%, transparent);
  outline-offset: -3px;
  transition: background-color 0.45s var(--ease);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  line-height: 1.1;
}

.brand-text strong {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.24em;
}

.brand-text small {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  height: 2.1rem;
  min-width: 2.1rem;
  padding: 0 0.55rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background-color 0.2s var(--ease), opacity 0.2s var(--ease);
}

.tool:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--rule);
  background: var(--paper-deep);
}

.tool:disabled {
  opacity: 0.32;
  cursor: default;
}

.size-switch {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 999px;
}

.size-switch .tool {
  min-width: 2.35rem;
  height: 2.05rem;
  padding: 0 0.45rem;
  border: 0;
  border-radius: 0;
  font-family: var(--font-num);
  font-size: 0.78rem;
}

.size-switch .tool + .tool {
  border-left: 1px solid var(--rule);
}

.a-mark {
  font-family: var(--font-num);
  font-size: 0.84rem;
}

.op {
  font-family: var(--font-ui);
  font-size: 0.66rem;
  transform: translateY(-0.04em);
}

.theme-toggle {
  border: 1px solid var(--rule);
  padding: 0 0.75rem;
}

.theme-toggle[aria-pressed="true"] {
  color: var(--ink);
}

.icon {
  display: block;
  flex: none;
}

.icon-sun { display: none; }
html[data-theme="night"] .icon-moon { display: none; }
html[data-theme="night"] .icon-sun { display: block; }

.tool-label {
  min-width: 2.1em;
}

.progress {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  overflow: hidden;
  pointer-events: none;
}

.progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--seal);
  transform: scaleX(0);
  transform-origin: 0 50%;
  will-change: transform;
}

/* --------------------------------------------------------------- 版心 */
main {
  position: relative;
  z-index: 1;
}

.rail {
  position: fixed;
  top: 50%;
  left: max(1.4rem, calc(50% - 27rem));
  display: none;
  transform: translateY(-50%);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.62rem;
  letter-spacing: 0.42em;
  line-height: 1;
  writing-mode: vertical-rl;
  pointer-events: none;
  opacity: 0.85;
}

.rail::before {
  content: "";
  display: block;
  width: 1px;
  height: 3.2rem;
  margin: 0 auto 0.9rem;
  background: var(--seal);
  opacity: 0.85;
}

.essay {
  width: min(100%, calc(var(--measure) + 2.5rem));
  margin: 0 auto;
  padding: clamp(3.4rem, 9vh, 6.5rem) 1.25rem clamp(4.5rem, 11vh, 8rem);
}

/* --------------------------------------------------------------- 篇首 */
.essay-head {
  position: relative;
}

.eyebrow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0 0 clamp(1.8rem, 4.5vh, 2.7rem);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  line-height: 1.6;
}

.eyebrow-key {
  color: var(--seal);
  font-weight: 600;
  letter-spacing: 0.16em;
}

.eyebrow-sep {
  color: var(--rule-strong);
  letter-spacing: 0;
  transform: translateY(-0.06em);
}

.issue-no {
  position: absolute;
  top: -2.6rem;
  right: -1.2rem;
  z-index: -1;
  color: transparent;
  font-family: var(--font-num);
  font-size: clamp(7rem, 18vw, 12rem);
  font-weight: 400;
  line-height: 0.8;
  letter-spacing: -0.045em;
  -webkit-text-stroke: 1px var(--rule-strong);
  opacity: 0.82;
  user-select: none;
  pointer-events: none;
}

.title-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1.2rem 2.2rem;
}

.title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: clamp(3.05rem, 8.2vw, 5.75rem);
  font-weight: 600;
  line-height: 1.07;
  letter-spacing: 0.015em;
}

.seal {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  place-items: center;
  width: clamp(3.5rem, 5.2vw, 4.5rem);
  aspect-ratio: 1;
  margin: 0 0 0.35rem auto;
  padding: 0.28rem;
  border-radius: 2px;
  background: var(--seal);
  color: var(--seal-ink);
  font-family: var(--font-kai);
  font-size: clamp(1.05rem, 1.7vw, 1.4rem);
  line-height: 1;
  box-shadow:
    inset 0 0 0 1px rgba(248, 240, 225, 0.48),
    inset 0 0 0 4px var(--seal);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--seal-ink) 48%, transparent),
    inset 0 0 0 4px var(--seal);
  transform: rotate(-2.5deg);
  opacity: 0.94;
  transition: background-color 0.45s var(--ease), color 0.45s var(--ease);
}

.seal span {
  display: block;
  transform: translateY(-0.02em);
}

.byline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 1.6rem 0 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  line-height: 1.8;
}

.author {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.byline-rule {
  width: 2.4rem;
  height: 1px;
  background: var(--seal);
  opacity: 0.75;
}

.byline-sep {
  color: var(--rule-strong);
  letter-spacing: 0;
}

/* --------------------------------------------------------------- 分隔 */
.rule {
  position: relative;
  height: 1px;
  margin: clamp(2.6rem, 7vh, 4.2rem) 0 clamp(2.2rem, 6vh, 3.4rem);
  background: linear-gradient(90deg, transparent, var(--rule-strong) 12%, var(--rule-strong) 88%, transparent);
}

.rule::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: var(--seal);
  transform: translate(-50%, -50%) rotate(45deg);
}

/* --------------------------------------------------------------- 正文 */
.body {
  max-width: var(--measure);
}

.body p {
  margin: 0 0 1.55em;
  color: var(--ink-soft);
  line-height: 2.06;
  text-align: justify;
  text-justify: inter-ideograph;
  text-indent: 2em;
  overflow-wrap: break-word;
  transition: color 0.45s var(--ease);
}

.body p:last-child {
  margin-bottom: 0;
}

.body .lead {
  margin-bottom: 1.75em;
  color: var(--ink);
  font-size: 1.15em;
  line-height: 1.94;
  text-indent: 0;
}

.lead::first-letter {
  float: left;
  margin: 0 0.12em 0 0;
  color: var(--seal);
  font-size: 3.2em;
  font-weight: 600;
  line-height: 1.21;
}

.latin {
  font-family: var(--font-num);
  font-style: italic;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.mark {
  background-image: linear-gradient(transparent 66%, var(--seal-wash) 66%);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  color: var(--ink);
}

.body .coda {
  margin-top: 2.4em;
  padding-top: 1.7em;
  border-top: 1px solid var(--rule);
  color: var(--ink);
}

/* --------------------------------------------------------------- 篇尾 */
.end-seal {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  margin: clamp(2.8rem, 7vh, 4rem) auto 0;
  border: 1px solid var(--seal);
  border-radius: 2px;
  color: var(--seal);
  font-family: var(--font-kai);
  font-size: 0.88rem;
  line-height: 1;
  transform: rotate(-3deg);
  opacity: 0.85;
}

.colophon {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  width: 100%;
  margin-top: clamp(2.4rem, 6vh, 3.4rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  line-height: 1.9;
}

.colophon p {
  margin: 0;
}

.colophon .source {
  color: var(--ink-soft);
}

.colophon .site {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
}

.to-top {
  margin-top: 0.55rem;
  color: var(--seal);
  text-decoration: none;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease);
}

.to-top:hover {
  border-bottom-color: currentColor;
}

.site-legal {
  width: 100%;
  margin-top: 1.5rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  line-height: 2;
  text-align: center;
}

.site-legal p {
  margin: 0;
}

.site-legal a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.site-legal a:hover {
  color: var(--seal);
  border-bottom-color: currentColor;
}

.legal-sep {
  margin: 0 0.5em;
  color: var(--rule-strong);
}

/* --------------------------------------------------------------- 动效 */
@media (prefers-reduced-motion: no-preference) {
  .eyebrow,
  .title,
  .seal,
  .byline {
    animation: rise-in 0.85s var(--ease) both;
  }

  .eyebrow { animation-delay: 0.05s; }
  .title { animation-delay: 0.12s; }
  .seal { animation-delay: 0.28s; }
  .byline { animation-delay: 0.24s; }

  @keyframes rise-in {
    from {
      opacity: 0;
      translate: 0 0.9rem;
    }
    to {
      opacity: 1;
      translate: 0 0;
    }
  }
}

/* --------------------------------------------------------------- 响应式 */
@media (min-width: 1280px) {
  .rail { display: block; }
}

@media (max-width: 760px) {
  .topbar-inner { height: 3.5rem; }
  .issue-no { display: none; }
  .essay { padding-top: 3rem; }
  .title-row { gap: 1rem; }
  .title { font-size: clamp(2.85rem, 12.5vw, 4.2rem); }
  .seal { width: 3.4rem; margin-bottom: 0.2rem; }
  .byline { margin-top: 1.3rem; }
  .body p { line-height: 2.02; }
}

@media (max-width: 460px) {
  .brand-text small { display: none; }
  .theme-toggle { padding: 0 0.6rem; }
  .tool-label { display: none; }
  .title { font-size: clamp(2.7rem, 13.2vw, 3.7rem); }
  .body p { text-align: left; }
}

/* --------------------------------------------------------------- 打印 */
@media print {
  html { font-size: 12pt; }

  .topbar,
  .rail,
  .to-top,
  .skip,
  .issue-no,
  .end-seal {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000;
    font-size: 11.5pt;
  }

  body::before,
  body::after { display: none !important; }

  .essay {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .body,
  .colophon { max-width: none; }

  .body p {
    color: #000;
    orphans: 3;
    widows: 3;
  }

  .title { font-size: 34pt; }

  .lead::first-letter { color: #000; }

  .mark { background: none; }

  .seal {
    background: none;
    color: #000;
    box-shadow: inset 0 0 0 1px #000;
    opacity: 1;
  }

  .colophon { border-color: #999; }

  @page { margin: 22mm 20mm; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
