/* =====================================================================
   El Tablero · banners.css · Animated promo + join banners (TAB-0028)
   Spec: docs/design/promo-banners.md · built on motion system v1 (motion.css).
   - The art (src/components/BannerArt.astro) is decorative: aria-hidden,
     alt="", house art from public/icons/optimized. Every word, number,
     CTA, 18+ and RG line stays live CMS HTML, above the art (z-index).
   - The art is absolutely positioned in a fixed box: zero layout shift.
     It only shows when its container has room beside the text
     (container queries on the content box), so it never sits under copy.
   - Motion: transform/opacity only, behind prefers-reduced-motion:
     no-preference, and only once motion.js adds .bn-play (in view).
     2 loops of 2.4 s = 4.8 s, then it rests on frame 0 (WCAG 2.2.2:
     stops by itself within 5 s, so no pause control is needed).
     No JS, reduced motion or print = the still frame (frame 0).
   - No pulse on the CTA (product veto), no glow, no confetti/coin rain.
   ===================================================================== */

:root {
  --bn-loop: 2400ms;      /* one loop */
  --bn-loops: 2;          /* then rest on frame 0 */
}

.bn-host { position: relative; }
.bn-host > :not(.bn-art) { position: relative; z-index: 1; }
.tile--promo.bn-host, .fomo__tile.bn-host, .join__copy { container-type: inline-size; }
.join__copy { position: relative; }
.join__copy > :not(.bn-art) { position: relative; z-index: 1; }

.bn-art { position: absolute; z-index: 0; display: none; pointer-events: none; user-select: none; }
.bn-art__obj { position: absolute; display: block; }
.bn-art__obj img { display: block; width: 100%; height: 100%; }
/* light sweep: a soft band clipped to the object's own silhouette by a mask */
.bn-art__sweep {
  position: absolute; inset: 0; overflow: hidden; opacity: 0;
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.bn-art__sweep::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255,255,255,.25) 50%, transparent 62%);
  transform: translateX(-100%);
}
.bn-art--bono .bn-art__sweep { -webkit-mask-image: url(icons/optimized/bono-208.webp); mask-image: url(icons/optimized/bono-208.webp); }
.bn-art--segob .bn-art__sweep { -webkit-mask-image: url(icons/optimized/segob-208.webp); mask-image: url(icons/optimized/segob-208.webp); }

/* --- placement 1 · aside promo tile (.tile--promo, ~380 px wide) -------
   Top-right corner, beside the label and countdown, above the copy. */
.bn-art--promo { top: 6px; right: 10px; width: 80px; height: 80px; }
.bn-art--promo .bn-art__obj { inset: 0; }
@container (min-width: 330px) { .bn-art--promo { display: block; } }

/* --- placement 2 · home hero promo (.fomo__tile in the fomo strip) ---- */
.bn-art--fomo { top: 6px; right: 14px; width: 64px; height: 64px; }   /* ends above the copy line */
.bn-art--fomo .bn-art__obj { inset: 0; }
@container (min-width: 360px) { .bn-art--fomo { display: block; } }

/* --- placement 3 · join band (left copy column, bottom right) --------
   The paragraph is capped at 46ch and the CTA row is ~460 px, so the
   art sits in the free space to their right; the H2 is above it. */
.bn-art--join { right: 0; bottom: 0; width: 150px; height: 150px; }
.bn-art--join .bn-art__obj--main { inset: 0; }
.bn-art--join .bn-art__obj--side { left: -38px; top: -10px; width: 64px; height: 64px; }
@container (min-width: 650px) { .bn-art--join { display: block; } }

@media (prefers-reduced-motion: no-preference) {
  /* Motion v2 (TAB-0117, V17): hidden until 40% in view (motion.js .bn-wait), then the art pops in with a spring,
     floats/tilts with one light sweep (no sparkles: design review D9). Still 2 loops (4.8 s), then rest.
     Hovering the tile replays the loop (user-initiated). The CTA, text and 18+ never move. */
  .bn-art { transform-origin: 70% 60%; }
  .bn-wait { opacity: 0; transform: scale(.85); }
  .bn-in { animation: bn-pop 600ms var(--ease-out) both; }
  .bn-play .bn-art__obj {
    animation: bn-float var(--bn-loop) var(--ease-out) var(--bn-loops) both;
  }
  .bn-play .bn-art__obj--side { animation-name: bn-float-side; animation-delay: 200ms; }
  .bn-play .bn-art__sweep { animation: bn-sweep-show var(--bn-loop) linear var(--bn-loops) both; }
  .bn-play .bn-art__sweep::before { animation: bn-sweep var(--bn-loop) var(--ease-out) var(--bn-loops) both; }
  .bn-play .bn-art__obj--side .bn-art__sweep,
  .bn-play .bn-art__obj--side .bn-art__sweep::before { animation-delay: 200ms; }
}

/* float + tilt: starts and ends on frame 0 (the still), so the seam and the rest are invisible */
@keyframes bn-float {
  0%   { transform: translateY(0) rotate(0deg); }
  30%  { transform: translateY(-8px) rotate(-5deg) scale(1.04); }
  70%  { transform: translateY(-3px) rotate(3deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
@keyframes bn-float-side {
  0%   { transform: translateY(0) rotate(0deg); }
  40%  { transform: translateY(3px) rotate(3deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
/* one soft pass per loop, around 1.1–1.8 s */
@keyframes bn-sweep-show { 0%, 44% { opacity: 0; } 48%, 72% { opacity: 1; } 76%, 100% { opacity: 0; } }
@keyframes bn-sweep { 0%, 44% { transform: translateX(-100%); } 76%, 100% { transform: translateX(100%); } }

@keyframes bn-pop { 0% { opacity: 0; transform: scale(.85); } 100% { opacity: 1; transform: none; } }

/* --- TAB-0136 · Ludo.ai loops (public/anim, docs/design/ludo-assets.md) -------------
   The loop carries its own motion, so these objects skip the CSS float and sweep (they keep the pop-in).
   The same goes for the deck / category / game-sheet art: no CSS bob on top of a loop.
   motion.js swaps the loop in (in view) and the still back (after 2 loops, off-screen or tab hidden). */
@media (prefers-reduced-motion: no-preference) {
  .bn-play .bn-art__obj.bn-art__obj--ludo { animation: none; }
  .mo-deal .card__art .ill3d.ill3d--anim, .cat-hero .card__art .ill3d.ill3d--anim, .ficha__card .card__art .ill3d.ill3d--anim { animation: none; }
}

@media print { .bn-art { display: none !important; } }
@media print, (prefers-reduced-motion: reduce) { .bn-wait { opacity: 1 !important; transform: none !important; } }
