:root {
  --night: #06141b;
  --pine: #0d2a24;
  --ink: #e8f1ee;
  --ink-soft: #b4c7c0;
  --gold: #d7b07a;
  --gold-soft: #e6c89a;
  --paper: #f3ead8;
  --shade: #071018;
  --rule: rgba(214, 196, 160, 0.16);
  --serif: "Cormorant Garamond", "Songti SC", "STSong", serif;
  --sans: "Source Sans 3", "PingFang SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background: var(--night);
  font-family: var(--sans);
  line-height: 1.55;
}

body[data-stage="gate"],
body[data-stage="cover"],
body[data-stage="letter"] { overflow: hidden; }

.grain,
.atmosphere {
  pointer-events: none;
  position: fixed;
  inset: 0;
}
.grain {
  z-index: 1;
  opacity: 0.11;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}
.atmosphere {
  z-index: 0;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(46, 110, 96, 0.38), transparent 58%),
    radial-gradient(800px 480px at 92% 8%, rgba(28, 72, 118, 0.42), transparent 56%),
    radial-gradient(700px 640px at 78% 88%, rgba(18, 86, 72, 0.28), transparent 62%),
    linear-gradient(180deg, #081820 0%, #07151c 42%, #0a221d 100%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.chrome {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 18px;
  pointer-events: none;
}
.chrome-mark,
.lang-switch,
.door-switch {
  pointer-events: auto;
  margin: 0;
  color: var(--paper);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}
body[data-stage="album"] .chrome {
  background: rgba(7, 21, 28, 0.92);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(10px);
}
body[data-stage="album"] .chrome-mark,
body[data-stage="album"] .lang-switch,
body[data-stage="album"] .door-switch {
  color: var(--ink);
  text-shadow: none;
}
.chrome-mark {
  font-family: var(--serif);
  font-size: 1.05rem;
}
.lang-switch,
.door-switch {
  border: 1px solid currentColor;
  background: transparent;
  min-width: 52px;
  height: 32px;
  padding: 0 10px;
  font: 500 0.78rem/1 var(--sans);
  letter-spacing: 0.08em;
  cursor: pointer;
}
.door-switch {
  display: none;
  justify-self: center;
  grid-column: 2;
  min-width: auto;
  font-family: var(--serif);
  font-style: italic;
  letter-spacing: 0.04em;
}
body[data-stage="cover"] .door-switch,
body[data-stage="letter"] .door-switch { display: inline-flex; align-items: center; }
.lang-switch:focus-visible,
.door-switch:focus-visible,
.gate-form button:focus-visible,
.enter:focus-visible,
.player:focus-visible,
.lightbox-close:focus-visible,
.lightbox-nav:focus-visible,
.toc a:focus-visible {
  outline: 2px solid var(--gold-soft);
  outline-offset: 3px;
}

.stage {
  min-height: 100dvh;
  position: relative;
  z-index: 2;
}
.stage-gate,
.stage-cover,
.stage-letter {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: transparent;
}
.stage-letter {
  overflow-y: auto;
  padding: 84px 20px 48px;
}
.stage-gate,
.stage-cover,
.stage-letter,
.album {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(84px);
  transition:
    opacity 1.15s ease,
    transform 1.25s cubic-bezier(.22, .82, .16, 1);
}
.stage-gate.is-on,
.stage-cover.is-on,
.stage-letter.is-on,
.album.is-on {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}
.stage-gate.is-leaving,
.stage-cover.is-leaving,
.stage-letter.is-leaving,
.album.is-leaving {
  opacity: 0;
  visibility: visible;
  pointer-events: none;
  transform: translateY(-96px);
}
.stage-cover.is-leaving,
.stage-gate.is-leaving,
.stage-letter.is-leaving {
  z-index: 9;
}
.stage-cover.is-leaving .cover-photo,
.stage-cover.is-leaving .cover-shade {
  opacity: 0.35;
  transition: opacity 900ms ease;
}

