/* ============================================================
   CONVERTU — Tunnel de paiement
   Trois étapes, un récapitulatif permanent, une validation qui
   se voit sans être agressive.
   ============================================================ */

.checkout { padding-top: var(--sp-8); }

.checkout__from {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: 1080px;
  margin: 0 auto var(--sp-7);
  padding: var(--sp-4) var(--sp-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-primary);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  color: var(--c-text-muted);
}
.checkout__from svg { width: 20px; height: 20px; color: var(--c-primary); flex: 0 0 auto; }
.checkout__from strong { color: var(--c-text); }

.checkout__head { max-width: 1080px; margin: 0 auto var(--sp-7); }
.checkout__title { font-size: clamp(1.75rem, 3.6vw, var(--fs-4xl)); margin-bottom: var(--sp-2); }
.checkout__lead { color: var(--c-text-muted); font-size: var(--fs-lg); margin: 0; }

.checkout__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 360px);
  gap: var(--sp-8);
  align-items: start;
  max-width: 1080px;
  margin: 0 auto;
}

.checkout__card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-7);
  box-shadow: var(--sh-md);
}

/* ---------- Fil des étapes ---------- */
.stepper {
  display: flex;
  list-style: none;
  margin: 0 0 var(--sp-5);
  padding: 0;
  counter-reset: step;
}
.stepper__item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--c-border);
  /* Les étapes à venir restent du texte informatif : --c-text-faint tombait à
     3,04:1 sur le fond papier, sous le seuil AA. */
  color: var(--c-text-soft);
  font-size: var(--fs-sm);
  font-weight: 500;
  min-width: 0;
  transition: color var(--t-base), border-color var(--t-base);
}
.stepper__dot {
  width: 24px; height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c-bg-muted);
  color: var(--c-text-soft);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  transition: background var(--t-base), color var(--t-base);
}
.stepper__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stepper__item[data-state="active"] { color: var(--c-text); border-bottom-color: var(--c-primary); }
.stepper__item[data-state="active"] .stepper__dot { background: var(--c-primary); color: #fff; }
.stepper__item[data-state="done"] { color: var(--c-accent-600); border-bottom-color: var(--c-accent); }
.stepper__item[data-state="done"] .stepper__dot {
  background: var(--c-accent); color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}

/* ---------- Contenu d'une étape ---------- */
.step__title { font-size: var(--fs-2xl); margin-bottom: var(--sp-2); outline: none; }
.step__lead { color: var(--c-text-muted); margin-bottom: var(--sp-6); font-size: var(--fs-base); }
.step__actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-7); }
.step__actions .btn { flex: 1; }
.step__actions .btn--secondary { flex: 0 0 auto; }
.step__fineprint { margin-top: var(--sp-5); font-size: var(--fs-sm); color: var(--c-text-soft); line-height: 1.6; }

/* ---------- Champ ---------- */
.fld { margin-bottom: var(--sp-5); }
.fld__label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: var(--sp-2);
}
.fld__opt { font-weight: 400; color: var(--c-text-faint); }
.fld__control { position: relative; display: flex; align-items: center; }
.fld__control .input, .fld__control .select { padding-right: 42px; }

