/* ==========================================================
   FORM WIZARD — Marie Julien Cuisine
   Convertit le long formulaire devis en parcours en 4 étapes
   avec progress bar, transitions et cards améliorées.
========================================================== */

/* — Conteneur wizard ———————————————————————————— */
.wizard {
  --wizard-accent: var(--navy, #243B69);
  --wizard-accent-soft: var(--navy-soft, #3a548a);
  --wizard-bg: var(--bg, #FFFEF8);
  --wizard-line: var(--line, rgba(36,59,105,.18));
  --wizard-text: var(--text, #243B69);
  --wizard-text-soft: var(--text-soft, rgba(36,59,105,.7));
  --wizard-peach: var(--peach, #E4CEC2);
}

/* — Progress bar sticky ————————————————————————— */
.wizard-progress {
  position: sticky;
  top: var(--header-h, 64px);
  z-index: 30;
  background: linear-gradient(180deg, var(--wizard-bg) 0%, var(--wizard-bg) 70%, rgba(255,254,248,.85) 100%);
  padding: 16px 0 18px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--wizard-line);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.wizard-progress-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
}
.wizard-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--wizard-text-soft);
}
.wizard-progress-meta .step-label {
  color: var(--wizard-accent);
  font-weight: 700;
}
.wizard-progress-bar {
  height: 4px;
  background: var(--wizard-line);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.wizard-progress-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 25%;
  background: linear-gradient(90deg, var(--wizard-accent) 0%, var(--wizard-accent-soft) 100%);
  border-radius: 999px;
  transition: width .55s cubic-bezier(.4,.2,.2,1);
}

/* Steps dots (sub-indicator) */
.wizard-steps-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}
.wizard-steps-dots .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--wizard-line);
  transition: background .25s, transform .25s;
}
.wizard-steps-dots .dot.is-done { background: var(--wizard-accent); }
.wizard-steps-dots .dot.is-current {
  background: var(--wizard-accent);
  transform: scale(1.6);
}

/* — Steps containers ———————————————————————————— */
/* Reset complet du fieldset natif (bordures, padding, min-width) */
.wizard-step {
  display: none;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  animation: wizard-step-in .5s cubic-bezier(.2,.8,.2,1);
}
.wizard-step legend {
  display: none;
}
.wizard-step.is-active {
  display: block;
}
/* Espacement vertical entre blocs successifs dans un step
   (sans cette règle, les .form-group / .form-row se collaient,
   labels du suivant venant écraser l'input précédent). */
.wizard-step > * + * {
  margin-top: 32px;
}
/* Force le respect de l'attribut [hidden] sur les form-group conditionnels.
   Sans ça, .form-group { display: flex } écrase l'invisibilité par défaut
   du user-agent (qui pose display: none sur [hidden]). */
