/* ============================================================================
   L ECRAN DE CONNEXION ET L ECRAN DE CHOIX, AU STYLE DE L ESPACE MEMBRE
   ============================================================================
   Demande de Nadir du 14/10 : « on enlève le fond Bourse à l'Aube et on
   applique les caractéristiques esthétiques de l'espace membre ».

   ⛔ CE FICHIER NE TOUCHE QUE LES DEUX ECRANS PARTAGES, #authScreen et
   #choixEspace : ce sont les seuls que la regle « le journal ne bouge pas »
   laisse ouverts. Rien ici ne mord sur #mainApp ni #coachApp.
   ⚠️ Il est charge APRES aube.css et ses regles portent `!important` parce
   que aube.css pose la photographie de bureau en `!important` aussi.
   La palette est celle de assets/formation.css, recopiee ici parce que ces
   variables vivent sur #formationApp et pas sur ces ecrans.
   ========================================================================== */

/* ── Le fond de la page elle-meme, derriere tout ──────────────────────────
   ⚠️ C est `<html>` qui se voit quand on tire la page au-dela de son bord
   (le rebond de macOS et d iOS) : retour de Nadir du 14/10, « quand je swipe
   en haut à gauche, ça laisse apparaître une petite ligne blanche ». Et c est
   lui qu on voit entre deux ecrans, le temps d une requete : « un fond bleu
   nuit » au chargement de l espace membre.
   ⛔ aube.css peint `html:has(body.dark-mode)` en bleu nuit et `html` en creme,
   et sa regle `:has` l emporte sur un simple `html`. Les notres ciblent donc
   les ETATS ou l on n est pas dans le journal, avec `!important`, et le journal
   garde son fond a lui : la regle ne mord que tant que ces etats sont la.
   - l ecran de connexion ou l ecran de choix est affiche ;
   - on attend l espace membre (`html[data-attente]`, pose par supabase-acces.js) ;
   - on est dans l espace membre (`body[data-espace="formation"]`). */
