/* ZingDisplay design animations — one vocabulary for the browser TV, the portal editor and the TV app
 * (lib/slides/canvas_anim.dart). An element's `anim` = { in, loop, delay, dur }:
 *   in   : fade | rise | drop | left | right | zoom | pop | flip | reveal | blur   (entrance, plays once per slide)
 *   loop : pulse | float | glow | shine | kenburns | blink | swing               (starts after the entrance)
 * Timing comes in as CSS variables --zb-d (delay, s) and --zb-t (duration, s). */

.zb-in {
  animation-duration: var(--zb-t, .8s);
  animation-delay: var(--zb-d, 0s);
  animation-timing-function: cubic-bezier(.22, 1, .36, 1);
  animation-fill-mode: both;
  will-change: transform, opacity;
}
.zb-in-fade   { animation-name: zbFade; }
.zb-in-rise   { animation-name: zbRise; }
.zb-in-drop   { animation-name: zbDrop; }
.zb-in-left   { animation-name: zbLeft; }
.zb-in-right  { animation-name: zbRight; }
.zb-in-zoom   { animation-name: zbZoom; }
.zb-in-pop    { animation-name: zbPop; animation-timing-function: cubic-bezier(.34, 1.56, .64, 1); }
.zb-in-flip   { animation-name: zbFlip; transform-origin: 50% 100%; }
.zb-in-reveal { animation-name: zbReveal; }
.zb-in-blur   { animation-name: zbBlur; }

@keyframes zbFade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes zbRise   { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes zbDrop   { from { opacity: 0; transform: translateY(-40px); } to { opacity: 1; transform: none; } }
@keyframes zbLeft   { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: none; } }
@keyframes zbRight  { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: none; } }
@keyframes zbZoom   { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
@keyframes zbPop    { 0% { opacity: 0; transform: scale(.3); } 70% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes zbFlip   { from { opacity: 0; transform: perspective(900px) rotateX(-75deg); } to { opacity: 1; transform: none; } }
@keyframes zbReveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes zbBlur   { from { opacity: 0; filter: blur(14px); transform: scale(1.08); } to { opacity: 1; filter: none; transform: none; } }

/* Loops run on an inner wrapper so they never fight the entrance transform. */
.zb-loop {
  width: 100%;
  height: 100%;
  animation-delay: calc(var(--zb-d, 0s) + var(--zb-t, .8s));
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}
.zb-loop-pulse    { animation-name: zbPulse; animation-duration: 1.8s; }
.zb-loop-float    { animation-name: zbFloat; animation-duration: 3.2s; }
.zb-loop-glow     { animation-name: zbGlow; animation-duration: 2.2s; }
.zb-loop-blink    { animation-name: zbBlink; animation-duration: 1.4s; }
.zb-loop-swing    { animation-name: zbSwing; animation-duration: 2.6s; transform-origin: 50% 0; }
.zb-loop-kenburns { overflow: hidden; }
.zb-loop-kenburns img, .zb-loop-kenburns video {
  animation: zbKen 14s ease-in-out infinite alternate;
  animation-delay: inherit;
}
.zb-loop-shine { position: relative; overflow: hidden; }
.zb-loop-shine::after {
  content: '';
  position: absolute;
  inset: -20% auto -20% -60%;
  width: 45%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: skewX(-18deg);
  animation: zbShine 3.4s ease-in-out infinite;
  animation-delay: inherit;
  pointer-events: none;
}

@keyframes zbPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes zbFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes zbGlow  { 0%, 100% { filter: drop-shadow(0 0 0 rgba(251, 191, 36, 0)); } 50% { filter: drop-shadow(0 0 18px rgba(251, 191, 36, .75)); } }
@keyframes zbBlink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes zbSwing { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes zbKen   { from { transform: scale(1); } to { transform: scale(1.14) translate(-2%, -2%); } }
@keyframes zbShine { 0% { left: -60%; } 55%, 100% { left: 130%; } }

/* A live refresh of the same slide (prices changed) must not replay the entrances. */
.zb-anim-skip .zb-in { animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  .zb-in, .zb-loop, .zb-loop *, .zb-loop::after { animation: none !important; }
}
