/* ============================================================
   MICRO-INTERACTIONS & DELIGHT
   Subtle, purposeful animations that enhance UX
   Based on Emil Kowalski design principles
   ============================================================ */

/* ============================================================
   BUTTON INTERACTIONS
   Les boutons du design system portent leurs propres feedbacks
   hover / active. On n'applique plus de règle globale qui casse
   les overlays (overflow) ou surcharge les transforms.
   ============================================================ */

/* Note : l'ancien ripple button::after était défini mais jamais animé
   (feature morte). Retiré. Utiliser les états explicites des boutons DS
   (btn-primary, mode-card, quiz-header__end-btn, etc.). */

/* ============================================================
   QUESTION BOX INTERACTIONS
   ============================================================ */

.question-box {
  position: relative;
  overflow: hidden;
}

/* Hover animation - subtle scale and color shift */
@media (hover: hover) and (pointer: fine) {
  .question-box:hover {
    animation: questionBoxPulse 600ms var(--ease-out);
  }
}

@keyframes questionBoxPulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in oklch, var(--color-primary-500) 40%, transparent);
  }
  70% {
    box-shadow: 0 0 0 6px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

/* ============================================================
   INPUT FOCUS ANIMATIONS
   ============================================================ */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  position: relative;
}

input:focus, select:focus, textarea:focus {
  animation: inputFocus 300ms var(--ease-out);
}

@keyframes inputFocus {
  from {
    box-shadow: 0 0 0 0 color-mix(in oklch, var(--color-primary-500) 30%, transparent);
  }
  to {
    box-shadow: var(--focus-ring);
  }
}

/* ============================================================
   BADGE & NOTIFICATION ANIMATIONS
   ============================================================ */

.badge {
  animation: badgeEnter 400ms var(--ease-out);
}

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

/* Success flash */
.badge-success {
  animation: successFlash 2000ms ease-out forwards;
}

@keyframes successFlash {
  0% {
    background-color: #22c55e;
    color: white;
  }
  100% {
    background-color: #dcfce7;
    color: #166534;
  }
}

/* ============================================================
   PROGRESS BAR ANIMATIONS
   ============================================================ */

.progress-fill {
  animation: progressFill 400ms var(--ease-out);
}

@keyframes progressFill {
  from {
    width: 0%;
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Pulse effect on progress fill for active sessions */
.progress-fill.active {
  animation: progressPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes progressPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 color-mix(in oklch, var(--color-primary-500) 40%, transparent);
  }
  50% {
    box-shadow: 0 0 0 8px transparent;
  }
}

/* ============================================================
   FEEDBACK MESSAGES
   ============================================================ */

.feedback-container {
  animation: feedbackSlide 300ms var(--ease-out);
}

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

/* Feedback réponse correcte — pulse subtil, easing standard (plus de bounce/elastic). */
.answer-option.correct {
  animation: answerPulse 320ms var(--ease-out);
}

@keyframes answerPulse {
  0%   { transform: scale(1); }
  55%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* Feedback réponse incorrecte — nudge horizontal court, easing standard (plus d'elastic négatif). */
.answer-option.incorrect {
  animation: answerNudge 260ms var(--ease-out);
}

@keyframes answerNudge {
  0%, 100% { transform: translateX(0); }
  30%      { transform: translateX(-4px); }
  70%      { transform: translateX(4px); }
}

/* ============================================================
   SIDEBAR INTERACTIONS
   ============================================================ */

.sidebar-inner {
  animation: sidebarFade 400ms var(--ease-out);
}

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

/* Question box number flip */
/* questionFlip retiré : le flip 3D sur chaque clic dans la sidebar
   navigation était distracting. Le feedback :active est déjà géré
   par question-box dans design-system.css (scale 0.97). */

/* ============================================================
   FLOATING LABEL ANIMATION (for future form inputs)
   ============================================================ */

.floating-label {
  position: relative;
}

.floating-label input {
  padding-top: 1.25rem;
  padding-bottom: 0.375rem;
}

.floating-label label {
  position: absolute;
  top: 0.625rem;
  left: 0.75rem;
  font-size: 0.875rem;
  color: #9ca3af;
  pointer-events: none;
  transition: all 200ms var(--ease-out);
}

.floating-label input:focus ~ label,
.floating-label input:not(:placeholder-shown) ~ label {
  top: 0.125rem;
  font-size: 0.75rem;
  color: var(--color-primary-500);
  font-weight: 600;
}

/* ============================================================
   TOAST NOTIFICATIONS (Future)
   ============================================================ */

.toast {
  animation: toastSlide 300ms var(--ease-out);
}

@keyframes toastSlide {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast.exiting {
  animation: toastExit 300ms var(--ease-out) forwards;
}

@keyframes toastExit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(100%);
  }
}

/* ============================================================
   STAGGER ANIMATIONS (for lists)
   ============================================================ */

.stagger-item {
  animation: staggerFade 400ms var(--ease-out) backwards;
}

.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 50ms; }
.stagger-item:nth-child(3) { animation-delay: 100ms; }
.stagger-item:nth-child(4) { animation-delay: 150ms; }
.stagger-item:nth-child(5) { animation-delay: 200ms; }
.stagger-item:nth-child(6) { animation-delay: 250ms; }
.stagger-item:nth-child(n+7) { animation-delay: 300ms; }

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

/* ============================================================
   LOADING SPINNER VARIATION
   ============================================================ */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid color-mix(in oklch, var(--color-primary-500) 20%, transparent);
  border-top-color: var(--color-primary-500);
  border-radius: 50%;
  animation: spinnerRotate 0.8s linear infinite;
}

@keyframes spinnerRotate {
  to {
    transform: rotate(360deg);
  }
}

.spinner.fast {
  animation-duration: 0.6s;
}

.spinner.slow {
  animation-duration: 1.2s;
}

/* ============================================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================================ */

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

/* ============================================================
   DARK MODE SUPPORT (Future)
   ============================================================ */

@media (prefers-color-scheme: dark) {
  button:focus-visible {
    outline-color: #60a5fa;
  }

  input:focus,
  select:focus,
  textarea:focus {
    border-color: #60a5fa;
  }
}
