/* ============================================================
   故事 · STORY —— 黑白基调 + 每页主色调自适应
   ============================================================ */

:root {
  --ink-strong: #141416;   /* 近黑（浅色页用） */
  --ink-soft: rgba(20, 20, 22, 0.55);
  --paper-strong: #f5f5f6; /* 近白（深色页用） */
  --paper-soft: rgba(245, 245, 246, 0.55);

  --serif: Georgia, "Times New Roman", "Noto Serif SC", "Source Han Serif SC",
    "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;

  --page-h: 100vh;
  --page-h: 100svh;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-snap-type: y proximity;
  scroll-behavior: smooth;
}

html, body { height: 100%; }

body {
  font-family: var(--serif);
  background: #08080a;
  color: var(--paper-strong);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.locked { overflow: hidden; }

/* ============================================================
   加载动画
   ============================================================ */
.loading {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #08080a;
  color: var(--paper-strong);
  text-align: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loading.done { opacity: 0; visibility: hidden; pointer-events: none; }

.loading__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6rem;
}

.loading__word {
  font-size: clamp(2rem, 7vw, 3.2rem);
  font-weight: 400;
  letter-spacing: 0.3em;
  margin-left: 0.3em;
  line-height: 1;
}

.loading__bar {
  position: relative;
  width: 7rem;
  height: 1px;
  background: rgba(245, 245, 246, 0.16);
  overflow: hidden;
}

.loading__bar i {
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  height: 100%;
  background: var(--paper-strong);
  animation: loadingSlide 1.1s ease-in-out infinite;
}

@keyframes loadingSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.loading__hint {
  font-family: var(--sans);
  font-size: 0.6rem;
  letter-spacing: 0.42em;
  margin-left: 0.42em;
  color: var(--paper-soft);
}

/* ============================================================
   封面（极简）
   ============================================================ */
.cover {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 90% at 50% 36%, #151518 0%, #08080a 64%);
  color: var(--paper-strong);
  text-align: center;
  will-change: transform;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.cover.dragging { transition: none; }
.cover:not(.dragging) { transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1); }

.cover.unlocked { transform: translateY(-101%); pointer-events: none; }

.cover__inner { padding: 0 1.5rem; }

.cover__back {
  position: absolute;
  top: calc(1.4rem + env(safe-area-inset-top, 0px));
  left: 1.5rem;
  z-index: 10;
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  color: var(--paper-soft);
  text-decoration: none;
  transition: color 0.3s ease;
}

.cover__back:hover { color: var(--paper-strong); }

.cover__title {
  font-size: clamp(4rem, 17vw, 9rem);
  font-weight: 400;
  letter-spacing: 0.22em;
  margin-left: 0.22em;
  line-height: 1;
}

.cover__subtitle {
  margin-top: 3.2rem;
  font-size: 1rem;
  letter-spacing: 0.22em;
  color: var(--paper-soft);
}

/* 解锁手柄：一条细线 + 两字 */
.cover__handle {
  position: absolute;
  bottom: calc(2.6rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  cursor: grab;
  outline: none;
}

.cover__handle-line {
  width: 1px;
  height: 2.6rem;
  background: linear-gradient(to bottom, transparent, rgba(245, 245, 246, 0.6));
  animation: nudge 2.4s ease-in-out infinite;
}

.cover__handle-text {
  font-size: 0.78rem;
  letter-spacing: 0.5em;
  margin-left: 0.5em;
  color: var(--paper-soft);
}

@keyframes nudge {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.35; }
}

.cover__hint {
  position: absolute;
  bottom: calc(1.3rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  letter-spacing: 0.4em;
  margin-left: 0.4em;
  color: var(--paper-strong);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.cover__hint.show { opacity: 1; }

/* ============================================================
   顶栏 + 进度条
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(1rem + env(safe-area-inset-top, 0px)) 1.6rem 0.9rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.9s ease 0.15s, transform 0.9s ease 0.15s;
}

body.unlocked .topbar { opacity: 1; transform: translateY(0); }

.topbar__word {
  pointer-events: auto;
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.26em;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.topbar__word em { font-style: normal; opacity: 0.55; }

.topbar__chapters { display: flex; gap: 0.95rem; pointer-events: auto; }

.topbar__chapters button {
  border: none;
  background: none;
  padding: 0.35rem 0;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  color: inherit;
  opacity: 0.4;
  position: relative;
  transition: opacity 0.3s ease;
}

.topbar__chapters button::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transition: right 0.3s ease;
}

.topbar__chapters button.active { opacity: 1; }
.topbar__chapters button.active::after { right: 0; }

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 41;
  background: rgba(128, 128, 128, 0.14);
  opacity: 0;
  transition: opacity 0.9s ease 0.15s;
}

body.unlocked .scroll-progress { opacity: 1; }

.scroll-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: currentColor;
  transition: width 0.1s linear;
}

/* ============================================================
   背景音乐播放器
   ============================================================ */
.music-toggle {
  position: fixed;
  right: 1.4rem;
  bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem 0.55rem 0.8rem;
  border: 1px solid rgba(245, 245, 246, 0.22);
  border-radius: 999px;
  background: rgba(8, 8, 10, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--paper-strong);
  cursor: pointer;
  font-family: var(--sans);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.9s ease 0.35s, transform 0.9s ease 0.35s;
}

body.unlocked .music-toggle {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.music-toggle:hover { border-color: rgba(245, 245, 246, 0.55); }

.music-toggle__icon {
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
}

.music-toggle__track {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  opacity: 0.72;
}

.music-toggle.playing .music-toggle__icon { animation: musicpulse 1.1s ease-in-out infinite; }
@keyframes musicpulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.28); opacity: 0.55; }
}

.music-toggle:not(.playing) .music-toggle__icon { animation: musicbreathe 3.2s ease-in-out infinite; }
@keyframes musicbreathe {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.4; }
}

