/* ============================================================
   Écrans de connexion en DS2 (pages autonomes, tous les rôles)
   ------------------------------------------------------------
   Pages concernées : auth/login.html, auth/magic_link_sent.html,
   auth/adresse_probleme.html, auth/connexion_sms.html, qui
   étendent toutes auth/_base_carte.html.
   Chargée APRÈS client_design_system2.css. Aucun jeton nouveau :
   tout vient de .ta-v2. Préfixe .cx- pour ne rien heurter.

   Un seul formulaire de connexion, deux modes posés sur la carte :
     data-mode="lien"  lien de connexion (défaut)
     data-mode="mdp"   mot de passe
   Tout élément propre à un mode porte data-pour="lien|mdp".
   ============================================================ */

/* Sans Bootstrap, plus personne ne pose border-box : un bouton à
   width:100% avec bordure et marge intérieure déborderait de sa carte. */
.cx-page, .cx-page *, .cx-page *::before, .cx-page *::after { box-sizing: border-box; }

.cx-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 32px 16px; background: var(--color-creme);
}
.cx-colonne { width: 100%; max-width: 420px; }
.cx-logo { display: block; width: 150px; height: auto; margin: 0 auto 24px; }

.ta-v2-scope .cx-carte { padding: 28px 24px; }
.cx-titre { font: 800 22px/1.2 var(--font-nunito); letter-spacing: -.02em; color: var(--color-encre); margin: 0 0 6px; }
.cx-sous { font: 400 14px/1.45 var(--font-nunito); color: var(--color-encre-2); margin: 0 0 20px; }

/* Modes : un élément propre à l'autre mode n'est pas rendu. */
.cx-carte[data-mode="lien"] [data-pour="mdp"],
.cx-carte[data-mode="mdp"] [data-pour="lien"] { display: none; }

/* Messages (flash et erreurs). Pas de croix de fermeture : la page se
   recharge à chaque envoi, le message ne s'accumule pas. */