/* Pastille d'état, à droite du champ */
.fld__mark {
  position: absolute;
  right: 14px;
  width: 18px; height: 18px;
  pointer-events: none;
  opacity: 0;
  transform: scale(.7);
  transition: opacity var(--t-fast), transform var(--t-fast);
  background-repeat: no-repeat;
  background-position: center;
}
.fld.is-valid .fld__mark {
  opacity: 1; transform: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%231F7A4C' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}
.fld.is-invalid .fld__mark {
  opacity: 1; transform: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23C0392B' stroke-width='2.6' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cline x1='12' y1='8' x2='12' y2='13'/%3E%3Cline x1='12' y1='16.5' x2='12' y2='16.5'/%3E%3C/svg%3E");
}

.fld.is-valid .input, .fld.is-valid .select { border-color: var(--c-accent); }
.fld.is-invalid .input, .fld.is-invalid .select { border-color: var(--c-danger); }
.fld.is-invalid .input:focus { box-shadow: 0 0 0 3px rgba(192, 57, 43, .16); }

.fld__msg {
  margin: var(--sp-2) 0 0;
  font-size: var(--fs-sm);
  color: var(--c-text-soft);
  line-height: 1.45;
  min-height: 1.1em;
}
.fld__msg--error { color: var(--c-danger); font-weight: 500; }
.fld__fix {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--c-primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.fld-row--postal { grid-template-columns: minmax(0, 140px) minmax(0, 1fr); }

/* Téléphone : l'indicatif est un préfixe figé, pas un champ à remplir */
.fld__control--phone { gap: 0; }
.phone-dial {
  display: inline-flex;
  align-items: center;
  height: 46px;
  padding: 0 var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  color: var(--c-text-muted);
  background: var(--c-bg-soft);
  border: 1px solid var(--c-border-strong);
  border-right: 0;
  border-radius: var(--r-md) 0 0 var(--r-md);
  white-space: nowrap;
  flex: 0 0 auto;
}
.phone-dial.is-empty { display: none; }
.fld__control--phone .input { border-radius: 0 var(--r-md) var(--r-md) 0; }
.fld__control--phone:has(.phone-dial.is-empty) .input { border-radius: var(--r-md); }

/* Carte : la marque s'affiche à droite, la pastille d'état se décale */
.fld__control--card .input { padding-right: 108px; }
.card-brand {
  position: absolute;
  right: 40px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .1em;
  color: var(--c-text-soft);
  pointer-events: none;
}
.card-brand[data-brand="visa"] { color: #1A1F71; }
.card-brand[data-brand="mastercard"] { color: #B3452A; }
.card-brand[data-brand="amex"] { color: #1B6FB0; }

.checkout__toggle {
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--c-border);
  margin-top: var(--sp-2);
}

/* ---------- Résumé des erreurs d'une étape ----------
   Il n'apparaît que quand une étape est bloquée, et se glisse au-dessus des
   boutons. Traité comme un message, pas comme un bandeau : icône, filet
   d'accent, et de l'air au-dessus comme en dessous. */
.checkout-error {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin: var(--sp-6) 0 0;
  padding: var(--sp-4) var(--sp-5);
  background: var(--c-danger-50);
  border: 1px solid #F0CFCA;
  border-left: 3px solid var(--c-danger);
  border-radius: var(--r-md);
  color: #93251A;
  font-size: var(--fs-base);
  font-weight: 500;
  line-height: 1.5;
}
.checkout-error::before {
  content: "";
  flex: 0 0 18px;
  width: 18px; height: 18px;
  margin-top: 1px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23C0392B' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cline x1='12' y1='7.5' x2='12' y2='13'/%3E%3Cline x1='12' y1='16.5' x2='12' y2='16.5'/%3E%3C/svg%3E") no-repeat center;
}
/* Placé avant les boutons, c'est lui qui porte l'écart : on neutralise celui
   que .step__actions ajoutait, sinon les deux se cumulent. */
.checkout-error + .step__actions { margin-top: var(--sp-4); }

/* ---------- Récapitulatif de l'étape 3 ---------- */
.recap {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-4);
  background: var(--c-bg-soft);
}
.recap__row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.recap__label { font-family: var(--font-mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .12em; color: var(--c-text-soft); }
.recap__edit {
  background: none; border: 0;
  /* Marge interne plutôt que texte plus gros : la cible atteint 24 px sans
     déséquilibrer la ligne (WCAG 2.5.8). */
  padding: 4px 6px;
  margin: -4px -6px;
  font: inherit; font-size: var(--fs-sm); font-weight: 600;
  color: var(--c-primary); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
  border-radius: var(--r-xs);
}
.recap__edit:hover { background: var(--c-primary-50); }
.recap__body { margin: 0; font-size: var(--fs-base); color: var(--c-text); line-height: 1.6; }

/* ---------- Colonne récapitulative ---------- */
.summary {
  position: sticky;
  top: calc(var(--header-h) + var(--sp-5));
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  box-shadow: var(--sh-md);
}
.summary__title { font-size: var(--fs-lg); margin-bottom: var(--sp-5); }
.summary__item {
  display: flex; justify-content: space-between; gap: var(--sp-3);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  font-size: var(--fs-base);
}
.summary__item-name { color: var(--c-text); font-weight: 500; }
.summary__item-price { font-family: var(--font-mono); color: var(--c-text); white-space: nowrap; }

.summary__lines { margin: var(--sp-4) 0 0; display: grid; gap: var(--sp-2); }
.summary__lines > div { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--c-text-soft); }
.summary__lines dt, .summary__lines dd { margin: 0; }
.summary__lines dd { font-family: var(--font-mono); }
.summary__total {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--c-border);
}
.summary__total dt { font-size: var(--fs-md); font-weight: 600; color: var(--c-text); }
.summary__total dd { font-size: var(--fs-xl); font-weight: 700; color: var(--c-text); font-family: var(--font-display); letter-spacing: -0.02em; }

.summary__reverse {
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  background: var(--c-accent-50);
  border: 1px solid var(--c-accent-100);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--c-accent-600);
}

.summary__features { list-style: none; padding: 0; margin: var(--sp-6) 0 0; display: grid; gap: var(--sp-2); }
.summary__features li { display: flex; align-items: flex-start; gap: var(--sp-2); margin: 0; font-size: var(--fs-sm); color: var(--c-text-muted); }
.summary__features svg { width: 15px; height: 15px; flex: 0 0 15px; margin-top: 3px; color: var(--c-accent); }

.summary__secure {
  display: flex; align-items: center; gap: var(--sp-2);
  margin: var(--sp-5) 0 0;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--c-border);
  font-size: var(--fs-sm);
  color: var(--c-text-soft);
}
.summary__secure svg { width: 15px; height: 15px; flex: 0 0 15px; }

/* La règle globale `[hidden] { display: none !important }` de style.css se charge
   du masquage ; il suffit de décrire l'état visible. */
.pay-btn-loader { align-items: center; gap: var(--sp-2); }
.pay-btn-loader:not([hidden]) { display: inline-flex; }

/* ---------- Responsive ---------- */
@media (max-width: 940px) {
  .checkout__grid { grid-template-columns: minmax(0, 1fr); gap: var(--sp-6); max-width: 620px; }
  /* Le récapitulatif passe au-dessus du formulaire : sur mobile on veut voir ce
     qu'on achète avant de saisir quoi que ce soit. */
  .summary { position: static; order: -1; }
}
@media (max-width: 620px) {
  .checkout__card { padding: var(--sp-5); }
  .fld-row { grid-template-columns: 1fr; gap: 0; }
  .fld-row--postal { grid-template-columns: minmax(0, 130px) minmax(0, 1fr); gap: var(--sp-3); }
  .stepper__label { display: none; }
  .stepper__item { justify-content: center; }
  .step__actions { flex-direction: column-reverse; }
  .step__actions .btn { width: 100%; }
  .summary__features { display: none; }
}
