@font-face {
  font-family: "Noto Serif SC";
  src: url("/fonts/NotoSerifSC.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans SC";
  src: url("/fonts/NotoSansSC.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --sky-deep: #070c16;
  --sky-teal: #163044;
  --horizon-amber: #e59b6a;
  --horizon-coral: #f2c4b0;
  --paper: #faf6ec;
  --paper-soft: #f4efe4;
  --ink: #3a2e24;
  --ink-soft: #5a4c40;
  --cream: #f4efe4;
  --ui: rgba(244, 239, 228, 0.62);
  --ui-hover: #faf6ec;
  --serif: "Noto Serif SC", "Songti SC", "Source Han Serif SC", serif;
  --sans: "Noto Sans SC", "Source Han Sans SC", "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--sky-deep);
  color: var(--cream);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
  min-height: 100dvh;
  opacity: 0;
  transition: opacity 1.8s var(--ease);
}

body.is-ready {
  opacity: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

#world {
  position: fixed;
  inset: -4%;
  z-index: 0;
  pointer-events: none;
  will-change: transform;
}

.plate {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.8s var(--ease);
  background-color: var(--sky-deep);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  transform: scale(1.03);
}

.plate.is-on {
  opacity: 1;
  animation: horizon-drift 84s var(--ease) infinite alternate;
}

/* Silent co-presence: residual warmth in the land, never a count or figure. */
.plate::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Even at ember 0.8 / recency 0.85, this should stay a flip-comparison warmth. */
  opacity: calc(var(--trace-ember, 0) * (0.14 + var(--trace-recency, 0) * 0.18));
  transition: opacity 7s var(--ease);
}

.plate[data-scene="home"]::after {
  background:
    radial-gradient(ellipse 48% 18% at 58% 76%, rgba(229, 155, 106, 0.16) 0%, transparent 74%),
    radial-gradient(ellipse 22% 14% at 22% 84%, rgba(242, 196, 176, 0.07) 0%, transparent 72%);
}

.plate[data-scene="mote"]::after {
  background:
    radial-gradient(ellipse 26% 18% at 18% 78%, rgba(242, 196, 176, 0.14) 0%, transparent 74%),
    radial-gradient(ellipse 12% 10% at 22% 70%, rgba(229, 155, 106, 0.08) 0%, transparent 68%);
}

.plate[data-scene="jiegou"]::after {
  background:
    radial-gradient(ellipse 20% 24% at 48% 84%, rgba(229, 155, 106, 0.12) 0%, transparent 72%),
    radial-gradient(ellipse 30% 14% at 70% 72%, rgba(242, 196, 176, 0.06) 0%, transparent 74%);
}

.plate[data-scene="yuxie"]::after {
  background:
    radial-gradient(ellipse 22% 16% at 30% 82%, rgba(229, 155, 106, 0.14) 0%, transparent 72%),
    radial-gradient(ellipse 14% 12% at 52% 64%, rgba(242, 196, 176, 0.07) 0%, transparent 72%);
}


.plate[data-scene="home"] {
  background-image: image-set(
    url("/img/home-horizon.webp") type("image/webp"),
    url("/img/home-horizon.jpg") type("image/jpeg")
  );
}

.plate[data-scene="mote"] {
  background-image: image-set(
    url("/img/scene-platform.webp") type("image/webp"),
    url("/img/scene-platform.jpg") type("image/jpeg")
  );
}

.plate[data-scene="jiegou"] {
  background-image: image-set(
    url("/img/scene-pylons.webp") type("image/webp"),
    url("/img/scene-pylons.jpg") type("image/jpeg")
  );
}

.plate[data-scene="yuxie"] {
  background-image: image-set(
    url("/img/scene-corridor.webp") type("image/webp"),
    url("/img/scene-corridor.jpg") type("image/jpeg")
  );
}

@keyframes horizon-drift {
  from {
    transform: scale(1.03) translate3d(0, 0, 0);
  }
  to {
    transform: scale(1.08) translate3d(-1.4%, 0.7%, 0);
  }
}

#air {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.055;
  mix-blend-mode: overlay;
  background-image: url("/img/grain.png");
  background-size: 180px 180px;
  pointer-events: none;
}

.vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(7, 12, 22, 0.26) 0%, rgba(7, 12, 22, 0.08) 26%, transparent 50%),
    radial-gradient(ellipse at center, transparent 46%, rgba(7, 12, 22, 0.24) 100%);
  pointer-events: none;
}

#stage {
  position: relative;
  z-index: 2;
  height: 100dvh;
  height: 100svh;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.6s var(--ease);
}

/* Full-bleed atmospheric paper mist: no rectangular card.
   A wide bottom wash has no left/right edges; a large ellipse
   sits under the type and fades in every direction. */
.view::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(
      to top,
      rgba(250, 246, 236, 0.22) 0%,
      rgba(244, 239, 228, 0.10) 18%,
      rgba(244, 239, 228, 0.03) 34%,
      transparent 52%
    ),
    radial-gradient(
      ellipse 78% 62% at 18% 100%,
      rgba(250, 246, 236, 0.62) 0%,
      rgba(250, 246, 236, 0.38) 28%,
      rgba(244, 239, 228, 0.14) 50%,
      rgba(244, 239, 228, 0.04) 68%,
      transparent 84%
    );
}

