/* ==========================================================================================================================
   Commande des guides (lot L4e2) : bouton flottant, fenêtre (<dialog> natif), formulaire en trois temps, page de secours, blocs de commande des pages
   Guides. Jetons du site uniquement ; violet pour l'action, jamais d'or sur un bouton ; un peu de jaune pâle en touche pour le montant.
   ========================================================================================================================== */

/* ---- Bouton flottant « Commander » : fixe en bas à droite, au-dessus du bandeau de cookies, absent de l'impression ---- */
.order-fab {
  position: fixed;
  right: calc(var(--s3) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--s5) + env(safe-area-inset-bottom, 0px) + var(--cookie-offset, 0px));
  z-index: var(--z-totop);
}

.order-fab .btn {
  box-shadow: var(--ombre-carte);
}

/* Le bouton « retour en haut » se place AU-DESSUS du bouton flottant sur les pages Guides. */
body:has(.order-fab) .totop {
  bottom: calc(var(--s5) + var(--h-md) + var(--s3) + env(safe-area-inset-bottom, 0px) + var(--cookie-offset, 0px));
}

/* Le bas de la page laisse la place du bouton : il ne masque jamais la dernière ligne du pied de page. */
body:has(.order-fab) .footer {
  padding-bottom: calc(var(--s7) + var(--h-md));
}

html.order-is-open .order-fab {
  display: none;
}

/* Mis à l'écart (JavaScript) tant qu'il recouvrirait un lien, un bouton ou le sommaire, ou qu'un bouton « Acheter » / « Commander ce guide » est visible. */
.order-fab.is-tucked {
  visibility: hidden;
  opacity: 0;
}

/* Mobile : bouton rond de 48 px, icône seule ; le libellé « Commander » reste le nom accessible. */
@media (max-width: 47.99em) {
  .order-fab .btn {
    width: 48px;
    height: 48px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .order-fab .btn__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .order-fab .icon {
    width: 24px;
    height: 24px;
  }
}

@media print {
  .order-fab,
  .order {
    display: none !important;
  }
}

/* ---- Fenêtre ---- */
html.order-lock {
  overflow: hidden;
}

dialog.order {
  box-sizing: border-box;
  width: min(46rem, calc(100vw - 2 * var(--s4)));
  max-width: none;
  max-height: calc(100dvh - 2 * var(--s4));
  padding: 0;
  overflow: hidden;
  color: var(--encre);
  background: var(--blanc);
  border: 1px solid var(--ligne);
  border-radius: var(--rayon);
  box-shadow: var(--ombre-menu);
}

dialog.order[open] {
  display: flex;
  flex-direction: column;
}

dialog.order::backdrop {
  background: color-mix(in srgb, var(--violet) 55%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
  dialog.order[open] {
    animation: order-in 0.24s cubic-bezier(0.22, 0.8, 0.3, 1);
  }
}

html[data-motion="reduced"] dialog.order[open] {
  animation: none;
}

@keyframes order-in {
  from {
    opacity: 0;
    translate: 0 12px;
  }
}

.order__panel {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.order__head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  background: var(--fond);
  border-bottom: 1px solid var(--ligne);
}

.order__title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.2;
  color: var(--violet);
}

.order__close {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: var(--h-md);
  height: var(--h-md);
  padding: 0;
  color: var(--violet);
  cursor: pointer;
  background: var(--blanc);
  border: 1px solid var(--violet);
  border-radius: var(--rayon-bouton);
}

.order__close:hover {
  background: var(--violet-pale);
}

.order__close .icon {
  width: 20px;
  height: 20px;
}

.order__body,
.order__result {
  flex: 1;
  scroll-padding-bottom: 7rem;
  min-height: 0;
  padding: 0 var(--s5);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.order__intro {
  margin: var(--s4) 0 0;
  color: var(--encre-2);
}

/* ---- Formulaire ---- */
.order__form {
  display: block;
}

.order__summary {
  margin-top: var(--s4);
  padding: var(--s3) var(--s4);
  font-weight: 700;
  color: var(--erreur);
  background: var(--erreur-pale);
  border-radius: var(--rayon-bouton);
}

.order__summary p {
  margin: 0;
}

.order__step {
  min-width: 0;
  margin: var(--s5) 0 0;
  padding: 0;
  border: 0;
}

.order__legend {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s3);
  padding: 0;
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--violet);
}

.order__num {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: var(--fs-sm);
  color: var(--blanc);
  background: var(--violet);
  border-radius: 50%;
}

