/*
 * Kokorosogi LeadGen — Form CSS
 * Design System tokens: cieleden-system-notes.md §7.1
 * Phase 1 MVP Obseques — 3 themes: light (default), normal, dark
 * Cible senior 55+ : 18px min, 56px bouton primaire, focus ring 3px
 * Police: Inter via Google Fonts (decision Sonia, Phase 1)
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');

/* ============================================================
   1. RESET & BASE
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ============================================================
   2. DESIGN TOKENS — Thème LIGHT (defaut)
   ============================================================ */

:root,
[data-theme="light"] {
  /* Couleurs primaires (Cieleden Blue Lagoon) */
  --color-primary:        #0D9DA4;
  --color-primary-hover:  #0A7A80;
  --color-primary-active: #085F65;
  --color-primary-light:  #E6F7F8;

  /* Texte */
  --color-text:             #1A2E30;
  --color-text-muted:       #4A6469;
  --color-text-placeholder: #8FB3BA;
  --color-text-inverse:     #FFFFFF;

  /* Fonds */
  --color-bg:       #FFFFFF;
  --color-bg-subtle: #F4F7F8;
  --color-bg-input: #FFFFFF;

  /* Bordures */
  --color-border:       #CBD8DB;
  --color-border-focus: #0D9DA4;
  --color-border-error: #B91C1C;

  /* Statuts */
  --color-success:    #047857;
  --color-success-bg: #ECFDF5;
  --color-warning:    #B45309;
  --color-warning-bg: #FFFBEB;
  --color-error:      #B91C1C;
  --color-error-bg:   #FEF2F2;
  --color-info:       #0369A1;
  --color-info-bg:    #EFF6FF;
}

/* ============================================================
   3. THÈME NORMAL
   ============================================================ */

[data-theme="normal"] {
  --color-bg:        #F4F7F8;
  --color-bg-subtle: #E8EDEF;
  --color-bg-input:  #FFFFFF;
  --color-border:    #A8BFC3;

  --color-text:       #1A2E30;
  --color-text-muted: #4A6469;

  --color-error:      #B91C1C;
  --color-error-bg:   #FEF2F2;
  --color-success:    #047857;
  --color-success-bg: #ECFDF5;
  --color-warning:    #B45309;
  --color-warning-bg: #FFFBEB;
  --color-info:       #0369A1;
  --color-info-bg:    #EFF6FF;
}

/* ============================================================
   4. THÈME DARK
   ============================================================ */

[data-theme="dark"] {
  --color-primary:        #0D9DA4;
  --color-primary-hover:  #1DB8BF;
  --color-primary-active: #085F65;
  --color-primary-light:  #E6F7F8;

  --color-bg:        #1A2E30;
  --color-bg-subtle: #243E41;
  --color-bg-input:  #2D4A52;
  --color-border:    #3D6068;

  --color-text:             #EDF4F5;
  --color-text-muted:       #8FB3BA;
  --color-text-placeholder: #5A8288;
  --color-text-inverse:     #FFFFFF;

  --color-border-focus: #0D9DA4;
  --color-border-error: #F87171;

  --color-error:      #F87171;
  --color-error-bg:   #450A0A;
  --color-success:    #34D399;
  --color-success-bg: #064E3B;
  --color-warning:    #FCD34D;
  --color-warning-bg: #451A03;
  --color-info:       #38BDF8;
  --color-info-bg:    #0C4A6E;
}

/* ============================================================
   5. TOKENS STRUCTURELS (partagés entre themes)
   ============================================================ */

