/* ============================================================
   Transitions inter-pages pour les écrans d'auth
   ============================================================ */

/* ── Animation d'entrée de la carte ───────────────────────── */
.auth-card {
  animation: authCardIn 380ms cubic-bezier(.22, 1, .36, 1) both;
  transform-origin: center top;
  will-change: transform, opacity;
}

@keyframes authCardIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── État "sortie" déclenché par le JS avant navigation ───── */
body.is-leaving .auth-card {
  animation: authCardOut 280ms cubic-bezier(.55, 0, .67, .2) forwards;
  pointer-events: none;
}

@keyframes authCardOut {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(.985);
    filter: blur(2px);
  }
}

/* Pendant la sortie, on estompe aussi le fond pour éviter le flash */
body.is-leaving {
  transition: background-color 280ms ease;
}

/* ── Hauteur fluide entre pages via View Transitions ──────── */
/* Chrome / Edge / Safari TP : la carte devient un "élément partagé"
   et anime automatiquement sa géométrie entre les deux pages.      */
@supports (view-transition-name: none) {
  .auth-card {
    view-transition-name: auth-card;
  }
}

/* Personnalisation de l'animation View Transition */
::view-transition-old(auth-card),
::view-transition-new(auth-card) {
  animation-duration: 380ms;
  animation-timing-function: cubic-bezier(.22, 1, .36, 1);
}

/* L'ancienne carte s'efface, la nouvelle apparaît — la taille
   s'interpole automatiquement entre les deux.                */
::view-transition-old(auth-card) {
  animation-name: vtFadeOut;
}
::view-transition-new(auth-card) {
  animation-name: vtFadeIn;
}

@keyframes vtFadeOut {
  to { opacity: 0; }
}
@keyframes vtFadeIn {
  from { opacity: 0; }
}

/* ── Respect des préférences utilisateur ──────────────────── */
@media (prefers-reduced-motion: reduce) {
  .auth-card,
  body.is-leaving .auth-card,
  ::view-transition-old(auth-card),
  ::view-transition-new(auth-card) {
    animation: none !important;
  }
}