/* ==========================================================================
   devispaysagiste.fr · Composants partagés
   --------------------------------------------------------------------------
   S'appuie sur tokens.css (à charger avant). Aucune couleur écrite en dur :
   tout passe par les variables, pour que les deux thèmes fonctionnent.
   Nommage des classes : bloc__element--variante.
   ========================================================================== */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--police-texte);
  font-size: var(--taille-texte);
  line-height: var(--interligne-texte);
  font-optical-sizing: auto;
  background: var(--fond);
  color: var(--texte);
  -webkit-font-smoothing: antialiased;
}
[data-theme] { background-color: var(--fond); color: var(--texte); }
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
p { margin: 0; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--anneau);
  outline-offset: 2px;
}

.visuellement-cache {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Mise en page ---------- */
.conteneur {
  max-width: var(--largeur-max);
  margin-inline: auto;
  padding-left: max(var(--gouttiere), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gouttiere), env(safe-area-inset-right, 0px));
}
.section { padding-block: var(--espace-section); }
.section__entete {
  display: grid;
  gap: var(--espace-4);
  max-width: 46rem;
  margin-bottom: var(--espace-7);
}

/* ---------- Typographie ---------- */
.titre-display, .titre-2, .titre-3 {
  margin: 0;
  font-family: var(--police-titre);
  font-stretch: var(--titre-largeur);
  font-weight: var(--titre-graisse);
  line-height: var(--interligne-titre);
  text-wrap: balance;
}
.titre-display { font-size: var(--taille-display); letter-spacing: -0.015em; }
.titre-2 { font-size: var(--taille-h2); letter-spacing: -0.01em; }
.titre-3 { font-size: var(--taille-h3); letter-spacing: -0.005em; line-height: 1.2; }
.surtitre { font-size: var(--taille-petit); font-weight: 500; color: var(--texte-2); }
.intro { font-size: var(--taille-texte-l); color: var(--texte-2); max-width: 60ch; text-wrap: pretty; }
.texte-2 { color: var(--texte-2); }
.texte-3 { color: var(--texte-3); }
.petit { font-size: var(--taille-petit); }
.legende { font-size: var(--taille-legende); line-height: 1.4; }
/* Chiffres à chasse fixe : les montants s'alignent en colonne. */
.chiffres { font-variant-numeric: tabular-nums; }

/* ---------- Boutons ----------
   .bouton--principal : le seul élément en Buis. Un par écran. */
.bouton {
  --bouton-fond: var(--surface);
  --bouton-texte: var(--texte);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--espace-2);
  min-height: var(--hauteur-controle);
  padding: 10px var(--espace-5);
  border: 0;
  border-radius: var(--rayon-pilule);
  background: var(--bouton-fond);
  color: var(--bouton-texte);
  font: 500 var(--taille-texte)/1.25 var(--police-texte);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--duree-rapide) var(--courbe),
    color var(--duree-rapide) var(--courbe),
    box-shadow var(--duree-rapide) var(--courbe),
    transform var(--duree-rapide) var(--courbe);
}
.bouton:active { transform: scale(0.98); }
.bouton--principal { --bouton-fond: var(--buis); --bouton-texte: var(--sur-buis); }
.bouton--principal:hover { --bouton-fond: var(--buis-survol); }
.bouton--secondaire { --bouton-fond: transparent; box-shadow: inset 0 0 0 1px var(--trait-fort); }
.bouton--secondaire:hover { --bouton-fond: var(--surface); }
.bouton--secondaire[aria-pressed="true"] { --bouton-fond: var(--texte); --bouton-texte: var(--fond); box-shadow: none; }
.bouton--petit { min-height: 40px; padding: 8px var(--espace-4); font-size: var(--taille-petit); }
.bouton--plein { width: 100%; }
.bouton-lien {
  padding: 0;
  border: 0;
  background: none;
  color: var(--texte);
  font: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
  border-radius: 4px;
}
.bouton-lien:hover { text-decoration-thickness: 2px; }

/* ---------- Choix segmenté (deux à quatre options) ---------- */
.choix {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--espace-1);
  padding: var(--espace-1);
  border-radius: var(--rayon-pilule);
  background: var(--surface);
}
.choix button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--rayon-pilule);
  background: transparent;
  color: var(--texte-2);
  font: 500 var(--taille-petit)/1 var(--police-texte);
  cursor: pointer;
  transition: background-color var(--duree-rapide) var(--courbe), color var(--duree-rapide) var(--courbe);
}
.choix button:hover { color: var(--texte); }
.choix button[aria-pressed="true"] { background: var(--texte); color: var(--fond); }

