/* ===================================================
   KURO ARCANA — Animation d'ouverture du booster
   Classes .booster-anim-* uniquement, sur les variables :root de style.css.
   Le paquet est l'image assets/booster_saison1_kuroarcana-detoure.png, superposée en deux calques
   découpés en CSS (bande du haut + corps). L'image n'est jamais modifiée.
   Ligne de déchirure (pointillés dorés) : 10.72 % de la hauteur, mesurée par tools/detourer-booster.py.
   =================================================== */

/* L'image d'origine du #booster-pack est masquée par booster.js pendant l'animation :
   les deux calques ci-dessous en affichent chacun une partie */

/* 1. Apparition : le paquet descend au centre puis flotte */
.booster-anim-paquet {
  position: relative;
  width: 100%;
  touch-action: none;           /* le glisser au doigt ne fait pas défiler la page */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  animation:
    booster-anim-descente 0.9s cubic-bezier(0.2, 0.8, 0.3, 1) both,
    booster-anim-flotte 3.4s ease-in-out 0.9s infinite;
}

/* Basculement 3D qui suit la souris (variables posées par booster.js) */
.booster-anim-incline {
  position: relative;
  transform: perspective(900px) rotateX(var(--booster-anim-rx, 0deg)) rotateY(var(--booster-anim-ry, 0deg));
  transition: transform 0.18s ease-out;
}

.booster-anim-calque img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* Corps : dans le flux, il donne sa taille au paquet */
.booster-anim-corps {
  position: relative;
  clip-path: polygon(0% 10.72%, 5% 9.82%, 10% 11.62%, 15% 9.82%, 20% 11.62%, 25% 9.82%, 30% 11.62%, 35% 9.82%, 40% 11.62%, 45% 9.82%, 50% 11.62%, 55% 9.82%, 60% 11.62%, 65% 9.82%, 70% 11.62%, 75% 9.82%, 80% 11.62%, 85% 9.82%, 90% 11.62%, 95% 9.82%, 100% 10.72%, 100% 100%, 0 100%);
}

/* Bande du haut : même image superposée, découpe complémentaire en dents de scie.
   Elle se soulève un peu pendant le geste (--booster-anim-progression, de 0 à 1) */
.booster-anim-haut {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 100% 0, 100% 10.72%, 95% 9.82%, 90% 11.62%, 85% 9.82%, 80% 11.62%, 75% 9.82%, 70% 11.62%, 65% 9.82%, 60% 11.62%, 55% 9.82%, 50% 11.62%, 45% 9.82%, 40% 11.62%, 35% 9.82%, 30% 11.62%, 25% 9.82%, 20% 11.62%, 15% 9.82%, 10% 11.62%, 5% 9.82%, 0% 10.72%);
  transform-origin: 100% 10.72%;
  transform: rotate(calc(var(--booster-anim-progression, 0) * -4deg));
  transition: transform 0.12s ease-out;
  z-index: 2;
}

/* Reflet holographique (violet, or) limité au métal du paquet par un masque de l'image */
.booster-anim-reflet {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(115deg,
    transparent 30%, rgba(155, 89, 255, 0.4) 42%, rgba(255, 215, 0, 0.55) 50%,
    rgba(200, 120, 255, 0.35) 57%, transparent 68%);
  background-size: 300% 100%;
  mix-blend-mode: screen;
  -webkit-mask-image: var(--booster-anim-masque);
  mask-image: var(--booster-anim-masque);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  animation: booster-anim-reflet 3.2s ease-in-out infinite;
  transition: opacity 0.3s ease;
}

/* 2. Ouverture interactive : ligne qui pulse, trace du geste, consigne */
.booster-anim-ligne,
.booster-anim-trace {
  position: absolute;
  top: 10.72%;
  pointer-events: none;
  z-index: 4;
  transform: translateY(-50%);
}

.booster-anim-ligne {
  left: 2%;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--or-lumineux), var(--or-dore), transparent);
  box-shadow: 0 0 8px var(--glow-or);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.booster-anim-invite .booster-anim-ligne {
  animation: booster-anim-pulse 1.4s ease-in-out infinite;
}