:root {
  /* Espacements (base 4px) */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;
  --space-9:  80px;
  --space-10: 96px;

  /* Radius */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-pill: 999px;

  /* Elevations */
  --shadow-none:        none;
  --shadow-card:        0 2px 8px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-raised:      0 4px 16px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-popover:     0 8px 32px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.08);
  --shadow-focus:       0 0 0 3px rgba(13,157,164,.35);
  --shadow-focus-error: 0 0 0 3px rgba(185,28,28,.25);

  /* Transitions */
  --transition-fast: 100ms ease-out;
  --transition-base: 200ms ease-out;
  --transition-slow: 300ms ease-in-out;

  /* Typographie — formulaire public */
  --text-form-title:    28px;
  --text-form-subtitle: 22px;
  --text-form-label:    18px;
  --text-form-input:    18px;
  --text-form-helper:   16px;
  --text-form-error:    16px;
  --text-form-step:     14px;
  --text-form-cta:      18px;

  /* Line-heights */
  --lh-form-title: 1.3;
  --lh-form-body:  1.5;

  /* Letter-spacing */
  --ls-title: -0.5px;
  --ls-body:  -0.3px;

  /* Tailles cibles (accessibilite senior) */
  --btn-height-primary:   56px;
  --btn-height-secondary: 48px;
  --input-height:         52px;
  --checkbox-size:        24px;
  --step-dot-size:        32px;
}

/* ============================================================
   6. BODY & WRAPPER
   ============================================================ */

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--text-form-input);
  line-height: var(--lh-form-body);
  background: var(--color-bg);
  color: var(--color-text);
  letter-spacing: var(--ls-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.form-wrapper {
  min-height: 100vh;
  padding: var(--space-5) var(--space-4);
  background: var(--color-bg);
}

/* ============================================================
   7. CARD FORMULAIRE
   ============================================================ */

.form-card {
  background: var(--color-bg);
  padding: var(--space-6);      /* 32px desktop */
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 599px) {
  .form-card {
    padding: var(--space-5);    /* 24px mobile */
    max-width: 100%;
  }

  .form-wrapper {
    padding: 0;
  }
}

/* En mode embarqué (iframe), le contenu seul dicte la hauteur — l'auto-resize
   (embed.js) ne pourrait pas réduire l'iframe si le wrapper imposait 100vh. */
html.is-embedded .form-wrapper {
  min-height: 0;
}

/* ============================================================
   8. INDICATEUR D'ETAPE
   ============================================================ */

.step-indicator {
  margin-bottom: var(--space-6);
}

/* Barre de progression lineaire */
.step-progress-bar {
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: var(--space-4);
  position: relative;
}

.step-progress-fill {
  display: block;
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  transition: width var(--transition-slow);
}

/* Legende etape — masquee (desktop + responsive), demande design 2026-06-07 */
.step-legend {
  display: none;
}

/* Cercles numerotes — chevauchent la barre de progression (margin-top negatif) */
.step-dots {
  list-style: none;      /* reset <ol> : pas de puces */
  margin: 0;
  padding: 0;            /* reset <ol> : retire le padding-inline-start de 40px qui decentrait les etapes */
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-1);
  margin-top: -34px;     /* les etapes chevauchent la ligne d'avancement (desktop + responsive) */
  position: relative;
  z-index: 1;            /* au-dessus de la barre de progression */
}

.step-dot-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
  min-width: 0;
}

.step-dot {
  width: var(--step-dot-size);
  height: var(--step-dot-size);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-form-step);
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
  /* Connecteur horizontal entre points */
}

.step-dot--future {
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
}

