/* =====================================================================
   style.css — ElephaCare · pages d'authentification (connexion / inscription
   / réinitialisation). Restylage complet des vues existantes.

   • DOM inchangé : aucun id / name / classe / data-i18n n'est modifié.
     Tout le style s'applique aux éléments déjà présents.
   • 100 % autonome : polices SYSTÈME uniquement, aucune ressource externe
     (icônes = SVG inline en data-URI, compatibles CSP font-src/img-src 'self').
   • Accessibilité : contraste ≥ 7:1, base 18px, cibles tactiles ≥ 56px,
     focus toujours visible, jamais la couleur seule.
   • Motion : transform / opacity uniquement + prefers-reduced-motion.
   ===================================================================== */

/* --- Design tokens ElephaCare ---------------------------------------- */
:root {
  /* Marque : rouge d'urgence */
  --red-500: #c0392b;   /* bouton primaire, accents */
  --red-600: #a93226;   /* survol */
  --red-700: #922114;   /* pressé / focus rouge */
  --red-ink: #8a1f14;   /* texte rouge sur clair (≥ 7:1) */
  --red-050: #fbeae7;   /* fond d'alerte doux */
  --red-100: #f4d3ce;   /* bordure rouge douce */

  /* Neutres (quasi-noir → blanc) */
  --ink-900: #14181a;   /* texte principal (~15:1) */
  --ink-800: #23292c;   /* titres forts */
  --ink-700: #3a4247;   /* texte secondaire (~8.5:1) */
  --ink-600: #556066;   /* texte atténué (≥ 7:1) */
  --ink-500: #6f7b82;   /* placeholder / icônes */
  --ink-300: #aab2b7;
  --ink-200: #d3d8db;   /* bordures */
  --ink-150: #e2e6e8;   /* filets / séparateurs */
  --ink-100: #eef1f2;   /* remplissage neutre */
  --ink-050: #f6f8f9;   /* fond de l'app */
  --white:   #ffffff;

  /* Accent médical sobre : teal profond */
  --teal-600: #0e5c5b;  /* liens, info, actions secondaires (≥ 7:1) */
  --teal-700: #0a4645;  /* survol */
  --teal-050: #e6f0f0;  /* fond info */

  /* Statuts (sobres) */
  --ok-700:  #1c6b3f;
  --ok-050:  #e7f2ec;
  --warn-800:#7a4b09;
  --warn-050:#f7efdd;

  /* Typographie — pile SYSTÈME uniquement */
  --font-base: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --fs-base: 18px;
  --fs-caption: 0.833rem;   /* 15px */
  --fs-small:   0.944rem;   /* 17px */
  --fs-body:    1rem;       /* 18px */
  --fs-lead:    1.167rem;   /* 21px */
  --fs-h2:      clamp(1.556rem, 1.3rem + 1.2vw, 2.111rem);
  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semibold:600;
  --fw-bold:    700;
  --lh-body:    1.55;
  --lh-heading: 1.2;
  --ls-tight:  -0.02em;
  --ls-label:   0.06em;

  /* Espacements / rayons */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;  --sp-3: 0.75rem;
  --sp-4: 1rem;     --sp-5: 1.5rem;  --sp-6: 2rem;   --sp-7: 2.5rem;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-pill: 999px;

  /* Cibles tactiles */
  --tap-min: 56px;   /* minimum */
  --tap-lg:  64px;   /* action primaire */
  --field-min: 56px;

  /* Élévation — ombres neutres et froides, jamais colorées */
  --shadow-sm: 0 1px 2px rgba(20, 24, 26, 0.08);
  --shadow-md: 0 2px 8px rgba(20, 24, 26, 0.10), 0 1px 2px rgba(20, 24, 26, 0.06);
  --shadow-lg: 0 8px 28px rgba(20, 24, 26, 0.12), 0 2px 6px rgba(20, 24, 26, 0.08);
  --shadow-focus:     0 0 0 3px rgba(14, 92, 91, 0.35);   /* halo teal */
  --shadow-focus-red: 0 0 0 3px rgba(146, 33, 20, 0.30);  /* halo rouge */

  /* Motion */
  --dur-fast: 160ms; --dur-base: 240ms; --dur-slow: 420ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Reset léger ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: var(--fs-base);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-base);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink-800);
  background: var(--ink-050);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  /* Centrage vertical de la colonne d'authentification */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  padding: var(--sp-6) var(--sp-4);
}

