/* ============================================================
   Aam Mahua Pooja — the mango tree answers the couple's offering.
   aam.js builds every element here (none exist without JS or under
   reduced motion). Ambient life plays only while the slide is on
   screen (.aam-live): both diya flames flicker, incense smoke curls up
   from the bride's thali, and the water the groom pours glints. A tap
   (or the "Tap to rustle the mango tree" pill) rains leaves, mahua
   blossoms and marigolds from the canopies, drawn on .aam-shower, and
   sends a gold ripple out from the sacred thread on the trunk.
   Positions are % of the 1080 x 1920 stage, read off
   assets/aam-layers/10-aam-mahua.webp (left 0, top 33.33%, height 70.31%).
   Only transform / opacity animate.
   ============================================================ */

.aam-slide {
  position: relative;
  /* every tap showers; keep scroll + pinch, drop double-tap zoom */
  touch-action: manipulation;
}

/* Sits above the painting, below the event copy (DOM order). */
.aam-fx,
.aam-shower {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.aam-fx {
  overflow: hidden;
}

/* The Haldi pill sits at 5.5%, over the couple's offering here; drop it
   onto the rangoli instead. */
.aam-slide .aam-cta {
  bottom: 1.2%;
}

/* ---- Diya flames: a warm halo with an irregular flicker ---- */
.aam-glow {
  position: absolute;
  width: 6%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 226, 150, 0.95) 0%,
    rgba(255, 178, 80, 0.42) 34%,
    rgba(255, 150, 60, 0) 68%
  );
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
  transition: opacity 900ms ease;
}

.aam-glow--ground { left: 46%; top: 90.1%; }
.aam-glow--thali { left: 62.2%; top: 76.5%; width: 5%; }

.aam-live .aam-glow {
  opacity: 0.7;
  animation: aam-flicker 2.3s ease-in-out infinite;
}

.aam-live .aam-glow--thali {
  animation-duration: 1.9s;
  animation-delay: -0.7s;
}

@keyframes aam-flicker {
  0%, 100% { opacity: 0.68; transform: translate(-50%, -50%) scale(1); }
  13% { opacity: 0.95; transform: translate(-50%, -50%) scale(1.09); }
  27% { opacity: 0.58; transform: translate(-50%, -50%) scale(0.93); }
  41% { opacity: 0.86; transform: translate(-50%, -50%) scale(1.04); }
  58% { opacity: 0.66; transform: translate(-50%, -50%) scale(0.97); }
  74% { opacity: 0.93; transform: translate(-50%, -50%) scale(1.07); }
  88% { opacity: 0.72; transform: translate(-50%, -50%) scale(0.99); }
}

/* ---- Incense smoke from the thali: three wisps, staggered ---- */
.aam-smoke {
  position: absolute;
  left: 64.6%;
  top: 74.4%;
  width: 2.4%;
  aspect-ratio: 1 / 2.4;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at 50% 60%,
    rgba(130, 128, 140, 0.5) 0%,
    rgba(130, 128, 140, 0) 70%
  );
  opacity: 0;
  transform: translate(-50%, -50%);
}

.aam-live .aam-smoke {
  animation: aam-smoke 4.2s ease-out infinite;
}

.aam-live .aam-smoke:nth-child(2) { --dx: -1; animation-delay: 1.4s; }
.aam-live .aam-smoke:nth-child(3) { animation-delay: 2.8s; }

@keyframes aam-smoke {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6, 0.7);
  }
  18% { opacity: 0.85; }
  55% {
    transform: translate(calc(-50% + var(--u) * 0.9 * var(--dx, 1)), calc(-50% - var(--u) * 6)) scale(1.1, 1.4);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% - var(--u) * 0.7 * var(--dx, 1)), calc(-50% - var(--u) * 13)) scale(1.9, 2.1);
  }
}

/* ---- Glints along the water poured on the roots ---- */
.aam-glint {
  position: absolute;
  width: 2.6%;
  aspect-ratio: 1;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 1) 0 14%, rgba(220, 240, 255, 0) 34%),
    linear-gradient(90deg, transparent 44%, rgba(235, 246, 255, 0.95) 50%, transparent 56%),
    linear-gradient(0deg, transparent 44%, rgba(235, 246, 255, 0.95) 50%, transparent 56%);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.3);
}

.aam-glint:nth-child(1) { left: 41.2%; top: 84.6%; }
.aam-glint:nth-child(2) { left: 40.9%; top: 86.1%; }
.aam-glint:nth-child(3) { left: 40.7%; top: 87.5%; }

.aam-live .aam-glint {
  animation: aam-twinkle 1.8s ease-in-out infinite;
}

.aam-live .aam-glint:nth-child(2) { animation-delay: 0.6s; }
.aam-live .aam-glint:nth-child(3) { animation-delay: 1.2s; }

@keyframes aam-twinkle {
  0%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(0deg); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(45deg); }
}

/* ---- The tree's answer: a gold ripple from the sacred thread ---- */
.aam-ripple {
  position: absolute;
  left: 34.7%;
  top: 75%;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid rgba(236, 184, 84, 0.9);
  box-shadow:
    0 0 14px rgba(255, 210, 120, 0.55),
    inset 0 0 14px rgba(255, 210, 120, 0.4);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.12);
  animation: aam-ripple 1.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes aam-ripple {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.12); }
  14% { opacity: 0.9; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
}

@media (prefers-reduced-motion: reduce) {
  .aam-fx,
  .aam-shower,
  .aam-cta {
    display: none;
  }
}