.step-dot--active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.step-dot--past {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

/* Checkmark SVG pour etapes passees */
.step-dot--past::after {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M2 7l3.5 3.5L12 3' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  position: absolute;
}

/* Correction #4 — Dots comme boutons : reset styles natifs button */
.step-dot {
  border: 1px solid var(--color-primary);   /* bordure fine primaire sur tous les dots */
  font-size: var(--text-form-step);
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  cursor: default;
}

/* Étape passée cliquable */
.step-dot--past:not([disabled]) {
  cursor: pointer;
}

.step-dot--past:not([disabled]):hover {
  opacity: 0.85;
  transform: scale(1.08);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.step-dot--past:not([disabled]):focus-visible {
  outline: 3px solid rgba(13, 157, 164, 0.6);
  outline-offset: 2px;
}

/* Étape active et future : non cliquables */
.step-dot--active,
.step-dot--future {
  cursor: default;
  pointer-events: none;
}

/* Libelle etape — visible seulement desktop */
.step-label {
  font-size: 10px;
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;   /* jamais de retour a la ligne (ex. "Confirmation" sur 8 etapes) */
  display: none;
}

/* Sur le point actif, le libelle est plus contraste */
.step-dot-wrapper--active .step-label {
  color: var(--color-text);
  font-weight: 600;
}

@media (min-width: 600px) {
  .step-label {
    display: block;
  }
}

/* ============================================================
   9. HEADER D'ETAPE
   ============================================================ */

.step-header {
  margin-bottom: var(--space-6);
}

.step-title {
  font-size: var(--text-form-title);
  font-weight: 600;
  line-height: var(--lh-form-title);
  letter-spacing: var(--ls-title);
  color: var(--color-text);
  margin: 0 0 var(--space-4) 0;
}

/* Le titre reçoit un focus programmatique à l'arrivée d'étape (tabindex=-1,
   pour l'annonce au lecteur d'écran). Il n'est pas atteignable au clavier :
   on masque donc son contour de focus, qui n'apporte rien visuellement et
   surprend l'utilisateur. Aucun impact sur l'accessibilité clavier. */
.step-title:focus,
.step-title:focus-visible {
  outline: none;
}

.step-description {
  font-size: var(--text-form-subtitle);
  font-weight: 400;
  line-height: var(--lh-form-body);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-5) 0;
}

/* ============================================================
   10. CHAMPS — Label
   ============================================================ */

.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);          /* 24px entre champs — genereux pour senior */
  margin-bottom: var(--space-6);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.field-label {
  display: block;
  font-size: var(--text-form-label);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2); /* 8px */
  line-height: var(--lh-form-body);
}

.field-label .required-mark {
  color: var(--color-error);
  margin-left: 2px;
  /* aria-hidden="true" pose cote JS */
}

/* ============================================================
   11. CHAMPS — Input texte
   ============================================================ */

