/* 正文区、计时面板、落款、彩蛋方块、配乐按钮。 */
#content {
  max-width: 58rem;
  margin-inline: auto;
  padding: clamp(2.5rem, 9vh, 6rem) var(--gutter, 1.5rem) clamp(2rem, 6vh, 4rem);
}

html.js:not(.is-opened) #content,
html.js:not(.is-opened) .rail,
html.js:not(.is-opened) .site-foot {
  display: none;
}

.chapter {
  position: relative;
  max-width: var(--read-max, 34rem);
  margin: 0 auto clamp(4.5rem, 13vh, 9rem);
  text-align: center;
  scroll-margin-top: clamp(1.6rem, 6vh, 4rem);
  transition:
    opacity 0.8s var(--ease-out, ease-out),
    transform 0.8s var(--ease-out, ease-out);
}

html.js.has-reveal .chapter {
  opacity: 0;
  transform: translateY(12px);
}

html.js.has-reveal .chapter.is-in {
  opacity: 1;
  transform: none;
}

.chapter:last-of-type {
  margin-bottom: 0;
}

.chapter__index,
.chapter__eyebrow,
.sign__date,
.site-foot__line {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.chapter__index,
.chapter__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.68rem;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  color: var(--ink-soft, #5b6b80);
}

.chapter__index::before,
.chapter__index::after,
.chapter__eyebrow::before,
.chapter__eyebrow::after {
  content: "";
  width: 1.4rem;
  height: 1px;
  background-image: linear-gradient(90deg, rgba(226, 199, 160, 0), rgba(226, 199, 160, 0.95));
}

.chapter__index::after,
.chapter__eyebrow::after {
  background-image: linear-gradient(270deg, rgba(226, 199, 160, 0), rgba(226, 199, 160, 0.95));
}

.chapter__title {
  margin-top: 0.9rem;
  font-family: var(--font-display, serif);
  font-size: clamp(1.42rem, 1.1rem + 1.5vw, 2.05rem);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.07em;
  text-indent: 0.07em;
  color: var(--ink, #2e3b4e);
}

.chapter__body {
  text-wrap: pretty;
  margin-top: clamp(1.4rem, 4vh, 2.1rem);
}

.chapter__body p,
p.chapter__body {
  margin: 0 0 1.05em;
  font-size: clamp(0.95rem, 0.9rem + 0.2vw, 1.02rem);
  line-height: 2;
  letter-spacing: 0.03em;
  color: rgba(46, 59, 78, 0.86);
}

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

/* ── 计时面板 ── */
.clock {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  margin-top: clamp(1.6rem, 4vh, 2.2rem);
  padding: clamp(1.05rem, 3vw, 1.6rem) clamp(0.4rem, 1.6vw, 1rem);
  border: 1px solid rgba(46, 59, 78, 0.07);
  border-radius: var(--radius-lg, 28px);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(251, 248, 241, 0.92));
  box-shadow: var(--shadow-soft, 0 18px 40px -24px rgba(46, 59, 78, 0.45));
}

.clock__cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.clock__cell + .clock__cell::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10%;
  bottom: 10%;
  width: 1px;
  background-image: linear-gradient(180deg, rgba(46, 59, 78, 0), rgba(46, 59, 78, 0.13), rgba(46, 59, 78, 0));
}

.clock__num {
  font-family: var(--font-display, serif);
  font-size: clamp(1.5rem, 4.2vw, 2.5rem);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--ink, #2e3b4e);
}

.clock__label {
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--ink-soft, #5b6b80);
}

