/* ═══════════════════════════════════════════════════════════════════════
   NOVA BURST · Personaje animado "Nova" (WebM VP9 con canal alfa)
   ───────────────────────────────────────────────────────────────────────
   El contenedor #nova-character se monta dentro de .game-shell (fuera del
   .slot-frame-container, que tiene overflow:hidden) y se posiciona en
   función de la geometría del marco oficial, que es siempre:
        ancho  = min(100vw, 150dvh)      (aspect-ratio 3:2, centrado)
        alto   = ancho · 2/3
   Así el personaje queda anclado al marco sin tocar el bundle del juego.

   Modos:
     · Escritorio / apaisado (por defecto): de pie a la izquierda del marco,
       sobre los cristales, junto al panel de apuesta.
     · Móvil vertical (aspect ≤ 1:1): encima del rodillo, ocupando el hueco
       libre que queda sobre el marco.
   Estados (data-state): idle · spin · win · bigwin
   ═══════════════════════════════════════════════════════════════════════ */

#nova-character {
  --nb-fw: min(100vw, 150vh);
  --nb-fh: calc(var(--nb-fw) * 2 / 3);
  --nb-fx: calc((100vw - var(--nb-fw)) / 2);
  --nb-fy: calc((100vh - var(--nb-fh)) / 2);

  position: absolute;
  z-index: 2;                       /* sobre el fondo, bajo overlays del marco (z 60/70 dentro del contenedor) */
  pointer-events: none;
  aspect-ratio: 540 / 600;

  /* Escritorio: izquierda del marco, de pie sobre los cristales */
  left: calc(var(--nb-fx) - var(--nb-fw) * 0.012);
  bottom: calc(var(--nb-fy) + var(--nb-fh) * 0.175);
  height: calc(var(--nb-fh) * 0.44);

  transform-origin: 50% 100%;
  opacity: 0;
  transition: opacity .6s ease;
  will-change: transform;
}

@supports (height: 100dvh) {
  #nova-character {
    --nb-fw: min(100vw, 150dvh);
    --nb-fy: calc((100dvh - var(--nb-fh)) / 2);
  }
}

#nova-character.nb-ready { opacity: 1; }

/* Sombra suave bajo los pies para que "pise" el suelo */
#nova-character::after {
  content: "";
  position: absolute;
  left: 18%; right: 18%; bottom: 1.5%;
  height: 7%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(5, 1, 15, .55) 0%, rgba(5, 1, 15, .25) 45%, transparent 72%);
  z-index: 0;
  filter: blur(2px);
}

/* Aura de energía: cambia de color según el estado */
#nova-character::before {
  content: "";
  position: absolute;
  inset: 6% 2% 2% 2%;
  border-radius: 50% 50% 46% 46% / 40% 40% 60% 60%;
  background: radial-gradient(ellipse at 50% 60%, var(--nb-aura, rgba(180, 92, 255, .26)) 0%, transparent 68%);
  z-index: 0;
  opacity: .85;
  transition: background .5s ease, opacity .5s ease, transform .5s ease;
  animation: nbAuraBreath 3.2s ease-in-out infinite;
}

@keyframes nbAuraBreath {
  0%, 100% { transform: scale(.96); opacity: .7; }
  50%      { transform: scale(1.04); opacity: .95; }
}

#nova-character[data-state="spin"]   { --nb-aura: rgba(125, 227, 255, .34); }
#nova-character[data-state="win"]    { --nb-aura: rgba(255, 215, 106, .34); }
#nova-character[data-state="bigwin"] { --nb-aura: rgba(255, 93, 242, .42); }
#nova-character[data-state="spin"]::before,
#nova-character[data-state="bigwin"]::before { animation-duration: 1.1s; }

/* Capas de vídeo: todas montadas y precargadas; sólo la activa es visible */
#nova-character video,
#nova-character img.nb-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  opacity: 0;
  transition: opacity .28s ease;
  z-index: 1;
  filter: drop-shadow(0 .6cqh 1.2cqh rgba(0, 0, 0, .45)) drop-shadow(0 0 1.4cqh rgba(180, 92, 255, .28));
  -webkit-user-select: none; user-select: none;
}
#nova-character video.nb-active,
#nova-character img.nb-poster.nb-active { opacity: 1; }

/* Pequeño rebote en los cambios a win / bigwin */
#nova-character.nb-pop { animation: nbPop .55s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes nbPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.07) translateY(-1.5%); }
  100% { transform: scale(1); }
}

/* Fallback sin soporte WebM-alfa (p. ej. Safari antiguo): póster con flotación */
#nova-character.nb-fallback img.nb-poster { animation: nbFloat 3.6s ease-in-out infinite; }
@keyframes nbFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2.5%); }
}

/* ── Móvil vertical: personaje sobre el rodillo ───────────────────────── */
@media (max-aspect-ratio: 1/1) {
  #nova-character {
    /* Hueco disponible encima del marco (menos un margen para el botón "Regresar") */
    --nb-gap-top: calc(var(--nb-fy) - 10px);
    left: 50%;
    bottom: auto;
    top: calc(var(--nb-fy) - var(--nb-h) + var(--nb-fh) * 0.012);
    --nb-h: min(calc(var(--nb-gap-top) - 34px), 64vw);
    height: var(--nb-h);
    transform: translateX(-50%);
    transform-origin: 50% 100%;
  }
  #nova-character.nb-pop { animation: nbPopMobile .55s cubic-bezier(.34, 1.56, .64, 1); }
  @keyframes nbPopMobile {
    0%   { transform: translateX(-50%) scale(1); }
    40%  { transform: translateX(-50%) scale(1.07) translateY(-1.5%); }
    100% { transform: translateX(-50%) scale(1); }
  }
  #nova-character.nb-fallback img.nb-poster { animation: nbFloat 3.6s ease-in-out infinite; }

  /* Si el hueco es demasiado pequeño (casi cuadrado), se oculta para no tapar el logo */
  @media (min-aspect-ratio: 5/6) {
    #nova-character { display: none; }
  }
}

@media (prefers-reduced-motion: reduce) {
  #nova-character::before,
  #nova-character.nb-pop,
  #nova-character.nb-fallback img.nb-poster { animation: none !important; }
}