/* Les vues masquées le restent, même si .card passe en display:flex */
[hidden] { display: none !important; }

/* --- En-tête de marque ---------------------------------------------- */
.site-header {
  width: 100%;
  max-width: 430px;
  text-align: center;
  margin: 0;
}
.site-header h1 {
  margin: 0;
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.4rem);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-heading);
  color: var(--ink-900);
}
.site-header p {
  margin: var(--sp-2) 0 0;
  font-size: var(--fs-small);
  color: var(--ink-600);
}

/* --- Colonne principale / vues -------------------------------------- */
main {
  width: 100%;
  max-width: 430px;
  display: flex;
  flex-direction: column;
}
.view { width: 100%; }

/* --- Carte (encart) -------------------------------------------------- */
.card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  background: var(--white);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(1.5rem, 1rem + 3vw, 2.25rem);
}
.card > h2 {
  margin: 0 0 var(--sp-1);
  font-size: var(--fs-h2);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-heading);
  color: var(--ink-900);
  text-wrap: balance;
}

/* --- Message d'état / erreur (#*-msg .msg) --------------------------- */
/* auth.js écrit le texte ici ; on n'affiche l'encadré que s'il est rempli. */
.msg:empty { display: none; }
.msg {
  margin: 0 0 var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  color: var(--ink-800);
  background: var(--ink-100);
  border: 1px solid var(--ink-200);
  border-left: 5px solid var(--ink-300);
  border-radius: var(--radius-md);
}
/* Variantes d'état — CONTRAT RÉEL : auth.js pose l'état via l'attribut
   `data-kind` (setMsg → node.setAttribute('data-kind', 'error'|'success'|'info')).
   On cible EXACTEMENT cet attribut (adaptation à l'intégration du repo). */
.msg[data-kind="error"] {
  color: var(--red-ink);
  background: var(--red-050);
  border-color: var(--red-100);
  border-left-color: var(--red-500);
  font-weight: var(--fw-semibold);
}
.msg[data-kind="success"] {
  color: var(--ok-700);
  background: var(--ok-050);
  border-color: #cfe6d8;
  border-left-color: var(--ok-700);
}
.msg[data-kind="info"] {
  color: var(--teal-700);
  background: var(--teal-050);
  border-color: #cfe2e2;
  border-left-color: var(--teal-600);
}

/* --- Champs ---------------------------------------------------------- */
.card label:not(.consent-label) {
  display: block;
  margin-top: var(--sp-4);
  margin-bottom: var(--sp-2);
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  color: var(--ink-900);
}
/* Premier label collé au titre/msg : pas de double marge */
.card > .msg + label,
.card > h2 + label { margin-top: var(--sp-2); }

.card input:not([type="checkbox"]) {
  display: block;
  width: 100%;
  min-height: var(--field-min);
  padding: var(--sp-3) var(--sp-4);
  font-family: inherit;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink-900);
  background-color: var(--white);
  border: 2px solid var(--ink-300);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard);
}
.card input::placeholder { color: var(--ink-500); }
.card input:not([type="checkbox"]):hover { border-color: var(--ink-600); }
.card input:not([type="checkbox"]):focus,
.card input:not([type="checkbox"]):focus-visible {
  outline: none;
  border-color: var(--teal-600);
  box-shadow: var(--shadow-focus);
}

/* Icônes de champ — SVG inline en data-URI (aucune requête externe).
   Injectées en background pour ne modifier aucun élément du DOM. */
.card input[type="email"],
.card input[type="password"],
.card input[type="text"],
.card input[type="date"] {
  background-repeat: no-repeat;
  background-position: left var(--sp-4) center;
  background-size: 20px 20px;
  padding-left: 46px;
}
.card input[type="email"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236f7b82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7'/%3E%3C/svg%3E");
}
.card input[type="password"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236f7b82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E");
}
.card input[type="text"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236f7b82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21a8 8 0 0 0-16 0'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
}
.card input[type="date"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236f7b82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
}

