/* ==========================================================================
   Star Letter — Base shell
   Atmosphere, loader, masthead, moon, shared scene frame and type.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Atmosphere layers
   -------------------------------------------------------------------------- */

.nebula {
  position: fixed;
  inset: -10%;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 38% 30% at 24% 32%, rgba(109, 93, 246, 0.16), transparent 70%),
    radial-gradient(ellipse 30% 24% at 78% 60%, rgba(255, 122, 168, 0.10), transparent 72%),
    radial-gradient(ellipse 36% 26% at 48% 94%, rgba(109, 93, 246, 0.13), transparent 74%);
  animation: nebulaDrift 46s ease-in-out infinite alternate;
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.34;
  transition: opacity 2.2s ease;
}

.aurora__ribbon {
  position: absolute;
  border-radius: 50%;
  mix-blend-mode: screen;
  opacity: 0.55;
  will-change: transform;
}

.aurora__ribbon--1 {
  width: 92vw; height: 52vh;
  left: 4vw; top: 14vh;
  background: radial-gradient(ellipse at 50% 50%, rgba(109, 93, 246, 0.42), rgba(109, 93, 246, 0.10) 44%, transparent 72%);
  transform: rotate(-13deg);
  animation: auroraOne 26s ease-in-out infinite alternate;
}

.aurora__ribbon--2 {
  width: 74vw; height: 42vh;
  left: 34vw; top: 26vh;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 122, 168, 0.30), rgba(255, 122, 168, 0.06) 44%, transparent 68%);
  transform: rotate(9deg);
  animation: auroraTwo 33s ease-in-out infinite alternate;
}

.aurora__ribbon--3 {
  width: 62vw; height: 34vh;
  left: 12vw; top: 42vh;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 217, 160, 0.16), transparent 68%);
  transform: rotate(-4deg);
  animation: auroraThree 29s ease-in-out infinite alternate;
}

body[data-scene="heart"] .aurora { opacity: 0.46; }
body[data-scene="question"] .aurora { opacity: 0.96; }
body[data-scene="dawn"] .aurora { opacity: 0; }

#sky-canvas,
#heart-canvas,
#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#sky-canvas {
  z-index: 0;
  opacity: 1;
  transition: opacity 2s ease;
}

body[data-scene="heart"] #sky-canvas { opacity: 0.82; }
body[data-scene="question"] #sky-canvas { opacity: 0.78; }
body[data-scene="dawn"] #sky-canvas { opacity: 0; }

#fx-canvas { z-index: 3; }

#heart-canvas {
  z-index: 3;
  opacity: 0;
  transition: opacity 1s ease;
}
#heart-canvas.is-live { opacity: 1; }

#dawn {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2.3s ease;
  background:
    radial-gradient(ellipse 70% 34% at 50% 104%, rgba(255, 236, 200, 0.95), rgba(255, 196, 140, 0.55) 40%, transparent 72%),
    radial-gradient(ellipse 54% 32% at 82% 78%, rgba(255, 154, 118, 0.55), transparent 68%),
    radial-gradient(ellipse 46% 30% at 16% 70%, rgba(255, 122, 168, 0.32), transparent 70%),
    linear-gradient(180deg, #1b0a2b 0%, #2a1030 16%, #4a1a44 34%, #7a2f57 53%, #c85a68 71%, #ff9a76 86%, #ffd9a0 100%);
}

body[data-scene="dawn"] #dawn { opacity: 1; }

.grain {
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  background-image: var(--noise);
  background-size: 170px 170px;
  opacity: 0.34;
  mix-blend-mode: soft-light;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 44%, transparent 44%, rgba(2, 3, 9, 0.55) 100%);
  opacity: 1;
  transition: opacity 2s ease;
}

body[data-scene="dawn"] .vignette { opacity: 0.55; }

.flash {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 54%, rgba(255, 255, 255, 0.95), rgba(255, 217, 160, 0.55) 22%, rgba(255, 122, 168, 0.18) 50%, transparent 74%);
  mix-blend-mode: screen;
}

/* --------------------------------------------------------------------------
   Loader
   -------------------------------------------------------------------------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 40%, #0b0d20 0%, #05060f 68%);
  transition: opacity 0.8s ease, visibility 0s 0.8s;
}

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

.loader__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(18px, 3vh, 26px);
  transform: translateY(-2vh);
}

.loader__star {
  position: relative;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  color: rgba(255, 217, 160, 0.85);
  font-size: 15px;
}

.loader__star span {
  animation: loaderStar 2.6s ease-in-out infinite;
  text-shadow: 0 0 18px rgba(255, 217, 160, 0.55);
}

.loader__star i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: #fff4e0;
  box-shadow: 0 0 7px rgba(255, 244, 224, 0.9);
  animation: loaderGather 2.6s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.loader__star i:nth-of-type(1) { --dx: -46px; --dy: -25px; animation-delay: 0s; }
.loader__star i:nth-of-type(2) { --dx: 39px; --dy: -35px; animation-delay: 0.22s; }
.loader__star i:nth-of-type(3) { --dx: -33px; --dy: 32px; animation-delay: 0.45s; }
.loader__star i:nth-of-type(4) { --dx: 48px; --dy: 16px; animation-delay: 0.68s; }
.loader__star i:nth-of-type(5) { --dx: -8px; --dy: 44px; animation-delay: 0.9s; }
.loader__star i:nth-of-type(6) { --dx: 12px; --dy: -48px; animation-delay: 1.1s; }

.loader__text {
  margin: 0;
  font-size: clamp(10px, 2.6vw, 11px);
  letter-spacing: 0.24em;
  padding-left: 0.24em;
  color: rgba(230, 220, 255, 0.5);
  white-space: nowrap;
}

.loader__line {
  width: 128px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 217, 160, 0.5), transparent);
  background-size: 200% 100%;
  animation: lineSweep 2.4s linear infinite;
  opacity: 0.7;
}

/* --------------------------------------------------------------------------
   Masthead, side rail, moon
   -------------------------------------------------------------------------- */