.booster-anim-trace {
  left: calc(var(--booster-anim-debut, 0) * 100%);
  width: calc((var(--booster-anim-fin, 0) - var(--booster-anim-debut, 0)) * 100%);
  height: 4px;
  border-radius: 2px;
  background: var(--or-lumineux);
  box-shadow: 0 0 10px var(--or-lumineux), 0 0 22px var(--glow-or);
}

.booster-anim-invite {
  cursor: grab;
}

.booster-anim-consigne {
  position: absolute;
  top: calc(100% + 14px);
  left: 50%;
  width: max-content;
  max-width: 90vw;
  transform: translateX(-50%);
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  letter-spacing: 1px;
  text-align: center;
  color: var(--or-dore);
  text-shadow: 0 0 10px var(--glow-or);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.booster-anim-invite .booster-anim-consigne {
  opacity: 1;
  animation: booster-anim-pulse 1.8s ease-in-out infinite;
}

/* Étincelles dorées le long de la ligne */
.booster-anim-etincelle {
  position: absolute;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: var(--or-lumineux);
  box-shadow: 0 0 6px var(--or-lumineux), 0 0 12px var(--glow-or);
  pointer-events: none;
  z-index: 5;
  animation: booster-anim-etincelle 0.6s ease-out forwards;
}

/* 3. Déchirure : la bande du haut s'envole, une lueur violette et rouge jaillit */
.booster-anim-lueur {
  position: absolute;
  left: -25%;
  right: -25%;
  top: 10.72%;
  height: 70%;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
    rgba(190, 90, 255, 0.95), rgba(220, 20, 60, 0.6) 40%, transparent 70%);
  mix-blend-mode: screen;
  opacity: 0;
  transform: translateY(-50%) scale(0.3);
}

.booster-anim-dechire .booster-anim-haut {
  animation: booster-anim-dechirure 0.75s cubic-bezier(0.45, 0, 0.7, 0.4) forwards;
}

.booster-anim-dechire .booster-anim-lueur {
  animation: booster-anim-lueur 1.2s ease-out forwards;
}

.booster-anim-dechire .booster-anim-reflet,
.booster-anim-dechire .booster-anim-ligne,
.booster-anim-dechire .booster-anim-trace {
  opacity: 0;
}

/* 4. Le paquet vide s'abaisse et s'efface */
.booster-anim-paquet.booster-anim-vide {
  animation: booster-anim-vide 0.6s ease-in forwards;
}

/* Cartes : montent du paquet une par une (remplace l'animation cardRise) */
.booster-card-placeholder.booster-anim-sortie {
  animation: booster-anim-sortie 0.6s cubic-bezier(0.2, 0.8, 0.3, 1.1) forwards;
  animation-delay: 0s;
}

/* Conteneur des cartes : défilement si l'écran est bas (mobile paysage) */
/* Même z-index que le paquet et placé après lui : les cartes passent devant */
.booster-anim-cartes {
  z-index: 10000;
  max-height: 85vh;
  overflow-y: auto;
  padding: 10px;
}

/* Invisible tant que les cartes ne sont pas sorties : ne gêne pas le geste sur le paquet */
.booster-anim-cartes:not(.booster-cards-visible) {
  pointer-events: none;
}

/* Placement final : éventail sur grand écran, en ligne sinon (rotate et translate
   ne touchent pas aux animations des cartes, qui utilisent transform) */
@media (min-width: 900px) {
  /* Marge pour les coins des cartes inclinées (le conteneur défile, donc rogne) */
  .booster-anim-cartes {
    padding: 20px 30px 60px;
  }
  .booster-anim-cartes.booster-anim-eventail {
    flex-wrap: nowrap;
  }
  .booster-anim-cartes .booster-card-placeholder {
    transition: rotate 0.6s ease, translate 0.6s ease;
  }
  .booster-anim-eventail .booster-card-placeholder:nth-child(1) { rotate: -10deg; translate: 0 26px; }
  .booster-anim-eventail .booster-card-placeholder:nth-child(2) { rotate: -5deg; translate: 0 7px; }
  .booster-anim-eventail .booster-card-placeholder:nth-child(4) { rotate: 5deg; translate: 0 7px; }
  .booster-anim-eventail .booster-card-placeholder:nth-child(5) { rotate: 10deg; translate: 0 26px; }
}

