/* ═══════════════════════════════════════════════════════════════════════════
   VARIABLES À AJUSTER — tout ce qui est testé/calé pendant le design est ici
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  /* ── Position des 3 fenêtres de slots sur bandit_v2.png ── */
  --slot-top:    31%;
  --slot-bottom: 45%;

  --slot1-left:  25%;
  --slot1-right: 39%;
  --slot2-left:  42%;
  --slot2-right: 56%;
  --slot3-left:  60%;
  --slot3-right: 74%;

  /* ── Vitesse de défilement des rouleaux (plus petit = plus rapide) ── */
  --vitesse-defilement: 0.15s;

  /* ── Position verticale de la pop-up résultat (0% = haut, 100% = bas) ── */
  --popup-top: 60%;

  /* ── Origine de l'explosion de runes — DOIT correspondre à --popup-top
        pour que l'explosion parte du même endroit que la pop-up ── */
  --explosion-top: 60%;
  --explosion-left: 50%;

  /* ── Délai entre l'arrêt du 3e rouleau et l'apparition de la pop-up (ms) ── */
  --delai-popup: 1000ms;
}

/* ─── Overlay ────────────────────────────────────────────────────────────── */
#slot-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  animation: slot-fadein 0.3s ease;
}

@keyframes slot-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Colonne verticale : bandit puis bouton ──────────────────────────────── */
.slot-colonne {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 420px;
  padding: 0 1rem;
}

/* ─── Conteneur bandit ───────────────────────────────────────────────────── */
.slot-bandit-wrapper {
  position: relative;
  width: 100%;
}

.slot-bandit-img {
  display: block;
  width: 100%;
  height: auto; /* pas de déformation, ratio natif conservé */
}

/* ─── Les 3 fenêtres de slots positionnées en absolu sur le bandit ───────── */
.slot-reel {
  position: absolute;
  top: var(--slot-top);
  bottom: var(--slot-bottom);
  overflow: hidden;
}

#reel-0 { left: var(--slot1-left); right: calc(100% - var(--slot1-right)); }
#reel-1 { left: var(--slot2-left); right: calc(100% - var(--slot2-right)); }
#reel-2 { left: var(--slot3-left); right: calc(100% - var(--slot3-right)); }

/* Conteneur interne qui défile — animé par requestAnimationFrame en JS */
.slot-reel-inner {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  will-change: transform; /* optimisation GPU */
}

/* Animation arrêt sur le rouleau */
.slot-reel.stopping {
  animation: slot-bounce 0.3s ease;
}

@keyframes slot-bounce {
  0%   { transform: scaleY(1.08); }
  50%  { transform: scaleY(0.95); }
  100% { transform: scaleY(1); }
}

/* Item dans un rouleau — centré verticalement et horizontalement */
.slot-item {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.slot-item img {
  width: 75%;
  height: 75%;
  object-fit: contain;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Item final (après arrêt) */
.slot-item-final img {
  animation: slot-item-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes slot-item-pop {
  0%   { transform: translate(-50%, -50%) scale(0.7); opacity: 0.5; }
  100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

/* ─── Bouton lancer — sous le bandit ──────────────────────────────────────── */
.slot-btn-lancer-img {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
}
.slot-btn-lancer-img img {
  display: block;
  height: 52px;
  width: auto;
  transition: transform 0.1s;
}
.slot-btn-lancer-img:active img { transform: scale(0.97); }
.slot-btn-lancer-img.invisible-stable {
  visibility: hidden;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   POP-UP RÉSULTAT — affichée par-dessus le bandit après le tirage
   ═══════════════════════════════════════════════════════════════════════════ */
#slot-resultat-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
}
#slot-resultat-overlay.hidden { display: none; }

@keyframes slot-modal-apparition {
  0%   { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

.slot-resultat-modal {
  position: absolute;
  top: var(--popup-top);
  left: 50%;
  transform: translate(-50%, -50%);
  width: 75%;
  max-width: 280px;
  background-image: url('/img/design/fond_pop_up_large.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border-radius: 16px;
  padding: 1.5rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  animation: slot-modal-apparition 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.slot-win-anim { font-size: 2rem; animation: slot-bounce-emoji 0.6s ease infinite alternate; }
@keyframes slot-bounce-emoji {
  from { transform: scale(1); }
  to   { transform: scale(1.2); }
}

.slot-msg-win {
  color: #2d6a3f;
  font-weight: 800;
  font-size: 0.88rem;
  margin: 0;
  text-align: center;
  text-shadow: 0 1px 2px rgba(255,255,255,0.4);
}
.slot-reward {
  color: #2a1a0a;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(139,69,19,0.12);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  text-align: center;
}
.slot-msg-lose {
  color: #5a3a1a;
  font-size: 0.82rem;
  font-weight: 700;
  margin: 0;
  text-align: center;
}
.slot-error {
  color: var(--error);
  text-align: center;
}

.slot-btn-fermer-img {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  margin-top: 0.5rem;
}
.slot-btn-fermer-img img {
  display: block;
  height: 38px;
  width: auto;
  transition: transform 0.1s;
}
.slot-btn-fermer-img:active img { transform: scale(0.97); }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 400px) {
  .slot-resultat-modal { padding: 1.5rem 1rem 1.25rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATION D'EXPLOSION DE RUNES — part du même point que la pop-up
   ═══════════════════════════════════════════════════════════════════════════ */
.slot-particules {
  position: absolute;
  inset: 0;
  z-index: 5; /* derrière la pop-up résultat (z-index 10) mais devant le bandit */
  overflow: visible;
  pointer-events: none;
}

.slot-particule {
  position: absolute;
  top: var(--explosion-top);
  left: var(--explosion-left);
  object-fit: contain;
  transform: translate(-50%, -50%);
  animation: slot-explosion ease-out forwards;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.5));
}

@keyframes slot-explosion {
  0% {
    transform: translate(-50%, -50%) scale(0.3) rotate(0deg);
    opacity: 1;
  }
  15% {
    transform: translate(-50%, -50%) scale(1.3) rotate(calc(var(--rot) * 0.1));
    opacity: 1;
  }
  75% {
    opacity: 1;
  }
  100% {
    transform:
      translate(calc(-50% + var(--tx)), calc(-50% + var(--ty)))
      scale(0.9)
      rotate(var(--rot));
    opacity: 0;
  }
}

/* Défaite : petit envol puis chute avec gravité (ease-in), au lieu de
   s'envoler dans toutes les directions comme pour une victoire. */
.slot-particule-chute { animation-name: slot-chute; animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
@keyframes slot-chute {
  0% {
    transform: translate(-50%, -50%) scale(0.6) rotate(0deg);
    opacity: 1;
  }
  20% {
    transform: translate(calc(-50% + var(--tx) * 0.3), calc(-50% - 40px)) scale(1) rotate(calc(var(--rot) * 0.2));
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    transform:
      translate(calc(-50% + var(--tx)), calc(-50% + var(--ty)))
      scale(0.7)
      rotate(var(--rot));
    opacity: 0;
  }
}