/* ---------- Cartes ---------- */
.carte {
  background: var(--carte);
  border-radius: var(--rayon-carte);
  box-shadow: var(--ombre-carte);
  padding: var(--espace-5);
}
@media (min-width: 768px) { .carte { padding: var(--espace-6); } }

/* ---------- Champs ----------
   Application : coins de 12 px. Vitrine : ajouter .saisie--pilule. */
.champ { display: grid; gap: 6px; align-content: start; }
.champ__label { font-size: var(--taille-petit); font-weight: 500; color: var(--texte); }
.champ__aide { font-size: var(--taille-legende); color: var(--texte-3); }
.champ__erreur { font-size: var(--taille-legende); color: var(--perte); }
.champ__boite { position: relative; display: flex; align-items: center; }
.saisie {
  width: 100%;
  min-height: var(--hauteur-controle);
  padding: 0 var(--espace-4);
  border: 1px solid transparent;
  border-radius: var(--rayon-champ);
  background: var(--surface);
  color: var(--texte);
  font: 400 var(--taille-texte)/1.2 var(--police-texte);
  appearance: none;
  transition: border-color var(--duree-rapide) var(--courbe), background-color var(--duree-rapide) var(--courbe);
}
.saisie::placeholder { color: var(--texte-3); }
.saisie:hover { border-color: var(--trait-fort); }
.saisie:focus { outline: none; border-color: var(--texte); background: var(--carte); box-shadow: 0 0 0 1px var(--texte); }
.saisie[aria-invalid="true"] { border-color: var(--perte); box-shadow: 0 0 0 1px var(--perte); }
.saisie--pilule { border-radius: var(--rayon-pilule); padding-inline: var(--espace-5); }
.saisie--chiffre { text-align: right; font-variant-numeric: tabular-nums; padding-right: 3.25em; }
.champ__unite {
  position: absolute;
  right: var(--espace-4);
  font-size: var(--taille-petit);
  color: var(--texte-3);
  pointer-events: none;
}
.champ__boite--liste::after {
  content: "";
  position: absolute;
  right: var(--espace-5);
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--texte-2);
  border-bottom: 1.5px solid var(--texte-2);
  transform: translateY(-2px) rotate(45deg);
  pointer-events: none;
}
.champ__boite--liste .saisie { padding-right: 3em; cursor: pointer; }
.case {
  display: flex;
  gap: var(--espace-3);
  align-items: flex-start;
  font-size: var(--taille-petit);
  color: var(--texte-2);
  cursor: pointer;
}
.case input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--texte); cursor: pointer; }

/* ---------- Pastilles ---------- */
.pastille {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--rayon-pilule);
  background: var(--surface);
  color: var(--texte-2);
  font: 500 var(--taille-legende)/1.1 var(--police-texte);
  white-space: nowrap;
}
.pastille__point { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pastille--perte { background: var(--perte-fond); color: var(--perte); }
.pastille--rentable { background: var(--rentable-fond); color: var(--rentable); }
.pastille--attention { background: var(--attention-fond); color: var(--attention); }
/* Coefficient appliqué : visible sur la ligne et désactivable d'un geste. */
.pastille--coef {
  min-height: 36px;
  padding: 0 14px;
  cursor: pointer;
  color: var(--texte);
  transition: background-color var(--duree-rapide) var(--courbe), color var(--duree-rapide) var(--courbe);
}
.pastille--coef::before {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(-45deg);
}
.pastille--coef:hover { background: var(--surface-survol); }
.pastille--coef[aria-pressed="false"] {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--trait-fort);
  color: var(--texte-3);
  text-decoration: line-through;
}
.pastille--coef[aria-pressed="false"]::before { visibility: hidden; width: 0; margin-right: -6px; }

/* ---------- Contexte du chantier ----------
   Un résumé en texte simple (rien qui ressemble à un bouton), et un lien
   « Modifier » qui ouvre les sélecteurs. Les majorations qui en découlent
   s'affichent sur les lignes, en pastilles désactivables. */