/* Scenes sit on darker lower thirds. Keep ink, raise a still-edgeless
   local paper so verse contrast is not lost after softening the home. */
#view-mote::before,
#view-jiegou::before,
#view-yuxie::before {
  background:
    linear-gradient(
      to top,
      rgba(250, 246, 236, 0.28) 0%,
      rgba(244, 239, 228, 0.12) 18%,
      rgba(244, 239, 228, 0.04) 34%,
      transparent 52%
    ),
    radial-gradient(
      ellipse 76% 60% at 18% 100%,
      rgba(250, 246, 236, 0.88) 0%,
      rgba(250, 246, 236, 0.58) 26%,
      rgba(244, 239, 228, 0.22) 48%,
      rgba(244, 239, 228, 0.06) 66%,
      transparent 82%
    );
}

#view-mote .reading,
#view-jiegou .reading,
#view-yuxie .reading {
  text-shadow:
    0 0 28px rgba(250, 246, 236, 0.95),
    0 0 14px rgba(250, 246, 236, 0.75),
    0 0 6px rgba(250, 246, 236, 0.55),
    0 1px 2px rgba(250, 246, 236, 0.5);
}

.view.is-on {
  opacity: 1;
  pointer-events: auto;
}

.reading {
  position: relative;
  z-index: 1;
  width: min(42rem, calc(100% - 3.2rem));
  margin: 0 0 max(2.4rem, env(safe-area-inset-bottom)) 8vw;
  padding: 4.5rem 0 0;
  background: none;
  color: var(--ink);
  /* Soft paper halo on glyphs only — keeps contrast without a box. */
  text-shadow:
    0 0 24px rgba(250, 246, 236, 0.8),
    0 0 10px rgba(250, 246, 236, 0.55),
    0 1px 2px rgba(250, 246, 236, 0.4);
}

.title {
  margin: 0 0 0.15em;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  letter-spacing: 0.38em;
  line-height: 1.2;
}

.latin {
  margin: 0 0 1.6em;
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  color: var(--ink-soft);
  text-transform: none;
}

.chapter {
  margin: 0 0 1.15em;
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  color: var(--ink-soft);
}

.verse {
  margin: 0 0 0.7em;
  max-width: 28em;
  font-weight: 400;
  font-size: clamp(0.92rem, 1.35vw, 1.05rem);
  line-height: 2.05;
  letter-spacing: 0.04em;
}

.passages,
.continue {
  margin: 1.7em 0 0;
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  color: var(--ink-soft);
}

.passages a,
.continue a {
  display: inline-block;
  padding: 0.2em 0;
  border-bottom: 1px solid transparent;
  transition: color 0.8s var(--ease), border-color 0.8s var(--ease);
}

.passages a:hover,
.continue a:hover,
.passages a:focus-visible,
.continue a:focus-visible {
  color: var(--ink);
  border-bottom-color: rgba(58, 46, 36, 0.35);
  outline: none;
}

.sep {
  display: inline-block;
  margin: 0 0.7em;
  opacity: 0.5;
}

.appear {
  opacity: 0;
  transform: translate3d(0, 0.55em, 0);
}

.view.is-settled .appear {
  animation: settle 2.1s var(--ease) forwards;
}

.view.is-settled .a1 { animation-delay: 2.2s; }
.view.is-settled .a2 { animation-delay: 3.4s; }
.view.is-settled .a3 { animation-delay: 5.1s; }
.view.is-settled .a4 { animation-delay: 6.8s; }
.view.is-settled .a5 { animation-delay: 8.8s; }

.view[data-view="home"].is-settled .a1 { animation-delay: 2.6s; }
.view[data-view="home"].is-settled .a2 { animation-delay: 3.8s; }
.view[data-view="home"].is-settled .a3 { animation-delay: 5.6s; }
.view[data-view="home"].is-settled .a4 { animation-delay: 7s; }
.view[data-view="home"].is-settled .a5 { animation-delay: 8s; }

/* Paths are already in the world, only very faintly, so a short stay
   can still find them; the later bloom is recognition, not a menu. */
.view[data-view="home"] .passages.appear {
  opacity: 0.3;
  transform: none;
}