.field-input {
  display: block;
  width: 100%;
  height: var(--input-height);   /* 52px */
  padding: 14px 16px;
  font-size: var(--text-form-input);
  font-family: inherit;
  font-weight: 400;
  color: var(--color-text);
  background: var(--color-bg-input);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

.field-input::placeholder {
  color: var(--color-text-placeholder);
}

.field-input:focus {
  border-color: var(--color-border-focus);
  box-shadow: var(--shadow-focus);
}

.field-input:not(:placeholder-shown):not(:focus) {
  border-color: var(--color-primary-hover);
}

.field-input.has-error {
  border-color: var(--color-border-error);
  box-shadow: var(--shadow-focus-error);
}

.field-input:disabled {
  background: var(--color-bg-subtle);
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================
   12. CHAMPS — Select
   ============================================================ */

.field-select {
  display: block;
  width: 100%;
  height: var(--input-height);   /* 52px */
  padding: 14px 44px 14px 16px;  /* droite = espace pour chevron */
  font-size: var(--text-form-input);
  font-family: inherit;
  font-weight: 400;
  color: var(--color-text);
  background: var(--color-bg-input);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  /* Chevron SVG custom */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5l5 5 5-5' stroke='%234A6469' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px 20px;
}

[data-theme="dark"] .field-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5l5 5 5-5' stroke='%238FB3BA' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.field-select:focus {
  border-color: var(--color-border-focus);
  box-shadow: var(--shadow-focus);
}

.field-select.has-error {
  border-color: var(--color-border-error);
  box-shadow: var(--shadow-focus-error);
}

.field-select:disabled {
  background-color: var(--color-bg-subtle);
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================
   13. CHAMPS — Helper text
   ============================================================ */

.field-helper {
  display: block;
  font-size: var(--text-form-helper);
  color: var(--color-text-muted);
  margin-top: var(--space-1);     /* 4px */
  line-height: var(--lh-form-body);
}

/* ============================================================
   14. CHAMPS — Message d'erreur inline
   ============================================================ */

.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  font-size: var(--text-form-error);
  color: var(--color-error);
  margin-top: var(--space-1);     /* 4px */
  line-height: var(--lh-form-body);
  min-height: 0;
  /* Occupe l'espace meme vide pour eviter le layout shift */
}

.field-error:empty {
  display: none;
}

.field-error-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

/* ============================================================
   15. CONSENTEMENT RGPD
   ============================================================ */

.consent-block {
  border-left: 3px solid var(--color-primary-light);
  padding-left: var(--space-4);
  margin-bottom: var(--space-5);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.consent-text {
  font-size: var(--text-form-helper);
  color: var(--color-text-muted);
  line-height: var(--lh-form-body);
  margin: 0 0 var(--space-4) 0;
}

.consent-checkbox-wrapper {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  padding: var(--space-2) 0;
  min-height: 44px;               /* Zone tactile minimale */
}

.consent-checkbox {
  width: var(--checkbox-size);
  height: var(--checkbox-size);
  min-width: var(--checkbox-size);
  border: 2px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg-input);
  cursor: pointer;
  margin-top: 1px;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  outline: none;
  flex-shrink: 0;
}

.consent-checkbox:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

/* Checkmark */
.consent-checkbox:checked::after {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M2 7l3.5 3.5L12 3' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.consent-checkbox:focus {
  box-shadow: var(--shadow-focus);
  border-color: var(--color-border-focus);
}

.consent-checkbox.has-error {
  border-color: var(--color-border-error);
  box-shadow: var(--shadow-focus-error);
}

.consent-label {
  font-size: var(--text-form-helper);
  color: var(--color-text);
  line-height: var(--lh-form-body);
  flex: 1;
  cursor: pointer;
}

/* ============================================================
   16. NAVIGATION (boutons Retour / Suivant)
   ============================================================ */

.form-nav {
  display: flex;
  /* DOM ordre : Suivant puis Retour (tab order logique : Tab depuis le
     dernier champ → Suivant en priorité). row-reverse rétablit le rendu
     visuel attendu : Retour à gauche, Suivant à droite. */
  flex-direction: row-reverse;
  justify-content: flex-start;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

/* Bouton primaire */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--btn-height-primary);  /* 56px */
  padding: var(--space-4) var(--space-6); /* 16px 32px */
  font-size: var(--text-form-cta);
  font-weight: 600;
  font-family: inherit;
  color: var(--color-text-inverse);
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  flex: 1;
  outline: none;
  text-align: center;
  letter-spacing: 0;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-primary:focus {
  box-shadow: var(--shadow-focus);
}

.btn-primary:active:not(:disabled) {
  background: var(--color-primary-active);
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

/* Variante critique (etape 6 — "Valider et envoyer") */
/* Bug #6 : les couleurs hover/active sont dérivées du même primary via JS */
/* Les variables --color-primary-critical* sont injectées par form.js si ?primary= est présent */
/* Sinon, fallback sur les valeurs par défaut de la palette */
.btn-primary--critical {
  background: var(--color-primary-critical, var(--color-primary-active));
}

.btn-primary--critical:hover:not(:disabled) {
  background: var(--color-primary-critical-hover, #064D53);
}

.btn-primary--critical:active:not(:disabled) {
  background: var(--color-primary-critical-active, #053F44);
}

/* Bouton secondaire (Retour) */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--btn-height-secondary);  /* 48px */
  padding: 14px var(--space-5);
  font-size: var(--text-form-helper);
  font-weight: 600;
  font-family: inherit;
  color: var(--color-text);
  background: transparent;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg-subtle);
  border-color: var(--color-primary);
}

.btn-secondary:focus {
  box-shadow: var(--shadow-focus);
}

.btn-secondary:active:not(:disabled) {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mention champs obligatoires — centree, sous les boutons (demande design 2026-06-07) */
.required-notice {
  text-align: center;
  font-size: var(--text-form-helper);
  color: var(--color-text-muted);
  line-height: var(--lh-form-body);
  margin: var(--space-4) 0 0;
}

/* Mobile : boutons cote a cote — ratio desktop conserve, jamais l'un sous l'autre
   (demande design 2026-06-07). On garde le row-reverse de base, gap reduit et
   padding horizontal compact pour laisser le texte des boutons respirer. */
@media (max-width: 599px) {
  .form-nav {
    gap: var(--space-2);
  }

  .btn-primary {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }

  .btn-secondary {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }
}

/* ============================================================
   17. SPINNER DE CHARGEMENT
   ============================================================ */

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   18. ALERTE GLOBALE (erreur reseau / 5xx)
   ============================================================ */

.global-error {
  display: none;
  padding: var(--space-4);
  background: var(--color-error-bg);
  border: 1px solid var(--color-border-error);
  border-left: 4px solid var(--color-error);
  border-radius: var(--radius-md);
  color: var(--color-error);
  font-size: var(--text-form-helper);
  line-height: var(--lh-form-body);
  margin-top: var(--space-4);
}

.global-error.is-visible {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.global-error-retry {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--color-error);
  font-size: var(--text-form-helper);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  margin-top: var(--space-1);
}

/* ============================================================
   19. ECRAN DE CONFIRMATION
   ============================================================ */

.confirmation-screen {
  text-align: center;
  padding: var(--space-8) var(--space-5);
}

.confirmation-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-success-bg);
  margin: 0 auto var(--space-5);
}