.order__error {
  margin: var(--s2) 0 0;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--erreur);
}

.order__error[hidden],
.order__summary[hidden],
.order__hint[hidden] {
  display: none;
}

.order__hint {
  margin: var(--s1) 0 0;
  font-size: var(--fs-sm);
  color: var(--encre-2);
}

/* Les deux guides : cartes à cocher */
.order__guides {
  display: grid;
  gap: var(--s3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.order__guide {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3);
  background: var(--blanc);
  border: 2px solid var(--ligne);
  border-radius: var(--rayon);
}

.order__guide.is-checked {
  background: var(--violet-pale);
  border-color: var(--violet-2);
}

.order__check {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--violet);
}

.order__guide > .order__check {
  position: absolute;
  top: var(--s3);
  left: var(--s3);
  z-index: 1;
}

.order__guide-card {
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-width: 0;
  padding-left: calc(22px + var(--s3));
  cursor: pointer;
}

.order__guide-card img {
  flex: none;
  width: 64px;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 6px 14px -8px color-mix(in srgb, var(--violet) 50%, transparent);
}

.order__guide-text {
  display: grid;
  gap: var(--s1);
  min-width: 0;
  font-size: var(--fs-sm);
}

.order__guide-text b {
  font-size: var(--fs-base);
  line-height: 1.25;
  color: var(--violet);
}

.order__price {
  font-weight: 800;
  color: var(--or-texte);
}

.order__qty {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
}

.order__qty-btn {
  display: inline-grid;
  place-items: center;
  width: var(--h-md);
  height: var(--h-md);
  padding: 0;
  color: var(--violet);
  cursor: pointer;
  background: var(--blanc);
  border: 1px solid var(--violet-2);
  border-radius: var(--rayon-bouton);
}

.order__qty-btn:disabled,
.order__qty-input:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.order__qty-btn .icon {
  width: 18px;
  height: 18px;
}

/* « Une de moins » : le chevron du kit pointe vers le bas. */
.order__qty-input {
  box-sizing: border-box;
  width: 52px;
  height: var(--h-md);
  padding: 0;
  font: inherit;
  font-weight: 800;
  color: var(--violet);
  text-align: center;
  background: var(--blanc);
  border: 2px solid var(--violet-2);
  border-radius: var(--rayon-bouton);
}

/* Coordonnées */
.order__grid {
  display: grid;
  gap: var(--s4);
}

@media (min-width: 40em) {
  .order__grid {
    grid-template-columns: 1fr 1fr;
  }

  .order__field--wide {
    grid-column: 1 / -1;
  }
}

.order__label {
  display: block;
  margin-bottom: var(--s1);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--violet);
}

.order__input {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: var(--s2) var(--s3);
  font: inherit;
  font-size: calc(16px * var(--echelle));
  color: var(--violet);
  background: var(--blanc);
  border: 2px solid var(--violet-2);
  border-radius: var(--rayon-bouton);
}

textarea.order__input {
  resize: vertical;
}

.order__input[aria-invalid="true"],
.order__qty-input[aria-invalid="true"] {
  border-color: var(--erreur);
}

/* Moyens de paiement : cartes à choix unique */
.order__methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
  gap: var(--s3);
}

.order__method {
  position: relative;
}

.order__radio {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  opacity: 0;
}

.order__method-card {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 56px;
  padding: var(--s2) var(--s3);
  background: var(--blanc);
  border: 2px solid var(--ligne);
  border-radius: var(--rayon);
}

.order__radio:checked + .order__method-card {
  background: var(--violet-pale);
  border-color: var(--violet-2);
}

.order__radio:focus-visible + .order__method-card {
  outline: 3px solid var(--violet);
  outline-offset: 2px;
}

.order__logo {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 32px;
  color: var(--violet-2);
  background: var(--fond-2);
  border-radius: 6px;
}

.order__logo .icon {
  width: 20px;
  height: 20px;
}

.order__method-name {
  font-weight: 800;
  white-space: nowrap;
  line-height: 1.2;
  color: var(--violet);
}

.order__payer {
  max-width: 24rem;
  margin-top: var(--s4);
}

.order__payer[hidden],
.order__card-note[hidden] {
  display: none;
}

.order__card-note,
.order__notice {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  margin: var(--s4) 0 0;
  padding: var(--s3) var(--s4);
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--encre);
  background: var(--info-pale);
  border-radius: var(--rayon-bouton);
}

.order__notice {
  background: var(--attente-pale);
}

