/* Animation d'ouverture des coffres (reprise de la version complète). */

/* Cartes qui se retournent */
.butin .fl { perspective: 800px; aspect-ratio: 3 / 4; }
.fli {
  position: relative; width: 100%; height: 100%; transform-style: preserve-3d;
  animation: flip .75s var(--d, 0s) both cubic-bezier(.3, 1.25, .5, 1);
}
@keyframes flip { from { transform: rotateY(0); } to { transform: rotateY(180deg); } }
.fb, .ff { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.fb {
  display: flex; align-items: center; justify-content: center; border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, .4); color: rgba(255, 255, 255, .85); font-size: 34px; font-weight: 800;
  background: repeating-linear-gradient(45deg, #4b50c9 0 10px, #3c40a8 10px 20px);
}
.butin.serre .fb { border-radius: 10px; border-width: 1.5px; font-size: 22px; }
.ff { transform: rotateY(180deg); }
.ff .fig { height: 100%; width: 100%; aspect-ratio: auto; }
.fl.hi .ff { animation: hi 1.4s calc(var(--d) + .6s) 2; }
@keyframes hi { 50% { filter: drop-shadow(0 0 14px var(--c)); } }

/* Fenêtre : apparaît après la boule, tremble à l'arrivée d'une légendaire ou spéciale */
.ouv .fenetre { position: relative; z-index: 1; animation: fondu .25s var(--b, 0s) both; }
.ouv .fenetre.secoue { animation: fondu .25s var(--b, 0s) both, secousse .55s var(--t, 0s) both; }
@keyframes fondu { from { opacity: 0; } }
@keyframes secousse {
  0% { transform: none; } 12% { transform: translate(-7px, 3px); } 28% { transform: translate(6px, -4px); }
  44% { transform: translate(-4px, 3px); } 60% { transform: translate(3px, -2px); } 80% { transform: translate(-1px, 1px); }
  100% { transform: none; }
}
.fenetre .puces, .fenetre .actions { animation: fondu .5s var(--fin, 0s) both; }
.puces { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.puces span { background: var(--carte2); border: 1px solid var(--ligne); border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 700; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions .btn { flex-direction: row; }

/* Boule lumineuse avant l'ouverture (toucher pour passer) */
.pkg {
  position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center;
  width: auto; padding: 0; margin: 0; border: 0; color: #fff; cursor: pointer; overflow: hidden;
  background: radial-gradient(circle at 50% 46%, #1c1c26, #000 75%); animation: pkout .4s var(--i) both;
}
@keyframes pkout { to { opacity: 0; visibility: hidden; } }
.pkg-gl {
  position: absolute; left: 50%; top: 50%; width: 330px; height: 330px; margin: -165px 0 0 -165px; border-radius: 50%;
  background: radial-gradient(circle, var(--c) 0, transparent 62%); opacity: 0; animation: pkgl var(--i) ease-in both;
}
@keyframes pkgl { from { opacity: 0; transform: scale(.35); } to { opacity: var(--gm, .9); transform: scale(1.5); } }
.pkg-ry, .fx-ry {
  position: absolute; left: 50%; top: 50%; width: 780px; height: 780px; margin: -390px 0 0 -390px; opacity: 0;
  -webkit-mask-image: radial-gradient(circle, #000 0, transparent 66%); mask-image: radial-gradient(circle, #000 0, transparent 66%);
}
.pkg-ry { animation: pkry var(--i) ease-in both; }
.pkg-ry i, .fx-ry i {
  position: absolute; inset: 0; background: repeating-conic-gradient(var(--c) 0 7deg, transparent 7deg 20deg);
  animation: pkspin 10s linear infinite;
}
@keyframes pkry { from { opacity: 0; } to { opacity: .55; } }
@keyframes pkspin { to { transform: rotate(360deg); } }
.pkg[data-k=C] .pkg-ry, .pkg[data-k=R] .pkg-ry { display: none; }
.pkp {
  position: relative; z-index: 2; width: 164px; height: 222px; border-radius: 16px;
  background: linear-gradient(160deg, var(--p1), var(--p2));
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .35) inset, 0 16px 36px -8px rgba(0, 0, 0, .75);
  overflow: hidden; display: flex; align-items: center; justify-content: center; animation: pkshk var(--i) ease-in both;
}
.pkp::before, .pkp::after {
  content: ""; position: absolute; left: 0; right: 0; height: 18px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .34) 0 3px, rgba(0, 0, 0, .28) 3px 6px);
}
.pkp::before { top: 0; } .pkp::after { bottom: 0; }
.pkp svg { width: 80px; height: 80px; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5)); }
.pkp i {
  position: absolute; inset: 0; background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .5) 50%, transparent 62%);
  background-size: 260% 100%; animation: brille 1.3s linear infinite;
}
@keyframes brille { from { background-position: 130% 0; } to { background-position: -130% 0; } }
/* La boule tremble de plus en plus fort jusqu'au flash */
@keyframes pkshk {
  0% { transform: none; }
  20% { transform: translate(calc(var(--sa, 1) * -1px), calc(var(--sa, 1) * .5px)) rotate(calc(var(--sa, 1) * -.6deg)); }
  40% { transform: translate(calc(var(--sa, 1) * 2px), calc(var(--sa, 1) * -1px)) rotate(calc(var(--sa, 1) * 1deg)) scale(1.01); }
  60% { transform: translate(calc(var(--sa, 1) * -3px), calc(var(--sa, 1) * 1.5px)) rotate(calc(var(--sa, 1) * -1.6deg)) scale(1.03); }
  80% { transform: translate(calc(var(--sa, 1) * 4px), calc(var(--sa, 1) * -2px)) rotate(calc(var(--sa, 1) * 2.2deg)) scale(1.06); }
  100% { transform: translate(calc(var(--sa, 1) * -5px), calc(var(--sa, 1) * 2px)) rotate(calc(var(--sa, 1) * -2.8deg)) scale(1.1); }
}
.pkg-fl {
  position: absolute; inset: 0; z-index: 4; opacity: 0;
  background: radial-gradient(circle at 50% 46%, #fff 0, var(--fc, #fff) 70%); animation: pkfl .3s calc(var(--i) - .28s) ease-in both;
}
@keyframes pkfl { to { opacity: 1; } }
.pkg.arc .pkg-gl { background: radial-gradient(circle, #fff 0, #ff8bd0 24%, transparent 62%); animation: pkgl var(--i) ease-in both, teinte 2s linear infinite; }
.pkg.arc .pkg-ry i, .fx.arc .fx-ry i {
  background: repeating-conic-gradient(#ff5f6d 0 7deg, #ffb347 7deg 14deg, #6dff9c 14deg 21deg, #5de0ff 21deg 28deg, #d26bff 28deg 35deg, transparent 35deg 42deg);
}
@keyframes teinte { to { filter: hue-rotate(360deg); } }

/* Effets au moment où la carte se retourne */
.fx { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.fx.fxf { z-index: 2; }
.fx-fl {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(circle at var(--x) var(--y), var(--fc) 0, transparent 62%); animation: fxfl .9s var(--t) ease-out both;
}
@keyframes fxfl { 0% { opacity: 0; } 12% { opacity: .9; } 100% { opacity: 0; } }
.fx-ry { left: var(--x); top: var(--y); width: 900px; height: 900px; margin: -450px 0 0 -450px; animation: fxry 5s var(--t) ease-out both; }
.fx-ry i { animation-duration: 16s; }
@keyframes fxry { 0% { opacity: 0; transform: scale(.3); } 12% { opacity: .6; } 100% { opacity: .3; transform: scale(1); } }
.fx-rg {
  position: absolute; left: var(--x); top: var(--y); width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%;
  border: 3px solid var(--c); box-shadow: 0 0 14px var(--c); opacity: 0; animation: fxrg .95s var(--t) ease-out both;
}
.fx-rg.r2 { animation-delay: calc(var(--t) + .18s); border-color: #fff; }
@keyframes fxrg { 0% { opacity: .95; transform: scale(.4); } 100% { opacity: 0; transform: scale(9); } }
.fx-p {
  position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2); background: hsl(var(--h) 100% 66%); opacity: 0;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: fxp var(--du) calc(var(--t) + var(--dl)) cubic-bezier(.1, .7, .3, 1) both;
}
@keyframes fxp {
  0% { opacity: 1; transform: translate(0, 0) scale(.3) rotate(0); } 65% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1) rotate(160deg); }
}

/* Passer l'animation, ou mouvement réduit : tout est montré tout de suite */
.sans-anim .fli { animation: none; transform: rotateY(180deg); }
.sans-anim, .sans-anim .puces, .sans-anim .actions, .sans-anim.fenetre { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .fli, .fl.hi .ff, .ouv .fenetre, .fenetre .puces, .fenetre .actions { animation: none; }
  .fli { transform: rotateY(180deg); }
}
