/* Gnaga à Babi — animations de l'interface : écrans, onglets, accueil, cartes, marché, calebasses, résultats.
   Les boucles et les apparitions décoratives ne tournent pas en mode économie (html.lowfx) ; la préférence système
   « réduire les animations » les coupe toutes (règle globale de main.css). Les boucles animent surtout transform et
   opacity, que le téléphone déplace sans tout redessiner ; les quelques lueurs (box-shadow) restent rares. */

/* ------------------------------------------------------------------ écrans et onglets */
html:not(.lowfx) .screen { animation: screenIn 0.3s ease-out; }
@keyframes screenIn { from { opacity: 0; transform: scale(1.03); } }

/* contenu d'un onglet : il glisse depuis le côté de l'onglet choisi */
html:not(.lowfx) .content.from-right { animation: tabFromRight 0.26s cubic-bezier(0.2, 0.9, 0.3, 1); }
html:not(.lowfx) .content.from-left { animation: tabFromLeft 0.26s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes tabFromRight { from { opacity: 0.2; transform: translateX(16%); } }
@keyframes tabFromLeft { from { opacity: 0.2; transform: translateX(-16%); } }

.tab .ico { transition: transform 0.15s; }
.tab:active .ico { transform: scale(0.85); }
.tab.on .ico { animation: tabPop 0.4s cubic-bezier(0.3, 1.7, 0.5, 1); }
@keyframes tabPop { 0% { transform: scale(0.6); } 55% { transform: scale(1.22) rotate(-6deg); } 100% { transform: none; } }
html:not(.lowfx) .tab .dot { animation: dotPulse 1.3s ease-in-out infinite; }
@keyframes dotPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }

/* ------------------------------------------------------------------ barre du haut */
.pill.up { animation: pillUp 0.7s cubic-bezier(0.3, 1.5, 0.5, 1); }
.pill.down { animation: pillDown 0.5s ease-out; }
@keyframes pillUp { 30% { transform: scale(1.2); border-color: var(--gold); box-shadow: 0 0 14px rgba(255, 207, 74, 0.7); } }
@keyframes pillDown { 30% { transform: scale(0.9); border-color: var(--red); box-shadow: 0 0 12px rgba(224, 72, 58, 0.6); } }
.topbar .who .xp i { transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }
.avatar .lvl.up { animation: lvlUp 0.8s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes lvlUp { 0% { transform: scale(0.4); } 40% { transform: scale(1.6); box-shadow: 0 0 16px #6cb6ff; } 100% { transform: none; } }

/* ------------------------------------------------------------------ apparitions en cascade (motion.stagger) */
html:not(.lowfx) .stag > * { animation: popIn 0.42s cubic-bezier(0.3, 1.45, 0.5, 1) backwards; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(0.82); } }

/* ------------------------------------------------------------------ accueil */
/* bouton GNAGA ! : un reflet traverse le bouton de temps en temps ; il s'enfonce bien quand on appuie */
.battle-btn { overflow: hidden; }
.battle-btn:active { animation: none; }
html:not(.lowfx) .battle-btn::after {
  content: ''; position: absolute; top: -30%; bottom: -30%; left: -50%; width: 34%; pointer-events: none;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0));
  transform: skewX(-20deg); animation: shine 3.6s ease-in-out 1s infinite;
}
@keyframes shine { 0% { transform: skewX(-20deg) translateX(0); } 35%, 100% { transform: skewX(-20deg) translateX(520%); } }

/* carte de l'arène : la jauge des trophées se remplit, le nom arrive en rebondissant */
html:not(.lowfx) .entering .arena-card .progress i { transform-origin: left center; animation: fillIn 1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s backwards; }
html:not(.lowfx) .entering .arena-card h2 { animation: titleIn 0.55s cubic-bezier(0.3, 1.5, 0.5, 1) 0.05s backwards; }
@keyframes fillIn { from { transform: scaleX(0); } }
@keyframes titleIn { from { opacity: 0; transform: translateY(12px) scale(0.9); } }