html { background: #0a0a0d; }
html[data-attente="formation"],
html:has(body[data-espace="formation"]),
html:has(#authScreen[style*="display: flex"]),
html:has(#choixEspace[style*="display: flex"]) { background: #0a0a0d !important; }
/* ⚠️ Et le journal reste masque tant qu on attend l espace membre : c est lui
   qui faisait le « fond bleu nuit », affiche par `login()` avant que les droits
   soient lus. Specificite (1,1,1) : passe devant `#mainApp.flex` (1,1,0). */
html[data-attente="formation"] #mainApp { display: none !important; }

/* ── Le pied de page legal du journal, pendant le chargement ──────────────────
   ⚠️ Retour de Nadir du 14/10 : « ça affiche une page CGV en haut, avec un
   petit bandeau bleu, juste avant la transition ». C est `.app-footer`
   (aube.css : bande bleu nuit, liens Mentions / CGV / CGU / Confidentialité),
   enfant direct de `<body>`. Tant que la session se verifie, aucun espace n est
   affiche, et ce pied de page est la SEULE chose a l ecran : il remonte en haut
   d une page vide. aube.css ne le masque que quand l ecran de connexion est
   affiche, c est-a-dire APRES cette attente. ⛔ Il ne se montre donc que quand
   le journal ou l espace coach est a l ecran, les seuls qui le portent. */
body:not(:has(#mainApp[style*="display: flex"], #coachApp[style*="display: flex"])) > .app-footer { display: none !important; }
/* ⚠️ Et pendant l attente de l espace membre : `login()` a pose `#mainApp` en
   flex (masque par la regle au-dessus), le pied de page se croyait donc dans le
   journal et remontait seul, en bleu. Retour de Nadir du 14/10, deuxieme fois. */
html[data-attente="formation"] .app-footer { display: none !important; }

/* ── Le voile de chargement ──────────────────────────────────────────────────
   « Il ne faut plus de pages entre deux ; je préfère un écran noir au
   chargement » (Nadir, 14/10). `#cxVoile` est le premier enfant de `<body>` :
   un fond sombre et la marque, par-dessus tout, des le premier rendu. Il tombe
   des qu un ecran est reellement a l ecran. ⛔ Pendant l attente de l espace
   membre, il reste meme si `#mainApp` est en flex : c est le cas qui laissait
   voir le journal, puis le pied de page, le temps d une requete.
   ⚠️ Un voile qui ne tomberait jamais serait pire qu un flash : le filet de
   `index.html` (5 s) affiche l ecran de connexion si rien n est visible, et
   cette regle le laisse passer. */
.cx-voile {
  position: fixed; inset: 0; z-index: 99990;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse 80% 55% at 50% 0%, rgba(232, 184, 75, .14), transparent 62%),
    radial-gradient(ellipse 120% 90% at 50% 50%, #101014, #0a0a0d 70%);
}
.cx-voile__marque {
  width: 180px; aspect-ratio: 1211 / 224; display: block;
  background-color: #e8b84b; opacity: .9;
  -webkit-mask: url('/assets/marque/t360-logo.svg') no-repeat center / contain;
  mask: url('/assets/marque/t360-logo.svg') no-repeat center / contain;
}
body:has(#authScreen[style*="display: flex"]) .cx-voile,
body:has(#choixEspace[style*="display: flex"]) .cx-voile,
body:has(#mainApp[style*="display: flex"]) .cx-voile,
body:has(#coachApp[style*="display: flex"]) .cx-voile,
body[data-espace="formation"] .cx-voile { display: none; }
/* ⚠️ `!important` et la double exclusion sont necessaires : la regle `:has`
   au-dessus porte un identifiant, elle pese plus lourd que celle-ci ; et sans
   l exclusion, un eleve non connecte dont le dernier espace etait la formation
   verrait le voile par-dessus l ecran de connexion. */
html[data-attente="formation"] body:not([data-espace="formation"]):not(:has(#authScreen[style*="display: flex"], #choixEspace[style*="display: flex"])) .cx-voile { display: grid !important; }

#authScreen, #choixEspace, .auth-container {
  --cx-bg: #0a0a0d; --cx-surface: rgba(17, 19, 24, .88); --cx-surface-2: #161a20;
  --cx-ink: #f7f6f3; --cx-ink-soft: #bdbcb6; --cx-ink-mute: #9c9b94;
  --cx-gold: #e8b84b; --cx-gold-2: #f3d585; --cx-gold-deep: #b98a2e;
  --cx-gold-line: rgba(232, 184, 75, .35); --cx-gold-glow: rgba(232, 184, 75, .5);
  --cx-line: #1e2128;
  background:
    radial-gradient(ellipse 80% 55% at 50% 0%, rgba(232, 184, 75, .14), transparent 62%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(232, 184, 75, .10), transparent 60%),
    radial-gradient(ellipse 120% 90% at 50% 50%, #101014, #0a0a0d 70%) !important;
  color: var(--cx-ink);
  padding: 2rem 24px 120px !important;
}

/* ── La carte ───────────────────────────────────────────────────────────── */
#authScreen .auth-card, #choixEspace .auth-card {
  background: var(--cx-surface) !important;
  border: 1px solid var(--cx-gold-line) !important;
  border-radius: 22px !important;
  box-shadow: 0 30px 80px -30px var(--cx-gold-glow), 0 20px 60px rgba(0, 0, 0, .5) !important;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  color: var(--cx-ink) !important;
  max-width: 460px !important;
  padding: 1.6rem 2rem 1.4rem !important;
}
#authScreen .auth-card h2, #choixEspace .auth-card h2 {
  color: var(--cx-ink) !important; text-shadow: none !important;
  font-weight: 800; letter-spacing: -.02em;
}
#authScreen .auth-card .logo + div,
#authScreen .auth-card div[style*="666"] {
  color: var(--cx-gold) !important; font-size: 12.5px !important;
  letter-spacing: .22em; text-transform: uppercase; font-weight: 700;
}
#authScreen .auth-card label { color: var(--cx-ink-soft) !important; font-size: 12.5px !important; letter-spacing: .06em; text-transform: uppercase; }
#authScreen .auth-card, #authScreen .auth-card p, #choixEspace .auth-card p { color: var(--cx-ink-soft) !important; }

/* ── Les champs ─────────────────────────────────────────────────────────── */
#authScreen .auth-card .form-group input,
#authScreen .auth-card .form-group select {
  background: var(--cx-surface-2) !important;
  color: var(--cx-ink) !important;
  border: 1px solid var(--cx-line) !important;
  border-radius: 12px !important;
  box-shadow: none !important;
}
#authScreen .auth-card .form-group input::placeholder { color: var(--cx-ink-mute) !important; }
#authScreen .auth-card .form-group input:focus { border-color: var(--cx-gold-line) !important; box-shadow: 0 0 0 3px rgba(232, 184, 75, .15) !important; }
#authScreen .auth-card .form-group input:-webkit-autofill,
#authScreen .auth-card .form-group input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--cx-surface-2) inset !important;
  -webkit-text-fill-color: var(--cx-ink) !important;
}

/* ── Les boutons : la forme des boutons de l espace membre (pilules) ─────── */
#authScreen .auth-card .trader-btn, #choixEspace .formation-btn-or {
  background: linear-gradient(180deg, var(--cx-gold-2), var(--cx-gold)) !important;
  color: #120e07 !important; border: 1px solid transparent !important;
  border-radius: 40px !important; font-weight: 700 !important;
  box-shadow: 0 8px 30px -8px var(--cx-gold-glow) !important;
  padding: .8rem 1rem !important; margin: 0 0 10px !important;
}
#authScreen .auth-card .trader-btn:hover, #choixEspace .formation-btn-or:hover { transform: translateY(-1px); filter: none !important; }
#authScreen .auth-card .trader-btn-secondary, #choixEspace .formation-btn-fantome {
  background: rgba(255, 255, 255, .03) !important;
  color: var(--cx-ink) !important;
  border: 1px solid var(--cx-line) !important;
  border-radius: 40px !important; font-weight: 600 !important;
  padding: .8rem 1rem !important; margin: 0 0 10px !important;
}
#authScreen .auth-card .trader-btn-secondary:hover, #choixEspace .formation-btn-fantome:hover { border-color: var(--cx-gold-line) !important; filter: none !important; }
/* ⚠️ Le bouton vers l espace membre : dore mais creux, le journal reste plein.
   Deux boutons l un sous l autre, meme largeur. */
#authScreen .auth-card .trader-btn.cx-btn-formation {
  background: transparent !important; color: var(--cx-gold) !important;
  border-color: var(--cx-gold-line) !important; box-shadow: none !important;
}
#authScreen .auth-card .trader-btn.cx-btn-formation:hover { background: rgba(232, 184, 75, .08) !important; }
#authScreen .forgot-pw-link { color: var(--cx-ink-mute) !important; }
#authScreen .forgot-pw-link:hover { color: var(--cx-gold) !important; }
#authScreen .auth-card .legal-consent-label, #authScreen .auth-card .legal-consent-label a { color: var(--cx-ink-soft) !important; }
#authScreen .auth-card .legal-consent-label a { color: var(--cx-gold) !important; }
#authScreen .aube-eye { color: var(--cx-ink-mute) !important; }
#choixEspace .choix-message-retire, #choixEspace .choix-aucun { color: var(--cx-ink-soft) !important; }
#choixEspace .choix-aucun a { color: var(--cx-gold) !important; }

/* ── Le bandeau « Sécurité avancée… » est retire ; l horloge reste ────────── */
#authScreen .aube-trust { display: none !important; }
body:has(#authScreen[style*="display: flex"]) .aube-clock,
body:has(#choixEspace[style*="display: flex"]) .aube-clock { color: var(--cx-ink-mute, #9c9b94) !important; opacity: 1; }

/* ── Les mentions legales, en pied de page de la connexion ─────────────────
   ⚠️ Fixe en bas, centre, sous l horloge qui est a droite. */
.cx-pied {
  position: fixed; left: 0; right: 0; bottom: 18px; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 110px 0 20px; pointer-events: none;
}
.cx-pied nav { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; pointer-events: auto; }
.cx-pied a { color: #9c9b94; text-decoration: none; font-size: 13.5px; }
.cx-pied a:hover { color: #e8b84b; text-decoration: underline; text-underline-offset: 3px; }
.cx-pied small { color: #6f6e68; font-size: 12.5px; }
@media (max-width: 640px) {
  #authScreen, #choixEspace, .auth-container { padding: 1.25rem 16px 150px !important; }
  #authScreen .auth-card, #choixEspace .auth-card { padding: 1.4rem 1.25rem 1.2rem !important; }
  .cx-pied { padding: 0 16px; bottom: 44px; }
  .aube-clock { bottom: 14px !important; right: 50% !important; transform: translateX(50%); }
}

/* ── Le graphique de fond (assets/connexion.js) ─────────────────────────────
   ⚠️ Pas d `overflow: hidden` sur l ecran : le canevas est fixe, il n en a pas
   besoin, et un ecran qui ne defile plus coupe le formulaire d inscription sur
   un petit telephone. Retour de Nadir du 14/10 : « tu as un peu bloqué le fond ». */
#authScreen { position: relative; }
#authScreen .cx-chart { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 0; }
#authScreen .auth-card { position: relative; z-index: 1; }

/* ── Les deux boutons d entree, l un sous l autre ─────────────────────────── */
#authScreen .auth-card #loginBtn { margin-top: 4px !important; }
#authScreen .auth-card #loginBtnFormation { margin-bottom: 14px !important; }
#authScreen .auth-card #showRegisterBtn { margin-top: 2px !important; }
#authScreen .cx-pied { z-index: 2; }

/* ── L acces coach : « en bas à gauche, discret, un tout petit bouton marqué
   admin » (Nadir, 14/10). Fixe au coin, gris, il ne se voit que si on le cherche. */
#authScreen .cx-admin {
  position: fixed; left: 14px; bottom: 14px; z-index: 6;
  padding: 3px 9px; margin: 0;
  background: transparent !important; border: 1px solid transparent !important; border-radius: 40px;
  box-shadow: none !important; width: auto !important;
  color: #6f6e68 !important; font-size: 11px !important; font-weight: 500; letter-spacing: .08em;
  text-transform: lowercase; text-decoration: none; cursor: pointer; line-height: 1.4;
}
#authScreen .cx-admin:hover, #authScreen .cx-admin:focus-visible {
  color: var(--cx-gold) !important; border-color: var(--cx-gold-line) !important; outline: none;
}
@media (max-width: 640px) {
  #authScreen .cx-admin { left: 10px; bottom: 8px; }
}