@keyframes settle-passages {
  from {
    opacity: 0.3;
    transform: none;
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.view[data-view="home"].is-settled .passages.appear {
  animation-name: settle-passages;
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translate3d(0, 0.55em, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

#sound {
  position: fixed;
  right: max(1.2rem, env(safe-area-inset-right));
  bottom: max(1.15rem, env(safe-area-inset-bottom));
  z-index: 5;
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  color: var(--ui);
  transition: color 0.8s var(--ease), opacity 0.8s var(--ease);
  opacity: 0.78;
}

#sound:hover,
#sound:focus-visible {
  color: var(--ui-hover);
  opacity: 1;
  outline: none;
}

#sound[aria-pressed="true"] {
  color: var(--horizon-coral);
}

@media (max-width: 720px) {
  .view::before {
    background:
      linear-gradient(
        to top,
        rgba(250, 246, 236, 0.4) 0%,
        rgba(244, 239, 228, 0.18) 24%,
        rgba(244, 239, 228, 0.05) 42%,
        transparent 58%
      ),
      radial-gradient(
        ellipse 90% 55% at 30% 100%,
        rgba(250, 246, 236, 0.86) 0%,
        rgba(250, 246, 236, 0.5) 32%,
        rgba(244, 239, 228, 0.14) 58%,
        transparent 78%
      );
  }

  .reading {
    width: calc(100% - 2rem);
    margin: 0 1rem max(1.5rem, env(safe-area-inset-bottom));
    padding-top: 3.4rem;
  }

  .title {
    letter-spacing: 0.28em;
  }

  .verse {
    line-height: 1.95;
  }
}

@media (min-width: 1440px) {
  .view::before {
    background:
      linear-gradient(
        to top,
        rgba(250, 246, 236, 0.2) 0%,
        rgba(244, 239, 228, 0.08) 16%,
        rgba(244, 239, 228, 0.03) 32%,
        transparent 50%
      ),
      radial-gradient(
        ellipse 62% 56% at 16% 100%,
        rgba(250, 246, 236, 0.58) 0%,
        rgba(250, 246, 236, 0.34) 30%,
        rgba(244, 239, 228, 0.12) 52%,
        rgba(244, 239, 228, 0.03) 68%,
        transparent 84%
      );
  }

  #view-mote::before,
  #view-jiegou::before,
  #view-yuxie::before {
    background:
      linear-gradient(
        to top,
        rgba(250, 246, 236, 0.26) 0%,
        rgba(244, 239, 228, 0.1) 16%,
        rgba(244, 239, 228, 0.03) 32%,
        transparent 50%
      ),
      radial-gradient(
        ellipse 64% 56% at 16% 100%,
        rgba(250, 246, 236, 0.86) 0%,
        rgba(250, 246, 236, 0.52) 28%,
        rgba(244, 239, 228, 0.18) 50%,
        rgba(244, 239, 228, 0.05) 68%,
        transparent 84%
      );
  }

  .reading {
    width: min(40rem, 38vw);
    margin: 0 0 max(3.2rem, env(safe-area-inset-bottom)) 9vw;
    padding-top: 5.25rem;
  }

  .title {
    font-size: 1.68rem;
    letter-spacing: 0.42em;
  }

  .latin {
    font-size: 0.7rem;
    letter-spacing: 0.32em;
    margin-bottom: 1.85em;
  }

  .chapter {
    letter-spacing: 0.46em;
    margin-bottom: 1.3em;
  }

  .verse {
    font-size: 1.02rem;
    letter-spacing: 0.05em;
    max-width: 26em;
    line-height: 2.12;
  }

  .passages,
  .continue {
    margin-top: 2em;
    letter-spacing: 0.26em;
  }
}

@media (min-width: 1920px) {
  .view::before {
    background:
      linear-gradient(
        to top,
        rgba(250, 246, 236, 0.18) 0%,
        rgba(244, 239, 228, 0.07) 15%,
        rgba(244, 239, 228, 0.02) 30%,
        transparent 48%
      ),
      radial-gradient(
        ellipse 54% 52% at 15% 100%,
        rgba(250, 246, 236, 0.55) 0%,
        rgba(250, 246, 236, 0.3) 32%,
        rgba(244, 239, 228, 0.1) 54%,
        rgba(244, 239, 228, 0.03) 70%,
        transparent 86%
      );
  }

  #view-mote::before,
  #view-jiegou::before,
  #view-yuxie::before {
    background:
      linear-gradient(
        to top,
        rgba(250, 246, 236, 0.24) 0%,
        rgba(244, 239, 228, 0.09) 15%,
        rgba(244, 239, 228, 0.03) 30%,
        transparent 48%
      ),
      radial-gradient(
        ellipse 58% 54% at 15% 100%,
        rgba(250, 246, 236, 0.84) 0%,
        rgba(250, 246, 236, 0.48) 30%,
        rgba(244, 239, 228, 0.16) 52%,
        rgba(244, 239, 228, 0.04) 70%,
        transparent 86%
      );
  }

  .reading {
    width: min(42rem, 34vw);
    margin: 0 0 max(3.8rem, env(safe-area-inset-bottom)) 10vw;
    padding-top: 5.8rem;
  }

  .title {
    font-size: 1.76rem;
    letter-spacing: 0.46em;
  }

  .latin {
    letter-spacing: 0.34em;
  }

  .verse {
    font-size: 1.05rem;
    line-height: 2.16;
  }
}

@media (prefers-reduced-motion: reduce) {
  body {
    transition: none;
  }

  .plate,
  .plate.is-on,
  .view,
  #sound,
  .passages a,
  .continue a {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }

  .appear,
  .view.is-settled .appear {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
}
