/*
 * LaMortaise.com : styles des calculateurs, VERSION 2 (PROTOTYPE du 10 nov. 2026)
 * Classes .lm-calc* seulement. Aucun style de bouton plein/contour ici : les boutons utilisent les classes du site
 * (uk-button, uk-button-primary, uk-button-default) réglées dans custom.css (charte, section 4).
 * Couleurs de la charte : #26292C texte, #2F5B7C titres, #4A7295 accent, #F2F1EE fond neutre, #E4E1DB filets.
 *
 * Mise en page des pièces : UNE ligne quand la colonne du calculateur est assez large (600 px avec une essence, 720 px avec plusieurs), DEUX lignes sinon (téléphone) : requêtes de conteneur, pas de fenêtre.
 */
.lm-calc { max-width: 860px; font-family: "Nunito Sans", system-ui, sans-serif; color: #26292C; }
.lm-calc *, .lm-calc *::before, .lm-calc *::after { box-sizing: border-box; }

/* Note d'estimation : tout à la fin, encadré NEUTRE, texte de 14 px (demande de David) */
.lm-calc-note { background: #F2F1EE; border: 1px solid #E4E1DB; border-radius: 8px; padding: 10px 14px; margin: 20px 0 0; color: #26292C; font-size: 14px; line-height: 1.45; }
.lm-calc-note p { margin: 0; }
.lm-calc-note p + p { margin-top: 6px; }
.lm-calc-note strong { color: #2F5B7C; font-weight: 700; }

/* Titres de section */
.lm-calc-section { margin: 20px 0 6px; font-family: Kreon, Georgia, serif; font-size: 24px; line-height: 1.25; color: #2F5B7C; }
.lm-calc-intro { margin: 0 0 10px; font-size: 15px; color: #5B5A57; }

/* Choix des unités */
.lm-calc-unites { border: 0; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 24px; }
.lm-calc-unites legend { font-weight: 700; padding: 0; margin-bottom: 4px; width: 100%; }
.lm-calc-radio { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.lm-calc-radio input { width: 20px; height: 20px; margin: 0; }
.lm-calc-radio label { font-size: 16px; }
.lm-calc-radio { margin-bottom: 4px; }

/* Champs : libellé au-dessus, 44 px de haut, texte de 16 px (évite le zoom sur iPhone) */
.lm-calc-champ { display: flex; flex-direction: column; min-width: 0; }
.lm-calc-etiquette { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.lm-calc-champ label { font-weight: 600; font-size: 14px; margin: 0; }
.lm-calc-champ input[type="text"], .lm-calc-champ select { width: 100%; height: 44px; padding: 0 10px; font: 400 16px "Nunito Sans", system-ui, sans-serif; color: #26292C; background: #fff; border: 1px solid #d5d5d5; border-radius: 8px; }
.lm-calc-champ input[type="text"]:focus, .lm-calc-champ input[type="text"]:focus-visible,
.lm-calc-champ select:focus, .lm-calc-champ select:focus-visible { outline: 2px solid #26292C; outline-offset: 1px; border-color: #4A7295; }
.lm-calc-radio input:focus-visible, .lm-calc-retirer:focus-visible, .lm-calc .uk-button:focus-visible { outline: 2px solid #26292C; outline-offset: 2px; }
.lm-calc-champ input[aria-invalid="true"], .lm-calc-champ select[aria-invalid="true"] { border-color: #B42318; }
.lm-calc-aide { margin-top: 4px; font-size: 14px; color: #5B5A57; }
.lm-calc-erreur { margin: 4px 0 0; padding: 6px 10px; border-left: 3px solid #B42318; background: #FBEFEE; border-radius: 0 6px 6px 0; font-size: 14px; font-weight: 600; line-height: 1.35; color: #8C1D13; }
.lm-calc-erreur[hidden] { display: none; }
.lm-calc-refus { display: block; margin-top: 4px; font-size: 14px; line-height: 1.35; color: #5B5A57; }
.lm-calc-refus:empty { display: none; }
.lm-calc-ligne { margin: 8px 0 12px; }
.lm-calc-global { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 16px; }
@media (max-width: 420px) { .lm-calc-global { grid-template-columns: 1fr; } }
.lm-calc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
@media (max-width: 420px) { .lm-calc-actions .uk-button { flex: 1 1 100%; } }


/* Bouton « Retirer » : bouton-lien de composant (dérogation inscrite à la charte) */
.lm-calc-retirer { background: none; border: 0; padding: 0 4px; font: 600 14px "Nunito Sans", system-ui, sans-serif; color: #2F5B7C; text-decoration: underline; cursor: pointer; min-height: 44px; align-self: end; }
.lm-calc-retirer:hover { color: #4A7295; }
.lm-calc-retirer[hidden] { display: none; }
.lm-calc-corbeille { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 1px solid #E4E1DB; border-radius: 8px; background: #fff; color: #2F5B7C; text-decoration: none; }
.lm-calc-corbeille:hover { background: #4A7295; border-color: #4A7295; color: #fff; }

/* ---- Pièces : une rangée par pièce ---- */
.lm-calc-fiche { margin: 0 0 12px; padding: 0 0 12px; border-bottom: 1px solid #E4E1DB; }
.lm-calc-fiche:last-child { border-bottom: 0; }
.lm-calc-grille { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px 10px; align-items: end; }
/* TÉLÉPHONE : ligne 1 = épaisseur, largeur, longueur ; ligne 2 = quantité, (essence), retirer ; le nom (facultatif) ajoute une ligne au-dessus */
.lm-calc-c-nom, .lm-calc-c-ess { display: none; }
.lm-calc-c-e, .lm-calc-c-l, .lm-calc-c-L, .lm-calc-c-q { grid-column: span 4; }
.lm-calc-grille > .lm-calc-retirer { grid-column: span 8; justify-self: end; }
.lm-calc-noms .lm-calc-c-nom { display: flex; grid-column: span 12; }
.lm-calc-multi .lm-calc-c-ess { display: flex; grid-column: span 6; }
.lm-calc-multi .lm-calc-c-q { grid-column: span 3; }
.lm-calc-multi .lm-calc-grille > .lm-calc-retirer { grid-column: span 3; }
/* Les aides ne se répètent que sur la première pièce */
.lm-calc-fiche:not(:first-child) .lm-calc-aide { display: none; }

/* ORDINATEUR : une seule ligne par pièce, selon la LARGEUR DU CONTENEUR (la colonne de l'article), pas celle de la fenêtre.
   Quatre cas : (A) une essence, sans noms ; (B) plusieurs essences ; (C) avec noms ; (D) noms + plusieurs essences. */
.lm-calc { container-type: inline-size; }
@container (min-width: 600px) {
  .lm-calc:not(.lm-calc-multi):not(.lm-calc-noms) .lm-calc-grille { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr) auto; gap: 8px 12px; }
  .lm-calc:not(.lm-calc-multi):not(.lm-calc-noms) .lm-calc-grille > * { grid-column: auto; }
  .lm-calc:not(.lm-calc-multi):not(.lm-calc-noms) .lm-calc-grille > .lm-calc-retirer { justify-self: auto; }
  .lm-calc:not(.lm-calc-multi):not(.lm-calc-noms) .lm-calc-fiche:not(:first-child) .lm-calc-champ label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lm-calc:not(.lm-calc-multi):not(.lm-calc-noms) .lm-calc-fiche { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 0; }
}
@container (min-width: 720px) {
  .lm-calc-multi:not(.lm-calc-noms) .lm-calc-grille { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr) minmax(0, 1.5fr) auto; gap: 8px 12px; }
  .lm-calc-multi:not(.lm-calc-noms) .lm-calc-grille > * { grid-column: auto; }
  .lm-calc-multi:not(.lm-calc-noms) .lm-calc-grille > .lm-calc-retirer { justify-self: auto; }
  .lm-calc-multi:not(.lm-calc-noms) .lm-calc-fiche:not(:first-child) .lm-calc-champ label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lm-calc-multi:not(.lm-calc-noms) .lm-calc-fiche { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 0; }
}
@container (min-width: 760px) {
  .lm-calc-noms:not(.lm-calc-multi) .lm-calc-grille { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr) auto; gap: 8px 12px; }
  .lm-calc-noms:not(.lm-calc-multi) .lm-calc-grille > * { grid-column: auto; }
  .lm-calc-noms:not(.lm-calc-multi) .lm-calc-grille > .lm-calc-retirer { justify-self: auto; }
  .lm-calc-noms:not(.lm-calc-multi) .lm-calc-fiche:not(:first-child) .lm-calc-champ label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lm-calc-noms:not(.lm-calc-multi) .lm-calc-fiche { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 0; }
}
@container (min-width: 860px) {
  .lm-calc-noms.lm-calc-multi .lm-calc-grille { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr) minmax(0, 1.5fr) auto; gap: 8px 12px; }
  .lm-calc-noms.lm-calc-multi .lm-calc-grille > * { grid-column: auto; }
  .lm-calc-noms.lm-calc-multi .lm-calc-grille > .lm-calc-retirer { justify-self: auto; }
  .lm-calc-noms.lm-calc-multi .lm-calc-fiche:not(:first-child) .lm-calc-champ label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lm-calc-noms.lm-calc-multi .lm-calc-fiche { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 0; }
}

/* ---- Essences : nom, prix du PMP, perte prévue ---- */
.lm-calc-ligne-ess { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px 10px; align-items: end; margin: 0 0 12px; max-width: 680px; }
.lm-calc-ligne-ess > .lm-calc-champ:nth-child(1) { grid-column: span 12; }
.lm-calc-ligne-ess > .lm-calc-champ:nth-child(2), .lm-calc-ligne-ess > .lm-calc-champ:nth-child(3) { grid-column: span 5; }
.lm-calc-ligne-ess > .lm-calc-retirer { grid-column: span 2; justify-self: end; }
.lm-calc-ligne-ess:not(:first-child) .lm-calc-aide { display: none; }
/* quand la colonne est assez large : nom, prix et perte sur une seule ligne (les libellés ne s'affichent que sur la première) */
@container (min-width: 520px) {
  .lm-calc-ligne-ess { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) auto; margin: 0 0 8px; }
  .lm-calc-ligne-ess > .lm-calc-champ:nth-child(n) { grid-column: auto; }
  .lm-calc-ligne-ess > .lm-calc-retirer { grid-column: auto; justify-self: auto; }
  .lm-calc-ligne-ess:not(:first-child) .lm-calc-champ label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Aide « épaisseur à acheter », garder ses résultats, statut */
.lm-calc-brut { margin: 0 0 16px; border: 1px solid #E4E1DB; border-radius: 8px; padding: 0 14px; background: #fff; }
.lm-calc-brut summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; color: #2F5B7C; cursor: pointer; }
.lm-calc-brut summary:focus-visible { outline: 2px solid #26292C; outline-offset: 2px; }
.lm-calc-brut .lm-calc-champ { max-width: 320px; }
.lm-calc-brut-resultat { margin: 8px 0 12px; font-weight: 600; }
.lm-calc-export { margin-bottom: 4px; }
.lm-calc-explication { margin: 4px 0 8px; }
.lm-calc-etiquette { min-height: 24px; }
.lm-calc-statut p { margin: 8px 0 0; font-size: 16px; }
.lm-calc-copie { width: 100%; margin-top: 8px; padding: 10px; font: 400 16px/1.4 "Nunito Sans", system-ui, sans-serif; border: 1px solid #d5d5d5; border-radius: 8px; }
.lm-calc-date { margin: 0 0 12px; font-size: 14px; color: #5B5A57; }

/* Résultats : liste clé/valeur (dl), pas de tableau large */
.lm-calc-resultat:focus { outline: none; }   /* zone non interactive : focus donné par le script seulement */
.lm-calc-titre { margin: 24px 0 8px; font-family: Kreon, Georgia, serif; font-size: 24px; color: #2F5B7C; }
.lm-calc-sous-titre { margin: 20px 0 6px; font-family: Kreon, Georgia, serif; font-size: 18px; color: #2F5B7C; }
.lm-calc-liste { margin: 0; border: 1px solid #E4E1DB; border-radius: 8px; overflow: hidden; }
.lm-calc-rang { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; background: #fff; }
.lm-calc-rang + .lm-calc-rang { border-top: 1px solid #E4E1DB; }
.lm-calc-rang:nth-child(even) { background: #F2F1EE; }
.lm-calc-rang dt { margin: 0; }
.lm-calc-rang dd { margin: 0; text-align: right; font-weight: 600; }
.lm-calc-rang-fort dd { font-size: 18px; color: #2F5B7C; font-weight: 700; }
.lm-calc-detail { margin: 0; padding-left: 20px; font-size: 16px; }
.lm-calc-rappel { font-size: 14px; color: #5B5A57; margin: 12px 0 0; }

/* Écran : le gabarit d'impression n'existe qu'au moment d'imprimer (le script le crée et le retire) */
.lm-calc-gabarit { display: none; }
@media print {
  html.lm-impression .lm-imp-chemin > :not(.lm-imp-chemin):not(.lm-imp-cible) { display: none !important; }
  html.lm-impression .lm-imp-cible > :not(.lm-calc-gabarit) { display: none !important; }
  html.lm-impression .lm-calc-gabarit { display: block; color: #000; font: 400 14px/1.4 "Nunito Sans", system-ui, sans-serif; }
  html.lm-impression .lm-calc-gabarit-tete { margin: 0 0 12px; }
  html.lm-impression .lm-calc-gabarit-tete img { display: block; width: 180px; height: auto; }
  html.lm-impression .lm-calc-gabarit-slogan { margin: 4px 0 12px; font-size: 14px; color: #000; }
  html.lm-impression .lm-calc-gabarit-pied { margin: 16px 0 0; padding-top: 8px; border-top: 1px solid #000; font-size: 14px; color: #000; text-align: center; }
  html.lm-impression .lm-calc-gabarit-titre { margin: 0 0 4px; font: 700 22px/1.2 "Kreon", Georgia, serif; color: #000; }
  html.lm-impression .lm-calc-gabarit-date { margin: 0 0 12px; }
  html.lm-impression .lm-calc-gabarit h3 { margin: 16px 0 6px; font: 700 16px/1.2 "Nunito Sans", system-ui, sans-serif; color: #000; }
  html.lm-impression .lm-calc-gabarit-table { width: 100%; border-collapse: collapse; margin: 0 0 8px; }
  html.lm-impression .lm-calc-gabarit-table th, html.lm-impression .lm-calc-gabarit-table td { border: 1px solid #000; padding: 4px 6px; text-align: left; vertical-align: top; }
  html.lm-impression .lm-calc-gabarit-table thead { display: table-header-group; }
  html.lm-impression .lm-calc-gabarit-table tr { break-inside: avoid; page-break-inside: avoid; }
  html.lm-impression .lm-calc-gabarit-total { margin: 0 0 12px; }
  html.lm-impression .lm-calc-gabarit .lm-calc-rang { display: flex; justify-content: space-between; border: 0; padding: 2px 0; }
  html.lm-impression .lm-calc-gabarit .lm-calc-rang dt, html.lm-impression .lm-calc-gabarit .lm-calc-rang dd { margin: 0; }
  html.lm-impression .lm-calc-gabarit .lm-calc-rang, html.lm-impression .lm-calc-gabarit .lm-calc-rang:nth-child(even) { background: #fff; }
  html.lm-impression .lm-calc-gabarit .lm-calc-rang dd, html.lm-impression .lm-calc-gabarit .lm-calc-rang-fort dd { color: #000; font-size: 14px; font-weight: 700; }
  html.lm-impression .lm-calc-gabarit .lm-calc-note { margin-top: 16px; background: #fff; border: 1px solid #000; color: #000; }
  html.lm-impression body { margin: 0; padding: 0; background: #fff; }
}

/* Impression : seulement les résultats et la note (fond blanc, bordure noire) */
@media print {
  .lm-calc-brut, .lm-calc-export, .lm-calc-explication, .lm-calc-statut, .lm-calc-unites, .lm-calc-section, .lm-calc-intro, .lm-calc-essences, .lm-calc-fiches, .lm-calc-global, .lm-calc-actions, .lm-calc-ligne { display: none !important; }
  .lm-calc-note { background: #fff; border: 1px solid #000; color: #000; break-inside: avoid; page-break-inside: avoid; }
  .lm-calc-note strong { color: #000; }
}
