/* Non-modal foreground lyric performance. H owns the canvas departure and return; this layer only
   raises the close-up and talkbox from below while the site navigation remains available. */

.lyric-performance[hidden] { display: none; }

.lyric-performance {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--rounded);
  isolation: isolate;
  pointer-events: none;
}

.lyric-performance__sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.lyric-performance__flyer {
  position: fixed;
  left: var(--figure-x, 50vw);
  top: var(--figure-y, 55vh);
  z-index: 3;
  width: var(--figure-w, 120px);
  height: var(--figure-h, 220px);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(var(--flight-x, 0), var(--bottom-y, 100vh), 0)
             scale(var(--flight-scale, 4));
  transform-origin: 50% 50%;
}

.lyric-performance.is-entering .lyric-performance__flyer,
.lyric-performance.is-exiting .lyric-performance__flyer {
  opacity: 1;
  will-change: transform;
}

.lyric-performance.is-singing .lyric-performance__flyer {
  opacity: 1;
  transform: translate3d(var(--flight-x, 0), var(--flight-y, 50vh), 0)
             scale(var(--flight-scale, 4));
}

.lyric-performance__flyer img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 50% 88%;
}

.lyric-performance.is-singing .lyric-performance__flyer img,
.lyric-performance.is-exiting .lyric-performance__flyer img {
  animation: lyric-body-sway 2800ms cubic-bezier(.45, 0, .55, 1) infinite;
  will-change: transform;
}

@keyframes lyric-body-sway {
  0%, 50%, 100% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  25% { transform: translate3d(-3.1%, -1.15%, 0) rotate(-2.65deg) scale(1.012, .993); }
  75% { transform: translate3d(3.1%, -1.15%, 0) rotate(2.65deg) scale(1.012, .993); }
}

.lyric-performance__card {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 max(28px, var(--gutter))
           calc(100vh - var(--performance-head-y, 53vh) + 21px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 190ms ease-out;
}

.lyric-performance.is-entering .lyric-performance__card,
.lyric-performance.is-singing .lyric-performance__card { opacity: 1; }

.lyric-performance.is-exiting .lyric-performance__card {
  opacity: 0;
  transition-duration: 180ms;
}

.lyric-performance__content {
  width: min(1120px, calc(100vw - 24px));
  padding: 0;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, -8px, 0);
  transition:
    opacity 190ms ease-out,
    transform 360ms cubic-bezier(.2, .82, .2, 1);
}

.lyric-performance.is-entering .lyric-performance__content,
.lyric-performance.is-singing .lyric-performance__content {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.lyric-performance__line {
  position: relative;
  isolation: isolate;
  display: grid;
  width: fit-content;
  min-width: min(320px, 100%);
  max-width: 100%;
  min-height: 0;
  place-items: center;
  margin: 0 auto;
  padding: clamp(13px, 1.7vh, 17px) clamp(26px, 3vw, 38px)
           clamp(14px, 1.8vh, 18px);
  box-sizing: border-box;
  border: 1px solid rgba(22, 24, 28, .16);
  border-radius: clamp(24px, 3vw, 34px);
  background: #fff;
  box-shadow: 0 2px 4px rgba(30, 40, 60, .22);
  font-size: clamp(25px, 2.8vw, 38px);
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -.018em;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
  row-gap: 0;
  opacity: 0;
  transform: scale(.86);
  transform-origin: 50% calc(100% + 15px);
  transition:
    opacity 150ms ease-out,
    transform 360ms cubic-bezier(.2, 1.18, .3, 1);
}

.lyric-performance__line::before,
.lyric-performance__line::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  pointer-events: none;
}

/* Two nested triangles make one outlined tail. Its tip is also the scale origin, matching the
   canvas HELP balloon: the talkbox grows out of the figure instead of swelling in empty space. */
.lyric-performance__line::before {
  bottom: -15px;
  border-right: 9px solid transparent;
  border-left: 5px solid transparent;
  border-top: 15px solid rgba(22, 24, 28, .16);
  filter: drop-shadow(0 2px 2px rgba(30, 40, 60, .16));
}