/* Validation native : bordure rouge quand le champ est invalide après saisie */
.card input:not([type="checkbox"]):user-invalid {
  border-color: var(--red-600);
}
.card input:not([type="checkbox"]):user-invalid:focus {
  box-shadow: var(--shadow-focus-red);
}

/* Indice sous un champ (.hint) */
.hint {
  margin: var(--sp-2) 0 0;
  font-size: var(--fs-caption);
  color: var(--ink-600);
}

/* --- Consentement RGPD (case + texte + lien) ------------------------ */
.consent {
  margin-top: var(--sp-5);
  padding: var(--sp-4);
  background: var(--ink-050);
  border: 1px solid var(--ink-150);
  border-radius: var(--radius-md);
}
.consent-label {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.45;
  color: var(--ink-800);
  cursor: pointer;
}
.consent-label input[type="checkbox"] {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 1px 0 0;
  accent-color: var(--teal-600);
  cursor: pointer;
}
.consent-label input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--teal-600);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.consent > a {
  display: inline-block;
  margin-top: var(--sp-2);
  margin-left: calc(24px + var(--sp-3));
  font-size: var(--fs-small);
}

/* --- Bouton primaire (submit) --------------------------------------- */
.card button[type="submit"] {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-lg);
  margin-top: var(--sp-6);
  padding: var(--sp-3) var(--sp-6);
  font-family: inherit;
  font-size: var(--fs-lead);
  font-weight: var(--fw-semibold);
  line-height: 1.1;
  color: var(--white);
  background: var(--red-500);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-fast) var(--ease-standard),
              background-color var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard);
}
.card button[type="submit"]:hover { background: var(--red-600); }
.card button[type="submit"]:active { background: var(--red-700); transform: scale(0.97); }
.card button[type="submit"]:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus-red);
}
.card button[type="submit"][disabled],
.card button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* --- Liens d'action secondaires (.form-links / .linklike) ------------ */
.form-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2) var(--sp-5);
  margin-top: var(--sp-5);
}
.linklike {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-3);
  font-family: inherit;
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  color: var(--teal-600);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1.5px;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-standard),
              background-color var(--dur-fast) var(--ease-standard);
}
.linklike:hover { color: var(--teal-700); background: var(--teal-050); }
.linklike:focus-visible {
  outline: 3px solid var(--teal-600);
  outline-offset: 2px;
  text-decoration: none;
}

/* --- Liens (ancres) -------------------------------------------------- */
a {
  color: var(--teal-600);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1.5px;
  transition: color var(--dur-fast) var(--ease-standard);
}
a:hover { color: var(--teal-700); }
a:focus-visible {
  outline: 3px solid var(--teal-600);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Pied de page ---------------------------------------------------- */
.site-footer {
  width: 100%;
  max-width: 430px;
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2) var(--sp-5);
}
.site-footer a {
  font-size: var(--fs-caption);
  color: var(--ink-600);
  text-decoration: none;
}
.site-footer a:hover { color: var(--teal-700); text-decoration: underline; }

/* --- noscript -------------------------------------------------------- */
noscript {
  display: block;
  max-width: 430px;
  padding: var(--sp-4);
  font-size: var(--fs-small);
  color: var(--red-ink);
  background: var(--red-050);
  border: 1px solid var(--red-100);
  border-left: 5px solid var(--red-500);
  border-radius: var(--radius-md);
}

/* --- Motion : entrée de carte (transform/opacity uniquement) --------- */
@media (prefers-reduced-motion: no-preference) {
  .view:not([hidden]) > .card {
    animation: ec-rise var(--dur-slow) var(--ease-out) both;
  }
}
@keyframes ec-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* --- Coupe-circuit mouvement réduit --------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --- Confort large écran -------------------------------------------- */
@media (min-width: 560px) {
  body { gap: var(--sp-6); }
}
