/* challenge-banner.css — Indicateur défi actif (pill flottant, discret) */

#challengeBanner {
  position: fixed;
  bottom: 80px; /* au-dessus de la bottom nav */
  right: 16px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 8px;
  background: rgba(15, 15, 15, 0.92);
  border: 1px solid rgba(230, 57, 70, 0.5);
  border-radius: 32px;
  backdrop-filter: blur(10px);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(230, 57, 70, 0.15);
  cursor: default;
  animation: cbSlideIn 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
  max-width: 240px;
}

@keyframes cbSlideIn {
  from {
    transform: translateY(20px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* ── Avatar ── */
.cb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #e63946;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(230, 57, 70, 0.45);
}

/* ── Texte ── */
.cb-text {
  flex: 1;
  min-width: 0;
  line-height: 1.2;
}

.cb-pseudo {
  font-size: 0.75rem;
  font-weight: 700;
  color: #f0f0f0;
  font-family: "Oswald", Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cb-score {
  font-size: 0.65rem;
  color: #e63946;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Icône défi ── */
.cb-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ── Bouton dismiss ── */
.cb-dismiss {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #888;
  border-radius: 50%;
  /* WCAG 2.5.5 : taille cible minimale 44x44px */
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background 0.15s,
    color 0.15s;
  line-height: 1;
}
.cb-dismiss:hover {
  background: rgba(230, 57, 70, 0.25);
  color: #e63946;
}

/* ── Abandonner ──────────────────────────────────────────────
   Volontairement plus discret que le ✕ : c'est l'action qui ENGAGE
   (elle renonce vraiment au défi), alors que le ✕ ne fait que masquer.
   Un bouton flatteur inviterait au clic réflexe. */
.cb-abandon {
  background: none;
  border: 1px solid rgba(230, 57, 70, 0.35);
  color: #b0b0b0;
  border-radius: 8px;
  padding: 6px 10px;
  /* WCAG 2.5.5 : cible tactile d'au moins 44px de haut, comme le ✕. */
  min-height: 44px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}
.cb-abandon:hover:not(:disabled) {
  background: rgba(230, 57, 70, 0.18);
  border-color: #e63946;
  color: #e63946;
}
/* Désactivé pendant l'appel serveur : l'abandon attend la confirmation, un
   double-clic enverrait deux PATCH pour le même défi. */
.cb-abandon:disabled {
  opacity: 0.5;
  cursor: progress;
}

/* ── Dark mode ── */
body.darkmode #challengeBanner {
  background: rgba(8, 8, 8, 0.95);
  border-color: rgba(230, 57, 70, 0.6);
}

/* ── Mobile ── */
@media (max-width: 480px) {
  #challengeBanner {
    bottom: 70px;
    right: 10px;
    max-width: 200px;
  }
}

/* ── prefers-reduced-motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .challenge-banner,
  .btn-challenge,
  .cb-avatar {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
