/* =============================================================
   MOTAMORPHOSE — animations et effets
   ============================================================= */

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px) scale(0.995); }
  to { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(10px) scale(0.97); }
}

@keyframes row-in {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: none; }
}

@keyframes tile-pop {
  0% { transform: scale(0.82); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes tile-flip {
  0% { transform: rotateX(-90deg) scale(0.9); }
  55% { transform: rotateX(12deg) scale(1.04); }
  100% { transform: rotateX(0) scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-7px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-5px); }
  60% { transform: translateX(4px); }
  80% { transform: translateX(-2px); }
}

@keyframes caret-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(20, 224, 200, 0.28), 0 0 18px rgba(20, 224, 200, 0.22); }
  50% { box-shadow: 0 0 0 3px rgba(20, 224, 200, 0.5), 0 0 30px rgba(20, 224, 200, 0.38); }
}

@keyframes letter-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  40% { transform: translateY(-5px) rotate(-1.6deg); }
  70% { transform: translateY(-2px) rotate(1.2deg); }
}

@keyframes logo-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 18px 50px rgba(90, 60, 220, 0.45); }
  50% { transform: scale(1.06); box-shadow: 0 22px 64px rgba(90, 60, 220, 0.65); }
}

@keyframes blob-drift-1 {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(8vmax, 6vmax, 0) scale(1.15); }
}

@keyframes blob-drift-2 {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to { transform: translate3d(-7vmax, -5vmax, 0) scale(0.92); }
}

@keyframes blob-drift-3 {
  from { transform: translate3d(0, 0, 0) scale(0.95); }
  to { transform: translate3d(-5vmax, 7vmax, 0) scale(1.1); }
}

@keyframes star-pop {
  0% { transform: scale(0.4) rotate(-25deg); opacity: 0; }
  60% { transform: scale(1.18) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes countdown-pop {
  0% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulse-soft {
  0%, 100% { box-shadow: 0 0 0 1px rgba(20, 224, 200, 0.3), 0 10px 24px rgba(20, 224, 200, 0.16); }
  50% { box-shadow: 0 0 0 2px rgba(20, 224, 200, 0.55), 0 14px 34px rgba(20, 224, 200, 0.32); }
}

@keyframes glow-sweep {
  from { background-position: -140% 0; }
  to { background-position: 240% 0; }
}

/* Effet « réussite » sur les tuiles du dernier mot */
.chain-row--win .tile {
  animation: tile-win 760ms var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}

@keyframes tile-win {
  0% { transform: scale(1) rotate(0); }
  35% { transform: scale(1.16) rotate(-4deg); background: linear-gradient(160deg, #ffd93d, #ff8a3d); }
  70% { transform: scale(1.05) rotate(3deg); }
  100% { transform: scale(1) rotate(0); }
}

/* Halo de victoire */
.result__card::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(120deg, rgba(255, 77, 157, 0.9), rgba(43, 108, 255, 0.9), rgba(20, 224, 200, 0.9));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.75;
  animation: glow-sweep 6s linear infinite;
  background-size: 200% 100%;
  pointer-events: none;
}

/* Particules de validation (générées en JS) */
.particle {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 70;
  will-change: transform, opacity;
}

/* Respect des préférences d'accessibilité : neutralise les boucles */
@media (prefers-reduced-motion: reduce) {
  .logo__letter,
  .blob,
  .result__card::before,
  .level-card--next,
  .loading__logo {
    animation: none !important;
  }
}

[data-reduced-motion="true"] .logo__letter,
[data-reduced-motion="true"] .result__card::before,
[data-reduced-motion="true"] .level-card--next,
[data-reduced-motion="true"] .loading__logo {
  animation: none !important;
}