.lyric-performance__line::after {
  bottom: -13px;
  border-right: 8px solid transparent;
  border-left: 4px solid transparent;
  border-top: 14px solid #fff;
}

.lyric-performance.is-entering .lyric-performance__line,
.lyric-performance.is-singing .lyric-performance__line {
  opacity: 1;
  transform: scale(1);
}

.lyric-performance.is-exiting .lyric-performance__line {
  opacity: 0;
  transform: scale(.94);
  transition-duration: 140ms;
}

.lyric-performance__line-copy,
.lyric-performance__line-fill {
  display: block;
  justify-self: center;
  width: fit-content;
  max-width: none;
  text-align: center;
  white-space: nowrap;
  transform: scaleX(var(--guide-scale-x, 1));
  transform-origin: 50% 50%;
  transition: opacity 180ms ease;
}

.lyric-performance__line-copy,
.lyric-performance__line-fill { grid-area: 1 / 1; }

.lyric-performance__line.has-phonetic .lyric-performance__line-copy,
.lyric-performance__line.has-phonetic .lyric-performance__line-fill {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  direction: ltr;
  line-height: 1;
  letter-spacing: 0;
}

/* Each sing-along cue is physically attached to its Han glyph. One shared grid column keeps
   both centers identical regardless of how wide the English-friendly spelling becomes. */
.lyric-performance__guide {
  display: inline-grid;
  flex: 0 0 auto;
  grid-template-columns: 100%;
  grid-template-rows: auto auto;
  justify-items: center;
  align-items: start;
  width: max(1.22em, 37px);
  min-width: 0;
  margin: 0;
  ruby-align: center;
  ruby-position: under;
  -webkit-ruby-position: after;
}

.lyric-performance__guide-glyph {
  display: block;
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
  width: 1em;
  line-height: 1.08;
  text-align: center;
}

.lyric-performance__guide rt {
  display: block;
  grid-column: 1;
  grid-row: 2;
  justify-self: center;
  width: max-content;
  margin-top: clamp(3px, .45vh, 5px);
  color: rgba(17, 60, 159, .86);
  font-size: var(--guide-reading-size, clamp(9px, .72vw, 10.5px));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
}

.lyric-performance__guide-space {
  flex: 0 0 .42em;
  overflow: hidden;
}

.lyric-performance__guide-punctuation {
  flex: 0 0 auto;
  align-self: flex-start;
  line-height: 1.08;
}

.lyric-performance__line-copy { color: rgba(22, 24, 28, .55); }

.lyric-performance__line-fill {
  color: var(--ink);
  pointer-events: none;
  clip-path: inset(0 100% 0 0);
  will-change: clip-path;
}

.lyric-performance__line-fill .lyric-performance__guide rt { color: var(--blue-deep); }

.lyric-performance__line:dir(rtl) .lyric-performance__line-fill {
  clip-path: inset(0 0 0 100%);
}

.lyric-performance__line.is-changing .lyric-performance__line-copy,
.lyric-performance__line.is-changing .lyric-performance__line-fill { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .lyric-performance__card,
  .lyric-performance__content,
  .lyric-performance__line,
  .lyric-performance__flyer { transition: none; }

  .lyric-performance__line { transform: none; }

  .lyric-performance__line-copy,
  .lyric-performance__line-fill { transition-duration: 120ms; }

  .lyric-performance.is-entering .lyric-performance__flyer,
  .lyric-performance.is-singing .lyric-performance__flyer {
    opacity: 1;
    transform: translate3d(var(--flight-x, 0), var(--flight-y, 50vh), 0)
               scale(var(--flight-scale, 4));
  }

  .lyric-performance.is-exiting .lyric-performance__flyer { opacity: 0; }

  .lyric-performance.is-singing .lyric-performance__flyer img,
  .lyric-performance.is-exiting .lyric-performance__flyer img {
    animation: none;
    will-change: auto;
  }

  .lyric-performance__line.is-karaoke .lyric-performance__line-fill {
    clip-path: inset(0);
  }

}

@media (prefers-contrast: more) {
  .lyric-performance__line { border-color: var(--ink); }
  .lyric-performance__line-copy { color: var(--ink); }
  .lyric-performance__guide rt { color: var(--blue-deep); }
}