.order__notice--ok {
  background: var(--succes-pale);
}

.order__card-note .icon,
.order__notice .icon {
  flex: none;
  width: 20px;
  height: 20px;
}

/* Consentement, total et envoi */
.order__consent {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  margin-top: var(--s5);
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.order__consent .order__check {
  flex: none;
  margin-top: 2px;
}

.order__consent a {
  font-weight: 800;
  color: var(--violet);
}

.order__foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3) var(--s5);
  margin: var(--s5) calc(-1 * var(--s5)) 0;
  padding: var(--s4) var(--s5);
  background: var(--blanc);
  border-top: 1px solid var(--ligne);
}

.order__total {
  display: grid;
  gap: 0;
  margin: 0;
  padding: var(--s2) var(--s4);
  background: var(--or-pale);
  border-radius: var(--rayon-bouton);
}

.order__total[hidden] {
  display: none;
}

.order__total-label {
  font-size: var(--fs-sm);
  color: var(--or-texte);
}

.order__total-amount {
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.2;
  color: var(--violet);
}

.order__submit {
  margin-left: auto;
}

.order__trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Résultat */
.order__result {
  padding-top: var(--s6);
  padding-bottom: var(--s6);
}

.order__result[hidden],
.order__body[hidden] {
  display: none;
}

.order__result:focus {
  outline: none;
}

.order__result-text {
  margin: 0 0 var(--s5);
  padding: var(--s4) var(--s5);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.5;
  color: var(--violet);
  background: var(--succes-pale);
  border-radius: var(--rayon);
}

.order__result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
}

/* Mobile : la fenêtre occupe l'écran, le défilement est interne, le bouton d'envoi reste atteignable (barre collante). */
@media (max-width: 40em) {
  dialog.order {
    width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .order__body,
  .order__result {
    padding: 0 var(--s4);
  }

  .order__head {
    padding: var(--s3) var(--s4);
  }

  .order__foot {
    margin-inline: calc(-1 * var(--s4));
    padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom, 0px));
  }

  .order__submit {
    flex: 1 1 100%;
    justify-content: center;
    margin-left: 0;
  }

  .order__guide {
    grid-template-columns: 1fr;
  }
}

/* Page de secours */
.order-page {
  max-width: 46rem;
  padding-block: var(--s6) var(--s8);
}

.order-page .order__foot {
  position: static;
  margin-inline: 0;
  padding-inline: 0;
}

/* ---- Blocs de commande des pages Guides ---- */
.guide-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3) var(--s5);
  margin-top: var(--s4);
}

.guide-price {
  display: inline-block;
  margin: var(--s2) 0 0;
  padding: var(--s1) var(--s3);
  font-weight: 800;
  color: var(--violet);
  background: var(--or-pale);
  border-radius: var(--rayon-bouton);
}

.guide-order {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3) var(--s5);
  margin-top: var(--s4);
}

.guide-order__price {
  margin: 0;
  padding: var(--s2) var(--s4);
  color: var(--or-texte);
  background: var(--or-pale);
  border-radius: var(--rayon-bouton);
}

.guide-order__price strong {
  color: var(--violet);
}

/* Lot G1b : ALIGNEMENT des champs d'une même ligne de la commande (méthode de G1 : sous-grille). Chaque champ de `.order__grid` est une sous-grille de quatre lignes : libellé, zone de saisie, aide courte, erreur ; la liste
   `.fld` (ville, commune) occupe les trois premières et les partage. Les libellés d'une ligne partagent donc la même hauteur : « Adresse e-mail (facultatif) » et « Ville », « Commune » et « Quartier » ont leur zone de saisie sur la même
   ligne horizontale ; une erreur sous un champ n'agrandit que SA colonne en bas. Les icônes d'aide sont positionnées en absolu et ne prennent aucune place. Sans sous-grille (navigateur ancien) : rendu empilé, utilisable. */
@supports (grid-template-rows: subgrid) {
  .order__grid {
    row-gap: 0;
  }

  .order__grid > .order__field {
    display: grid;
    grid-row: span 4;
    grid-template-rows: subgrid;
    row-gap: 0;
    padding-bottom: var(--s4);
  }

  .order__grid > .order__field > .fld {
    display: grid;
    grid-row: 1 / span 3;
    grid-template-rows: subgrid;
    row-gap: 0;
  }

  .order__grid > .order__field > .fld > label {
    margin-bottom: var(--s1);
  }

  .order__grid > .order__field > .order__error[hidden] {
    display: none;
  }
}
