/*
 * Tunnel de commande : récapitulatif, livraison, paiement.
 * Chargé par les trois pages — le récapitulatif de droite y est identique.
 * Les jetons viennent de fondations.css : aucune couleur en dur ici.
 */

/* — Récapitulatif — */

.recapitulatif {
    position: sticky;
    top: var(--espace-3);
    padding: var(--espace-4);
    background: var(--blanc-chaud);
    border-radius: var(--rayon-l);
    box-shadow: var(--ombre-carte);
}

.recapitulatif__titre {
    font-family: var(--police-titre);
    font-size: var(--taille-m);
    font-weight: 700;
    color: var(--texte);
    margin: 0 0 var(--espace-3);
}

.recapitulatif__lignes {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--espace-1) var(--espace-2);
    margin: 0 0 var(--espace-3);
    font-size: var(--taille-s);
    color: var(--texte-doux);
}
.recapitulatif__lignes dt { margin: 0; }
.recapitulatif__lignes dd { margin: 0; text-align: right; color: var(--texte); }

.recapitulatif__lignes .recapitulatif__total {
    padding-top: var(--espace-2);
    border-top: 1px solid var(--creme-sombre);
    font-size: var(--taille-m);
    font-weight: 700;
    color: var(--texte);
}

.recapitulatif__message {
    margin: 0 0 var(--espace-2);
    font-size: var(--taille-xs);
    line-height: 1.5;
    color: var(--texte-doux);
}
.recapitulatif__message:empty { margin: 0; }
.recapitulatif__message--erreur { color: var(--bordeaux); font-weight: 600; }

.recapitulatif__commander {
    width: 100%;
    justify-content: center;
}

.recapitulatif__retour {
    display: block;
    margin-top: var(--espace-2);
    text-align: center;
    font-size: var(--taille-s);
    color: var(--texte-doux);
}
.recapitulatif__retour:hover { color: var(--bordeaux-vif); }

.recapitulatif__garanties {
    list-style: none;
    margin: var(--espace-3) 0 0;
    padding: var(--espace-3) 0 0;
    border-top: 1px solid var(--creme-sombre);
    display: flex;
    flex-direction: column;
    gap: var(--espace-1);
    font-size: var(--taille-xs);
    color: var(--texte-doux);
}
.recapitulatif__garanties li::before {
    content: "✓";
    margin-right: var(--espace-1);
    color: var(--bordeaux-vif);
}


/* — Les pages livraison et paiement — */

.tunnel { padding-bottom: var(--espace-8); }

.tunnel__titre {
    font-family: var(--police-titre);
    font-size: var(--taille-xl);
    font-weight: 700;
    color: var(--texte);
    margin: var(--espace-5) 0 var(--espace-3);
}

.tunnel__etat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--espace-3);
    max-width: 34rem;
    margin-inline: auto;
    padding: var(--espace-8) var(--espace-3);
    text-align: center;
    color: var(--texte-doux);
    background: var(--blanc-chaud);
    border-radius: var(--rayon-l);
    box-shadow: var(--ombre-carte);
}
.tunnel__etat--erreur { color: var(--bordeaux); }

.tunnel__corps {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 21rem;
    align-items: start;
    gap: var(--espace-4);
}

.tunnel__colonne {
    display: flex;
    flex-direction: column;
    gap: var(--espace-3);
    min-width: 0;
}

/* — Les trois jalons — */

.jalons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--espace-2);
    list-style: none;
    margin: 0 0 var(--espace-4);
    padding: 0;
    font-size: var(--taille-s);
    color: var(--texte-doux);
    counter-reset: jalon;
}
.jalons__etape { counter-increment: jalon; }
.jalons__etape::before {
    content: counter(jalon);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    margin-right: var(--espace-1);
    border-radius: var(--rayon-rond);
    background: var(--creme-sombre);
    font-size: var(--taille-xs);
    font-weight: 600;
    color: var(--texte-doux);
}
.jalons__etape + .jalons__etape::after { content: none; }
.jalons__etape + .jalons__etape { margin-left: var(--espace-2); }
.jalons__etape--faite a { color: var(--bordeaux-vif); }
.jalons__etape--faite::before {
    background: var(--rose-pale);
    color: var(--bordeaux-vif);
}
.jalons__etape--courante {
    color: var(--texte);
    font-weight: 600;
}
.jalons__etape--courante::before {
    background: var(--bordeaux-vif);
    color: var(--texte-inverse);
}

/* — Une section du tunnel — */

.carte {
    padding: var(--espace-4);
    background: var(--blanc-chaud);
    border-radius: var(--rayon-l);
    box-shadow: var(--ombre-carte);
}

.carte__titre {
    font-family: var(--police-titre);
    font-size: var(--taille-m);
    font-weight: 700;
    color: var(--texte);
    margin: 0 0 var(--espace-3);
}

/* — Formulaire d'adresse — */

