/**
 * Ascua – animaciones
 *
 * Solo se activan con la clase .ascua-anim en el <body> (Personalizar >
 * Página de inicio > Colores y animaciones) y nunca si el visitante pide
 * «reducir movimiento». Se animan transform y opacity (fluido en móvil).
 */

@media (prefers-reduced-motion: no-preference) {

  /* ---------- Barra de progreso de lectura ---------- */
  .ascua-anim .ascua-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--bx-amber), rgb(var(--bx-glow-rgb)));
    transform: scaleX(var(--ascua-progress, 0));
    transform-origin: 0 50%;
    pointer-events: none;
  }

  /* ---------- Cabecera: entra al cargar y se compacta al bajar ---------- */
  .ascua-anim .bx-header {
    animation: ascua-drop 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .ascua-anim .bx-main-inner {
    transition: min-height 0.35s ease;
  }

  .ascua-anim .bx-header.is-compact .bx-main-inner {
    min-height: 58px;
  }

  .ascua-anim .bx-header.is-compact {
    box-shadow: 0 10px 30px rgba(var(--bx-primary-rgb), 0.18) !important;
  }

  @keyframes ascua-drop {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: none; opacity: 1; }
  }

  /* ---------- Héroe: zoom lento y entrada escalonada del texto ---------- */
  .ascua-anim .bx-slide.is-active .bx-slide-img {
    animation: ascua-kenburns 9s ease-out both;
  }

  @keyframes ascua-kenburns {
    from { transform: scale(1.12) translate3d(1.5%, 1%, 0); }
    to { transform: scale(1) translate3d(0, 0, 0); }
  }

  .ascua-anim .bx-slide.is-active .bx-kicker,
  .ascua-anim .bx-slide.is-active .bx-slide-title,
  .ascua-anim .bx-slide.is-active .bx-slide-text,
  .ascua-anim .bx-slide.is-active .bx-btn {
    animation: ascua-rise 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .ascua-anim .bx-slide.is-active .bx-kicker { animation-delay: 0.15s; }
  .ascua-anim .bx-slide.is-active .bx-slide-title { animation-delay: 0.3s; }
  .ascua-anim .bx-slide.is-active .bx-slide-text { animation-delay: 0.45s; }
  .ascua-anim .bx-slide.is-active .bx-btn { animation-delay: 0.6s; }

  /* La palabra destacada «se enciende» */
  .ascua-anim .bx-slide.is-active .bx-slide-title .ascua-em {
    display: inline-block;
    background: linear-gradient(90deg, var(--bx-amber) 0%, rgb(var(--bx-glow-rgb)) 50%, var(--bx-amber) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: ascua-glow 3.5s ease-in-out 1s infinite;
  }

  @keyframes ascua-glow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
  }

  @keyframes ascua-rise {
    from { transform: translate3d(0, 26px, 0); opacity: 0; }
    to { transform: none; opacity: 1; }
  }

  /* Bloque lateral: entra desde la derecha */
  .ascua-anim .bx-side {
    animation: ascua-slide-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.35s both;
  }

  @keyframes ascua-slide-in {
    from { transform: translate3d(40px, 0, 0); opacity: 0; }
    to { transform: none; opacity: 1; }
  }

  /* Brasas que suben en el héroe (canvas creado por anim.js) */
  .ascua-embers {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    pointer-events: none;
    mix-blend-mode: screen;
  }

  .bx-slide-copy {
    z-index: 2;
  }

  /* Puntos del slider: barra de progreso dentro del punto activo */
  .ascua-anim .bx-dot {
    position: relative;
    overflow: hidden;
  }

  .ascua-anim .bx-dot.is-active {
    background: rgba(255, 255, 255, 0.35);
  }

  .ascua-anim .bx-dot.is-active::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--bx-amber);
    transform-origin: 0 50%;
    animation: ascua-dot var(--ascua-interval, 6s) linear both;
  }

  .ascua-anim .bx-slider:hover .bx-dot.is-active::after,
  .ascua-anim .bx-slider:focus-within .bx-dot.is-active::after {
    animation-play-state: paused;
  }

  @keyframes ascua-dot {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
  }

  /* ---------- Aparición al desplazarse ---------- */
  .ascua-anim .ascua-reveal {
    opacity: 0;
    transform: translate3d(0, 34px, 0);
    transition:
      opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--ascua-delay, 0s);
    will-change: opacity, transform;
  }

  .ascua-anim .ascua-reveal--left {
    transform: translate3d(-34px, 0, 0);
  }

  .ascua-anim .ascua-reveal--zoom {
    transform: scale(0.94);
  }

  .ascua-anim .ascua-reveal.is-visible {
    opacity: 1;
    transform: none;
  }

  /* ---------- Cartas de producto ---------- */
  .ascua-anim .bx-card__add {
    position: relative;
    overflow: hidden;
  }

  .ascua-anim .bx-card__add::before {
    content: "";
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
  }

  .ascua-anim .bx-card:hover .bx-card__add::before {
    left: 130%;
  }

  .ascua-anim .bx-card__add.added svg {
    animation: ascua-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  /* Carrito de la cabecera: rebote al añadir */
  .ascua-anim .bx-cart.is-bumped {
    animation: ascua-bump 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .ascua-anim .bx-cart.is-bumped .cart-count-badge {
    animation: ascua-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes ascua-bump {
    0% { transform: scale(1); }
    30% { transform: scale(1.25) rotate(-8deg); }
    60% { transform: scale(0.95) rotate(4deg); }
    100% { transform: scale(1); }
  }

  @keyframes ascua-pop {
    0% { transform: scale(0.4); }
    60% { transform: scale(1.35); }
    100% { transform: scale(1); }
  }

  /* Chispa que vuela del botón al carrito */
  .ascua-fly {
    position: fixed;
    z-index: 3000;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    background: radial-gradient(circle, #FFF 0%, rgb(var(--bx-glow-rgb)) 45%, var(--bx-amber) 100%);
    box-shadow: 0 0 18px 6px rgba(var(--bx-glow-rgb), 0.6);
    pointer-events: none;
  }

  /* ---------- Iconos ---------- */
  .ascua-anim .bx-shelf-icon svg,
  .ascua-anim .bx-guide-facts dt svg {
    transform-origin: 50% 90%;
    animation: ascua-flicker 2.6s ease-in-out infinite;
  }

  @keyframes ascua-flicker {
    0%, 100% { transform: scale(1) rotate(0deg); }
    20% { transform: scale(1.06, 0.96) rotate(-3deg); }
    40% { transform: scale(0.97, 1.05) rotate(2deg); }
    60% { transform: scale(1.04, 0.98) rotate(-1deg); }
    80% { transform: scale(0.99, 1.03) rotate(2deg); }
  }

  .ascua-anim .bx-usps-list li {
    transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
  }

  .ascua-anim .bx-usps-list li:hover {
    transform: translateY(-4px);
    border-color: var(--bx-amber);
    box-shadow: 0 14px 30px rgba(var(--bx-primary-rgb), 0.1);
  }

  .ascua-anim .bx-usps-list li:hover .bx-usp-icon {
    animation: ascua-wiggle 0.6s ease;
  }

  @keyframes ascua-wiggle {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-10deg) scale(1.08); }
    60% { transform: rotate(8deg) scale(1.08); }
  }

  /* ---------- Selector de combustible: cambio de panel ---------- */
  .ascua-anim .nd-selector-body.is-enhanced .nd-selector-panel:not([hidden]) {
    animation: ascua-panel 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .ascua-anim .nd-selector-body.is-enhanced .nd-selector-panel:not([hidden]) .nd-selector-fuels li {
    animation: ascua-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .ascua-anim .nd-selector-panel .nd-selector-fuels li:nth-child(2) {
    animation-delay: 0.08s !important;
  }

  .ascua-anim .nd-selector-panel .nd-selector-fuels li:nth-child(3) {
    animation-delay: 0.16s !important;
  }

  @keyframes ascua-panel {
    from { transform: translate3d(18px, 0, 0); opacity: 0; }
    to { transform: none; opacity: 1; }
  }

  /* ---------- Bloque de presupuesto: degradado vivo ---------- */
  .ascua-anim .bx-offer-inner {
    background-size: 200% 200%;
    animation: ascua-shift 10s ease-in-out infinite;
  }

  @keyframes ascua-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
  }

  /* ---------- Botones: pequeño relieve ---------- */
  .ascua-anim .bx-btn,
  .ascua-anim .bx-more,
  .ascua-anim .nd-selector-fuels a {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  }

  .ascua-anim .bx-btn:hover,
  .ascua-anim .nd-selector-fuels a:hover {
    transform: translateY(-2px) scale(1.02);
  }

  .ascua-anim .bx-more:hover svg {
    animation: ascua-nudge 0.6s ease;
  }

  @keyframes ascua-nudge {
    50% { transform: translateX(4px); }
  }

  /* ---------- Bolha de WhatsApp: latido suave ---------- */
  .ascua-anim .ascua-wa-bubble::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: 50%;
    background: #25D366;
    animation: ascua-pulse 2.6s ease-out infinite;
  }

  @keyframes ascua-pulse {
    0% { transform: scale(1); opacity: 0.45; }
    70%, 100% { transform: scale(1.6); opacity: 0; }
  }
}

/* Con «reducir movimiento», todo visible desde el principio */
@media (prefers-reduced-motion: reduce) {
  .ascua-reveal {
    opacity: 1 !important;
    transform: none !important;
  }
  .ascua-embers,
  .ascua-progress {
    display: none !important;
  }
}