.form-group[hidden],
.type-autre-detail[hidden] {
  display: none !important;
}
.wizard-step-lead + * {
  margin-top: 24px;
}
@media (max-width: 700px) {
  .wizard-step > * + * {
    margin-top: 24px;
  }
}
@keyframes wizard-step-in {
  0%   { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}
.wizard-step-title {
  font-family: 'Sora', system-ui, sans-serif;
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 600;
  color: var(--wizard-accent);
  margin-bottom: 6px;
  letter-spacing: -0.005em;
}
.wizard-step-title em {
  font-style: italic;
  font-weight: 500;
  color: var(--wizard-accent-soft);
}
.wizard-step-lead {
  font-size: 15px;
  line-height: 1.6;
  color: var(--wizard-text-soft);
  margin-bottom: 32px;
  max-width: 640px;
}

/* — Cards radios améliorées (avec icônes + select state) ————— */
.wizard .radio-grid,
.wizard .checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.wizard .radio-card,
.wizard .check-card {
  position: relative;
  cursor: pointer;
  margin: 0;
  /* En CSS Grid les cellules s'étirent à la hauteur de la rangée par défaut.
     On rend le <label> flex pour que le .card-inner (visible bordered box)
     remplisse cette hauteur → toutes les cards d'une rangée = même taille,
     peu importe la longueur du texte. */
  display: flex;
}
.wizard .radio-card input,
.wizard .check-card input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.wizard .radio-card .radio-card-inner,
.wizard .check-card .check-card-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px 18px;
  background: var(--wizard-bg);
  border: 1px solid var(--wizard-line);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--wizard-text);
  transition: border-color .25s, background .25s, transform .15s, box-shadow .25s;
  /* Rempli toute la hauteur de la cellule (le parent <label> est en
     display:flex, donc width:100% + flex:1 → la card s'étire). */
  width: 100%;
  flex: 1;
}
.wizard .radio-card .icon,
.wizard .radio-card-inner .icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wizard-accent);
}
.wizard .radio-card .icon svg,
.wizard .radio-card-inner .icon svg {
  width: 100%; height: 100%;
}
.wizard .radio-card-inner .label {
  font-size: 14px;
  line-height: 1.3;
}
.wizard .check-card .check-card-inner {
  flex-direction: row;
  align-items: center;
  font-size: 13px;
  padding: 14px 16px;
  gap: 12px;
}
.wizard .check-card .check-card-inner::before {
  content: '';
  flex-shrink: 0;
  width: 18px; height: 18px;
  border: 1.5px solid var(--wizard-line);
  border-radius: 4px;
  background: var(--wizard-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFEF8' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: 0% 0%;
  background-position: center;
  background-repeat: no-repeat;
  transition: all .25s;
}
.wizard .check-card input:checked ~ .check-card-inner::before {
  background-color: var(--wizard-accent);
  border-color: var(--wizard-accent);
  background-size: 70% 70%;
}

/* Hover & focus states */
.wizard .radio-card:hover .radio-card-inner,
.wizard .check-card:hover .check-card-inner {
  border-color: var(--wizard-accent-soft);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(36,59,105,.10);
}
.wizard .radio-card input:checked ~ .radio-card-inner,
.wizard .check-card input:checked ~ .check-card-inner {
  border-color: var(--wizard-accent);
  border-width: 2px;
  background: linear-gradient(135deg, rgba(36,59,105,.06) 0%, rgba(228,206,194,.22) 100%);
  box-shadow: 0 8px 24px rgba(36,59,105,.16);
}
.wizard .radio-card input:checked ~ .radio-card-inner .label,
.wizard .radio-card input:checked ~ .radio-card-inner .icon {
  color: var(--wizard-accent);
  font-weight: 600;
}
/* Compense le passage à border-width 2px pour ne pas faire sauter le layout */
.wizard .radio-card .radio-card-inner,
.wizard .check-card .check-card-inner {
  border-width: 2px;
  border-color: transparent;
  outline: 1px solid var(--wizard-line);
  outline-offset: -1px;
}
.wizard .radio-card input:checked ~ .radio-card-inner,
.wizard .check-card input:checked ~ .check-card-inner {
  outline: 0;
}
.wizard .radio-card input:focus-visible ~ .radio-card-inner,
.wizard .check-card input:focus-visible ~ .check-card-inner {
  outline: 2px solid var(--wizard-accent);
  outline-offset: 3px;
}

/* — Inputs améliorés (floating-style) ——————————————————— */
.wizard .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.wizard .field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wizard .field-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--wizard-text-soft);
}
.wizard .field-label .req {
  color: #c0392b;
  margin-left: 2px;
}
.wizard .field input,
.wizard .field select,
.wizard .field textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--wizard-text);
  background: var(--wizard-bg);
  border: 1px solid var(--wizard-line);
  border-radius: 10px;
  padding: 14px 16px;
  width: 100%;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.wizard .field input:focus,