.confirmation-icon svg {
  width: 40px;
  height: 40px;
  color: var(--color-success);
}

.confirmation-title {
  font-size: var(--text-form-title);
  font-weight: 600;
  line-height: var(--lh-form-title);
  letter-spacing: var(--ls-title);
  color: var(--color-text);
  margin: 0 0 var(--space-4) 0;
}

.confirmation-body {
  font-size: var(--text-form-input);
  color: var(--color-text-muted);
  line-height: var(--lh-form-body);
  margin: 0 0 var(--space-4) 0;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

.confirmation-email-notice {
  font-size: var(--text-form-helper);
  color: var(--color-text-muted);
  line-height: var(--lh-form-body);
  margin: 0 auto var(--space-5);
  max-width: 440px;
}

/* ============================================================
   20. VISIBILITE DES ETAPES
   ============================================================ */

.form-step {
  display: none;
}

.form-step.is-active {
  display: block;
}

/* ============================================================
   21. ACCESSIBILITE — prefers-reduced-motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }

  .step-progress-fill {
    transition: none !important;
  }
}

/* ============================================================
   22. FOCUS RING UNIVERSEL (visible meme en navigation souris)
      Cible senior : jamais supprimer le focus outline
   ============================================================ */

:focus-visible {
  outline: 3px solid rgba(13, 157, 164, 0.6);
  outline-offset: 2px;
}

/* Les composants avec box-shadow focus utilisent outline:none mais gardent le shadow */
.field-input:focus,
.field-select:focus,
.consent-checkbox:focus,
.btn-primary:focus,
.btn-secondary:focus {
  outline: none;
  /* box-shadow deja posé ci-dessus */
}

/* ============================================================
   23. CHAMP MASQUE DE DATE (jj/mm/aaaa)
   ============================================================ */

.field-input--date {
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   24. CIVILITE — Radio cards (3 options, layout horizontal compact)
   ============================================================ */

.field--civility {
  border: none;
  padding: 0;
  margin: 0;
}

/* Desktop ≥600px : label à gauche + 3 cards à droite sur la même ligne */
@media (min-width: 600px) {
  .field--civility {
    display: flex;
    align-items: center;
    gap: var(--space-4);
  }

  .field--civility .civility-legend {
    flex-shrink: 0;
    margin-bottom: 0;
    white-space: nowrap;
  }

  .field--civility .civility-cards {
    flex: 1;
    margin-top: 0;
  }
}

/* Mobile <600px : legend sur 1 ligne, 3 cards en dessous */
.field--civility legend.civility-legend {
  display: block;
  float: none;           /* reset fieldset natif */
  width: auto;
  padding: 0;
  margin-bottom: var(--space-2);
}

.civility-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);  /* 3 options = 3 colonnes */
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* Input radio visuellement caché mais accessible */
.civility-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  appearance: none;
  -webkit-appearance: none;
}