.gate-card,
.cover-copy,
.letter-copy {
  position: relative;
  z-index: 3;
  width: min(680px, calc(100vw - 48px));
  text-align: center;
  text-shadow:
    0 2px 12px rgba(4, 14, 18, 0.85),
    0 10px 36px rgba(4, 14, 18, 0.8);
}
.letter-copy {
  z-index: 8;
  width: min(720px, calc(100vw - 48px));
  text-align: left;
  padding: 28px 28px 32px;
  border: 1px solid rgba(214, 196, 160, 0.16);
  background: rgba(6, 22, 28, 0.78);
  box-shadow: 0 30px 90px rgba(2, 10, 14, 0.45);
  backdrop-filter: blur(10px);
}
.stage-letter .float-words { z-index: 1; opacity: 0.42; }
.letter-copy h1 { text-align: center; }
.letter-copy .whisper,
.letter-copy .from,
.letter-copy .enter { display: block; margin-left: auto; margin-right: auto; text-align: center; }
.letter-copy .enter { margin-top: 8px; }
.stage-letter { align-items: start; }
.letter-zh,
.letter-en {
  margin: 18px 0 0;
  font-size: clamp(1.12rem, 2.1vw, 1.28rem);
  line-height: 1.85;
  color: rgba(232, 241, 238, 0.92);
}
.letter-zh p,
.letter-en p { margin: 0 0 1em; }
.letter-zh p:last-child,
.letter-en p:last-child { margin-bottom: 0; }
body[data-lang="en"] .letter-zh { display: none; }
body[data-lang="zh"] .letter-en { display: none; }
.acrostic {
  margin: 28px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.4rem, 2.6vw, 1.85rem);
  line-height: 1.7;
  color: rgba(232, 241, 238, 0.94);
}
.acrostic p { margin: 0; }
.cover-copy::before {
  content: "";
  position: absolute;
  inset: -6% -4%;
  z-index: -1;
  background: radial-gradient(ellipse at center, rgba(6, 20, 27, 0.72) 0 42%, transparent 76%);
}
.stage-gate .float-words {
  position: absolute;
  z-index: 1;
}
.gate-card {
  padding: 32px 24px 36px;
  border: 1px solid rgba(214, 196, 160, 0.16);
  background: rgba(6, 22, 28, 0.48);
  box-shadow: 0 30px 90px rgba(2, 10, 14, 0.45);
  backdrop-filter: blur(10px);
}
.whisper {
  margin: 0 0 16px;
  color: var(--gold-soft);
  font-size: clamp(1.68rem, 2.6vw, 1.9rem);
  letter-spacing: 0.04em;
}
h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.8rem, 8vw, 6rem);
  font-weight: 500;
  line-height: 1.08;
}
.gate-form {
  display: grid;
  gap: 16px;
  margin-top: 34px;
}
.gate-form input,
.enter,
.gate-form button { font: inherit; }
.gate-form input {
  height: 64px;
  border: 0;
  border-bottom: 1px solid rgba(232, 241, 238, 0.38);
  background: transparent;
  color: var(--ink);
  text-align: center;
  font-size: 1.7rem;
  outline: none;
}
.gate-form button,
.enter,
.lightbox-close {
  border: 1px solid rgba(214, 196, 160, 0.45);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.gate-form button,
.enter {
  height: 58px;
  padding: 0 34px;
  justify-self: center;
  font-size: 1.15rem;
  letter-spacing: 0.16em;
}
.gate-error {
  min-height: 1.6em;
  margin: 16px 0 0;
  color: #efb3a0;
  font-size: 1.7rem;
}
.gate-card.is-wrong { animation: shake 360ms ease; }
@keyframes shake {
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.cover-photo,
.cover-shade { position: absolute; inset: 0; }
.cover-photo {
  background: #07151c center / cover no-repeat;
  transform: scale(1.04);
  filter: saturate(0.62) contrast(1.08) brightness(0.7);
}
.cover-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(8, 38, 44, 0.55);
  mix-blend-mode: multiply;
}
.cover-shade {
  background:
    linear-gradient(180deg, rgba(6, 24, 32, 0.5), rgba(5, 22, 30, 0.66) 48%, rgba(4, 16, 22, 0.94)),
    radial-gradient(circle at 16% 10%, rgba(32, 96, 88, 0.38), transparent 44%),
    radial-gradient(circle at 88% 12%, rgba(24, 64, 110, 0.42), transparent 48%),
    radial-gradient(circle at 50% 42%, transparent 0 22%, rgba(6, 20, 27, 0.62) 100%);
}
.stage-gate::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(720px 420px at 50% 42%, rgba(8, 28, 32, 0.18), transparent 64%);
}
.lede {
  max-width: 24ch;
  margin: 22px auto 0;
  color: rgba(232, 241, 238, 0.92);
  font-size: clamp(2.05rem, 3.4vw, 2.3rem);
  line-height: 1.35;
}
.wish {
  max-width: 28ch;
  margin: 18px auto 0;
  color: var(--gold-soft);
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(2.05rem, 3.4vw, 2.3rem);
  line-height: 1.4;
}
.from {
  margin: 22px 0 32px;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(2.35rem, 3.6vw, 2.6rem);
}