.cx-alerte {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--r-carte); padding: 12px 14px; margin: 0 0 16px;
  font: 600 14px/1.45 var(--font-nunito);
}
.cx-alerte > svg { flex: none; margin-top: 2px; }
.cx-alerte__corps { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.cx-alerte--danger { background: var(--color-rouge-clair); color: var(--color-rouge-fonce); }
.cx-alerte--success { background: var(--color-succes-bg); color: var(--color-succes); }
.cx-alerte--warning { background: var(--color-attention-bg); color: var(--color-encre); }
/* Le texte ambre sur fond ambre du DS2 est trop pâle pour 14 px : le texte passe
   en encre, l'ambre reste sur l'icône. */
.cx-alerte--warning > svg { color: var(--color-attention); }
.cx-alerte--info { background: var(--color-hover); color: var(--color-encre); }
/* Lien d'action DANS un message : zone de toucher d'au moins 44 px. */
.cx-alerte a.cx-alerte__action { display: inline-flex; align-items: center; min-height: 44px; color: inherit; font-weight: 800; text-decoration: underline; }

.cx-form { display: flex; flex-direction: column; gap: 16px; }

/* Lien de bascule entre les deux modes. Zone de toucher de 44 px. */
.cx-lien {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px;
  margin-top: 4px; padding: 0 8px; border: none; background: transparent; cursor: pointer;
  border-radius: var(--r-controle); text-decoration: none;
  font: 700 14px/1.2 var(--font-nunito); color: var(--color-encre); text-align: center;
}
.cx-lien:hover { text-decoration: underline; }
.cx-lien:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* « Mot de passe oublié » : à droite, sous le champ, là où on en a besoin. */
.cx-oublie { display: flex; justify-content: flex-end; margin-top: -6px; }
.cx-oublie a { display: inline-flex; align-items: center; min-height: 44px; margin: -8px 0; font: 600 13px/1.2 var(--font-nunito); color: var(--color-encre); text-decoration: none; }
.cx-oublie a:hover { text-decoration: underline; }

/* Note rassurante. encre-2 et non ardoise : lisible en petit texte. */
.cx-note { display: flex; gap: 6px; align-items: center; justify-content: center; margin: 12px 0 0; font: 400 13px/1.4 var(--font-nunito); color: var(--color-encre-2); text-align: center; }
.cx-note svg { flex: none; }

.cx-sep { display: flex; align-items: center; gap: 12px; margin: 20px 0; font: 700 11px/1 var(--font-nunito); letter-spacing: .06em; text-transform: uppercase; color: var(--color-encre-2); }
.cx-sep::before, .cx-sep::after { content: ''; flex: 1; height: 1px; background: var(--color-filet); }

/* Retour visuel à l'envoi : remplace .btn-loading de l'ancienne page. */
.ta-v2 .ta-btn .cx-spin { display: none; width: 16px; height: 16px; flex: none; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: var(--r-rond); }
.ta-v2 .ta-btn--secondary .cx-spin { border-color: var(--color-filet-fort); border-top-color: var(--color-encre); }
.ta-v2 .ta-btn.cx-charge { pointer-events: none; }
.ta-v2 .ta-btn.cx-charge .cx-spin { display: inline-block; animation: cx-tour .8s linear infinite; }
@keyframes cx-tour { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .ta-v2 .ta-btn.cx-charge .cx-spin { animation-duration: 2.4s; } }

/* Porte d'entrée pour qui n'a pas de compte : sous la carte, hors du formulaire. */
.cx-nouveau { margin-top: 20px; }
.cx-nouveau__titre { margin: 0 0 10px; text-align: center; font: 700 13px/1.3 var(--font-nunito); color: var(--color-encre-2); }
.cx-choix { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 16px; margin-bottom: 10px; background: var(--color-surface); border: 1px solid var(--color-filet-fort); border-radius: var(--r-carte); text-decoration: none; color: var(--color-encre); transition: background var(--ease-standard); }
.cx-choix:hover { background: var(--color-hover); }
.cx-choix:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cx-choix__texte { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cx-choix__titre { font: 700 15px/1.2 var(--font-nunito); }
.cx-choix__sous { font: 400 13px/1.3 var(--font-nunito); color: var(--color-encre-2); }
.cx-choix > svg { flex: none; color: var(--color-encre-2); }

/* Écran « Regardez vos courriels ». */
.cx-envoi { text-align: center; }
.cx-envoi__icone { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin-bottom: 14px; border-radius: var(--r-rond); background: var(--color-succes-bg); color: var(--color-succes); }
.cx-envoi .cx-sous { margin-bottom: 8px; }
/* Un formulaire dans une carte centrée (second facteur, SMS) reste aligné à gauche : étiquette, aide et case. */
.cx-envoi .cx-form { text-align: left; }
.cx-envoi .cx-sous strong { color: var(--color-encre); overflow-wrap: anywhere; }
.cx-aide { margin: 20px 0; padding: 14px 16px; text-align: left; background: var(--color-creme); border: 1px solid var(--color-filet); border-radius: var(--r-carte); font: 400 14px/1.45 var(--font-nunito); color: var(--color-encre-2); }
.cx-aide__titre { margin: 0 0 6px; font: 700 14px/1.3 var(--font-nunito); color: var(--color-encre); }
.cx-aide ul { margin: 0; padding-left: 18px; }
.cx-aide li + li { margin-top: 4px; }
.cx-aide a { color: var(--color-encre); font-weight: 700; }
.cx-envoi__actions { display: flex; flex-direction: column; gap: 4px; }

@media (max-width: 480px) {
  .cx-page { align-items: flex-start; padding: 24px 16px; }
  .ta-v2-scope .cx-carte { padding: 24px 20px; }
}

/* Texte réservé aux lecteurs d'écran (annonce « Envoi du lien… »). */
.cx-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Zones de toucher : 48 px pour les boutons de cette page (le DS2 en pose 40),
   et le lien « Créer un compte » de l'aide devient une vraie cible. */
.ta-v2 .cx-carte .ta-btn--md { min-height: 48px; }
.cx-aide li a { display: inline-flex; align-items: center; min-height: 44px; margin: -12px 0; }

/* Écrans de secours (adresse bloquée, connexion par SMS). Même carte que
   « Regardez vos courriels », avec une icône d'attention au lieu de succès. */
.cx-envoi__icone--attention { background: var(--color-attention-bg); color: var(--color-attention); }
.cx-code { letter-spacing: .32em; font-weight: 700; }
.cx-code::placeholder { letter-spacing: normal; font-weight: 400; }

/* Choix d'un mot de passe (auth/_mot_de_passe.html + js/auth_mot_de_passe.js). */
/* Le bloc des deux champs est un seul enfant du formulaire : il porte lui-même l'espacement. */
.cx-form [data-mdp] { display: flex; flex-direction: column; gap: 16px; }
.cx-oeil {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin: -11px -13px -11px 0; padding: 0;
  border: none; background: transparent; cursor: pointer; color: var(--color-encre-2);
  border-radius: var(--r-controle);
}
.cx-oeil:hover { color: var(--color-encre); }
.cx-oeil__vu, .cx-oeil__barre { display: inline-flex; }
.cx-oeil__barre { display: none; }
.cx-oeil[aria-pressed="true"] .cx-oeil__vu { display: none; }
.cx-oeil[aria-pressed="true"] .cx-oeil__barre { display: inline-flex; }

.cx-force { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.cx-force[hidden] { display: none; }
.cx-force__barre { flex: 1; height: 6px; overflow: hidden; background: var(--color-filet); border-radius: var(--r-rond); }
.cx-force__niveau { display: block; height: 100%; width: 0; background: var(--color-rouge); border-radius: var(--r-rond); transition: width var(--ease-standard); }
.cx-force[data-niveau="faible"] .cx-force__niveau { width: 25%; }
.cx-force[data-niveau="moyen"] .cx-force__niveau { width: 50%; background: var(--color-attention); }
.cx-force[data-niveau="bon"] .cx-force__niveau { width: 75%; background: var(--color-succes); }
.cx-force[data-niveau="fort"] .cx-force__niveau { width: 100%; background: var(--color-succes); }
.cx-force__texte { min-width: 64px; text-align: right; font: 700 13px/1 var(--font-nunito); color: var(--color-encre-2); }

.cx-regles { margin-top: 10px; padding: 12px 14px; background: var(--color-creme); border: 1px solid var(--color-filet); border-radius: var(--r-carte); font: 400 13px/1.45 var(--font-nunito); color: var(--color-encre-2); }
.cx-regles__titre { margin: 0; font: 700 13px/1.3 var(--font-nunito); color: var(--color-encre); }
.cx-regles ul { margin: 6px 0 0; padding-left: 18px; }

.cx-correspondance { display: flex; align-items: center; gap: 6px; margin: 2px 0 0; font: 600 13px/1.4 var(--font-nunito); }
.cx-correspondance[hidden] { display: none; }
.cx-correspondance[data-etat="oui"] { color: var(--color-succes); }
.cx-correspondance[data-etat="non"] { color: var(--color-rouge-fonce); }

/* Une phrase puis un lien à toucher, centrés : « Besoin d'aide ? (438)… », « Vous vous souvenez… ». */
.cx-ligne-lien { margin: 8px 0 0; text-align: center; font: 400 14px/1.4 var(--font-nunito); color: var(--color-encre-2); }
.cx-ligne-lien a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--color-encre); font-weight: 700; text-decoration: none; }
.cx-ligne-lien a:hover { text-decoration: underline; }
.cx-ligne-lien--tel a { white-space: nowrap; }

/* Lignes d'avertissement (suppression de compte) : icône + phrase. */
.cx-avertissement { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 10px; padding: 12px 14px; text-align: left; background: var(--color-attention-bg); border-radius: var(--r-carte); font: 600 14px/1.45 var(--font-nunito); color: var(--color-encre); }
.cx-avertissement > svg { flex: none; margin-top: 2px; color: var(--color-attention); }

/* Étapes numérotées (vérification du courriel en attente). */
.cx-aide ol { margin: 0; padding-left: 20px; }
.cx-aide ol li + li { margin-top: 8px; }
.cx-aide ol strong { color: var(--color-encre); }
.cx-aide ol span { display: block; font-size: 13px; }
.cx-aide + .cx-aide { margin-top: -6px; }

.cx-aide p:not(.cx-aide__titre):not(.cx-aide__sous) { margin: 0; }
/* Un lien au milieu d'une phrase reste dans la phrase, mais sa zone à toucher dépasse 44 px (marges négatives : l'interligne ne bouge pas). */
.cx-aide p a { display: inline-block; padding: 13px 2px; margin: -13px 0; color: var(--color-encre); font-weight: 700; }
.cx-aide__sous { margin: 10px 0 4px; font: 700 13px/1.3 var(--font-nunito); color: var(--color-encre-2); }
.cx-aide ul + .cx-aide__sous { margin-top: 12px; }
