/**
 * login-animations.css — couche d'ANIMATION de l'écran de connexion.
 *
 * PURELY ADDITIVE. Ce fichier n'écrase aucune règle du gabarit
 * (layouts/auth_login.php) ni de la vue (auth/login.php) : il n'ajoute que des
 * propriétés absentes de ces feuilles — `animation`, `transform-origin`,
 * `will-change` — et quelques pseudo-éléments décoratifs qui n'existaient pas.
 * Couleurs, tailles, espacements et disposition restent inchangés.
 *
 * SÉCURITÉ D'AFFICHAGE. Aucun élément n'est mis à `opacity: 0` dans son état
 * de base : l'état initial invisible ne vit que dans le `from` des keyframes,
 * appliqué via `animation-fill-mode: both`. Si ce fichier ne se charge pas
 * (cache, CDN, erreur réseau), la page reste parfaitement lisible — elle
 * s'affiche simplement sans mouvement.
 *
 * RTL. Les animations directionnelles (glissements, balayages) sont inversées
 * sous `[dir="rtl"]` : en arabe, un contenu qui entre par la gauche irait à
 * contre-sens de la lecture.
 *
 * ACCESSIBILITÉ. Tout est neutralisé sous `prefers-reduced-motion: reduce`
 * (voir la fin du fichier) — y compris les boucles ambiantes, qui sont la
 * première cause de gêne pour les personnes sensibles au mouvement.
 */

/* ═══════════════════════════════════════════════════════════════
   1. KEYFRAMES
   ═══════════════════════════════════════════════════════════════ */