/* ---------- PAQUET DE SECOURS (si le visuel du booster ne charge pas) ---------- */
.booster-anim-paquet.booster-anim-secours {
  aspect-ratio: 5 / 7;
}

.booster-anim-secours .booster-anim-calque img {
  display: none;
}

.booster-anim-secours .booster-anim-incline,
.booster-anim-secours .booster-anim-corps {
  position: absolute;
  inset: 0;
}

.booster-anim-secours .booster-anim-calque {
  background:
    repeating-linear-gradient(90deg, transparent 0 8px, rgba(255, 215, 0, 0.08) 8px 10px) top / 100% 10.72% no-repeat,
    linear-gradient(160deg, var(--violet-profond), var(--noir-fonce) 55%, var(--rouge-sang));
  border: 2px solid var(--or-pale);
  border-radius: 10px;
  box-shadow: 0 0 25px var(--glow-violet);
}

.booster-anim-secours .booster-anim-reflet {
  -webkit-mask-image: none;
  mask-image: none;
  border-radius: 10px;
}

.booster-anim-secours-titre {
  display: none;
}

.booster-anim-secours .booster-anim-secours-titre {
  position: absolute;
  inset: 11% 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: 'Cinzel', serif;
  color: var(--or-dore);
  text-align: center;
  text-shadow: 0 0 10px var(--glow-or);
  letter-spacing: 2px;
}

.booster-anim-secours-kanji {
  font-size: 3rem;
  color: var(--rouge-crimson);
  text-shadow: 0 0 15px var(--glow-rouge);
}

.booster-anim-secours-nom {
  font-size: 1.1rem;
  font-weight: 700;
}

.booster-anim-secours-sous {
  font-size: 0.7rem;
  opacity: 0.8;
}

/* ---------- KEYFRAMES ---------- */
@keyframes booster-anim-descente {
  0%   { opacity: 0; transform: translateY(-70vh) rotate(-6deg); }
  70%  { opacity: 1; transform: translateY(10px) rotate(1deg); }
  100% { opacity: 1; transform: translateY(0) rotate(0); }
}

@keyframes booster-anim-flotte {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

@keyframes booster-anim-reflet {
  0%   { background-position: 100% 0; }
  60%, 100% { background-position: 0 0; }
}

@keyframes booster-anim-pulse {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}

@keyframes booster-anim-etincelle {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, -20px)) scale(0.2); }
}

@keyframes booster-anim-dechirure {
  0%   { transform: rotate(calc(var(--booster-anim-progression, 0) * -4deg)); opacity: 1; }
  30%  { transform: translate(2%, -6%) rotate(-14deg); opacity: 1; }
  100% { transform: translate(35%, -140%) rotate(38deg); opacity: 0; }
}

@keyframes booster-anim-lueur {
  0%   { opacity: 0; transform: translateY(-50%) scale(0.3); }
  25%  { opacity: 1; transform: translateY(-50%) scale(1); }
  100% { opacity: 0.35; transform: translateY(-50%) scale(1.5); }
}

@keyframes booster-anim-vide {
  to { opacity: 0; transform: translateY(60px) scale(0.92); }
}

