/* 共同栖居 · 开场与书籍视觉精修（源码预览版，确认后再同步 dist） */

:root {
  --opening-ink: #f4eddf;
  --opening-muted: rgba(235, 226, 210, 0.78);
  --book-ink: #233752;
  --book-paper: #f4ead1;
}

/* 首页先让主题成立，再让地球村进入视野。 */
.earth-copy--beat-one {
  left: 50%;
  top: 51%;
  width: min(82vw, 76rem);
  max-width: none;
  text-align: center;
  transform: translate(-50%, -50%);
}

/* 原叙事时间轴用更高优先级只改了 Y 轴，曾把居中的首屏推到视口右侧。 */
.has-js .earth-copy--beat-one {
  transform: translate(-50%, calc(-46% - var(--local-progress) * 1.2rem));
}

.earth-copy--beat-one .eyebrow {
  justify-content: center;
  color: rgba(244, 237, 223, 0.68);
  letter-spacing: 0.22em;
}

.earth-copy--beat-one h1 {
  max-width: min(18ch, 92vw);
  margin: 1.05rem auto 0;
  font-family: "Noto Serif SC", "Source Han Serif SC", "STSong", "Songti SC", serif;
  font-size: clamp(2.75rem, 4.35vw, 5.65rem);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: 0.025em;
  text-wrap: balance;
  text-shadow: 0 0.16em 1.2em rgba(4, 12, 29, 0.72);
}

.earth-copy--beat-one h1 .display-line {
  white-space: nowrap;
}

.earth-copy--beat-one .lead {
  width: fit-content;
  margin: 1.6rem auto 0;
  padding: 0.48rem 1rem;
  border: 1px solid rgba(230, 188, 104, 0.34);
  border-radius: 999px;
  color: var(--opening-ink);
  background: rgba(10, 19, 38, 0.34);
  backdrop-filter: blur(12px);
  font-size: clamp(1rem, 1.25vw, 1.35rem);
  letter-spacing: 0.12em;
}

.earth-theme-note {
  margin: 0.85rem auto 0;
  color: rgba(239, 228, 207, 0.64);
  font-size: clamp(0.78rem, 0.9vw, 0.96rem);
  letter-spacing: 0.2em;
}

.earth-copy--beat-two,
.earth-copy--beat-three,
.earth-copy--beat-four {
  width: min(43vw, 43rem);
  max-width: none;
}

.earth-copy h2 {
  text-wrap: balance;
}

.earth-copy .lead,
.earth-copy > p:not(.eyebrow):not(.earth-theme-note) {
  max-width: 35em;
  text-wrap: pretty;
}

/* 原有四个空心圆缺乏信息与动势，独立生态画面已承担其叙事。 */
.life-signal {
  display: none;
}

.earth-system {
  filter: saturate(1.16) brightness(1.08);
  transform-origin: 50% 55%;
}

.earth-globe {
  opacity: 0;
  visibility: hidden;
}

.earth-globe__ocean {
  fill: url(#oceanGradient);
}

.earth-children {
  z-index: 4;
  top: 0;
  width: 92%;
  height: auto;
  max-height: 29%;
  object-fit: contain;
  object-position: center top;
  mix-blend-mode: normal;
  -webkit-mask-image: none;
  mask-image: none;
  filter: saturate(1.02) brightness(1.08) drop-shadow(0 1.1rem 1.55rem rgba(2, 8, 24, 0.42));
  transform-origin: 50% 88%;
  animation: earth-children-arrive 1.4s cubic-bezier(0.22, 1, 0.36, 1) both,
    earth-children-breathe 7.2s 1.4s ease-in-out infinite;
}

.earth-living-art {
  position: absolute;
  z-index: 2;
  inset: 7%;
  width: 86%;
  height: 86%;
  object-fit: contain;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 62%, rgba(0, 0, 0, 0.96) 76%, transparent 100%);
  mask-image: radial-gradient(circle at 50% 50%, #000 62%, rgba(0, 0, 0, 0.96) 76%, transparent 100%);
  filter: saturate(1.12) brightness(1.11) contrast(1.02) drop-shadow(0 2rem 4.8rem rgba(60, 122, 148, 0.34));
  animation: living-earth-breathe 6.8s ease-in-out infinite;
}

/* 真实视频在普通亮度屏幕上也应看清，不再沿用早期的压暗滤镜。 */
.earth-life-reel__canvas video {
  filter: saturate(1.02) contrast(1.02) brightness(1.03);
}

.earth-scroll-invite {
  color: rgba(238, 229, 212, 0.7);
}

@keyframes living-earth-breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-0.7rem) scale(1.012); }
}