/* Card label — hauteur 44px (compact mais tactile senior) */
.civility-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--space-2) var(--space-2);
  font-size: var(--text-form-helper);
  font-weight: 600;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-bg-input);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  line-height: 1.2;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
}

/* Etat sélectionné */
.civility-radio:checked + .civility-card {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Focus clavier sur la card */
.civility-radio:focus-visible + .civility-card {
  box-shadow: var(--shadow-focus);
  border-color: var(--color-border-focus);
  outline: none;
}

/* Focus (compatibilité :focus sans :focus-visible pour vieux navigateurs) */
.civility-radio:focus + .civility-card {
  box-shadow: var(--shadow-focus);
  border-color: var(--color-border-focus);
}

/* Hover */
.civility-card:hover {
  background: var(--color-bg-subtle);
  border-color: var(--color-primary);
}

/* ============================================================
   25. AUTOCOMPLETE ADRESSE (Bug #4)
   ============================================================ */

.address-combobox {
  position: relative;
}

.address-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-popover);
  list-style: none;
  margin: 0;
  padding: var(--space-1) 0;
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
}

.address-suggestion-item {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-form-helper);
  color: var(--color-text);
  cursor: pointer;
  line-height: var(--lh-form-body);
  transition: background-color var(--transition-fast);
}

.address-suggestion-item:hover,
.address-suggestion-item.is-active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.address-suggestion-item.is-active {
  outline: none;
}

/* ============================================================
   26. LAYOUT CODE POSTAL + VILLE SUR 1 LIGNE
   Grid 1fr 2fr (CP = 1/3, Ville = 2/3), gap 16px
   Valable mobile ET desktop (pas de breakpoint — la ligne est
   compacte par conception : les deux champs courts côte à côte)
   ============================================================ */

.field-row--postal-city {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-4); /* 16px */
  align-items: start;  /* labels de hauteur differente → aligner en haut */
}