/* calebasses : celle qui s'ouvre se balance, celle qui est prête sautille, une nouvelle tombe dans son emplacement */
html:not(.lowfx) .slot.unlocking .chest-ico { transform-origin: 50% 85%; animation: chestSway 2.4s ease-in-out infinite; }
html:not(.lowfx) .slot.ready .chest-ico, html:not(.lowfx) .bonus.ready .chest-ico { transform-origin: 50% 92%; animation: chestHop 1.5s ease-in-out infinite; }
html:not(.lowfx) .slot.ready .sub { animation: pulse 1.2s ease-in-out infinite; }
@keyframes chestSway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes chestHop {
  0%, 52%, 100% { transform: none; }
  62% { transform: scale(1.1, 0.88); }
  76% { transform: translateY(-16%) scale(0.94, 1.08) rotate(-4deg); }
  88% { transform: scale(1.06, 0.94); }
}
html:not(.lowfx) .slot.arrive { animation: slotArrive 0.7s cubic-bezier(0.3, 1.4, 0.5, 1) 0.25s backwards; }
@keyframes slotArrive { 0% { opacity: 0; transform: translateY(-60px) scale(0.5) rotate(-12deg); } 60% { opacity: 1; transform: translateY(4px) scale(1.08, 0.92); } }
.bonus .chest-ico { transition: transform 0.15s; }
.bonus:active .chest-ico { transform: scale(0.9); }

/* ------------------------------------------------------------------ cartes */
/* carte améliorable : halo vert qui respire autour du cadre */
.gcard.can-up::before {
  content: ''; position: absolute; inset: -3px; z-index: 0; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 12px 3px rgba(125, 255, 138, 0.75); opacity: 0;
}
html:not(.lowfx) .gcard.can-up::before { animation: upGlow 1.8s ease-in-out infinite; }
@keyframes upGlow { 50% { opacity: 1; } }
.coll-grid .gcard, .deck-grid .gcard, .offer .gcard { transition: transform 0.12s; }
.coll-grid .gcard:active, .deck-grid .gcard:active, .offer .gcard:active { transform: scale(0.94); }
/* carte posée dans le deck */
.deck-grid .gcard.placed { animation: placed 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes placed { 0% { transform: scale(0.6) rotate(-8deg); } 55% { transform: scale(1.12); filter: brightness(1.35); } 100% { transform: none; } }
/* étiquette « Nouveau » : elle garde son inclinaison et grossit par à-coups */
html:not(.lowfx) .gcard .newtag { animation: newTag 1.4s ease-in-out infinite; }
@keyframes newTag { 0%, 60%, 100% { transform: rotate(8deg); } 70% { transform: rotate(14deg) scale(1.18); } 80% { transform: rotate(4deg) scale(1.1); } }

/* ------------------------------------------------------------------ marché */
html:not(.lowfx) .offer.free { border-color: var(--green); animation: freeGlow 1.6s ease-in-out infinite; }
html:not(.lowfx) .offer.free .btn { animation: breathe 1.2s ease-in-out infinite; }
@keyframes freeGlow { 0%, 100% { box-shadow: 0 4px 0 #1c0f06; } 50% { box-shadow: 0 4px 0 #1c0f06, 0 0 18px rgba(125, 255, 138, 0.55); } }
.shop-chest .chest-ico, .wari-pack .big-cur { transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1); }
.shop-chest:hover .chest-ico, .wari-pack:hover .big-cur { transform: translateY(-4px) rotate(-4deg) scale(1.06); }

/* ------------------------------------------------------------------ ouverture de calebasse */
html:not(.lowfx) .chest-open .big-chest.shaking { animation: chestDrop 0.6s cubic-bezier(0.3, 1.4, 0.5, 1), chestShake 0.5s ease-in-out 0.6s infinite; }
@keyframes chestDrop { 0% { transform: translateY(-55vh) scale(0.7) rotate(-15deg); } 70% { transform: translateY(0) scale(1.08, 0.9); } 100% { transform: none; } }
.chest-open .flash {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(255, 252, 230, 0.95), rgba(255, 220, 120, 0.45) 35%, rgba(255, 220, 120, 0) 70%);
  animation: flash 0.55s ease-out forwards;
}
@keyframes flash { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }
html:not(.lowfx) .chest-open .reveal .gcard { animation: cardFlip 0.6s cubic-bezier(0.3, 1.3, 0.5, 1); }
@keyframes cardFlip { 0% { opacity: 0; transform: perspective(700px) rotateY(110deg) scale(0.55); } 40% { opacity: 1; } 100% { transform: perspective(700px) rotateY(0) scale(1); } }
/* halo de rareté derrière la carte révélée */
.chest-open .reveal .halo { position: absolute; left: 50%; top: 88px; width: 300px; height: 300px; margin: -150px 0 0 -150px; z-index: -1; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, var(--halo) 0%, rgba(0, 0, 0, 0) 66%); opacity: 0.7; }
html:not(.lowfx) .chest-open .reveal .halo { animation: haloPulse 1.6s ease-in-out infinite; }
@keyframes haloPulse { 0%, 100% { transform: scale(0.9); opacity: 0.55; } 50% { transform: scale(1.08); opacity: 0.85; } }
.chest-open .reveal .cnt { display: inline-block; }
html:not(.lowfx) .chest-open .reveal .cnt { animation: cntPop 0.5s cubic-bezier(0.3, 1.7, 0.5, 1) 0.25s backwards; }
@keyframes cntPop { from { opacity: 0; transform: scale(2.2); } }
html:not(.lowfx) .chest-open .tap { animation: pulse 1.2s infinite, tapIn 0.4s ease-out backwards; }
@keyframes tapIn { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------------ éclats (motion.burst) */
.fx-spark, .fx-confetti { position: absolute; z-index: 30; pointer-events: none; }
.fx-spark {
  width: 14px; height: 14px; margin: -7px 0 0 -7px; background: var(--c);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 4px var(--c)); animation: spark 0.9s cubic-bezier(0.1, 0.7, 0.3, 1) backwards;
}
@keyframes spark {
  0% { transform: translate(0, 0) scale(0.2) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--r)); opacity: 0; }
}
.fx-confetti { width: 9px; height: 14px; margin: -7px 0 0 -4px; border-radius: 2px; background: var(--c); animation: confetti 2.2s cubic-bezier(0.2, 0.6, 0.4, 1) backwards; }
@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  30% { transform: translate(var(--dx), var(--dy)) rotate(calc(var(--r) * 0.4)); }
  85% { opacity: 1; }
  100% { transform: translate(calc(var(--dx) * 1.25), calc(var(--dy) + 340px)) rotate(var(--r)); opacity: 0; }
}

