:root {
  color-scheme: light;
  --login-blue: #1d4ed8;
  --login-blue-dark: #1e3a8a;
  --login-text: #172b4d;
  --login-muted: #64748b;
  --login-border: #dbe3ee;
  --login-background: #f3f6fb;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--login-text);
  background: var(--login-background);
  font-family: Arial, Helvetica, sans-serif;
}

button, input { font: inherit; }

.login-page {
  display: flex;
  min-height: 100vh;
  min-height: 100svh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 20px;
  background:
    radial-gradient(circle at 12% 18%, rgba(59, 130, 246, 0.12), transparent 27%),
    radial-gradient(circle at 88% 82%, rgba(30, 58, 138, 0.1), transparent 30%),
    var(--login-background);
}

.login-card {
  width: min(100%, 460px);
  padding: 36px;
  border: 1px solid rgba(219, 227, 238, 0.9);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(30, 58, 138, 0.12);
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 28px;
  color: var(--login-text);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
}

.login-brand-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--login-blue), var(--login-blue-dark));
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.login-card h1 {
  margin: 0 0 8px;
  color: var(--login-text);
  font-size: 1.8rem;
  line-height: 1.2;
}

.login-intro {
  margin: 0 0 22px;
  color: var(--login-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.login-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 22px;
  padding: 4px;
  border-radius: 10px;
  background: #eef2f8;
}

.login-method {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  color: #52627a;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

.login-method[aria-pressed="true"] {
  color: var(--login-blue-dark);
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

.login-field { margin-bottom: 17px; }

.login-field label {
  display: block;
  margin-bottom: 7px;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 600;
}

.login-field input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--login-border);
  border-radius: 9px;
  outline: none;
  color: var(--login-text);
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-field input::placeholder { color: #9aa7b8; }
.login-field input:hover { border-color: #aab9cc; }

.login-field input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.13);
}

.login-field small {
  display: block;
  margin-top: 6px;
  color: var(--login-muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 3px 0 20px;
  color: var(--login-muted);
  font-size: 0.84rem;
}

.login-options label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.login-options input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--login-blue);
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--login-blue);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

.text-button:hover { color: var(--login-blue-dark); text-decoration: underline; }

.primary-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 18px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: var(--login-blue);
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease, transform 160ms ease;
}

.primary-button:hover { background: var(--login-blue-dark); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: 0.65; cursor: wait; }

#btn-connexion, #btn-send-code, #btn-verify-code { width: 100%; }

.form-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: #b42318;
  font-size: 0.86rem;
  line-height: 1.45;
}

.form-message[data-state="success"] { color: #166534; }
.form-message[data-state="info"] { color: #475569; }

.auth-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: #94a3b8;
  font-size: 0.82rem;
}

.auth-separator::before, .auth-separator::after {
  height: 1px;
  flex: 1;
  background: #e5eaf1;
  content: "";
}

.google-button {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 10px 16px;
  border: 1px solid var(--login-border);
  border-radius: 9px;
  color: #27364b;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
}

.google-button:hover { background: #f8fafc; }
.google-button:disabled { opacity: 0.65; cursor: wait; }

.google-mark {
  color: #4285f4;
  font-size: 1.15rem;
  font-weight: 800;
}

.login-signup {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-top: 21px;
  color: var(--login-muted);
  font-size: 0.88rem;
}

.login-recaptcha { margin: 0 0 15px; }
.phone-code-group { margin-top: 20px; }

.login-footer {
  margin-top: 22px;
  color: #7b8798;
  font-size: 0.8rem;
  text-align: center;
}

.signup-overlay {
  position: fixed;
  z-index: 10000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 18px;
  background: rgba(15, 23, 42, 0.58);
}

.signup-modal {
  width: min(100%, 540px);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.signup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid #e7ebf1;
}

.signup-header h2 {
  margin: 0 0 5px;
  color: #172b4d;
  font-size: 1.25rem;
}

.signup-header p {
  margin: 0;
  color: var(--login-muted);
  font-size: 0.88rem;
}

.close-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 0;
  border-radius: 50%;
  color: #475569;
  background: #f1f5f9;
  font-size: 1.5rem;
  cursor: pointer;
}

.signup-body { padding: 22px 24px 8px; }

.signup-name-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.signup-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid #e7ebf1;
  background: #f8fafc;
}