@media (max-width: 720px) {
  .music-toggle__track { display: none; }
  .music-toggle { padding: 0.55rem 0.7rem; }
}

/* ============================================================
   页面通用
   ============================================================ */
.story { position: relative; opacity: 0; }
body.unlocked .story { opacity: 1; }

.page {
  position: relative;
  min-height: var(--page-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(4.2rem + env(safe-area-inset-top, 0px)) clamp(1.4rem, 5vw, 5rem)
           calc(2.6rem + env(safe-area-inset-bottom, 0px));
  scroll-snap-align: start;
  overflow: hidden;
  --base: #08080a;
  --tint: #18181c;
  --ink: var(--paper-strong);
  --ink-soft: var(--paper-soft);
  color: var(--ink);
  background:
    radial-gradient(110% 85% at 50% 30%, var(--tint) 0%, transparent 58%),
    var(--base);
}

/* ============================================================
   章节引言页
   ============================================================ */
.chapter-intro { flex-direction: column; text-align: center; }

.chapter-intro .chapter__label {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.chapter-intro .chapter__no {
  display: block;
  margin-top: 2rem;
  font-size: 0.9rem;
  letter-spacing: 0.5em;
  color: var(--ink-soft);
}

.chapter-intro .chapter__title {
  margin-top: 1rem;
  font-size: clamp(2.8rem, 9vw, 5.6rem);
  font-weight: 400;
  letter-spacing: 0.22em;
  margin-left: 0.22em;
  line-height: 1.05;
}

.chapter-intro .chapter__title-en {
  display: block;
  margin-top: 1.4rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.5em;
  margin-left: 0.5em;
  color: var(--ink-soft);
}

.chapter-intro .chapter__rule {
  width: 1px;
  height: 3.2rem;
  margin: 2.2rem auto 0;
  background: linear-gradient(to bottom, transparent, currentColor, transparent);
  opacity: 0.35;
}

.chapter-intro .chapter__intro {
  margin-top: 2.1rem;
  max-width: 34em;
  font-size: 1.02rem;
  line-height: 2.05;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

/* ============================================================
   照片页（左右交替的编辑式排版）
   ============================================================ */
.photo {
  flex-direction: row;
  align-items: center;
  gap: clamp(2rem, 5vw, 5.5rem);
  text-align: left;
}

.photo--right { flex-direction: row-reverse; }

.photo__media {
  flex: 1 1 56%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo__body {
  flex: 1 1 44%;
  min-width: 0;
  max-width: 34em;
}

/* 竖幅照片：图窄字宽，重心更稳 */
.photo--tall .photo__media { flex-basis: 44%; }
.photo--tall .photo__body  { flex-basis: 56%; }

.photo__img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 76vh;
  max-height: 76svh;
  object-fit: contain;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
  border-radius: 1px;
}

.page[data-tone="light"] .photo__img {
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
  outline: 1px solid rgba(20, 20, 22, 0.06);
  outline-offset: -1px;
}

.photo__idx {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.4em;
  color: var(--ink-soft);
}

.photo__title {
  margin-top: 1.1rem;
  font-size: clamp(1.7rem, 3.4vw, 2.4rem);
  font-weight: 400;
  letter-spacing: 0.22em;
  margin-left: 0.22em;
  line-height: 1.15;
}

.photo__rule {
  width: 3rem;
  height: 1px;
  margin-top: 1.3rem;
  background: currentColor;
  opacity: 0.35;
}

.photo__story {
  margin-top: 1.2rem;
  font-size: 0.98rem;
  line-height: 2;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.photo__place {
  margin-top: 1.2rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--ink-soft);
  opacity: 0.75;
}

/* ============================================================
   视频页（附录 · 微电影）
   ============================================================ */
.video { flex-direction: column; text-align: center; }

.video__media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

.video__player {
  display: block;
  max-width: min(88vw, 1120px);
  max-height: 62vh;
  max-height: 62svh;
  width: auto;
  height: auto;
  background: #000;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.video__body {
  margin-top: 2.1rem;
  max-width: 36em;
}

.video__label {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.4em;
  color: var(--ink-soft);
}

.video__title {
  margin-top: 1rem;
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: 0.26em;
  margin-left: 0.26em;
  line-height: 1.15;
}

.video__caption {
  margin-top: 0.9rem;
  font-size: 0.98rem;
  line-height: 2;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.video__place {
  margin-top: 1rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--ink-soft);
  opacity: 0.75;
}

/* ============================================================
   尾页
   ============================================================ */
.end { flex-direction: column; text-align: center; }

.end__mark {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.5em;
  color: var(--ink-soft);
}

.end__line {
  margin-top: 2rem;
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  line-height: 2;
  color: var(--ink-soft);
}

.end__back {
  margin-top: 3.2rem;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--serif);
  color: var(--ink);
  letter-spacing: 0.3em;
  font-size: 0.95rem;
}

.end__back::before {
  content: "";
  width: 1px;
  height: 2.4rem;
  background: linear-gradient(to top, transparent, currentColor);
  opacity: 0.4;
}

.end__back-en {
  font-family: var(--sans);
  font-size: 0.6rem;
  letter-spacing: 0.34em;
  color: var(--ink-soft);
}

/* ============================================================
   进入视口动画
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 1.1s cubic-bezier(0.22, 1, 0.36, 1),
              transform 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal-img {
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  transition: opacity 1.3s cubic-bezier(0.22, 1, 0.36, 1),
              transform 1.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.in-view .reveal,
.in-view .reveal-img { opacity: 1; transform: none; }

.in-view .photo__body.reveal { transition-delay: 0.15s; }

/* 章节引言的逐行浮现 */
.in-view .chapter-intro .reveal:nth-child(1) { transition-delay: 0s; }
.in-view .chapter-intro .reveal:nth-child(2) { transition-delay: 0.08s; }
.in-view .chapter-intro .reveal:nth-child(3) { transition-delay: 0.16s; }
.in-view .chapter-intro .reveal:nth-child(4) { transition-delay: 0.24s; }
.in-view .chapter-intro .reveal:nth-child(5) { transition-delay: 0.32s; }
.in-view .chapter-intro .reveal:nth-child(6) { transition-delay: 0.4s; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 820px) {
  .photo,
  .photo--right {
    flex-direction: column;
    gap: 1.8rem;
    justify-content: center;
  }
  .photo__media,
  .photo--tall .photo__media,
  .photo__body,
  .photo--tall .photo__body {
    flex: none;
    width: 100%;
    max-width: none;
  }
  .photo__img { max-height: 52vh; max-height: 52svh; }
  .photo__body { max-width: 34em; }
  .photo__title { font-size: 1.5rem; }
  .photo__story { font-size: 0.94rem; }
  .video__player { max-height: 46vh; max-height: 46svh; }
}

@media (max-width: 720px) {
  .topbar { padding: calc(0.8rem + env(safe-area-inset-top, 0px)) 1.1rem 0.7rem; }
  .topbar__chapters { gap: 0.7rem; }
  .topbar__chapters button { font-size: 0.62rem; letter-spacing: 0.12em; }

  .chapter-intro .chapter__intro { font-size: 0.94rem; padding: 0 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cover, .cover:not(.dragging) { transition: none; }
  .cover__handle-line { animation: none; }
  .reveal, .reveal-img { transition: none; opacity: 1; transform: none; }
}