.clock__meta {
  margin-top: 1.1rem;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  color: var(--ink-soft, #5b6b80);
  opacity: 0.78;
}

/* ── 落款 ── */
.chapter--sign {
  padding-bottom: clamp(6.5rem, 16vh, 9rem);
}

.chapter__sign-line {
  font-family: var(--font-display, serif);
  font-size: clamp(1.02rem, 0.96rem + 0.3vw, 1.16rem);
  line-height: 2;
  letter-spacing: 0.06em;
  color: var(--ink, #2e3b4e);
}

.sign {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  margin-top: clamp(2.2rem, 6vh, 3.2rem);
  font-family: var(--font-display, serif);
}

.sign__from {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  color: var(--ink-soft, #5b6b80);
}

.sign__from b {
  font-size: 1.12rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--ink, #2e3b4e);
}

.sign__date {
  font-size: 0.74rem;
  letter-spacing: 0.2em;
  color: var(--ink-soft, #5b6b80);
}

.chapter__note {
  margin-top: clamp(1.8rem, 5vh, 2.6rem);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--ink-soft, #5b6b80);
  opacity: 0.7;
}

/* ── 彩蛋：一块方块 ── */
.egg {
  position: absolute;
  right: clamp(-0.4rem, -1vw, 0rem);
  bottom: 0;
}

.egg__block {
  display: block;
  width: 44px;
  height: 44px;
  padding: 5px;
  border: 0;
  background: none;
  opacity: 0.34;
  cursor: pointer;
  transform: scale(1);
  transition:
    opacity 180ms var(--ease-out, ease-out),
    transform 180ms var(--ease-out, ease-out);
}

.egg__block svg {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.egg__block:hover,
.egg__block:focus-visible {
  opacity: 1;
  transform: scale(1.06);
}

.egg__block.is-settling {
  transform: scale(1);
  transition: transform 120ms var(--ease-out, ease-out);
}

.egg__grid {
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  width: 34px;
  height: 34px;
  margin-left: -17px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 1px;
  opacity: 0.18;
  pointer-events: none;
  transition: opacity 300ms var(--ease-out, ease-out);
}

.egg__grid i {
  background: rgba(143, 196, 122, 0.85);
}

.egg__grid.is-fading {
  opacity: 0;
}

.egg__reveal {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.9rem);
  width: max-content;
  max-width: min(19rem, 74vw);
  text-align: right;
  pointer-events: none;
}

.egg__title {
  font-family: var(--font-display, serif);
  font-size: 1.25rem;
  line-height: 1.6;
  letter-spacing: 0.05em;
  color: var(--ink, #2e3b4e);
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 340ms var(--ease-out, ease-out),
    transform 340ms var(--ease-out, ease-out);
}

.egg__sub {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft, #5b6b80);
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 300ms var(--ease-out, ease-out) 0.4s,
    transform 300ms var(--ease-out, ease-out) 0.4s;
}

.egg.is-revealed .egg__title,
.egg.is-revealed .egg__sub {
  opacity: 1;
  transform: none;
}

/* ── 配乐开关 ── */
.music {
  position: fixed;
  right: clamp(0.9rem, 3vw, 1.7rem);
  bottom: calc(clamp(0.9rem, 3vw, 1.7rem) + env(safe-area-inset-bottom, 0px));
  z-index: 12;
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  padding: 0;
  border: 1px solid rgba(46, 59, 78, 0.1);
  border-radius: 50%;
  color: var(--ink, #2e3b4e);
  background-color: #fdfbf6;
  box-shadow: 0 10px 24px -16px rgba(46, 59, 78, 0.6);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--dur-1, 220ms) var(--ease-out, ease-out),
    box-shadow var(--dur-1, 220ms) var(--ease-out, ease-out),
    opacity var(--dur-1, 220ms) var(--ease-out, ease-out);
}

.music:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px -16px rgba(46, 59, 78, 0.6);
}

.music:active {
  transform: translateY(0) scale(0.97);
}

.music:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.music__icon {
  position: absolute;
  width: 1.15rem;
  height: 1.15rem;
  opacity: 0;
  transition: opacity var(--dur-1, 220ms) var(--ease-out, ease-out);
}

.music[data-state="playing"] .music__icon--wave,
.music[data-state="paused"] .music__icon--note,
.music[data-state="off"] .music__icon--mute {
  opacity: 1;
}

.music[data-state="playing"] .music__icon--wave path {
  transform-box: fill-box;
  transform-origin: center;
  animation: bar-sway 1.15s ease-in-out infinite;
}

.music[data-state="playing"] .music__icon--wave path:nth-child(2) { animation-delay: 0.13s; }
.music[data-state="playing"] .music__icon--wave path:nth-child(3) { animation-delay: 0.26s; }
.music[data-state="playing"] .music__icon--wave path:nth-child(4) { animation-delay: 0.39s; }

@keyframes bar-sway {
  0%, 100% { transform: scaleY(0.6); }
  50% { transform: scaleY(1.05); }
}

/* ── 章节分隔 ── */
.chapter-sep {
  max-width: var(--read-max, 34rem);
  margin: calc(-0.5 * clamp(4.5rem, 13vh, 9rem)) auto calc(0.5 * clamp(4.5rem, 13vh, 9rem));
  color: rgba(226, 199, 160, 0.62);
  opacity: 1;
  transition: opacity 1.2s var(--ease-out, ease-out);
}

.chapter-sep svg {
  width: 100%;
  height: 12px;
}

html.js.has-reveal .chapter-sep {
  opacity: 0;
}

html.js.has-reveal .chapter-sep.is-in {
  opacity: 1;
}

/* ── 右缘章节导航 ── */
.rail {
  position: fixed;
  top: 50%;
  right: clamp(1rem, 2.6vw, 2.2rem);
  z-index: 11;
  transform: translateY(-50%);
}

.rail__list {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rail__dot {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-soft, #5b6b80);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rail__tick {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: rgba(46, 59, 78, 0.2);
  transition:
    transform 0.32s var(--ease-out, ease-out),
    background-color 0.32s var(--ease-out, ease-out),
    box-shadow 0.32s var(--ease-out, ease-out);
}

.rail__dot:hover .rail__tick,
.rail__dot:focus-visible .rail__tick {
  background-color: rgba(46, 59, 78, 0.42);
  transform: scale(1.15);
}

.rail__dot[aria-current="true"] .rail__tick {
  background-color: var(--peach, #f7c9a8);
  box-shadow: 0 0 0 4px rgba(247, 201, 168, 0.24);
  transform: scale(1.3);
}

.rail__label {
  position: absolute;
  right: 100%;
  margin-right: 0.4rem;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(4px);
  pointer-events: none;
  transition:
    opacity 0.25s var(--ease-out, ease-out),
    transform 0.25s var(--ease-out, ease-out);
}

.rail__dot:hover .rail__label,
.rail__dot:focus-visible .rail__label {
  opacity: 0.9;
  transform: none;
}

/* ── 页脚 ── */
.site-foot {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  padding: clamp(1.5rem, 5vh, 3rem) var(--gutter, 1.5rem) clamp(2rem, 6vh, 3.5rem);
  text-align: center;
  color: var(--ink-soft, #5b6b80);
}

.site-foot__line {
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  opacity: 0.55;
}

.site-foot__sign {
  font-family: var(--font-display, serif);
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  opacity: 0.68;
}

.to-top {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-top: 0.3rem;
  padding: 0;
  border: 1px solid rgba(46, 59, 78, 0.12);
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft, #5b6b80);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--dur-1, 220ms) var(--ease-out, ease-out),
    color var(--dur-1, 220ms) var(--ease-out, ease-out),
    border-color var(--dur-1, 220ms) var(--ease-out, ease-out);
}

.to-top svg {
  width: 17px;
  height: 17px;
}

.to-top:hover {
  transform: translateY(-2px);
  color: var(--ink, #2e3b4e);
  border-color: rgba(46, 59, 78, 0.24);
}

.to-top:active {
  transform: translateY(0) scale(0.96);
}

@media (max-width: 1100px) {
  .rail {
    display: none;
  }
}

@media (max-width: 600px) {
  .clock {
    grid-template-columns: repeat(3, 1fr);
    row-gap: 1.3rem;
  }

  .clock__cell:nth-child(4)::before {
    display: none;
  }

  .sign {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
  }

  .egg {
    right: -0.2rem;
  }
}