.contexte {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--espace-3);
  padding-block: var(--espace-3);
  border-block: 1px solid var(--trait);
}
.contexte__resume { min-width: 0; font-size: var(--taille-petit); color: var(--texte); }
.contexte__label { margin-right: var(--espace-2); color: var(--texte-3); }
.contexte__modifier { flex: none; font-size: var(--taille-petit); padding-block: 6px; }
.contexte-edition {
  display: grid;
  gap: var(--espace-4);
  padding: var(--espace-4);
  border-radius: var(--rayon-carte);
  background: var(--carte);
  box-shadow: var(--ombre-carte);
}
.contexte-edition__champ { display: grid; gap: var(--espace-2); justify-items: start; }

/* ---------- Ligne de devis ---------- */
.lignes { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--espace-3); }
.ligne-devis { background: var(--carte); border-radius: var(--rayon-carte); box-shadow: var(--ombre-carte); }
.ligne-devis__resume {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 14px;
  align-items: baseline;
  column-gap: var(--espace-3);
  row-gap: 2px;
  width: 100%;
  padding: var(--espace-4);
  border: 0;
  border-radius: var(--rayon-carte);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ligne-devis__libelle { font-weight: 500; min-width: 0; }
.ligne-devis__montant { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ligne-devis__chevron {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--texte-3);
  border-bottom: 1.5px solid var(--texte-3);
  transform: translateY(-3px) rotate(45deg);
  transition: transform var(--duree) var(--courbe);
  justify-self: end;
}
.ligne-devis__resume[aria-expanded="true"] .ligne-devis__chevron { transform: translateY(1px) rotate(-135deg); }
.ligne-devis__calcul {
  grid-column: 1 / -1;
  font-size: var(--taille-petit);
  color: var(--texte-2);
  font-variant-numeric: tabular-nums;
}
.ligne-devis__coefs { display: flex; flex-wrap: wrap; gap: var(--espace-2); padding: 0 var(--espace-4) var(--espace-4); margin-top: -4px; }
.ligne-devis__detail {
  display: grid;
  gap: var(--espace-4);
  padding: var(--espace-4);
  border-top: 1px solid var(--trait);
}
.ligne-devis__champs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--espace-3); }
.ligne-devis__conseil { font-size: var(--taille-petit); color: var(--texte-2); }
.ligne-devis__pied { display: flex; flex-wrap: wrap; align-items: center; gap: var(--espace-3); }
.ligne-devis.est-non-facturee .ligne-devis__montant { color: var(--attention); font-weight: 500; }
.ligne-devis__oubli {
  margin: 0 var(--espace-4) var(--espace-4);
  padding: var(--espace-3) var(--espace-4);
  border-radius: var(--rayon-petit);
  background: var(--attention-fond);
  color: var(--texte);
  font-size: var(--taille-petit);
  display: grid;
  gap: var(--espace-2);
  justify-items: start;
}

/* « Pourquoi ce prix ? » */
.pourquoi summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: var(--taille-petit);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  border-radius: 4px;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.pourquoi summary::-webkit-details-marker { display: none; }
.pourquoi summary::before {
  content: "?";
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  font-size: 12px;
  text-decoration: none;
}
.pourquoi p {
  margin-top: var(--espace-2);
  padding: var(--espace-3) var(--espace-4);
  border-radius: var(--rayon-petit);
  background: var(--surface);
  font-size: var(--taille-petit);
  line-height: 1.55;
  color: var(--texte);
}

/* ---------- Bandeau de marge ----------
   Collé en bas de l'écran pendant tout le chiffrage.
   data-etat="perte" : passe au rouge sous le point mort.
   .est-compact : une seule ligne pendant la saisie au clavier.
   --clavier : de combien remonter le bandeau pour qu'il se pose juste
   au-dessus du clavier du téléphone. Calculé par le script, sans animation
   pour suivre le défilement sans retard. */