/* ------------------------------------------------------------------ résultat d'un combat */
html:not(.lowfx) .bt-result.win .res-title { animation: pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1), winGlow 2s ease-in-out 0.5s infinite; }
@keyframes winGlow { 0%, 100% { text-shadow: 0 5px 0 #1b0f07; } 50% { text-shadow: 0 5px 0 #1b0f07, 0 0 24px rgba(255, 207, 74, 0.8); } }

/* ------------------------------------------------------------------ chargement et choix du joueur */
html:not(.lowfx) .splash .logo { animation: logoIn 0.9s cubic-bezier(0.3, 1.5, 0.5, 1) backwards; }
@keyframes logoIn { 0% { opacity: 0; transform: rotate(-12deg) translateY(-50px) scale(0.5); } 60% { opacity: 1; transform: rotate(-1deg) translateY(4px) scale(1.06); } 100% { transform: rotate(-3deg); } }
html:not(.lowfx) .splash .logo .l1 { animation: float 3.2s ease-in-out 1s infinite; }
@keyframes float { 0%, 100% { transform: none; } 50% { transform: translateY(-5px); } }
html:not(.lowfx) .loadbar i { animation: stripes 0.9s linear infinite; }
@keyframes stripes { to { background-position: 55px 0; } }
html:not(.lowfx) .profile-list > * { animation: popIn 0.42s cubic-bezier(0.3, 1.45, 0.5, 1) backwards; }
.profile-list > :nth-child(2) { animation-delay: 0.05s; }
.profile-list > :nth-child(3) { animation-delay: 0.1s; }
.profile-list > :nth-child(4) { animation-delay: 0.15s; }
.profile-list > :nth-child(n + 5) { animation-delay: 0.2s; }