.secondary-button {
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid #d5dce7;
  border-radius: 8px;
  color: #334155;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
}

#btn-create-account { min-width: 150px; }

#btn-connexion:focus-visible,
#btn-google:focus-visible,
.login-method:focus-visible,
.text-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.close-button:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.35);
  outline-offset: 3px;
}

@media (max-width: 520px) {
  .login-page { justify-content: flex-start; padding: 18px 12px; }
  .login-card { margin: auto 0; padding: 27px 21px; border-radius: 14px; }
  .login-brand { margin-bottom: 24px; }
  .login-card h1 { font-size: 1.6rem; }
  .signup-overlay { padding: 10px; }
  .signup-modal { max-height: calc(100vh - 20px); border-radius: 12px; }
  .signup-name-row { grid-template-columns: 1fr; gap: 0; }
  .signup-header, .signup-body { padding-right: 18px; padding-left: 18px; }
  .signup-footer { flex-direction: column-reverse; padding: 14px 18px; }
  .signup-footer button { width: 100%; }
  .login-options { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Case « J’accepte les conditions… » (création de compte) */
.signup-conditions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 6px;
  color: var(--login-text);
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
}

.signup-conditions input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--login-blue);
}

.signup-conditions a {
  color: var(--login-blue);
  font-weight: 600;
}

.signup-conditions.signup-conditions-erreur {
  color: #b42318;
}


/* =========================================================
   VERRE GLACÉ AU SURVOL (afficher-mot-de-passe.js)
   Plaque de glace qui glisse d'une phrase à l'autre,
   aussi au-dessus de la fenêtre « Créer un compte ».
   ========================================================= */
.cx-glace {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10050;
  width: 0;
  height: 0;
  overflow: hidden;
  border: 1px solid rgba(147, 197, 253, .8);
  border-left: 3px solid #244d9b;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .24) 0%, rgba(255, 255, 255, .04) 40%, rgba(255, 255, 255, 0) 48%),
    radial-gradient(90% 60% at 15% 120%, rgba(147, 197, 253, .2), rgba(147, 197, 253, 0) 65%),
    rgba(36, 77, 155, .05);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .9),
    inset 0 0 10px rgba(147, 197, 253, .22),
    0 4px 14px rgba(31, 58, 104, .12);
  opacity: 0;
  pointer-events: none;
  transition:
    transform .32s cubic-bezier(.22, 1, .36, 1),
    width .32s cubic-bezier(.22, 1, .36, 1),
    height .32s cubic-bezier(.22, 1, .36, 1),
    opacity .2s ease;
}
.cx-glace.cx-visible { opacity: 1; }
.cx-glace.cx-sans-animation { transition: opacity .2s ease; }
@media (prefers-reduced-motion: reduce) { .cx-glace { transition: opacity .2s ease; } }

/* =========================================================
   CONNEXION AUTOMATIQUE APRÈS REMPLISSAGE PAR CHROME (auth.js)
   ========================================================= */
/* Petite animation invisible : elle permet de savoir que Chrome a rempli le champ */
@keyframes cx-rempli-auto { from { opacity: 1; } to { opacity: 1; } }
#login-email:-webkit-autofill,
#login-password:-webkit-autofill { animation: cx-rempli-auto 1ms; }

/* Bouton « Se connecter » qui se remplit pendant les 2 secondes */
#btn-connexion.cx-auto {
  background-image: linear-gradient(90deg, rgba(255, 255, 255, .28) 0%, rgba(255, 255, 255, .28) 100%);
  background-repeat: no-repeat;
  background-size: 0% 100%;
  animation: cx-compte-a-rebours 2s linear forwards;
}
@keyframes cx-compte-a-rebours { to { background-size: 100% 100%; } }

