/**
 * puzzle-captcha.css — MadaPayExchange
 * Styles du widget "puzzle glissant" (anti-robot maison).
 * Ne redéfinit que des classes préfixées .mp-captcha-* : n'entre en
 * conflit avec aucune autre feuille de style du site.
 */
.mp-captcha {
  margin: 14px 0 18px;
  user-select: none;
}

.mp-captcha-stage {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border, #1e2833);
  background: #0f151d;
  line-height: 0;
}

.mp-captcha-bg,
.mp-captcha-piece {
  display: block;
  width: 100%;
  height: auto;
}

.mp-captcha-piece {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateX(0px);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
  transition: filter 0.15s ease;
}

/* ===== AJOUT : transition douce (fondu) à chaque nouveau puzzle chargé ===== */
.mp-captcha-bg,
.mp-captcha-piece {
  transition: opacity 0.25s ease, filter 0.15s ease;
}
.mp-captcha--loading .mp-captcha-bg,
.mp-captcha--loading .mp-captcha-piece {
  opacity: 0;
}

/* ===== AJOUT : effet "snap" (rebond) quand le puzzle est validé =====
   La pièce se cale précisément dans l'encoche avec un léger overshoot,
   au lieu d'un saut instantané, pour un rendu plus fluide. */
.mp-captcha--solved .mp-captcha-piece {
  filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)) drop-shadow(0 0 6px rgba(0, 217, 126, 0.65));
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
}

/* ===== AJOUT : petite secousse discrète en cas d'échec de vérification ===== */
@keyframes mp-captcha-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.mp-captcha--error .mp-captcha-stage {
  animation: mp-captcha-shake 0.4s ease;
}

/* ===== AJOUT : indice discret — léger halo pulsant sur l'encoche quand
   la pièce approche de la bonne position pendant le glisser ===== */
.mp-captcha-hint {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.mp-captcha--near .mp-captcha-hint {
  opacity: 1;
  animation: mp-captcha-hint-pulse 0.9s ease-out infinite;
}
@keyframes mp-captcha-hint-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(0, 217, 126, 0.5); }
  70%  { box-shadow: 0 0 0 16px rgba(0, 217, 126, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 217, 126, 0); }
}
.mp-captcha--near .mp-captcha-piece {
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 7px rgba(0, 217, 126, 0.55));
}
.mp-captcha--near .mp-captcha-handle {
  box-shadow: 0 0 0 4px rgba(0, 217, 126, 0.22);
}

/* ===== AJOUT : petit "grip" visuel pendant le glisser (poignée) ===== */
.mp-captcha-handle.is-dragging {
  box-shadow: 0 0 0 6px rgba(0, 217, 126, 0.16);
}

/* ===== AJOUT : retour en douceur (au lieu d'un saut) quand la
   vérification échoue, juste avant de charger un nouveau puzzle ===== */
.mp-captcha--returning .mp-captcha-piece,
.mp-captcha--returning .mp-captcha-handle {
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), filter 0.15s ease, box-shadow 0.15s ease;
}
.mp-captcha--returning .mp-captcha-track-fill {
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.mp-captcha-refresh {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border, #1e2833);
  background: rgba(15, 21, 29, 0.75);
  color: var(--muted, #7c8894);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.mp-captcha-refresh:hover {
  color: var(--green, #00d97e);
  border-color: var(--green, #00d97e);
}

.mp-captcha-status {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}
.mp-captcha-status--ok { color: var(--green, #00d97e); }
.mp-captcha-status--error { color: var(--danger, #ff5c5c); }

.mp-captcha-track {
  position: relative;
  margin-top: 10px;
  height: 40px;
  border-radius: 8px;
  background: var(--card-2, #0f151d);
  border: 1px solid var(--border, #1e2833);
  overflow: hidden;
}

.mp-captcha-track-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: var(--green-dim, #0a3d2c);
  transition: width 0.05s linear;
}
/* AJOUT : remplissage final plus doux (avec léger rebond) à la validation */
.mp-captcha--solved .mp-captcha-track-fill {
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mp-captcha-track-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  color: var(--muted, #7c8894);
  font-family: 'Inter', sans-serif;
  pointer-events: none;
}

.mp-captcha--solved .mp-captcha-track-label {
  color: var(--green, #00d97e);
  font-weight: 600;
}

.mp-captcha-handle {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 36px;
  height: 34px;
  border-radius: 6px;
  background: var(--green, #00d97e);
  color: #06120c;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  transition: transform 0.05s linear, background 0.15s ease;
  z-index: 2;
}
.mp-captcha-handle:active,
.mp-captcha-handle.is-dragging {
  cursor: grabbing;
  background: #04ff9c;
}
.mp-captcha--solved .mp-captcha-handle {
  background: var(--green, #00d97e);
  /* AJOUT : la poignée termine sa course avec un léger rebond plutôt qu'un saut sec */
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s ease;
}
.mp-captcha--error .mp-captcha-handle {
  background: var(--danger, #ff5c5c);
  color: #fff;
}

.mp-captcha-handle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ============================================================
   AJOUT : classe utilitaire réutilisable pour cacher un bouton
   (ex : "Se connecter") tant que le puzzle n'est pas validé.
   Usage : entourer le bouton d'un <div class="mp-btn-gate" id="...">
   puis, dans les callbacks onVerified/onReset de MadaPayCaptcha.mount(),
   basculer la classe "mp-btn-gate--visible" sur ce conteneur.
   N'affecte que les éléments portant explicitement cette classe.
   ============================================================ */
.mp-btn-gate {
  max-height: 0;
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.34, 1.1, 0.64, 1),
              opacity 0.35s ease,
              transform 0.35s cubic-bezier(0.34, 1.1, 0.64, 1);
}
.mp-btn-gate--visible {
  max-height: 90px;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ============================================================
   AJOUT : apparition retardée + fondu doux du bloc captcha
   (utilisé sur login.html : le widget est monté après un court
   délai en JS, puis révélé ici en fondu + léger glissement).
   ============================================================ */
.mp-captcha-delayed {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.mp-captcha-delayed.mp-captcha-delayed--show {
  opacity: 1;
  transform: translateY(0);
}
