/* ============================================================
   好了歌 · 前半首 — 石牌坊之前的开场
   ============================================================ */

.opening {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  overflow: hidden;
  /* Opaque: the intro/mirror sits behind this prelude and must not
     show through as a black oval around the poem. */
  background:
    radial-gradient(ellipse at 50% 42%, #1e293b 0%, #0a1018 68%),
    #0a1018;
  color: var(--yuebai);
  cursor: pointer;
  opacity: 1;
  visibility: visible;
  transition:
    opacity 820ms var(--ease),
    visibility 0ms linear 0ms;
}

.opening[hidden] {
  display: none;
}

.opening.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 820ms var(--ease),
    visibility 0ms linear 820ms;
}

.opening::before {
  content: "";
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(ellipse 42vw 18vh at 32% 30%, rgba(226, 232, 240, 0.06), transparent 70%),
    radial-gradient(ellipse 48vw 20vh at 68% 64%, rgba(91, 127, 122, 0.1), transparent 72%);
  filter: blur(18px);
  opacity: 0.8;
  animation: opening-fog 24s ease-in-out infinite alternate;
  pointer-events: none;
}

.opening__veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 52%, transparent 20%, rgba(4, 8, 12, 0.46) 78%);
  pointer-events: none;
}

.opening__inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.4vh;
  max-width: 92vw;
  padding: 5vh 3vw;
  pointer-events: none;
}

.opening__head {
  text-align: center;
  opacity: 0;
}

.opening__kicker {
  display: block;
  color: rgba(198, 161, 91, 0.62);
  font-size: clamp(9px, 1.05vh, 12px);
  letter-spacing: 0.4em;
  text-indent: 0.4em;
}

.opening__title {
  display: block;
  margin-top: 0.8vh;
  color: rgba(242, 244, 244, 0.94);
  font-size: clamp(28px, 4.2vh, 48px);
  font-weight: 400;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  text-shadow:
    0 0 3vh rgba(198, 161, 91, 0.14),
    0 0 1vh rgba(226, 232, 240, 0.16);
}

.opening__part {
  display: block;
  margin-top: 0.5vh;
  color: rgba(226, 232, 240, 0.4);
  font-size: clamp(9px, 1vh, 11px);
  letter-spacing: 0.36em;
  text-indent: 0.36em;
}

.opening__poem {
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(6px, 1.1vw, 18px);
  max-width: 86vw;
  max-height: 62vh;
}

.opening__line {
  margin: 0;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  color: rgba(226, 232, 240, 0.82);
  font-size: clamp(11px, 1.55vh, 17px);
  letter-spacing: 0.16em;
  line-height: 1.7;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(1.4vh);
  filter: blur(2px);
  text-shadow: 0 0 1.2vh rgba(0, 0, 0, 0.6);
}

.opening.is-playing .opening__head {
  animation: opening-head 1100ms var(--ease) both 180ms;
}

.opening.is-playing .opening__line {
  animation: opening-line 980ms var(--ease) both;
  animation-delay: calc(var(--i) * 420ms + 460ms);
}

.opening__source {
  margin: 0;
  color: rgba(226, 232, 240, 0.3);
  font-size: clamp(8px, 0.95vh, 10px);
  letter-spacing: 0.16em;
  opacity: 0;
}

.opening.is-static .opening__head,
.opening.is-static .opening__line,
.opening.is-static .opening__source,
.opening.is-static .opening__skip,
.opening.is-static .opening__hint {
  opacity: 1;
  transform: none;
  filter: none;
  animation: none;
}

.opening.is-playing .opening__source,
.opening.is-playing .opening__hint {
  animation: opening-fade 1000ms ease both 3.7s;
}

.opening__skip {
  position: absolute;
  right: 3vw;
  bottom: 3vh;
  z-index: 4;
  padding: 0.7vh 1vw;
  border: 1px solid rgba(198, 161, 91, 0.28);
  background: rgba(10, 14, 20, 0.36);
  color: rgba(226, 232, 240, 0.58);
  font-size: clamp(9px, 1.05vh, 12px);
  letter-spacing: 0.18em;
  cursor: pointer;
  opacity: 0.62;
  transition:
    color 240ms ease,
    border-color 240ms ease,
    background 240ms ease;
}

.opening__skip:hover,
.opening__skip:focus-visible {
  color: #f3d693;
  border-color: rgba(198, 161, 91, 0.6);
  background: rgba(10, 14, 20, 0.56);
}

.opening__hint {
  position: absolute;
  left: 50%;
  bottom: 2.4vh;
  z-index: 3;
  transform: translateX(-50%);
  margin: 0;
  color: rgba(226, 232, 240, 0.22);
  font-size: clamp(8px, 0.95vh, 10px);
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

@keyframes opening-line {
  from {
    opacity: 0;
    transform: translateY(1.4vh);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@keyframes opening-head {
  from {
    opacity: 0;
    transform: translateY(-1vh);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes opening-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes opening-fog {
  from {
    transform: translate3d(-2vw, 0, 0) scale(1.02);
  }
  to {
    transform: translate3d(3vw, -1vh, 0) scale(1.08);
  }
}

@media (max-width: 767px) {
  .opening__inner {
    gap: 1.8vh;
    padding: 4.4vh 4vw;
  }

  .opening__poem {
    gap: 5px;
    max-height: 58vh;
  }

  .opening__line {
    font-size: 11px;
    letter-spacing: 0.1em;
    line-height: 1.65;
  }

  .opening__skip {
    right: 4vw;
    bottom: 2.2vh;
  }

  .opening__hint {
    bottom: 6.2vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .opening::before,
  .opening.is-playing .opening__head,
  .opening.is-playing .opening__line,
  .opening.is-playing .opening__source,
  .opening.is-playing .opening__skip,
  .opening.is-playing .opening__hint {
    animation: none !important;
  }
}