#login-message .cx-auto-annuler {
  margin-left: 6px;
  padding: 0;
  font-weight: 700;
  text-decoration: underline;
}

/* =========================================================
   CASES À COCHER RONDES (au lieu de carrées)
   Toutes les cases à cocher : un rond, et une coche blanche
   sur fond bleu quand elle est cochée. Fonctionnement inchangé.
   ========================================================= */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    display: inline-block;
    flex-shrink: 0;
    box-sizing: border-box;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    margin: 0;
    padding: 0;
    border: 2px solid #94a3b8;
    border-radius: 50%;
    background: #ffffff center / 11px 11px no-repeat;
    vertical-align: middle;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
input[type="checkbox"]:hover:not(:disabled) {
    border-color: #244d9b;
}
input[type="checkbox"]:checked {
    border-color: #244d9b;
    background-color: #244d9b;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.2 6.3 4.8 8.8 9.8 3.4' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
input[type="checkbox"]:indeterminate {
    border-color: #244d9b;
    background-image: linear-gradient(#244d9b, #244d9b);
    background-size: 8px 2px;
}
input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(36, 77, 155, .25);
}
input[type="checkbox"]:disabled {
    opacity: .5;
    cursor: not-allowed;
}
@media print {
    input[type="checkbox"] { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* =========================================================
   ARRIVÉE DE LA FENÊTRE DE CONNEXION — « depuis la caméra »
   La fenêtre sort d'une petite pastille en haut au centre de l'écran
   (là où se trouve la caméra frontale du téléphone), s'élargit et
   descend se poser à sa place, en un seul geste rapide (0,55 s).
   Le contenu apparaît d'un coup ; la fenêtre répond tout de suite.
   (Les personnages qui poussaient la carte ont été retirés.)
   ========================================================= */
@keyframes lg-fond { from { opacity: 0; } to { opacity: 1; } }
@keyframes lg-camera {
  0%   { opacity: 0; transform: translateY(calc(-50vh + 30px)) scale(.14, .05); border-radius: 999px; }
  15%  { opacity: 1; }
  60%  { border-radius: 26px; }
  100% { opacity: 1; transform: none; }
}
@keyframes lg-contenu { from { opacity: 0; } to { opacity: 1; } }

.login-page { animation: lg-fond .25s ease backwards; }
.login-card {
  transform-origin: 50% 0;
  animation: lg-camera .55s cubic-bezier(.2, .9, .25, 1) backwards;
}
.login-card > * { animation: lg-contenu .22s ease .28s backwards; }
.login-footer { animation: lg-fond .3s ease .4s backwards; }

/* Fenêtre « Créer un compte » : même sortie depuis la caméra */
.signup-overlay:not([hidden]) { animation: lg-fond .2s ease backwards; }
.signup-overlay:not([hidden]) .signup-modal {
  transform-origin: 50% 0;
  animation: lg-camera .55s cubic-bezier(.2, .9, .25, 1) backwards;
}
.signup-overlay:not([hidden]) .signup-modal > * { animation: lg-contenu .22s ease .28s backwards; }

@media (prefers-reduced-motion: reduce) {
  .login-page, .login-card, .login-card > *, .login-footer,
  .signup-overlay, .signup-modal, .signup-modal > * { animation: none !important; }
}
/* Version téléphone : carte adaptée aux petits écrans et aux zones sûres */
@media (max-width: 520px) {
  .login-page {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  }

  .login-card {
    box-sizing: border-box;
    width: min(100%, 420px);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
    margin: auto 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: clamp(18px, 5vw, 24px) clamp(16px, 5vw, 21px);
  }

  .signup-overlay {
    padding: max(10px, env(safe-area-inset-top, 0px)) 10px max(10px, env(safe-area-inset-bottom, 0px));
  }

  .signup-modal {
    box-sizing: border-box;
    width: min(100%, 420px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 20px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}
.whatsapp-button {
  width: 100%;
  margin-top: 10px;
  background: #16834d;
}

.whatsapp-button:hover { background: #126b3f; }
.whatsapp-button[hidden] { display: none; }