/* ==========================================================================
   ANIMATIONS — Top Layer (<dialog>) & Scroll-Driven Entry Animations
   Cumple modern-web-guidance: animate-to-from-top-layer & scroll-entry-exit-effects
   ========================================================================== */

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* --------------------------------------------------------------------------
   1. TOP-LAYER DIALOG ANIMATIONS (@starting-style + allow-discrete + overlay)
   Incluye soporte para fallback data-closing en Firefox/Safari
   -------------------------------------------------------------------------- */
.portal-dialog {
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.28s;
  transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  transition-behavior: allow-discrete;
}

.portal-dialog::backdrop {
  background-color: rgb(0 0 0 / 0);
  backdrop-filter: blur(0px);
  transition-property: background-color, backdrop-filter, display, overlay;
  transition-duration: 0.28s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

:is(.portal-dialog[open]):where(:not([data-closing])) {
  opacity: 1;
  transform: translateY(0) scale(1);

  @starting-style {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }

  &::backdrop {
    background-color: rgb(5 6 8 / 0.78);
    backdrop-filter: blur(8px);

    @starting-style {
      background-color: rgb(5 6 8 / 0);
      backdrop-filter: blur(0px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-dialog {
    transform: none;
    transition-duration: 0.1s;
  }

  @starting-style {
    .portal-dialog[open] {
      transform: none;
    }
  }

  .pulse-dot {
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   2. SCROLL-DRIVEN REVEAL ANIMATIONS (CSS View Timeline + Fallback IO)
   -------------------------------------------------------------------------- */
@keyframes uniko-reveal-in {
  from {
    opacity: 0;
    transform: translateY(26px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    .reveal-on-scroll {
      animation: uniko-reveal-in auto ease-out backwards;
      animation-timeline: view(block);
      animation-range: entry 0% cover 26%;
    }
  }

  /* Clases usadas solo por el fallback IntersectionObserver en navegadores sin view() */
  .reveal-io-pending {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .reveal-io-visible {
    opacity: 1;
    transform: translateY(0);
  }
}