.formulaire {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--espace-2);
}

.champ { grid-column: span 6; }
.champ--moitie { grid-column: span 3; }
.champ--tiers { grid-column: span 2; }
.champ--deux-tiers { grid-column: span 4; }

.champ label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: var(--taille-xs);
    font-weight: 600;
    color: var(--texte);
}
.champ__facultatif { font-weight: 400; color: var(--texte-doux); }

.champ input,
.champ select {
    width: 100%;
    /* 44 px de haut : cible tactile minimale, ENF-01. */
    min-height: 44px;
    padding: 0 var(--espace-2);
    border: 1px solid var(--creme-sombre);
    border-radius: var(--rayon-s);
    background: var(--creme);
    font-family: var(--police-corps);
    font-size: var(--taille-s);
    color: var(--texte);
}
.champ input:focus,
.champ select:focus {
    outline: 2px solid var(--bordeaux-vif);
    outline-offset: 1px;
    background: var(--blanc-chaud);
}
.champ input:invalid:not(:placeholder-shown) { border-color: var(--bordeaux); }

.formulaire__erreur,
.points__erreur {
    grid-column: span 6;
    margin: 0;
    font-size: var(--taille-xs);
    font-weight: 600;
    color: var(--bordeaux);
}
.formulaire__erreur:empty,
.points__erreur:empty { display: none; }

.formulaire__valider {
    grid-column: span 6;
    justify-content: center;
    margin-top: var(--espace-1);
}

/* — Modes de livraison et points relais — */

.modes,
.points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--espace-2);
}

/*
 * Au-delà de cinq points, la liste ferait défiler la page entière avant
 * d'atteindre le récapitulatif. Elle défile donc dans sa propre boîte.
 */
.points {
    max-height: 26rem;
    overflow-y: auto;
    padding-right: var(--espace-1);
}