@keyframes earth-children-arrive {
  from { opacity: 0; transform: translateX(-50%) translateY(1.8rem) scale(0.97); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes earth-children-breathe {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  50% { transform: translateX(-50%) translateY(-0.45rem) scale(1.008); }
}

/* 从地球过渡为一本实体书。 */
.transition-book,
.book__cover {
  background-image: url("assets/visual/integrated/cohabitation-book-cover-watercolor-clothbound-v2.png");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.transition-book::after,
.book__cover::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 250, 235, 0.28), transparent 28%),
    linear-gradient(90deg, rgba(85, 60, 33, 0.12), transparent 8%, transparent 92%, rgba(85, 60, 33, 0.09));
  box-shadow: inset 0 0 0 1px rgba(130, 99, 54, 0.17);
}

.transition-book__kicker,
.book__cover-kicker {
  top: -4%;
  color: rgba(35, 69, 81, 0.7);
  letter-spacing: 0.22em;
}

.transition-book strong,
.book__cover strong {
  top: -1.5%;
  width: 86%;
  color: #234551;
  font-family: "FZKai-Z03", "STKaiti", "KaiTi", "Noto Serif SC", serif;
  font-size: clamp(1.55rem, 2.15vw, 2.8rem);
  font-weight: 500;
  letter-spacing: 0.12em;
  white-space: nowrap;
  text-align: center;
  text-shadow: 0 1px rgba(255, 255, 255, 0.7);
}

.transition-book__note,
.book__cover-note {
  top: 7.5%;
  color: rgba(42, 72, 77, 0.68);
  font-size: clamp(0.72rem, 0.88vw, 0.95rem);
  letter-spacing: 0.16em;
}

.transition-book__orbit,
.book__cover-orbit {
  opacity: 0.34;
  border-color: rgba(191, 144, 68, 0.38);
}

.book-cover-action {
  top: 20.5%;
  bottom: auto;
  z-index: 3;
  min-height: 3rem;
  padding: 0.7rem 1.25rem;
  border-color: rgba(184, 137, 63, 0.56);
  background: rgba(255, 250, 236, 0.86);
  color: #294954;
  box-shadow: 0 0.8rem 2.2rem rgba(71, 54, 32, 0.12);
  backdrop-filter: blur(8px);
}

.book-cover-action:hover,
.book-cover-action:focus-visible {
  transform: translateX(-50%) translateY(-2px);
  border-color: rgba(174, 118, 35, 0.85);
  background: rgba(255, 253, 244, 0.96);
}

.book-chapter__backdrop {
  background:
    radial-gradient(circle at 23% 40%, rgba(90, 155, 161, 0.12), transparent 28%),
    radial-gradient(circle at 78% 58%, rgba(212, 157, 85, 0.11), transparent 30%);
}