.masthead {
  position: fixed;
  z-index: 6;
  top: calc(env(safe-area-inset-top) + clamp(16px, 3.4vh, 34px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 18px);
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
  transition: opacity 1.6s ease;
}

.masthead__rule {
  width: clamp(18px, 4vw, 54px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 217, 160, 0.5));
}

.masthead__rule--rev { transform: rotate(180deg); }

.masthead__label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  white-space: nowrap;
}

.masthead__label .lat {
  font-family: var(--font-latin);
  font-size: clamp(9px, 1vw, 11px);
  letter-spacing: 0.38em;
  color: rgba(255, 217, 160, 0.72);
}

.masthead__label .mid {
  font-size: 9px;
  color: rgba(255, 217, 160, 0.45);
  transform: translateY(-1px);
}

.masthead__label .cn {
  font-size: clamp(9.5px, 1vw, 11px);
  letter-spacing: 0.32em;
  color: rgba(230, 220, 255, 0.56);
}

body[data-scene="dawn"] .masthead { opacity: 0; }

.side-rail {
  position: fixed;
  z-index: 6;
  left: 22px;
  bottom: 34px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-latin);
  font-size: 9px;
  letter-spacing: 0.4em;
  color: rgba(255, 217, 160, 0.2);
  pointer-events: none;
  transition: opacity 1.6s ease;
}

body[data-scene="dawn"] .side-rail { opacity: 0; }

.moon-wrap {
  position: fixed;
  z-index: 2;
  top: clamp(86px, 13vh, 148px);
  right: clamp(30px, 7.5vw, 132px);
  width: clamp(92px, 12vw, 168px);
  aspect-ratio: 1;
  pointer-events: none;
  animation: moonFloat 16s ease-in-out infinite;
  transition: opacity 2s ease, transform 2s ease;
}

body[data-scene="dawn"] .moon-wrap {
  opacity: 0;
  transform: translateY(-18px);
}

.moon {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 31%, #fffdf8 0%, #fff4e0 34%, #f7ddb9 62%, #e5c094 84%, #cfa77c 100%);
  box-shadow:
    0 0 26px rgba(255, 244, 224, 0.52),
    0 0 88px rgba(255, 217, 160, 0.26),
    0 0 190px rgba(255, 217, 160, 0.11);
}

.moon::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-image:
    radial-gradient(circle at 64% 36%, rgba(148, 108, 82, 0.20) 0 7%, transparent 8.5%),
    radial-gradient(circle at 46% 62%, rgba(148, 108, 82, 0.16) 0 10%, transparent 12%),
    radial-gradient(circle at 73% 68%, rgba(148, 108, 82, 0.13) 0 4.5%, transparent 6%),
    radial-gradient(circle at 29% 47%, rgba(148, 108, 82, 0.11) 0 4%, transparent 5.5%),
    radial-gradient(circle at 57% 21%, rgba(255, 255, 255, 0.4) 0 5%, transparent 7%);
  box-shadow:
    inset -16px -20px 38px rgba(102, 68, 62, 0.20),
    inset 12px 14px 28px rgba(255, 255, 255, 0.5);
}

.moon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 186%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(-19deg) scaleY(0.42);
  border: 1px solid rgba(255, 217, 160, 0.16);
  border-radius: 50%;
}

.moon-dot {
  position: absolute;
  width: 4px;
  height: 4px;
  left: 5%;
  top: 46%;
  border-radius: 50%;
  background: rgba(255, 230, 188, 0.8);
  box-shadow: 0 0 10px rgba(255, 217, 160, 0.7);
  animation: moonDot 5s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Scenes & shared type
   -------------------------------------------------------------------------- */

main { position: relative; z-index: 4; }

.scene {
  position: fixed;
  inset: 0;
  z-index: 4;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 20px, 0);
  transition:
    opacity 1s var(--ease-soft),
    transform 1.2s var(--ease-out),
    visibility 0s linear 1s;
}

.scene.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0);
  transition:
    opacity 1s var(--ease-soft),
    transform 1.2s var(--ease-out),
    visibility 0s linear 0s;
}

.chapter {
  position: absolute;
  z-index: 3;
  top: clamp(92px, 14vh, 136px);
  left: var(--pad-x);
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 217, 160, 0.62);
  font-size: 10px;
  letter-spacing: 0.28em;
}

.chapter__num {
  font-size: 13px;
  letter-spacing: 0.1em;
  color: rgba(255, 230, 190, 0.9);
}

.chapter__rule {
  width: clamp(20px, 3vw, 32px);
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 217, 160, 0.55), rgba(255, 217, 160, 0));
}

.chapter__name { padding-left: 0.1em; }

.eyebrow {
  margin: 0;
  font-family: var(--font-latin);
  font-size: clamp(9.5px, 0.9vw, 11px);
  font-weight: 400;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  text-transform: uppercase;
  color: rgba(255, 217, 160, 0.52);
  text-shadow: 0 1px 12px rgba(5, 6, 15, 0.55);
}

.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(255, 217, 160, 0.55);
  font-size: 8px;
  line-height: 1;
}

.ornament span {
  display: block;
  width: clamp(26px, 4vw, 54px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 217, 160, 0.46));
}

.ornament span:last-child {
  background: linear-gradient(270deg, transparent, rgba(255, 217, 160, 0.46));
}

.ornament i { font-style: normal; }