/* Champ readonly après sélection autocomplete */
.field-input--readonly {
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

/* Lien "Modifier manuellement" */
.unlock-link {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: var(--space-1) 0;
  text-decoration: underline;
  margin-top: var(--space-1);
}

.unlock-link:hover {
  color: var(--color-primary-hover);
}

/* ============================================================
   27. VISUAL-CARD (B1) — Grille de radio cards visuelles
   Spec : form-builder-spec.md §6.4
   Cible senior : min-height 120px desktop, 80px mobile
   ============================================================ */

/* Fieldset réinitialisation */
.field--visual-card {
  border: none;
  padding: 0;
  margin: 0;
}

.vc-legend {
  width: 100%;
}

/* Grille responsive : nombre de colonnes configuré par le builder */
.vc-grid {
  display: grid;
  gap: 12px;
  margin-top: var(--space-3, 12px);
}

.vc-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.vc-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.vc-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Mobile : toujours 2 colonnes max (lisibilité senior) */
@media (max-width: 599px) {
  .vc-grid--cols-3,
  .vc-grid--cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Input radio : masqué visuellement, accessible */
.vc-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Card : label cliquable qui encapsule le radio
   États (Sprint B4 — refonte Lucide + inversion états) :
     default (off)    : bg blanc + bordure {--vc-bg} + icône/texte couleur
     hover (desktop)  : bg tinté 8% + scale + ombre
     selected (on)    : bg {--vc-bg} + icône/texte blanc + checkmark + ring
     focus (keyboard) : outline 3px {--vc-bg} offset 2px
*/
.vc-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 12px;
  min-height: 120px;
  border-radius: var(--radius-md, 10px);
  border: 2px solid var(--vc-bg, var(--color-primary, #0D9DA4));
  background-color: #fff;
  color: var(--vc-bg, var(--color-primary, #0D9DA4));
  cursor: pointer;
  position: relative;
  text-align: center;
  transition: background-color 150ms ease-out, color 150ms ease-out, transform 150ms ease-out, box-shadow 150ms ease-out;
}

.vc-card svg {
  color: var(--vc-bg, var(--color-primary, #0D9DA4));
}

.vc-card__label {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: inherit;
}

/* Checkmark : visible uniquement quand sélectionné */
.vc-checkmark {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #fff;
  opacity: 0;
  transition: opacity 120ms ease-out;
  width: 20px;
  height: 20px;
}

/* État hover (desktop only) */
@media (hover: hover) {
  .vc-card:hover {
    background-color: color-mix(in srgb, var(--vc-bg, #0D9DA4) 8%, white);
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
  }
  /* Fallback pour navigateurs sans color-mix (Safari < 16.4) : tint primaire fixe */
  @supports not (background: color-mix(in srgb, red 8%, white)) {
    .vc-card:hover {
      background-color: rgba(13, 157, 164, 0.08);
    }
  }
}

/* État sélectionné */
.vc-radio:checked + .vc-card {
  background-color: var(--vc-bg, var(--color-primary, #0D9DA4));
  color: #fff;
  box-shadow: 0 0 0 3px var(--vc-bg, var(--color-primary, #0D9DA4));
  transform: scale(1.02);
}

.vc-radio:checked + .vc-card svg,
.vc-radio:checked + .vc-card .vc-card__label {
  color: #fff;
}

.vc-radio:checked + .vc-card .vc-checkmark {
  opacity: 1;
}

/* Focus visible (keyboard nav) */
.vc-radio:focus-visible + .vc-card {
  outline: 3px solid var(--vc-bg, var(--color-primary, #0D9DA4));
  outline-offset: 2px;
}

/* Focus (compatibilité :focus sans :focus-visible pour vieux navigateurs) */
.vc-radio:focus + .vc-card {
  outline: 3px solid var(--vc-bg, var(--color-primary, #0D9DA4));
  outline-offset: 2px;
}

/* Mobile : taille tactile minimale (spec senior 56px+) */
@media (max-width: 599px) {
  .vc-card {
    min-height: 80px;
    padding: 12px 8px;
  }

  .vc-card__label {
    font-size: 15px;
  }
}

/* prefers-reduced-motion : désactive transitions et transforms */
@media (prefers-reduced-motion: reduce) {
  .vc-card,
  .vc-checkmark {
    transition: none;
  }
  .vc-card:hover,
  .vc-radio:checked + .vc-card {
    transform: none;
  }
}


/* ============================================================
   SPRINT B2 — Bannière mode aperçu (preview)
   ============================================================ */

.preview-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 32px;
  background: #FFFBEB;
  color: #B45309;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 32px;
  padding: 0 16px;
  z-index: 1000;
  border-bottom: 1px solid #FDE68A;
  box-sizing: border-box;
}

/* Le wrapper du form est décalé de 32px quand la bannière est présente */
.form-root--preview {
  margin-top: 32px;
}

@media (prefers-reduced-motion: reduce) {
  .preview-banner {
    transition: none;
  }
}

/* ============================================================
   EMAIL HELPER (Sprint EH — post Go-Live Phase 1.5)
   Autocomplete dropdown + typo banner
   ============================================================ */

/* Suggestions email — layout chips/tags sous le champ (au lieu d'un
   dropdown vertical), s'enroulent en plusieurs lignes selon la place.
   Sémantique ARIA listbox conservée pour les screen readers. */
.email-suggestions__dropdown {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.email-suggestions__dropdown[hidden] {
  display: none;
}

.email-suggestions__item {
  padding: 6px 12px;
  font-size: 14px;
  font-family: inherit;
  /* color-primary-active (#0A7A80) au repos pour contraste WCAG AA Normal
     (4.5:1) sur le fond primary-light. La version base (#0D9DA4) ne le
     respectait que pour du texte large/bold. */
  color: var(--color-primary-active, #0A7A80);
  background-color: var(--color-primary-light, #E6F7F8);
  border: 1px solid var(--color-primary-active, #0A7A80);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 120ms ease-out, color 120ms ease-out, transform 120ms ease-out;
  user-select: none;
  font-weight: 600;
  line-height: 1.3;
  /* Tactile minimum 32px hauteur pour senior */
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}

.email-suggestions__item:hover,
.email-suggestions__item[aria-selected="true"],
.email-suggestions__item:focus-visible {
  background-color: var(--color-primary, #0D9DA4);
  color: #fff;
  outline: none;
}

.email-suggestions__item[aria-selected="true"] {
  /* Légère élévation pour le focus clavier */
  transform: translateY(-1px);
}

/* Banner typo au blur */
.email-typo-banner {
  margin-top: 8px;
  padding: 10px 12px;
  background-color: #FEF3C7;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  color: var(--color-text, #1A2E30);
}

.email-typo-banner[hidden] {
  display: none;
}

.email-typo-banner__message {
  flex: 1;
  line-height: 1.4;
}

.email-typo-banner__message strong {
  /* color-primary-active (#0A7A80) pour contraste sur fond #FEF3C7 (>=4.5:1) */
  color: var(--color-primary-active, #0A7A80);
  font-weight: 700;
}

.email-typo-banner__btn {
  padding: 6px 12px;
  min-height: 36px;
  /* color-primary-active (#0A7A80) pour contraste WCAG AA Normal text 4.5:1
     sur fond blanc (le primary base #0D9DA4 était à 3.1:1). */
  border: 1px solid var(--color-primary-active, #0A7A80);
  background: #fff;
  color: var(--color-primary-active, #0A7A80);
  font-weight: 600;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease-out, color 120ms ease-out;
}

.email-typo-banner__btn:hover,
.email-typo-banner__btn:focus-visible {
  background: var(--color-primary, #0D9DA4);
  color: #fff;
}

.email-typo-banner__btn:focus-visible {
  outline: 3px solid var(--color-primary, #0D9DA4);
  outline-offset: 2px;
}

/* Mobile : banner en colonne sous 480px */
@media (max-width: 479px) {
  .email-typo-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .email-typo-banner__btn {
    width: 100%;
  }
}

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .email-suggestions__item,
  .email-typo-banner__btn {
    transition: none;
  }
}

/* Cartes-boutons radio génériques (capital décès, etc.) — style aligné sur la civilité */
.field--radio-cards { border: none; margin: 0; padding: 0; }
.radio-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.radio-card-input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 52px; padding: 10px 14px;
  border: 2px solid var(--color-border, #dee2e6); border-radius: 12px;
  font-weight: 600; color: var(--color-title, #222831); cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.radio-card:hover { border-color: var(--color-primary, #0D9DA4); }
.radio-card-input:focus-visible + .radio-card { outline: 3px solid var(--color-primary, #0D9DA4); outline-offset: 2px; }
.radio-card-input:checked + .radio-card {
  border-color: var(--color-primary, #0D9DA4);
  background: var(--color-primary-light, #E6F7F8);
  color: var(--color-primary, #0D9DA4);
}
