/* Bulletin de commande (commander.html), dans l'identité « La page de titre ». Complète style.css.
   Le formulaire se lit comme un bulletin en quatre parties : chiffre romain de la partie, filets fins,
   questions de l'aperçu composées comme un sommaire, carte cadeau dessinée par carte.js, et sur grand écran
   la dédicace qui s'écrit à mesure qu'on remplit. Logique, identifiants et validation : commander.js. */

main.commande { padding-block: 28px 64px; }
.commande-tete { display: grid; gap: 10px; max-width: 40rem; margin-bottom: 34px; }
.commande-tete h1 { font-size: clamp(2.2rem, 7vw, 3.4rem); }
.commande-tete .muted { font-size: 1.06rem; }
.commande-tete .petit { font-size: 1rem; }
.commande-grille { display: grid; gap: 40px; align-items: start; }
.commande-grille > * { min-width: 0; }
.commande-form { display: grid; gap: 32px; max-width: 44rem; }
.commande-aside { display: none; }
@media (min-width: 1000px) {
  .commande-grille { grid-template-columns: minmax(0, 1fr) 19rem; gap: 64px; }
  .commande-aside { display: block; position: sticky; top: 88px; }
}

/* Progression : quatre parties, la seconde couleur pour ce qui est fait */
.progression { display: grid; gap: 10px; scroll-margin-top: 80px; }
.progression-texte { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.progression-num { font-style: italic; font-size: 1rem; color: var(--rubrique); }
.progression-nom { font-weight: 600; }
.progression-etapes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.progression-etapes li { display: grid; gap: 6px; }
.progression-etapes li::before { content: ""; height: 3px; background: var(--filet); }
.progression-etapes li.fait::before, .progression-etapes li.courant::before { background: var(--rubrique); }
.progression-lien { font: 400 .98rem/1.25 var(--texte); color: var(--encre-2); background: none; border: 0; padding: 6px 0; margin-top: -6px; min-height: 44px; text-align: left; cursor: pointer; }
.progression-lien:disabled { cursor: default; }
.progression-etapes li.fait .progression-lien { color: var(--encre); text-decoration: underline; text-underline-offset: 3px; }
.progression-etapes li.courant .progression-lien { color: var(--encre); font-weight: 600; }
@media (max-width: 480px) {
  .progression-lien { font-size: .9rem; }
}

/* Parties du bulletin */
.etape { display: grid; gap: 26px; }
.etape-tete { display: grid; gap: 6px; }
.etape-tete h2 { display: flex; align-items: baseline; gap: .45em; font-size: clamp(1.9rem, 6vw, 2.4rem); }
.etape-tete h2:focus { outline: none; }
/* Chiffre romain de la partie : décoratif (texte de remplacement vide pour les lecteurs d'écran). */
.etape-tete h2::before { font-family: var(--titre); font-style: normal; font-size: .9em; color: var(--rubrique); }
#etape-1 .etape-tete h2::before { content: "I"; content: "I" / ""; }
#etape-2 .etape-tete h2::before { content: "II"; content: "II" / ""; }
#etape-3 .etape-tete h2::before { content: "III"; content: "III" / ""; }
#etape-4 .etape-tete h2::before { content: "IV"; content: "IV" / ""; }
.etape-tete .muted { font-style: italic; }
.field .hint { margin-top: -2px; }
.field-court input { max-width: 9rem; }
.field-moyen input { max-width: 16rem; }
.facultatif { font-style: italic; font-weight: 400; font-size: .92rem; color: var(--encre-2); margin-left: .3em; white-space: nowrap; }
.field legend { padding: 0; margin-bottom: 2px; }
fieldset.field { gap: 8px; }
.field .error::before { content: "! "; font-weight: 700; }
.compteur { font-size: .92rem; font-variant-numeric: tabular-nums; color: var(--encre-2); text-align: right; }
.date-longue { font-style: italic; font-size: 1.1rem; color: var(--rubrique); }
.date-longue:empty { display: none; }
.field label.choice, .field label.check { font-weight: 400; font-size: inherit; }
.choice input[aria-invalid="true"] + span { border-color: var(--danger); }
.check { cursor: pointer; }
.check input { width: 1.2rem; height: 1.2rem; flex: none; accent-color: var(--toile); }
.check input[aria-invalid="true"] { outline: 2px solid var(--danger); outline-offset: 2px; }
/* Case en erreur et sélectionnée au clavier : le contour du focus reste visible, l'erreur passe en ombre. */
.check input[aria-invalid="true"]:focus-visible { outline: 3px solid var(--encre); outline-offset: 2px; box-shadow: 0 0 0 2px var(--danger); }
.check a, .check + .hint a { color: var(--encre); text-underline-offset: 3px; }
.check + .hint { padding-left: 1.85rem; }
.lien { display: inline-block; font: inherit; font-size: 1rem; font-style: italic; color: var(--encre); background: none; border: 0; padding: 10px 0; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.lien:hover { color: var(--rubrique); }

/* « Passer cette étape » : les parties II et III sont entièrement facultatives (commander-passer.js). */
.passer { margin-top: -4px; }

/* Navigation entre les parties ; sous « Payer », les trois faits de l'accueil (partie IV seulement). */
.faits-paiement { margin-top: -14px; justify-self: end; text-align: right; max-width: 26rem; }
#etape-4[hidden] ~ .faits-paiement { display: none; }
.nav-etapes { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; border-top: 1px solid var(--filet); padding-top: 24px; }
.nav-etapes #btn-suivant, .nav-etapes .btn-payer { margin-left: auto; }
.btn-payer { font-size: 1.15rem; padding-inline: 2rem; }
.btn.chargement { padding-left: 3rem; opacity: .9; cursor: progress; }
.btn.chargement::before { content: ""; position: absolute; left: 1.2rem; top: 50%; width: 1rem; height: 1rem; margin-top: -.5rem; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn.chargement::before { animation: none; border-right-color: currentColor; opacity: .6; }
}
#erreur-envoi:focus { outline: 3px solid var(--danger); outline-offset: 2px; }
@media (max-width: 420px) {
  .nav-etapes .btn { flex: 1 1 auto; text-align: center; }
}

/* Aperçu des 52 questions, composé comme le sommaire du livre */
.apercu { display: grid; gap: 20px; border-top: 1px solid var(--filet); padding-top: 28px; }
.apercu-tete { display: grid; gap: 8px; }
.apercu-tete h3 { font-family: var(--titre); font-style: italic; font-weight: 400; font-size: clamp(1.6rem, 4.6vw, 2rem); line-height: 1.1; }
.apercu-liste { display: grid; gap: 0; border-top: 1px solid var(--filet); }
.trimestre { border-bottom: 1px solid var(--filet); }
.trimestre > summary { cursor: pointer; padding: 14px 0; min-height: 44px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; list-style: none; }
.trimestre > summary::-webkit-details-marker { display: none; }
.trimestre > summary::before { content: "+"; font-family: var(--titre); font-size: 1.4rem; line-height: 1; color: var(--rubrique); width: 1rem; flex: none; }
.trimestre[open] > summary::before { content: "\2212"; }
.trimestre-titre { font-family: var(--titre); font-style: italic; font-size: 1.4rem; line-height: 1.15; }
.trimestre-sous { font-size: .96rem; font-style: italic; color: var(--encre-2); }
.q-liste { list-style: none; margin: 0; padding: 0 0 10px; }
.q { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; padding-block: 12px; border-top: 1px solid color-mix(in srgb, var(--filet) 70%, transparent); align-items: start; }
.q-tete { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0 .7em; font-size: .94rem; font-style: italic; color: var(--encre-2); }
.q-semaine { font-style: normal; color: var(--rubrique); font-weight: 600; }
.q-tete > span + span::before { content: "·"; margin-right: .7em; font-style: normal; }
.q-texte { font-size: 1.08rem; line-height: 1.42; overflow-wrap: anywhere; }
.q-perso .q-theme { color: var(--encre); }
.q-perso .q-texte { font-style: italic; }
.q-retirer { font: 400 .98rem var(--texte); color: var(--encre); background: transparent; border: 1px solid var(--filet-champ); border-radius: 2px; padding: 8px 14px; min-height: 44px; cursor: pointer; white-space: nowrap; }
.q-retirer:hover { border-color: var(--danger); color: var(--danger); }
.q-erreur { grid-column: 1 / -1; color: var(--danger); font-size: .96rem; font-weight: 600; }

.retirees { border: 1px dashed var(--filet-champ); padding: 12px 16px; }
.retirees > summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.retirees-liste { list-style: none; margin: 8px 0 0; padding: 0; display: grid; }
.retiree { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start; padding-block: 8px; border-top: 1px solid var(--filet); }
.retiree .q-texte { color: var(--encre-2); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--encre-2) 60%, transparent); }

