/**
 * STYLES POUR LE SYSTÈME DE GAMIFICATION
 * ✅ Accessible (WCAG 2.1 AAA)
 * ✅ Responsive
 * ✅ Animations respectueuses (prefers-reduced-motion)
 */

/* ============================================================================
   VARIABLES
   ============================================================================ */

:root {
  --_gamification-primary: #8b5cf6;
  --_gamification-secondary: #10b981;
  --_gamification-warning: #f59e0b;
  --_gamification-danger: #ef4444;
  --_gamification-success: #10b981;

  --_gamification-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --_gamification-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --_gamification-shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.15);

  --_gamification-radius: 1rem;
  --_gamification-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   POPUP DE SCORE (positionné en haut à droite, pas au centre)
   ============================================================================ */

.gamification-score-popup {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: linear-gradient(
    135deg,
    var(--_gamification-primary) 0%,
    #764ba2 100%
  );
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--_gamification-radius);
  box-shadow: var(--_gamification-shadow-lg);
  z-index: 9999;
  pointer-events: none;
  text-align: center;
  min-width: 150px;
  animation: slideInRight 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.score-amount {
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.score-message {
  font-size: 0.875rem;
  font-weight: 600;
  opacity: 0.95;
}

.gamification-score-popup.fade-out {
  animation: slideOutRight 0.5s ease-out forwards;
}

@keyframes slideInRight {
  0% {
    opacity: 0;
    transform: translateX(100%);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  0% {
    opacity: 1;
    transform: translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ============================================================================
   MODAL DE BADGE
   ============================================================================ */

.gamification-badge-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.badge-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  animation: fadeIn 0.3s ease-out;
}

.badge-modal-content {
  position: relative;
  background: white;
  padding: 3rem;
  border-radius: calc(var(--_gamification-radius) * 1.5);
  text-align: center;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--_gamification-shadow-lg);
  animation: modalSlideIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.badge-icon {
  font-size: 5rem;
  line-height: 1;
  margin-bottom: 1.5rem;
  animation: badgeBounce 1s ease-in-out infinite;
}

.badge-modal-content h2 {
  font-size: 1.75rem;
  margin-bottom: 1rem;
  color: var(--_gamification-primary);
}

.badge-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #1f2937;
}

.badge-description {
  font-size: 1.125rem;
  color: #6b7280;
  margin-bottom: 2rem;
}

.badge-close-btn {
  padding: 1rem 2rem;
  font-size: 1.125rem;
  font-weight: 700;
  background: linear-gradient(
    135deg,
    var(--_gamification-primary) 0%,
    #764ba2 100%
  );
  color: white;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: transform var(--_gamification-transition);
  box-shadow: var(--_gamification-shadow-md);
}

.badge-close-btn:hover,
.badge-close-btn:focus {
  transform: scale(1.05);
  outline: 3px solid var(--_gamification-primary);
  outline-offset: 3px;
}

.badge-close-btn:active {
  transform: scale(0.98);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes badgeBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}

/* ============================================================================
   NOTIFICATION DE NIVEAU
   ============================================================================ */

.gamification-level-up {
  position: fixed;
  top: 2rem;
  right: 2rem;
  background: white;
  padding: 1.5rem 2rem;
  border-radius: var(--_gamification-radius);
  box-shadow: var(--_gamification-shadow-lg);
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 9998;
  animation: slideInRight 0.5s ease-out;
  border-left: 4px solid var(--_gamification-success);
}

.level-icon {
  font-size: 3rem;
  line-height: 1;
}

.level-message {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1f2937;
}

.gamification-level-up.fade-out {
  animation: slideOutRight 0.5s ease-out forwards;
}

@keyframes slideInRight {
  0% {
    opacity: 0;
    transform: translateX(100%);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  0% {
    opacity: 1;
    transform: translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateX(100%);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================================================
   BARRE DE PROGRESSION
   ============================================================================ */

.progress-bar-container {
  width: 100%;
  height: 1rem;
  background: #e5e7eb;
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--_gamification-secondary) 0%,
    var(--_gamification-primary) 50%,
    var(--_gamification-warning) 100%
  );
  border-radius: 9999px;
  transition: width var(--_gamification-transition);
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ============================================================================
   CARTES DE BADGES
   ============================================================================ */

.badge-card {
  background: white;
  border-radius: var(--_gamification-radius);
  padding: 1.5rem;
  box-shadow: var(--_gamification-shadow-sm);
  transition: all var(--_gamification-transition);
  text-align: center;
  border: 2px solid transparent;
}

.badge-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--_gamification-shadow-md);
}

.badge-card.unlocked {
  border-color: var(--_gamification-success);
  background: linear-gradient(to bottom, white 0%, #f0fdf4 100%);
}

.badge-card.locked {
  opacity: 0.6;
  filter: grayscale(100%);
}

.badge-card-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 1rem;
}

.badge-card-name {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #1f2937;
}

.badge-card-description {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.badge-card-date {
  display: block;
  font-size: 0.75rem;
  color: var(--_gamification-success);
  font-weight: 600;
  margin-top: 0.5rem;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
  .gamification-score-popup {
    padding: 1rem 1.5rem;
    min-width: 150px;
  }

  .score-amount {
    font-size: 2rem;
  }

  .score-message {
    font-size: 0.875rem;
  }

  .badge-modal-content {
    padding: 2rem 1.5rem;
    margin: 1rem;
  }

  .badge-icon {
    font-size: 4rem;
  }

  .badge-modal-content h2 {
    font-size: 1.5rem;
  }

  .badge-name {
    font-size: 1.25rem;
  }

  .gamification-level-up {
    top: 1rem;
    right: 1rem;
    left: 1rem;
    padding: 1rem;
  }

  .level-icon {
    font-size: 2rem;
  }

  .level-message {
    font-size: 1rem;
  }
}

/* ============================================================================
   ACCESSIBILITÉ - REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .badge-icon {
    animation: none !important;
  }

  .progress-bar-fill::after {
    animation: none !important;
  }
}

/* ============================================================================
   THÈME SOMBRE
   ============================================================================ */

:root[data-theme="dark"] {
  --gamification-primary: #a78bfa;
  --gamification-secondary: #34d399;
}

:root[data-theme="dark"] .badge-modal-content {
  background: #1f2937;
  color: #f9fafb;
}

:root[data-theme="dark"] .badge-name {
  color: #f9fafb;
}

:root[data-theme="dark"] .badge-description {
  color: #d1d5db;
}

:root[data-theme="dark"] .gamification-level-up {
  background: #1f2937;
  color: #f9fafb;
}

:root[data-theme="dark"] .badge-card {
  background: #1f2937;
  color: #f9fafb;
}

:root[data-theme="dark"] .badge-card.unlocked {
  background: linear-gradient(to bottom, #1f2937 0%, #064e3b 100%);
}

:root[data-theme="dark"] .badge-card-name {
  color: #f9fafb;
}

:root[data-theme="dark"] .badge-card-description {
  color: #d1d5db;
}

:root[data-theme="dark"] .progress-bar-container {
  background: #374151;
}

/* ============================================================================
   PROTECTIONS DE SÉCURITÉ ADDITIONNELLES
   ============================================================================ */

/* Protection contre les URLs malveillantes */
a[href^="javascript:"],
a[href^="data:"],
a[href^="vbscript:"] {
  pointer-events: none !important;
  cursor: not-allowed !important;
  opacity: 0.5;
  text-decoration: line-through;
}