.book-stage--chapter {
  transition: transform 1.05s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.book--chapter {
  width: min(34vw, 62vh, 39rem);
  transition: width 1.05s cubic-bezier(0.2, 0.8, 0.2, 1), transform 1.05s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.book--chapter.is-open {
  width: min(48vw, 72vh, 53rem);
  transform: translateX(50%) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
}

.book__page--story,
.book__left-page {
  color: var(--book-ink);
  background:
    radial-gradient(circle at 48% 28%, rgba(255, 251, 234, 0.93), rgba(244, 234, 209, 0.95) 60%, rgba(225, 208, 174, 0.94));
}

.book-page-copy {
  inset: 14% 11% 9% 12%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 1.15rem;
}

.book-page-copy > span {
  font-size: clamp(0.78rem, 0.9vw, 1rem);
  letter-spacing: 0.16em;
}

.book-page-copy h2 {
  margin: 0;
  font-family: "FZKai-Z03", "STKaiti", "KaiTi", "Noto Serif SC", serif;
  font-size: clamp(2.1rem, 3.8vw, 5rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.book-page-copy p {
  max-width: 27em;
  margin: 0;
  font-size: clamp(1rem, 1.22vw, 1.38rem);
  line-height: 1.9;
  text-wrap: pretty;
}

.book-page-copy a {
  margin-top: 0.45rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  font-size: clamp(0.92rem, 1.05vw, 1.1rem);
}

.book__right-ecosystem {
  opacity: 0.42;
  transform: scale(0.94) translate(2%, 2%);
}

.book__popup-ecosystem {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  margin: 0;
  overflow: hidden;
  border-radius: 1.35rem 0.3rem 0.3rem 1.35rem;
  background: #f4ead3;
}

.book__popup-ecosystem img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
  filter: saturate(1.04) brightness(1.08);
  box-shadow: none;
}

/* 打开书时，立体生态画直接成为整张左页，不露出旧底图或二重画框。 */
.book__left-page:has(.book__popup-ecosystem) {
  overflow: hidden;
  background: #f4ead3;
}

.book__popup-ground,
.book__left-caption {
  display: none;
}

.book__left-page::before,
.book__left-page::after {
  display: none;
}

.book__left-caption {
  left: 9%;
  right: auto;
  bottom: 4.2%;
  font-family: "FZKai-Z03", "STKaiti", "KaiTi", serif;
  font-size: clamp(0.92rem, 1.05vw, 1.16rem);
  line-height: 1.5;
  letter-spacing: 0.08em;
  text-align: left;
}

.book-companion-art {
  width: min(28vw, 34rem);
  right: 5vw;
}

.book-companion-art__frame {
  aspect-ratio: 0.82;
  transform: rotate(3deg);
  border-width: 0.65rem;
  border-color: rgba(244, 230, 194, 0.88);
  box-shadow: 0 2.2rem 5rem rgba(0, 0, 0, 0.35);
}

.book-companion-art__frame img {
  filter: saturate(1.08) brightness(1.08);
}

.book-chapter__hint {
  bottom: 2.5vh;
  color: rgba(237, 227, 206, 0.68);
}

@media (max-width: 900px) {
  .earth-copy--beat-one {
    top: 48%;
    width: min(90vw, 43rem);
  }

  .earth-copy--beat-one h1 {
    font-size: clamp(2.35rem, 9.2vw, 4.2rem);
    line-height: 1.23;
  }

  .earth-copy--beat-one h1 .display-line {
    white-space: normal;
  }

  .earth-copy--beat-one .lead {
    max-width: 88vw;
    font-size: 0.92rem;
    line-height: 1.5;
    letter-spacing: 0.08em;
  }

  .earth-copy--beat-two,
  .earth-copy--beat-three,
  .earth-copy--beat-four {
    width: min(88vw, 36rem);
  }

  .earth-children {
    top: 2%;
    width: 96%;
    max-height: 25%;
  }

  .earth-living-art {
    inset: 8%;
    width: 84%;
    height: 84%;
  }

  .book--chapter,
  .book--chapter.is-open {
    width: min(82vw, 58vh, 31rem);
  }

  .book--chapter.is-open {
    transform: translateX(0) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }

  .book__left-page {
    display: none;
  }

  .book-page-copy {
    inset: 12% 10% 8%;
  }

  .book-page-copy h2 {
    font-size: clamp(2rem, 9vw, 3.7rem);
  }

  .book-page-copy p {
    font-size: clamp(0.96rem, 4vw, 1.12rem);
    line-height: 1.78;
  }

  .book-companion-art {
    display: none;
  }

  .transition-book strong,
  .book__cover strong {
    font-size: clamp(1.4rem, 6vw, 2.3rem);
  }
}

@media (max-width: 520px) {
  .earth-copy--beat-one h1 {
    max-width: 10.5em;
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .earth-theme-note {
    font-size: 0.72rem;
    letter-spacing: 0.12em;
  }

  .book--chapter,
  .book--chapter.is-open {
    width: min(88vw, 64vh, 29rem);
  }

  /* 窄屏封面保持完整居中，避免透视位移把翻书按钮裁出画面。 */
  .book-stage--chapter {
    width: 100%;
    transform: none;
  }

  .book--chapter:not(.is-open) {
    width: min(78vw, 18.5rem);
    transform: rotateX(2deg) rotateY(-7deg) rotateZ(0.5deg);
  }

  .book--chapter:not(.is-open) .book__cover {
    transform: translateZ(0.8rem);
  }

  .book-page-copy h2 {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .earth-globe,
  .earth-children,
  .earth-living-art {
    animation: none !important;
  }
}