.ajout-ligne { display: flex; gap: 8px; }
.ajout-ligne input { flex: 1 1 auto; min-width: 0; }
.ajout-ligne .btn { flex: none; min-height: 48px; }
.ajout .compteur { text-align: left; }
@media (max-width: 420px) {
  .ajout-ligne { flex-direction: column; }
  .ajout-ligne .btn { align-self: flex-start; }
}

/* Carte cadeau et récapitulatif */
.carte-apercu { margin: 0; display: grid; gap: 8px; }
.carte-legende { font-style: italic; color: var(--encre-2); }
.carte-apercu canvas { width: 100%; height: auto; aspect-ratio: 2480 / 1748; display: block; border-radius: 2px; box-shadow: 0 1px 1px rgba(0, 0, 0, .2), 0 22px 40px -26px rgba(var(--ombre), .7); background: var(--toile); }
.recap { display: grid; gap: 12px; }
.recap h3 { font-family: var(--titre); font-style: italic; font-weight: 400; font-size: 1.7rem; line-height: 1.1; }
.recap-liste { margin: 0; display: grid; }
.recap-liste > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; padding-block: 10px; border-top: 1px solid var(--filet); }
.recap-liste dt { grid-column: 1; font-style: italic; font-size: .98rem; color: var(--encre-2); }
.recap-liste dd { margin: 0; grid-column: 1; overflow-wrap: anywhere; }
.recap-liste dd.recap-modifier { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.recap-liste b { font-family: var(--titre); font-weight: 400; font-size: 1.2em; }
@media (min-width: 640px) {
  .recap-liste > div { grid-template-columns: 10rem minmax(0, 1fr) auto; }
  .recap-liste dd { grid-column: 2; }
  .recap-liste dd.recap-modifier { grid-column: 3; grid-row: 1; }
}

/* Encadré latéral (grand écran) : la dédicace s'écrit, puis ce que vous offrez */
.aside-bloc { display: grid; gap: 14px; padding: 22px 22px 20px; background: var(--papier-2); border: 1px solid var(--filet); }
.dedicace-vive { font-style: italic; font-size: 1.3rem; line-height: 1.45; padding-bottom: 14px; border-bottom: 1px solid var(--filet); }
.dedicace-vive .dv-ligne { display: block; }
.dedicace-vive .dv-mot { color: var(--encre-2); }
.dedicace-vive .dv-nom { color: var(--rubrique); font-weight: 600; overflow-wrap: anywhere; }
.dedicace-vive .dv-nom.vide { display: inline-block; width: 3.4em; height: 1px; border-bottom: 1px dotted var(--encre-2); vertical-align: baseline; }
.aside-prix { font-family: var(--titre); font-size: 2.8rem; line-height: 1; }
.aside-liste { margin: 0; padding-left: 1.1rem; display: grid; gap: 6px; font-size: 1.02rem; line-height: 1.4; }
.aside-bloc .petit { font-size: .96rem; }

/* Mouvement (si permis) : à chaque changement de partie, la nouvelle arrive en fondu (pas au chargement :
   commander-mouvement.js pose html.etapes-animees au premier changement) ; la barre de progression se
   remplit ; l'aperçu des questions arrive en cascade à son premier affichage. La logique n'en dépend pas. */
@media screen and (prefers-reduced-motion: no-preference) {
  .etapes-animees .etape:not([hidden]) { animation: etape-entree .5s var(--entree) both; }
  @keyframes etape-entree { from { opacity: 0; transform: translateY(10px); } }
  .progression-etapes li { position: relative; }
  .progression-etapes li.fait::before, .progression-etapes li.courant::before { background: var(--filet); }
  .progression-etapes li::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--rubrique); transform: scaleX(0); transform-origin: left center; transition: transform .7s var(--deplacement); }
  .progression-etapes li.fait::after, .progression-etapes li.courant::after { transform: none; }
  .apercu-liste.cascade > * { animation: etape-entree .6s var(--entree) both; }
  .apercu-liste.cascade > :nth-child(2) { animation-delay: 80ms; }
  .apercu-liste.cascade > :nth-child(3) { animation-delay: 160ms; }
  .apercu-liste.cascade > :nth-child(n + 4) { animation-delay: 240ms; }
  .q-retirer { transition: border-color .2s ease, color .2s ease; }
}
@media (forced-colors: active) {
  .progression-etapes li::before, .progression-etapes li::after { forced-color-adjust: none; background: GrayText; }
  .progression-etapes li.fait::before, .progression-etapes li.courant::before, .progression-etapes li.fait::after, .progression-etapes li.courant::after { background: Highlight; }
}