.wizard .field select:focus,
.wizard .field textarea:focus {
  outline: none;
  border-color: var(--wizard-accent);
  box-shadow: 0 0 0 4px rgba(36,59,105,.08);
}
.wizard .field input:invalid:not(:placeholder-shown):not(:focus),
.wizard .field select:invalid:not(:focus) {
  border-color: rgba(192,57,43,.5);
}
.wizard .field-help {
  font-size: 12px;
  line-height: 1.5;
  color: var(--wizard-text-soft);
  font-style: italic;
}

/* — Submit / Nav buttons ——————————————————————————— */
.wizard-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--wizard-line);
}
.wizard-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 28px;          /* 14→16 : 44px+ touch target (WCAG 2.1) */
  min-height: 44px;             /* garantit la cible tactile minimum */
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 100px;
  cursor: pointer;
  border: 1px solid var(--wizard-accent);
  background: transparent;
  color: var(--wizard-accent);
  transition: background .25s, color .25s, transform .15s, box-shadow .25s;
}
.wizard-btn:hover { transform: translateY(-2px); }
.wizard-btn--prev { padding-left: 16px; }
.wizard-btn--next,
.wizard-btn--submit {
  background: var(--wizard-accent);
  color: var(--wizard-bg);
  box-shadow: 0 8px 24px rgba(36,59,105,.18);
}
.wizard-btn--next:hover,
.wizard-btn--submit:hover {
  background: #1a2c4f;
  box-shadow: 0 14px 30px rgba(36,59,105,.28);
}
.wizard-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.wizard-btn svg { width: 16px; height: 16px; }

/* — Récap final (avant submit) ————————————————————— */
.wizard-recap {
  display: grid;
  gap: 12px;
  background: linear-gradient(135deg, rgba(36,59,105,.03) 0%, rgba(228,206,194,.15) 100%);
  border: 1px solid var(--wizard-line);
  border-radius: 14px;
  padding: 22px 24px;
  margin-top: 24px;
  font-size: 14px;
  line-height: 1.6;
}
.wizard-recap h4 {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--wizard-text-soft);
  font-weight: 600;
  margin-bottom: 8px;
}
.wizard-recap dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 16px;
}
.wizard-recap dt {
  font-size: 12px;
  font-weight: 600;
  color: var(--wizard-text-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.wizard-recap dd {
  color: var(--wizard-text);
  font-weight: 500;
}
.wizard-recap dd:empty::before {
  content: '—';
  color: var(--wizard-text-soft);
  font-weight: 400;
}

/* — Erreurs de validation par étape ——————————————————— */
.wizard-step-error {
  display: none;
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(192,57,43,.08);
  border-left: 3px solid #c0392b;
  border-radius: 0 8px 8px 0;
  color: #c0392b;
  font-size: 13px;
  line-height: 1.5;
}
.wizard-step-error.is-shown { display: block; animation: wizard-shake .35s; }
@keyframes wizard-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* — Mobile : reduce paddings ——————————————————————— */
@media (max-width: 600px) {
  .wizard-progress { padding: 12px 0 14px; }
  .wizard-progress-meta { font-size: 10px; }
  .wizard-actions { flex-wrap: wrap; }
  .wizard-btn { flex: 1 1 auto; justify-content: center; padding: 18px 24px; }
  .wizard-recap dl { grid-template-columns: 1fr; gap: 4px; }
  .wizard-recap dt { margin-top: 8px; }
}

/* — Petit mobile (iPhone SE 320-380px) : cards + grilles + labels — */
@media (max-width: 480px) {
  .wizard .radio-grid,
  .wizard .checkbox-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }
  .wizard .radio-card .radio-card-inner,
  .wizard .check-card .check-card-inner {
    min-height: auto;
    padding: 14px 12px;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.35;
  }
  .wizard .form-group-label {
    font-size: 10px;
    letter-spacing: 0.10em;
  }
}
@media (max-width: 360px) {
  .wizard .radio-grid,
  .wizard .checkbox-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wizard-step,
  .wizard-progress-bar-fill,
  .wizard-btn { animation: none !important; transition: none !important; }
}