.bandeau-marge {
  position: sticky;
  bottom: calc(var(--espace-3) + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  border-radius: var(--rayon-carte);
  background: var(--carte);
  color: var(--texte);
  box-shadow: var(--ombre-flottante);
  transform: translateY(calc(-1 * var(--clavier, 0px)));
  transition:
    background-color var(--duree) var(--courbe),
    box-shadow var(--duree) var(--courbe);
}
.bandeau-marge[data-etat="perte"] {
  background: var(--perte-fond);
  box-shadow: inset 0 0 0 1px var(--perte), var(--ombre-flottante);
}
.bandeau-marge__complet {
  display: grid;
  gap: var(--espace-2);
  width: 100%;
  padding: var(--espace-4);
  border: 0;
  border-radius: inherit;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.bandeau-marge__haut { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--espace-4); row-gap: var(--espace-1); }
.bandeau-marge__etat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--taille-petit);
  font-weight: 500;
  color: var(--rentable);
}
.bandeau-marge[data-etat="perte"] .bandeau-marge__etat { color: var(--perte); }
.bandeau-marge__total {
  margin-left: auto;
  font-size: var(--taille-montant);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bandeau-marge__total small { font-size: var(--taille-petit); font-weight: 500; letter-spacing: 0; color: var(--texte-2); margin-left: 4px; }
.bandeau-marge__bas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--espace-1) var(--espace-4);
  font-size: var(--taille-petit);
  color: var(--texte-2);
}
.bandeau-marge__bas b { font-weight: 500; color: var(--texte); font-variant-numeric: tabular-nums; }
.bandeau-marge[data-etat="perte"] [data-b="taux"] { color: var(--perte); }
.bandeau-marge__plus {
  align-self: center;
  display: inline-flex;
  font-size: var(--taille-petit);
  align-items: center;
  gap: 6px;
  color: var(--texte-2);
}
.bandeau-marge__plus::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(1px) rotate(-135deg);
  transition: transform var(--duree) var(--courbe);
}
.bandeau-marge__complet[aria-expanded="true"] .bandeau-marge__plus::after { transform: translateY(-2px) rotate(45deg); }
/* Petit écran : la flèche seule, pour garder le bandeau sur deux lignes. */
@media (max-width: 420px) {
  .bandeau-marge__plus { font-size: 0; gap: 0; padding: 6px 2px; }
  .bandeau-marge__bas { column-gap: var(--espace-3); }
}
.bandeau-marge__detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--espace-2) var(--espace-4);
  margin: 0;
  padding: var(--espace-3) var(--espace-4) var(--espace-4);
  border-top: 1px solid var(--trait);
  font-size: var(--taille-petit);
}
.bandeau-marge__detail dt { color: var(--texte-2); }
.bandeau-marge__detail dd { margin: 0; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.bandeau-marge__compact {
  display: none;
  align-items: center;
  gap: var(--espace-3);
  min-height: 44px;
  padding: 0 var(--espace-4);
  font-size: var(--taille-petit);
}
.bandeau-marge__compact .bandeau-marge__etat { flex: 1; min-width: 0; }
.bandeau-marge__compact b { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bandeau-marge__compact span:last-child { color: var(--texte-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bandeau-marge.est-compact .bandeau-marge__complet,
.bandeau-marge.est-compact .bandeau-marge__detail { display: none; }
.bandeau-marge.est-compact .bandeau-marge__compact { display: flex; }

/* ---------- Navigation de la vitrine ----------
   Transparente sur la photo du hero, floutée dès qu'on fait défiler.
   Le script lui donne le data-theme de la section qu'elle recouvre :
   claire sur une section claire, sombre sur une section sombre. */
.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  padding-top: env(safe-area-inset-top, 0px);
  background-color: transparent;
  transition: background-color var(--duree) var(--courbe), box-shadow var(--duree) var(--courbe);
}
.nav.est-defile {
  background-color: var(--voile-nav);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 1px 0 var(--trait);
}
.nav__interieur {
  display: flex;
  align-items: center;
  gap: var(--espace-4);
  height: 64px;
  max-width: var(--largeur-max);
  margin-inline: auto;
  padding-left: max(var(--gouttiere), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gouttiere), env(safe-area-inset-right, 0px));
}
.marque {
  font-family: var(--police-titre);
  font-stretch: var(--titre-largeur);
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  color: var(--texte);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--duree) var(--courbe);
}
.marque span { color: var(--texte-3); font-weight: 500; transition: color var(--duree) var(--courbe); }
.nav__liens { display: none; gap: var(--espace-1); }
.nav__liens a {
  padding: 8px 14px;
  border-radius: var(--rayon-pilule);
  color: var(--texte-2);
  font-size: var(--taille-petit);
  text-decoration: none;
  transition: color var(--duree-rapide) var(--courbe), background-color var(--duree-rapide) var(--courbe);
}
.nav__liens a:hover { color: var(--texte); background: var(--surface); }
.nav__action { margin-left: auto; }
@media (min-width: 768px) {
  .nav__liens { display: flex; margin-left: auto; }
  .nav__action { margin-left: 0; }
}

/* ---------- Moins d'animations si le téléphone le demande ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