.album {
  position: relative;
  z-index: 2;
  padding: 108px 18px 140px;
}
body[data-stage="album"] .album {
  padding-left: max(18px, 7vw);
  padding-right: max(18px, 7vw);
}
@media (min-width: 1180px) {
  body[data-stage="album"] .album {
    padding-left: 168px;
    padding-right: 168px;
  }
}
#chapters {
  min-height: 40vh;
  transition: opacity 480ms ease, transform 480ms ease, filter 480ms ease;
}
#chapters.is-switching {
  opacity: 0;
  transform: translateY(12px);
  filter: blur(4px);
}
.chapter {
  content-visibility: auto;
  contain-intrinsic-size: 900px;
}

.float-words {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, #000 0 18%, rgba(0,0,0,.18) 38% 62%, #000 82% 100%);
  mask-image: linear-gradient(90deg, #000 0 18%, rgba(0,0,0,.18) 38% 62%, #000 82% 100%);
}
body[data-stage="album"] .float-words {
  position: fixed;
  z-index: 1;
}
.float-word {
  position: absolute;
  bottom: -18%;
  color: rgba(244, 250, 246, 0.96);
  text-shadow: 0 10px 28px rgba(4, 14, 18, 0.45);
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--size, 2.6rem);
  letter-spacing: 0.02em;
  white-space: nowrap;
  animation:
    rise var(--dur, 18s) linear infinite,
    twinkle var(--twinkle, 2.4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s), var(--twinkle-delay, 0s);
}
.float-word.is-left { left: var(--x); }
.float-word.is-right { left: auto; right: var(--x); }
.float-word.is-mid {
  left: var(--x);
  color: rgba(244, 250, 246, 0.7);
  font-size: calc(var(--size, 2.6rem) * 0.7);
}
body[data-stage="album"] .float-word {
  color: rgba(244, 250, 246, 0.88);
}
body[data-stage="album"] .float-word.is-mid {
  color: rgba(244, 250, 246, 0.5);
}
@keyframes rise {
  0% { transform: translate3d(0, 18vh, 0); }
  100% { transform: translate3d(var(--drift, 18px), -122vh, 0); }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.06; }
  18% { opacity: 0.22; }
  42% { opacity: 1; }
  58% { opacity: 0.18; }
  76% { opacity: 0.82; }
}
.chrome-mark { justify-self: start; grid-column: 1; }
.lang-switch { justify-self: end; grid-column: 3; }
.toc {
  display: none;
  gap: 4px;
  justify-self: center;
  grid-column: 2;
  padding: 4px;
  background: rgba(8, 28, 32, 0.72);
  border: 1px solid var(--rule);
  pointer-events: auto;
}
body[data-stage="album"] .toc { display: flex; }
.toc a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 6px 12px;
}
.toc a:hover,
.toc a.is-active {
  color: var(--gold-soft);
  background: rgba(215, 176, 122, 0.1);
}

.chapter {
  margin: 0 auto;
  width: min(980px, 100%);
}
.chapter-head {
  max-width: 40rem;
  margin: 0 auto 42px;
}
.chapter-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.4rem);
  font-weight: 500;
}
.chapter-head p {
  margin: 10px 0 0;
  color: var(--ink-soft);
  max-width: 46ch;
}
.note {
  margin: 12px 0 0;
  color: var(--gold-soft);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
}