@keyframes booster-anim-sortie {
  0%   { opacity: 0; transform: translateY(120px) scale(0.3); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- MOUVEMENT RÉDUIT : ouverture instantanée ---------- */
@media (prefers-reduced-motion: reduce) {
  .booster-anim-paquet,
  .booster-anim-haut,
  .booster-anim-reflet,
  .booster-anim-ligne,
  .booster-anim-consigne,
  .booster-anim-lueur,
  .booster-anim-etincelle {
    animation: none !important;
  }
  .booster-card-placeholder.booster-anim-sortie {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
  .booster-anim-cartes,
  .booster-anim-cartes .booster-card-placeholder {
    transition: none !important;
  }
}

/* ===================================================
   ANNONCES (étape 5) — classes .booster-annonce-*
   =================================================== */

.booster-annonce-zone {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10002;
}

/* Compteur « Booster #N » */
.booster-annonce-compteur {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: calc(24px + env(safe-area-inset-left, 0px));
  padding: 6px 16px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 2px;
  color: var(--or-dore);
  border: 1px solid var(--or-pale);
  border-radius: 20px;
  background: rgba(10, 5, 5, 0.75);
  box-shadow: 0 0 12px var(--glow-or);
  font-variant-numeric: tabular-nums;
  animation: booster-annonce-fondu 0.4s ease-out both;
}

/* Bandeau central (une annonce à la fois) */
.booster-annonce-bandeau {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 20px;
  text-align: center;
  border-radius: 12px;
  border: 2px solid var(--or-pale);
  background: linear-gradient(160deg, rgba(26, 10, 10, 0.95), rgba(75, 0, 130, 0.9));
  box-shadow: 0 0 30px var(--glow-violet);
  animation: booster-annonce-entree 0.45s cubic-bezier(0.2, 0.8, 0.3, 1.2) both;
}

.booster-annonce-titre {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: clamp(1.1rem, 4vw, 1.7rem);
  letter-spacing: 2px;
  color: var(--or-dore);
  text-shadow: 0 0 12px var(--glow-or);
  text-wrap: balance;
}

.booster-annonce-sous {
  font-family: 'Raleway', sans-serif;
  font-size: clamp(0.85rem, 2.6vw, 1rem);
  color: #fff;
  text-wrap: balance;
}

/* Variantes */
.booster-annonce-alerte {
  border-color: var(--or-dore);
  box-shadow: 0 0 35px var(--glow-or);
}

.booster-annonce-verite {
  border-color: var(--rouge-vif);
  background: linear-gradient(160deg, rgba(26, 10, 10, 0.95), rgba(139, 0, 0, 0.9));
  box-shadow: 0 0 35px var(--glow-rouge);
  animation: booster-annonce-entree 0.45s ease-out both, booster-annonce-pulsation 0.9s ease-in-out 0.45s infinite;
}

.booster-annonce-verite .booster-annonce-titre {
  color: var(--rouge-lumineux);
  text-shadow: 0 0 14px var(--glow-rouge);
}

.booster-annonce-epique {
  border-color: var(--violet-orchidee);
  box-shadow: 0 0 40px var(--glow-violet);
}

.booster-annonce-legendaire {
  border-color: var(--or-lumineux);
  background: linear-gradient(160deg, rgba(26, 10, 10, 0.95), rgba(218, 165, 32, 0.35));
  box-shadow: 0 0 50px var(--glow-or);
}

/* Flux : annonce courte, plus discrète */
.booster-annonce-flux {
  top: 8%;
  width: min(420px, calc(100% - 32px));
  padding: 10px 16px;
  border-color: var(--violet-orchidee);
}

.booster-annonce-flux .booster-annonce-titre {
  font-size: clamp(0.95rem, 3.4vw, 1.2rem);
}

/* Mouvement réduit : toutes les annonces listées */
.booster-annonce-statique {
  animation: none;
}

/* Révélations lentes des cartes garanties */
.booster-card-placeholder.booster-anim-sortie.booster-annonce-lente {
  animation: booster-annonce-revelation 1.4s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.booster-card-placeholder.booster-anim-sortie.booster-annonce-ultime {
  animation:
    booster-annonce-revelation 1.8s cubic-bezier(0.2, 0.7, 0.3, 1) forwards,
    booster-annonce-aura 1.2s ease-in-out 1.8s infinite alternate;
}

/* Boutons de fin */
.booster-annonce-actions {
  position: absolute;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: calc(100% - 32px);
  pointer-events: auto;
  animation: booster-annonce-fondu 0.4s ease-out both;
}

.booster-annonce-btn {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 10px 22px;
  border-radius: 8px;
  border: 1px solid var(--or-dore);
  background: var(--rouge-sang);
  color: var(--or-dore);
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.booster-annonce-btn:hover,
.booster-annonce-btn:focus-visible {
  background: var(--rouge-crimson);
  box-shadow: 0 0 15px var(--glow-rouge);
  outline: 2px solid var(--or-dore);
  outline-offset: 2px;
}

.booster-annonce-btn-secondaire {
  background: transparent;
}

/* Mobile : badge de rareté plus compact dans la modal */
@media (max-width: 480px) {
  .booster-anim-cartes .booster-card-rarity-badge {
    font-size: 0.62rem;
    padding: 2px 6px;
  }
  .booster-annonce-compteur {
    font-size: 0.9rem;
    top: calc(16px + env(safe-area-inset-top, 0px));
    left: calc(16px + env(safe-area-inset-left, 0px));
  }
}

@keyframes booster-annonce-fondu {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes booster-annonce-entree {
  from { opacity: 0; transform: translateX(-50%) scale(0.7); }
  to   { opacity: 1; transform: translateX(-50%) scale(1); }
}

@keyframes booster-annonce-pulsation {
  0%, 100% { box-shadow: 0 0 25px var(--glow-rouge); }
  50%      { box-shadow: 0 0 50px var(--glow-rouge); }
}

@keyframes booster-annonce-revelation {
  0%   { opacity: 0; transform: translateY(120px) scale(0.3) rotateY(90deg); filter: brightness(3); }
  60%  { opacity: 1; transform: translateY(-10px) scale(1.15) rotateY(0); filter: brightness(1.6); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotateY(0); filter: brightness(1); }
}

@keyframes booster-annonce-aura {
  from { box-shadow: 0 0 calc(15px * var(--card-glow-intensity, 1)) var(--card-glow, #888); }
  to   { box-shadow: 0 0 calc(35px * var(--card-glow-intensity, 1)) var(--card-glow, #888); }
}

@media (prefers-reduced-motion: reduce) {
  .booster-annonce-compteur,
  .booster-annonce-bandeau,
  .booster-annonce-actions {
    animation: none !important;
  }
  .booster-card-placeholder.booster-anim-sortie.booster-annonce-lente,
  .booster-card-placeholder.booster-anim-sortie.booster-annonce-ultime {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
}

/* ===================================================
   MENU DEBUG — section 🎲 TIRAGE (étape 6), classes .debug-tirage-*
   Mêmes tons que le menu debug existant (style.css, .debug-section)
   =================================================== */

.debug-tirage-bloc {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(0, 255, 0, 0.25);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.85em;
  line-height: 1.5;
  color: #00ff00;
}

.debug-tirage-titre {
  font-weight: bold;
  color: #00ff00;
  border-bottom: 1px dashed rgba(0, 255, 0, 0.3);
  padding-bottom: 4px;
  margin-bottom: 2px;
}

.debug-tirage-note {
  color: #00aa00;
  font-size: 0.9em;
}

.debug-tirage-table-wrap {
  overflow-x: auto;
}

.debug-tirage-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.debug-tirage-table th,
.debug-tirage-table td {
  padding: 2px 6px;
  text-align: right;
  border-bottom: 1px solid rgba(0, 255, 0, 0.12);
}

.debug-tirage-table th:first-child,
.debug-tirage-table td:first-child {
  text-align: left;
}

.debug-tirage-modifie td {
  color: #ffff66;
}

.debug-tirage-historique {
  margin: 0;
  padding-left: 20px;
}

.debug-tirage-tag {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid #00aa00;
  border-radius: 10px;
  font-size: 0.85em;
  color: #00ff00;
}

.debug-tirage-tag-pity {
  border-color: #ffff66;
  color: #ffff66;
}

/* Zone tactile du bouton ✕ agrandie (invisible, aucun changement d'apparence) */
#booster-close-btn::after {
  content: "";
  position: absolute;
  inset: -8px;
}