.mode,
.point {
    display: flex;
    align-items: flex-start;
    gap: var(--espace-2);
    padding: var(--espace-2) var(--espace-3);
    border: 1px solid var(--creme-sombre);
    border-radius: var(--rayon-m);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.mode:hover,
.point:hover { border-color: var(--rose-pale); background: var(--creme); }

.mode__choix,
.point__choix {
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 0.15rem;
    accent-color: var(--bordeaux-vif);
}

.mode:has(.mode__choix:checked),
.point:has(.point__choix:checked) {
    border-color: var(--bordeaux-vif);
    background: var(--rose-tres-pale);
}

.mode__texte,
.point__texte {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    min-width: 0;
}

.mode__nom,
.point__nom {
    font-size: var(--taille-s);
    font-weight: 600;
    color: var(--texte);
}

.mode__mention,
.point__adresse,
.point__horaires {
    font-size: var(--taille-xs);
    color: var(--texte-doux);
}
.point__horaires { line-height: 1.5; }

.mode__prix {
    flex: none;
    font-size: var(--taille-s);
    font-weight: 600;
    color: var(--texte);
    white-space: nowrap;
}

.points__element--attente { opacity: 0.5; pointer-events: none; }

.points__intro {
    margin: 0 0 var(--espace-2);
    font-size: var(--taille-xs);
    color: var(--texte-doux);
}
.points__intro:empty { display: none; }

/* — Résumé des articles dans le récapitulatif — */

.resume {
    list-style: none;
    margin: 0 0 var(--espace-3);
    padding: 0 0 var(--espace-3);
    border-bottom: 1px solid var(--creme-sombre);
    display: flex;
    flex-direction: column;
    gap: var(--espace-2);
}

.resume__ligne {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: var(--espace-2);
    align-items: center;
}

.resume__ligne img {
    width: 48px;
    height: 48px;
    border-radius: var(--rayon-s);
    object-fit: cover;
}

.resume__nom {
    margin: 0;
    font-size: var(--taille-xs);
    font-weight: 600;
    color: var(--texte);
    /* Deux lignes au plus : certains noms dépassent quarante caractères. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.resume__detail {
    margin: 0;
    font-size: var(--taille-xs);
    color: var(--texte-doux);
}

.resume__montant {
    margin: 0;
    font-size: var(--taille-xs);
    font-weight: 600;
    color: var(--texte);
    white-space: nowrap;
}

/* — Sous 960 px : le récapitulatif passe sous le formulaire — */

@media (max-width: 960px) {
    .tunnel__corps { grid-template-columns: minmax(0, 1fr); }
    .recapitulatif { position: static; }
}

@media (max-width: 560px) {
    .tunnel__titre { font-size: var(--taille-l); }
    /* Les champs à moitié de largeur deviennent pleine largeur : deux colonnes
       de saisie sous 560 px donnent des champs trop courts pour un nom. */
    .champ--moitie,
    .champ--tiers,
    .champ--deux-tiers { grid-column: span 6; }
    .carte { padding: var(--espace-3); }
}

/* — Vérification et remise au paiement — */

.verification {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--espace-1) var(--espace-3);
    margin: 0;
    font-size: var(--taille-s);
}
.verification dt {
    margin: 0;
    font-weight: 600;
    color: var(--texte-doux);
    white-space: nowrap;
}
.verification dd { margin: 0; color: var(--texte); }

.remise__texte {
    margin: 0 0 var(--espace-3);
    font-size: var(--taille-s);
    line-height: 1.6;
    color: var(--texte-doux);
}

.remise__avertissement {
    margin: 0 0 var(--espace-3);
    padding: var(--espace-2) var(--espace-3);
    border-left: 3px solid var(--bordeaux-vif);
    border-radius: var(--rayon-s);
    background: var(--rose-tres-pale);
    font-size: var(--taille-xs);
    line-height: 1.6;
    color: var(--texte);
}

.remise__bouton {
    justify-content: center;
    text-decoration: none;
}
/* Empêché, pas caché : le parcours reste visible et vérifiable. */
.remise__bouton--empeche { opacity: 0.55; }

.remise__mention {
    margin: var(--espace-2) 0 0;
    font-size: var(--taille-xs);
    color: var(--texte-doux);
}

@media (max-width: 560px) {
    .verification { grid-template-columns: minmax(0, 1fr); }
    .verification dd { margin-bottom: var(--espace-1); }
}

/*
 * Mention sous un champ : dit pourquoi on demande cette donnée. Le courriel et
 * le téléphone ne servent pas à livrer mais à suivre la commande — sans cette
 * précision, ils passent pour de la collecte gratuite.
 */
.champ__aide {
    margin: 0.3rem 0 0;
    font-size: var(--taille-xs);
    line-height: 1.4;
    color: var(--texte-doux);
}


/* — Étapes de la livraison — */
/* Le titre qui défile en haut de l'écran ne passe pas sous l'en-tête collant. */
.etape { scroll-margin-top: 110px; }
.etape__numero {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 1.6rem;
    height: 1.6rem;
    margin-right: 0.4rem;
    border-radius: var(--rayon-rond);
    background: var(--bordeaux-vif);
    color: var(--texte-inverse);
    font-family: var(--police-corps);
    font-size: 0.875rem;
    font-weight: 700;
    vertical-align: 0.15em;
}
/* Étape faite : la pastille passe au vert et prend une coche. */
.etape--faite .etape__numero { background: #46604c; color: transparent; }
.etape--faite .etape__numero::after {
    content: "✓";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--texte-inverse);
}

.adresse-resume {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--espace-3);
    padding: var(--espace-2) var(--espace-3);
    border-radius: var(--rayon-m);
    background: var(--creme);
}
.adresse-resume[hidden] { display: none; }
.adresse-resume p { margin: 0; line-height: 1.6; color: var(--texte); }
.adresse-resume__nom { font-weight: 700; }
.adresse-resume__contact { color: var(--texte-doux) !important; font-size: var(--taille-s); }
.adresse-resume__modifier {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 var(--espace-2);
    border: 1px solid var(--bordeaux);
    border-radius: var(--rayon-rond);
    background: transparent;
    color: var(--bordeaux);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.adresse-resume__modifier:hover { background: var(--bordeaux); color: var(--texte-inverse); }
.adresse-resume__modifier:focus-visible { outline: 3px solid var(--rose-vif); outline-offset: 2px; }
.formulaire[hidden] { display: none; }


/* — Mobile : résumé d'adresse, cartes et barre de commande — */
.barre-commande { display: none; }

@media (max-width: 960px) {
    .barre-commande:not([hidden]) {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 50;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--espace-2);
        padding: var(--espace-1) var(--espace-2) calc(var(--espace-1) + env(safe-area-inset-bottom));
        background: var(--blanc-chaud);
        box-shadow: 0 -4px 18px rgb(100 18 28 / 12%);
        transition: transform var(--transition);
    }
    .barre-commande--masquee { transform: translateY(110%); }
    .barre-commande__total { margin: 0; font-size: var(--taille-s); color: var(--texte-doux); }
    .barre-commande__total strong { display: block; font-size: var(--taille-m); color: var(--texte); }
    .barre-commande__bouton { flex: 0 1 auto; min-width: 150px; justify-content: center; }
    .barre-commande__bouton:disabled { opacity: 0.5; }
    /* La barre ne doit rien cacher en bas de page. */
    .tunnel { padding-bottom: calc(var(--espace-8) + 72px); }
}

@media (max-width: 560px) {
    .carte { padding: var(--espace-3) var(--espace-2); }
    /* Le bouton « Modifier » passe sous l'adresse : à côté, il la serrait
       sur une colonne de dix caractères. */
    .adresse-resume { flex-direction: column; gap: var(--espace-2); padding: var(--espace-2); }
    .adresse-resume__modifier { align-self: flex-start; }
}