.section { margin: 0 0 54px; }
.section h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 500;
}
.section-note {
  margin: 0 0 22px;
  color: var(--ink-soft);
  max-width: 48ch;
}

.masonry,
.timeline {
  columns: 2;
  column-gap: 28px;
}
.shot,
.group {
  break-inside: avoid;
  margin: 0 0 36px;
}
.shot button,
.group-grid button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.shot img,
.group-grid img {
  display: block;
  width: 100%;
  height: auto;
  background: #123038;
}
.shot img,
.group-grid {
  border-radius: 14px;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.38),
    0 2px 0 rgba(232, 241, 238, 0.08);
}
.group-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  padding: 8px;
  background: rgba(8, 28, 32, 0.55);
  border: 1px solid var(--rule);
}
.group-grid.n1 { grid-template-columns: 1fr; }
.group-grid.n3 { grid-template-columns: 1fr 1fr; }
.group-grid.n3 button:first-child { grid-column: 1 / -1; }
.group-grid.n4 { grid-template-columns: 1fr 1fr; }

.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 700ms ease, transform 700ms ease;
}
.reveal.is-in {
  opacity: 1;
  transform: none;
}

.close {
  width: min(720px, 100%);
  margin: 48px auto 0;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
  text-align: center;
}
.close p { margin: 0; }
.close-zh {
  font-family: var(--serif);
  font-size: clamp(1.45rem, 3vw, 2.05rem);
  line-height: 1.45;
}
.close-en {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 1rem;
}

.player {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 24;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--rule);
  background: rgba(7, 21, 28, 0.92);
  color: var(--ink);
  cursor: pointer;
}
.player-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: var(--night);
}
.player-icon::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 8px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  margin-left: 2px;
}
.player.is-playing .player-icon::before {
  width: 10px;
  height: 10px;
  margin: 0;
  border: 0;
  box-shadow: inset 3px 0 0 currentColor, inset -3px 0 0 currentColor;
}
.player-label {
  overflow: hidden;
  max-width: 12rem;
  font-size: 0.78rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lightbox {
  width: min(96vw, 1200px);
  max-width: 96vw;
  max-height: 94dvh;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: transparent;
  color: var(--paper);
  z-index: 40;
}
body:has(.lightbox[open]) .player { visibility: hidden; }
.lightbox::backdrop { background: rgba(4, 10, 14, 0.88); }
.lightbox figure {
  margin: 0;
  display: grid;
  place-items: center;
  min-height: 70dvh;
  overflow: hidden;
}
.lightbox img {
  max-width: min(92vw, 100%);
  max-height: 82dvh;
  object-fit: contain;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
}
.lightbox-close,
.lightbox-nav {
  position: absolute;
  border: 0;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
}
.lightbox-close {
  top: 8px;
  right: 8px;
  padding: 8px 12px;
  letter-spacing: 0.08em;
}
.lightbox-nav {
  top: 50%;
  font-size: 2.8rem;
  transform: translateY(-50%);
}
.lightbox-nav.prev { left: 4px; }
.lightbox-nav.next { right: 4px; }

@media (max-width: 720px) {
  .masonry,
  .timeline { columns: 1; }
  .chrome {
    grid-template-columns: 1fr auto;
    padding: 12px;
  }
  .chrome-mark { grid-column: 1; }
  .lang-switch { grid-column: 2; }
  .toc {
    grid-column: 1 / -1;
    margin-top: 6px;
  }
  .album { padding: 112px 12px 120px; }
  .player { right: 10px; bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .gate-card.is-wrong { animation: none; }
  .cover-photo { transform: none; }
  .reveal,
  .stage-gate,
  .stage-cover,
  .stage-letter,
  .album,
  #chapters {
    transform: none;
    filter: none;
    transition: none;
  }
  .stage-gate.is-leaving,
  .stage-cover.is-leaving,
  .stage-letter.is-leaving,
  .album.is-leaving {
    transform: none;
  }
  .float-word { animation: none; opacity: 0.28; }
}
@media (max-width: 1179px) {
  body[data-stage="album"] .float-word.is-mid { display: none; }
}
@media (max-width: 640px) {
  .float-word.is-mid { display: none; }
  .float-word { font-size: calc(var(--size, 1.8rem) * 0.82); }
}