/* — Entrées — */
@keyframes lgFadeUp {
  from { opacity: 0; transform: translate3d(0, 22px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes lgFadeDown {
  from { opacity: 0; transform: translate3d(0, -16px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes lgFadeInStart {
  from { opacity: 0; transform: translate3d(-26px, 0, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes lgFadeInStartRTL {
  from { opacity: 0; transform: translate3d(26px, 0, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes lgPopIn {
  0%   { opacity: 0; transform: scale(.72) translate3d(0, 14px, 0); }
  62%  { opacity: 1; transform: scale(1.045) translate3d(0, -3px, 0); }
  100% { opacity: 1; transform: scale(1) translate3d(0, 0, 0); }
}
@keyframes lgPanelIn {
  from { opacity: 0; transform: scale(1.04); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes lgRuleGrow {
  from { opacity: 0; transform: scaleX(0); }
  to   { opacity: 1; transform: scaleX(1); }
}

/* — Boucles ambiantes — */
@keyframes lgFloat {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50%      { transform: translate3d(0, -9px, 0); }
}
@keyframes lgOrbDrift1 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  33%      { transform: translate3d(-24px, 26px, 0) scale(1.07); }
  66%      { transform: translate3d(14px, 40px, 0) scale(.95); }
}
@keyframes lgOrbDrift2 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  40%      { transform: translate3d(30px, -22px, 0) scale(1.09); }
  75%      { transform: translate3d(-16px, -34px, 0) scale(.97); }
}
@keyframes lgAura {
  0%, 100% { opacity: .30; transform: translate3d(0, 0, 0) scale(1); }
  50%      { opacity: .55; transform: translate3d(0, -18px, 0) scale(1.12); }
}
/* Balayage lumineux : parcourt l'élément d'un bord à l'autre puis s'efface. */
@keyframes lgSweep {
  0%   { transform: translate3d(-140%, 0, 0) skewX(-18deg); }
  55%  { transform: translate3d(240%, 0, 0)  skewX(-18deg); }
  100% { transform: translate3d(240%, 0, 0)  skewX(-18deg); }
}
@keyframes lgSweepRTL {
  0%   { transform: translate3d(140%, 0, 0) skewX(18deg); }
  55%  { transform: translate3d(-240%, 0, 0) skewX(18deg); }
  100% { transform: translate3d(-240%, 0, 0) skewX(18deg); }
}
@keyframes lgRuleShine {
  0%, 100% { opacity: .35; }
  50%      { opacity: 1; }
}

/* — Interactions — */
@keyframes lgIconPop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.22) rotate(-6deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes lgIconBounce {
  0%   { transform: translate3d(0, 0, 0); }
  40%  { transform: translate3d(0, -5px, 0) scale(1.1); }
  70%  { transform: translate3d(0, 1px, 0) scale(.97); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes lgThemeSpin {
  from { opacity: 0; transform: rotate(-90deg) scale(.5); }
  to   { opacity: 1; transform: rotate(0) scale(1); }
}
@keyframes lgCheckDraw {
  from { stroke-dashoffset: 26; }
  to   { stroke-dashoffset: 0; }
}
@keyframes lgShake {
  0%, 100%   { transform: translate3d(0, 0, 0); }
  15%, 45%, 75% { transform: translate3d(-6px, 0, 0); }
  30%, 60%, 90% { transform: translate3d(6px, 0, 0); }
}
@keyframes lgPulseRing {
  0%   { box-shadow: 0 0 0 0 rgba(85, 102, 232, .35); }
  70%  { box-shadow: 0 0 0 12px rgba(85, 102, 232, 0); }
  100% { box-shadow: 0 0 0 0 rgba(85, 102, 232, 0); }
}

/* ═══════════════════════════════════════════════════════════════
   2. PANNEAU DE MARQUE
   ═══════════════════════════════════════════════════════════════ */

.lg-brand {
  animation: lgPanelIn .85s cubic-bezier(.22, 1, .36, 1) both;
  will-change: transform, opacity;
}

/* Halo respirant, ajouté en pseudo-élément : aucun nœud du DOM n'est requis.
   Placé sous le contenu (z-index 0, le contenu est en z-index 1). */
.lg-brand::after {
  content: '';
  position: absolute;
  width: 62%; padding-bottom: 62%;
  top: 50%; left: 50%;
  margin: -31% 0 0 -31%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.16) 0%, transparent 68%);
  pointer-events: none;
  z-index: 0;
  animation: lgAura 9s ease-in-out infinite;
}

.lg-orb-1 { animation: lgOrbDrift1 26s ease-in-out infinite; will-change: transform; }
.lg-orb-2 { animation: lgOrbDrift2 32s ease-in-out infinite 1.5s; will-change: transform; }

.lg-logo {
  animation:
    lgPopIn .95s cubic-bezier(.34, 1.32, .5, 1) .10s both,
    lgFloat 6s ease-in-out 1.2s infinite;
  will-change: transform;
}
.lg-brand-name    { animation: lgFadeUp .8s cubic-bezier(.22, 1, .36, 1) .30s both; }
.lg-brand-sub     { animation: lgFadeUp .8s cubic-bezier(.22, 1, .36, 1) .40s both; }
.lg-brand-rule    { animation: lgRuleGrow .7s cubic-bezier(.22, 1, .36, 1) .52s both,
                               lgRuleShine 4.5s ease-in-out 1.4s infinite; }

/* ═══════════════════════════════════════════════════════════════
   3. BARRE SUPÉRIEURE (langues + thème)
   ═══════════════════════════════════════════════════════════════ */

.lg-topbar { animation: lgFadeDown .7s cubic-bezier(.22, 1, .36, 1) .25s both; }

.lg-theme svg { transform-origin: 50% 50%; }
.lg-theme:hover svg { animation: lgIconPop .5s cubic-bezier(.34, 1.3, .5, 1); }
/* L'icône visible tourne à l'arrivée : la bascule de thème se lit comme un
   changement, pas comme un simple remplacement d'image. */
.lg-theme .ico-moon,
.lg-theme .ico-sun { animation: lgThemeSpin .45s cubic-bezier(.34, 1.3, .5, 1) both; }

.lg-lang { position: relative; }
.lg-lang::after {
  content: '';
  position: absolute; bottom: 2px;
  inset-inline-start: 50%; width: 0; height: 2px;
  border-radius: 2px; background: var(--lg-primary);
  transform: translateX(-50%);
  transition: width .25s cubic-bezier(.4, 0, .2, 1);
}
.lg-lang:hover::after { width: 60%; }
.lg-lang.active::after { width: 0; }

/* ═══════════════════════════════════════════════════════════════
   4. FORMULAIRE — entrée orchestrée
   ═══════════════════════════════════════════════════════════════ */

.lc-title    { animation: lgFadeInStart .75s cubic-bezier(.22, 1, .36, 1) .18s both; }
.lc-subtitle { animation: lgFadeInStart .75s cubic-bezier(.22, 1, .36, 1) .26s both; }

.lc-field:nth-of-type(1) { animation: lgFadeUp .7s cubic-bezier(.22, 1, .36, 1) .34s both; }
.lc-field:nth-of-type(2) { animation: lgFadeUp .7s cubic-bezier(.22, 1, .36, 1) .42s both; }
.lc-remember             { animation: lgFadeUp .7s cubic-bezier(.22, 1, .36, 1) .50s both; }
.lc-btn                  { animation: lgFadeUp .7s cubic-bezier(.22, 1, .36, 1) .58s both; }
.lc-forgot               { animation: lgFadeUp .7s cubic-bezier(.22, 1, .36, 1) .66s both; }
.lc-divider              { animation: lgFadeUp .7s cubic-bezier(.22, 1, .36, 1) .74s both; }
.lc-legal                { animation: lgFadeUp .7s cubic-bezier(.22, 1, .36, 1) 1.10s both; }

/* Cartes de rôle : apparition en cascade, de gauche à droite. */
.lc-role:nth-child(1) { animation: lgPopIn .62s cubic-bezier(.34, 1.3, .5, 1) .82s both; }
.lc-role:nth-child(2) { animation: lgPopIn .62s cubic-bezier(.34, 1.3, .5, 1) .89s both; }
.lc-role:nth-child(3) { animation: lgPopIn .62s cubic-bezier(.34, 1.3, .5, 1) .96s both; }
.lc-role:nth-child(4) { animation: lgPopIn .62s cubic-bezier(.34, 1.3, .5, 1) 1.03s both; }
/* En RTL la cascade part du bord droit, dans le sens de lecture. */
[dir="rtl"] .lc-role:nth-child(1) { animation-delay: 1.03s; }
[dir="rtl"] .lc-role:nth-child(2) { animation-delay: .96s; }
[dir="rtl"] .lc-role:nth-child(3) { animation-delay: .89s; }
[dir="rtl"] .lc-role:nth-child(4) { animation-delay: .82s; }

[dir="rtl"] .lc-title,
[dir="rtl"] .lc-subtitle { animation-name: lgFadeInStartRTL; }

/* ═══════════════════════════════════════════════════════════════
   5. CHAMPS — réactions à la saisie
   ═══════════════════════════════════════════════════════════════ */

.lc-control > svg { transform-origin: 50% 50%; }
/* L'icône du champ actif s'anime et prend la couleur d'accent : le focus se
   voit même en vision périphérique. */
.lc-control:focus-within > svg {
  color: var(--lg-primary);
  animation: lgIconPop .45s cubic-bezier(.34, 1.3, .5, 1);
}
.lc-control:focus-within .lc-prefix {
  color: var(--lg-primary);
  transition: color .25s cubic-bezier(.4, 0, .2, 1);
}
.lc-eye:active { transform: scale(.86); }

/* Coche « se souvenir de moi » : le trait se dessine au lieu d'apparaître. */
.lc-remember input:checked + .lc-check svg {
  stroke-dasharray: 26;
  animation: lgCheckDraw .34s cubic-bezier(.65, 0, .35, 1) .04s both;
}
.lc-remember input:checked + .lc-check { animation: lgPulseRing .55s ease-out; }

/* ═══════════════════════════════════════════════════════════════
   6. BOUTON PRIMAIRE — balayage lumineux
   ═══════════════════════════════════════════════════════════════ */

.lc-btn { position: relative; overflow: hidden; }
.lc-btn > * { position: relative; z-index: 1; }
.lc-btn::after {
  content: '';
  position: absolute; top: 0; bottom: 0;
  inset-inline-start: 0;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.28), transparent);
  pointer-events: none;
  z-index: 0;
  animation: lgSweep 4.2s ease-in-out 1.8s infinite;
}
[dir="rtl"] .lc-btn::after { animation-name: lgSweepRTL; }
/* Au survol, le balayage accélère — la réponse est immédiate et lisible. */
.lc-btn:hover::after { animation-duration: 1.5s; animation-delay: 0s; }

/* ═══════════════════════════════════════════════════════════════
   7. CARTES DE RÔLE
   ═══════════════════════════════════════════════════════════════ */

.lc-role svg { transform-origin: 50% 60%; }
.lc-role:hover svg { animation: lgIconBounce .55s cubic-bezier(.34, 1.3, .5, 1); }

/* Liseré qui se déploie sous la carte survolée. */
.lc-role { position: relative; overflow: hidden; }
.lc-role::after {
  content: '';
  position: absolute; bottom: 0;
  inset-inline-start: 50%; width: 0; height: 2px;
  background: var(--lg-primary);
  transform: translateX(-50%);
  transition: width .3s cubic-bezier(.4, 0, .2, 1);
}
.lc-role:hover::after { width: 100%; }

/* ═══════════════════════════════════════════════════════════════
   8. ALERTES
   ═══════════════════════════════════════════════════════════════ */

/* Une erreur de connexion se signale : glissement puis secousse brève. */
.lc-alert.err {
  animation:
    lgFadeDown .35s cubic-bezier(.22, 1, .36, 1) both,
    lgShake .5s cubic-bezier(.36, .07, .19, .97) .3s;
}
.lc-alert.ok { animation: lgFadeDown .4s cubic-bezier(.22, 1, .36, 1) both; }

/* ═══════════════════════════════════════════════════════════════
   9. FORMULAIRE D'INSCRIPTION (layouts/auth_form)
   Même vocabulaire de mouvement que la connexion : les deux écrans se
   suivent dans un parcours, ils doivent s'animer de la même manière.
   ═══════════════════════════════════════════════════════════════ */

.af-top  { animation: lgFadeDown .6s cubic-bezier(.22, 1, .36, 1) both; }
.rg-card { animation: lgFadeUp .7s cubic-bezier(.22, 1, .36, 1) .10s both; }
.rg-head { animation: lgFadeUp .65s cubic-bezier(.22, 1, .36, 1) .22s both; }
.rg-logo {
  animation:
    lgPopIn .8s cubic-bezier(.34, 1.32, .5, 1) .18s both,
    lgFloat 6s ease-in-out 1.2s infinite;
}

/* Le champ actif réagit comme sur la connexion. */
.rg-control > svg { transform-origin: 50% 50%; }
.rg-control:focus-within > svg {
  color: var(--lg-primary);
  animation: lgIconPop .45s cubic-bezier(.34, 1.3, .5, 1);
}
.rg-control:focus-within .rg-prefix {
  color: var(--lg-primary);
  transition: color .25s cubic-bezier(.4, 0, .2, 1);
}
.rg-eye:active { transform: scale(.86); }

/* Coche WhatsApp : trait dessiné + onde verte (accent du bloc). */
.rg-wa input:checked + .rg-wa-box svg {
  stroke-dasharray: 26;
  animation: lgCheckDraw .34s cubic-bezier(.65, 0, .35, 1) .04s both;
}
@keyframes rgPulseGreen {
  0%   { box-shadow: 0 0 0 0 rgba(37, 211, 102, .40); }
  70%  { box-shadow: 0 0 0 11px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}
.rg-wa input:checked + .rg-wa-box { animation: rgPulseGreen .55s ease-out; }

/* Bouton : même balayage lumineux que « Se connecter ». */
.rg-btn { position: relative; overflow: hidden; }
.rg-btn > * { position: relative; z-index: 1; }
.rg-btn::after {
  content: '';
  position: absolute; top: 0; bottom: 0;
  inset-inline-start: 0; width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.28), transparent);
  pointer-events: none; z-index: 0;
  animation: lgSweep 4.2s ease-in-out 2.2s infinite;
}
[dir="rtl"] .rg-btn::after { animation-name: lgSweepRTL; }
.rg-btn:hover::after { animation-duration: 1.5s; animation-delay: 0s; }

/* Erreur de validation : même signalement que sur la connexion. */
.rg-alert {
  animation:
    lgFadeDown .35s cubic-bezier(.22, 1, .36, 1) both,
    lgShake .5s cubic-bezier(.36, .07, .19, .97) .3s;
}

/* Le bloc Spécialité apparaît quand un niveau l'exige — il ne doit pas
   surgir sèchement au milieu du formulaire. */
#specialty-group { animation: lgFadeUp .4s cubic-bezier(.22, 1, .36, 1) both; }

/* ═══════════════════════════════════════════════════════════════
   10. MOUVEMENT RÉDUIT — neutralisation complète
   ═══════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .lg-brand, .lg-brand::after, .lg-orb-1, .lg-orb-2, .lg-logo,
  .lg-brand-name, .lg-brand-sub, .lg-brand-rule,
  .lg-topbar, .lg-theme:hover svg, .lg-theme .ico-moon, .lg-theme .ico-sun,
  .lc-title, .lc-subtitle, .lc-field, .lc-remember, .lc-btn, .lc-btn::after,
  .lc-forgot, .lc-divider, .lc-legal, .lc-role, .lc-role:hover svg,
  .lc-control:focus-within > svg, .lc-remember input:checked + .lc-check,
  .lc-remember input:checked + .lc-check svg,
  .lc-alert.err, .lc-alert.ok,
  .af-top, .rg-card, .rg-head, .rg-logo, .rg-alert, .rg-btn::after,
  .rg-control:focus-within > svg, #specialty-group,
  .rg-wa input:checked + .rg-wa-box,
  .rg-wa input:checked + .rg-wa-box svg {
    animation: none !important;
  }
  /* Les traits des coches doivent rester entièrement tracés sans animation. */
  .lc-remember input:checked + .lc-check svg,
  .rg-wa input:checked + .rg-wa-box svg { stroke-dasharray: none; }
  /* Les transitions courtes sont conservées mais ramenées à l'imperceptible. */
  .lg-lang::after, .lc-role::after { transition-duration: .01ms; }
}
