/* Les rapports PDF (src/rapports.js) : un seul gabarit, en noir et blanc (Henri, 30/09/2026 :
   « des rapports plus sobres, noir et blanc, premium », « il faut un seul style dans l'app »).
   Modèle : la coupe de profil et la fenêtre topo « Instrument ». Typographie système, trois
   tailles, deux graisses ; des filets fins au lieu des cadres, ombres et dégradés ; aucune
   couleur d'accent. Restent en couleur : la zone du PPRN (couleur réglementaire), la zone du PLU
   et le type d'une vente sur son plan, parce qu'elles portent l'information.
   Cette feuille passe après style.css (scripts/modules.json) : elle corrige les anciens styles
   des rapports (.rapport-*, .rp-*) sans les réécrire dans le monolithe gelé. */

.rapport {
  --fond: #fff; --surface: #fff; --encre: #111; --encre-2: #3c3c3c; --encre-3: #6b6b6b; --encre-4: #8c8c8c;
  --filet: #dcdcdc; --filet-2: #b9b9b9; --survol: #f4f4f4; --actif: #ececec;
  --accent: #111; --accent-fort: #111; --lien: #111; --jauge: #d2d2d2; --ponctuation: #111;
  /* Les encres du thème (src/jetons.css) aussi : la croix « Fermer » prend var(--attenue) (src/instrument.css), blanche à 68 % en
     thème sombre, donc invisible sur la barre blanche du rapport (Henri, 11/11/2026 : « je n'ai pas de bouton pour quitter les
     rapports de toutes natures », au téléphone, où ni le survol ni Échap ne la révèlent). */
  --texte: #111; --attenue: #6b6b6b; --discret: #8c8c8c;
  background: #fff; font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; font-feature-settings: "tnum";
}
.rapport .rp { --rp-encre: #111; --rp-encre-2: #3c3c3c; --rp-encre-3: #6b6b6b; --rp-filet: #dcdcdc; --rp-doux: #f4f4f4; --rp-accent: #111; font-family: inherit; }
.rapport-barre { background: #fff; }
.rapport-page { background: #fff; font-size: 13px; line-height: 1.5; }
.rapport a { color: var(--encre); }
/* le bouton principal de l'application est clair à texte sombre : dans le rapport, noir à texte blanc */
.rapport .bouton-primaire { background: var(--encre) !important; color: #fff !important; box-shadow: none !important; }
.rapport .bouton-primaire:disabled { opacity: 0.55; }
/* à l'écran, les boutons du rapport ont le dessin de l'app : 34 px, 13 px, graisse 500 (grille du 30/09) */
.rapport :is(.rapport-barre, .rapport-appel) .bouton { height: var(--h-bouton); padding: 0 14px; border-radius: 8px; font-size: 13px; font-weight: 500; }
/* Au téléphone, la barre d'un rapport tient sur une ligne : la croix reste à gauche, toujours visible, les actions défilent à
   l'horizontale au lieu de se replier sur quatre lignes (« Ranger dans un dossier », « Envoyer par e-mail », vu au simulateur). */
@media (max-width: 699px) {
  .rapport .rapport-barre { padding-left: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
  .rapport .rapport-barre::-webkit-scrollbar { display: none; }
  .rapport .rapport-barre > :is(.bouton, button:not(.fermer)) { flex: none; white-space: nowrap; }
  html[data-theme] :is(.page-app, body) .rapport .rapport-barre > .fermer { position: sticky; left: 0; z-index: 1; width: 56px; height: 44px; border-radius: 0; background: #fff; color: #111; box-shadow: 12px 0 10px -6px #fff; }
  .rapport .rapport-barre > .rapport-barre-titre:empty { display: none; }
}

/* ── L'en-tête : la marque et l'agence à gauche, la référence et la date à droite ── */
.rs-tete { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--encre); }
.rs-marque { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rs-marque img { flex: none; border-radius: 5px; }
.rs-marque p { margin: 0; display: flex; flex-direction: column; line-height: 1.35; }
.rs-marque b { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; }
.rs-marque span { font-size: 11px; color: var(--encre-3); }
.rs-ref { display: flex; gap: 18px; margin: 0; text-align: right; }
.rs-ref dt, .rs-nature, .rs-cle-lib, .rs-prep legend { font-size: 10px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--encre-3); }
.rs-ref dd { margin: 2px 0 0; font-size: 12px; font-weight: 600; white-space: nowrap; }
.rs-titre { padding: 22px 0 16px; }
.rs-nature { margin: 0; }
.rs-titre h1 { margin: 6px 0; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; text-wrap: balance; }
.rs-sous { margin: 0; font-size: 12.5px; color: var(--encre-2); }
/* l'en-tête de secours (carte.js) garde la colonne du rapport : logo au-dessus, texte au ras de la marge */
.rapport .rapport-tete { display: block; }
.rapport .rapport-tete img { display: block; margin-bottom: 14px; }
@media (max-width: 560px) {
  .rs-tete { flex-direction: column; align-items: flex-start; }
  .rs-ref { text-align: left; }
  .rs-titre h1 { font-size: 24px; }
}

/* ── Les chiffres clés : une bande à filets, la même partout (.rs-cles, .bande, .rp-cles) ── */
.rs-cles { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); margin: 0 0 24px; border-top: 1.5px solid var(--encre); border-bottom: 1px solid var(--filet); }
.rs-cles > div { min-width: 0; padding: 9px 10px 10px; border-left: 1px solid var(--filet); }
.rs-cles > div:first-child { padding-left: 0; border-left: 0; }
.rs-cle-lib { margin: 0; }
.rs-cle-val { margin: 4px 0 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.rs-cle-note { margin: 2px 0 0; font-size: 11px; color: var(--encre-3); }
@media (max-width: 640px) {
  .rs-cles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rs-cles > div { padding-left: 10px; border-left: 1px solid var(--filet); border-top: 1px solid var(--filet); }
  .rs-cles > div:nth-child(odd) { padding-left: 0; border-left: 0; }
}
.rapport .bande { border-top-width: 1.5px !important; border-bottom: 1px solid var(--filet); }
.rapport .bande-valeur { font-size: 17px; }
.rapport .bande-titre { font-size: 10px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; }

/* ── Titres : un chapitre s'ouvre sur un filet noir, sa note en gris à côté ── */
.rapport .rapport-section { margin: 0 0 24px; }
.rapport .rp-section { margin: 0 0 24px; padding-top: 0; }
.rapport .rapport-section > h2, .rapport .rp-h2 { margin: 0 0 12px; padding: 10px 0 0; border-top: 1px solid var(--encre); border-bottom: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.rapport h2 small { margin-left: 6px; font-size: 11px; font-weight: 400; letter-spacing: 0; color: var(--encre-3); }
.rapport .rp-h2-sur { display: none; }
.rapport .rp-h3, .rapport .rapport-h3 { margin: 16px 0 6px; font-size: 13px; font-weight: 600; }
.rapport .rapport-chapo { font-size: 13.5px; }
.rapport .rp-texte, .rapport .prevision { font-size: 12.5px; color: var(--encre-2); }
.rapport .feuille-section { margin: 14px 0 6px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.rapport .note, .rapport .rp-note { font-size: 11.5px; color: var(--encre-3); }
.rapport .limite, .rapport .methode .limite { border-left-color: var(--encre); }
.rs-verifier { font-style: italic; color: var(--encre-2); }
/* « Le terrain » : le titre de la fiche répète celui de la section (sa source est sous le plan) */
.rs [data-rs-section="terrain"] .rp-texte > .feuille-section:first-child { display: none; }

/* ── Tableaux denses : filets fins, en-têtes en capitales grises ── */
.rapport .table-defile { border: 0; border-radius: 0; background: none; border-top: 1px solid var(--encre); }
.rapport .table { font-size: 12px; }
.rapport .table th, .rapport .table td { padding: 5px 10px 5px 0; border-bottom: 1px solid var(--filet); background: none; }
.rapport .table .num { padding: 5px 10px; }
.rapport .table tr > :last-child { padding-right: 0; }
.rapport .table thead th { font-size: 10px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--encre-3); }
.rapport .table tbody tr:last-child > * { border-bottom: 1px solid var(--filet); }
.rapport .table tbody tr:hover > * { background: none; }
/* la classe .num de la page de présentation (gris, capitales espacées) déteignait sur les chiffres */
.rapport .table .num { margin: 0; color: var(--encre); font-size: inherit; letter-spacing: 0; }
/* bilan : la note de chaque poste sur la même ligne que lui, une ligne par poste */
.rapport .bl-table th small { display: inline; margin-left: 8px; }
.rs-table th, .rs-table td { white-space: normal; vertical-align: top; }
.rs-table th[scope="row"] { width: 24%; font-weight: 600; }
.rs-table .rs-src { width: 23%; font-size: 10.5px; color: var(--encre-3); }
.rs-pastille { display: inline-block; width: 9px; height: 9px; margin-right: 6px; vertical-align: -1px; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.6); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
/* le texte des règles de la division passe à la ligne (il sortait de la page à l'impression) */
.rapport .dv-regles td { white-space: normal; }

/* ── Blocs repris de la fiche : sans couleur, sans cadre arrondi ── */
.rapport .dv-statut { border-radius: 2px; background: none; color: var(--encre); box-shadow: inset 0 0 0 1px var(--filet-2); }
.rapport .dv-statut.dv-non { background: var(--encre); color: #fff; box-shadow: none; }
.rapport .dv-statut.dv-ok { color: var(--encre-2); }
.rapport .regle { border-radius: 0; box-shadow: none; border-left: 2px solid var(--encre); padding: 4px 0 4px 12px; }
.rapport .regle-titre i:not(.risque) { display: none; }
.rapport .estim { border-color: var(--filet); }
.rapport .plu-zone { border-top-width: 1px; }
.rapport .plu-remarque { border-left: 2px solid var(--encre); padding-left: 10px; }
/* la bande « Parcelle, adresse, surface, zone » de l'annexe répète l'en-tête du rapport de parcelle */
.rapport .rs .rs-annexe .plu-fiche { display: none; }

/* ── Les plans : un cadre fin comme les planches, légende et barre sans arrondi ── */
.rapport .rp-plan-cadre { border-radius: 0; background: #f2f2f2; box-shadow: inset 0 0 0 0.5px var(--encre); }
.rapport .rp-legende { border-radius: 0; box-shadow: none; border: 0.5px solid var(--encre); }
.rapport .rp-barre { border-radius: 0; }
.rapport .rp-chiffres { border-radius: 0; box-shadow: none; border-top: 1px solid var(--encre); }
.rapport .rp-chiffres > div { box-shadow: inset -1px -1px 0 var(--filet); }
.rapport .rp-chiffres dt { font-size: 10px; letter-spacing: 0.07em; }
.rapport .rp-chiffres dd { font-size: 13px; }

/* ── Le panneau de préparation : type de projet, destination, sections ── */
.rs-prep form { display: grid; gap: 20px; }
.rs-prep fieldset { min-width: 0; margin: 0; padding: 10px 0 0; border: 0; border-top: 1px solid var(--encre); }
.rs-prep legend { float: left; width: 100%; margin: 0 0 6px; padding: 0; }
.rs-prep legend small { margin-left: 6px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.rs-cases { clear: both; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); column-gap: 20px; }
.rs-cases-1 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.rs-case { display: flex; align-items: center; gap: 10px; min-height: 38px; border-bottom: 1px solid var(--filet); font-size: 14px; cursor: pointer; }
.rs-case small { color: var(--encre-3); font-size: 12px; }
.rs-case input { flex: none; display: grid; place-content: center; width: 16px; height: 16px; margin: 0; border: 1.5px solid var(--encre); border-radius: 2px; background: #fff; -webkit-appearance: none; appearance: none; cursor: pointer; }
.rs-case input[type="radio"] { border-radius: 50%; }
.rs-case input:checked { background: var(--encre); }
.rs-case input[type="radio"]:checked { box-shadow: inset 0 0 0 3px #fff; }
.rs-case input[type="checkbox"]:checked::after { content: ""; width: 8px; height: 4px; margin-top: -2px; border: solid #fff; border-width: 0 0 1.5px 1.5px; transform: rotate(-45deg); }
.rs-case input:disabled { opacity: 0.45; cursor: default; }
.rs-case input:focus-visible { outline: 2px solid var(--encre); outline-offset: 2px; }
.rs-prep-actions { display: flex; justify-content: flex-end; }
.rs-prep-actions .bouton { height: var(--h-bouton); padding: 0 18px; }

/* ── À l'impression : la page « rapport » et son cartouche, sur chaque feuille ──
   Le texte propre au document (nature, titre, référence, date) est écrit par rapports.js dans
   #rs-page ; ici, ce qui ne change pas : le logo, l'agence et son contact. */
@page rapport {
  size: A4;
  margin: 13mm 14mm 21mm;
  @bottom-left-corner { content: url("/logo.svg"); vertical-align: top; text-align: right; padding: 3.2mm 2.5mm 0 0; }
  @bottom-left { content: "91STUDIO\A Agence d'architecture · contact@91studio.fr · 0590 90 90 49"; white-space: pre; vertical-align: top; padding-top: 2.6mm; border-top: 0.5pt solid #111; font: 8pt/1.5 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; color: #111; }
  @bottom-center { white-space: pre; vertical-align: top; text-align: left; padding: 2.6mm 0 0 4mm; border-top: 0.5pt solid #111; font: 8pt/1.5 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; color: #3c3c3c; }
  @bottom-right { white-space: pre; vertical-align: top; text-align: right; padding-top: 2.6mm; border-top: 0.5pt solid #111; font: 8pt/1.5 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; color: #3c3c3c; }
}
@media print {
  /* le fond de l'app (sombre) ne passe pas dans les marges quand « graphiques d'arrière-plan » est cochée : le pied de page
     (agence, référence, « Page 3 / 6 ») y était gris sur noir (essai du 29/10/2026, rapport de commune en A4) */
  html, html body, html body.page-app { background: #FFFFFF !important; color-scheme: light !important; }
  .rapport-page { page: rapport; font-size: 9pt; }
  .rs-prep { display: none; }
  .rs-titre { padding: 14px 0 10px; }
  .rs-titre h1 { font-size: 21pt; }
  .rs-cle-val { font-size: 13pt; }
  .rapport .table { font-size: 9pt; }
  .rapport .table th, .rapport .table td { padding: 0.9mm 2.5mm 0.9mm 0; }
  .rapport .table .num { padding: 0.9mm 2.5mm; }
  /* un tableau large (recherche foncière : 9 colonnes) revient à la ligne au lieu de forcer le navigateur à réduire toute la page à 52 % (texte à 6 pt) */
  .rapport .table :is(td, th):not(.num) { white-space: normal; overflow-wrap: anywhere; }
  .rapport .table-defile { overflow: visible; }
  /* audit HIG du 02/10/2026 : rien sous 8 pt à l'impression (libellés, notes, sources), le texte courant et les tableaux à 9 pt */
  .rs-ref dt, .rs-nature, .rs-cle-lib, .rapport .bande-titre, .rapport .rp-chiffres dt, .rs-table .rs-src, .rs-marque span, .rs-cle-note, .rapport .note, .rapport .rp-note, .rapport h2 small { font-size: 8pt; }
  .rapport .rp-texte, .rapport .prevision, .rs-sous { font-size: 9.5pt; }
  .rapport .rapport-section, .rapport .rp-section { margin-bottom: 16px; }
  .rapport .rapport-deux { grid-template-columns: 45mm 1fr; }
  .rapport .table tr > :last-child { padding-right: 0; }
  /* un tableau court (comparables, repères, contraintes d'une ligne) ne se coupe pas */
  .rapport .rp-table, .rapport .plu-reperes { break-inside: avoid; }
  .rapport .table thead th { font-size: 8pt; }
  .rapport .table thead { display: table-header-group; }
  /* on laisse le texte couler d'une page à l'autre ; seuls les blocs qui se lisent d'un coup
     restent entiers (avant le 30/09, une section entière passait à la page suivante et laissait
     des feuilles à moitié vides : 21 pages pour AX 34) */
  .rapport .rapport-section, .rapport .rp-section, .rapport .plu-article { break-inside: auto; }
  .rapport .table tr, .rapport .rp-plan, .rs-cles, .rapport .bande, .rapport .rp-chiffres, .rapport .rp-estims, .rapport .estim, .rapport .regle, .rs-tete, .rs-titre, .rapport .courbe { break-inside: avoid; }
  .rapport h2, .rapport h3, .rapport .rp-h2 { break-after: avoid; }
  .rapport .rp-section.rapport-saut:not(.rs-annexe) { break-before: auto; }
  .rapport .rp-plan-cadre { box-shadow: inset 0 0 0 0.3mm #111; }
  /* l'appel « Passer au projet » : le contact de l'agence est dans le cartouche de chaque page */
  .rapport .rapport-appel { display: none; }
  .rapport .rapport-pied { margin-top: 14px; font-size: 8pt; }
  /* le règlement en annexe : sur deux colonnes, comme un recueil de textes */
  .rapport .plu-article .texte-corps { column-count: 2; column-gap: 7mm; font-size: 9pt; line-height: 1.45; }
  .rapport .plu-article .texte-corps p { break-inside: avoid-column; }
  .rapport .plu-article { margin-top: 10px; }
}

/* ── Les sections rédigées (17/10/2026, Henri : « plutôt des paragraphes », langage de l'étude Natural E) ── */
.rs-prose { max-width: 72ch; }
.rs-prose p { margin: 0 0 10px; line-height: 1.6; }
.rs-prose .rs-prose-titre { margin: 18px 0 6px; font-size: 14px; font-weight: 600; }
.rs-prose .rs-src { color: var(--encre-3); font-size: .86em; white-space: normal; }
.rs-prose .rs-reco { padding: 8px 0 8px 14px; border-left: 2px solid currentColor; font-weight: 500; }
.rs-prose .rs-liste { margin: 0 0 10px; padding-left: 20px; line-height: 1.6; }
.rs-prose .rs-liste li { margin-bottom: 4px; }
.rs-prose .rs-point { padding-left: 14px; text-indent: -14px; }
.rs-synthese .rs-prose { max-width: none; font-size: 1.04em; }
@media print {
  .rs-prose { max-width: none; }
  .rs-prose p, .rs-prose .rs-liste { font-size: 9.5pt; }
  .rs-prose .rs-reco { break-inside: avoid; }
}

/* L'export au format choisi (src/export-dialogue.js, Henri 28/10/2026) : chaque carte seule sur sa page, à la taille de la
   zone utile (redessinée par src/rapports.js pour les plans, agrandie pour les cartes vectorielles) ; en paysage, le texte
   courant en deux colonnes plutôt que des lignes de 40 cm. */
@media print {
  /* la section qui porte une carte commence sa page : son titre et sa carte sont ensemble, la suite passe à la page d'après */
  html.ex-pleine-page .rapport .rp-section:has(> .rp-plan[data-plan]) { break-before: page; }
  html.ex-pleine-page .rapport .rp-plan[data-plan] { break-after: page; break-inside: avoid; margin: 0; }
  html.ex-pleine-page .rapport .re-carte { break-before: page; break-after: page; break-inside: avoid; margin: 0; }
  html.ex-pleine-page .rc-garde { width: var(--ex-page-w, 210mm); height: var(--ex-page-h, 297mm); }
  html.ex-pleine-page .rapport .rp-plan[data-plan] .rp-plan-cadre { width: 100%; max-height: var(--ex-carte-h, none); }
  html.ex-pleine-page .rapport .re-carte svg { display: block; width: auto; max-width: 100%; height: var(--ex-carte-h, auto); margin: 0 auto; }
  html.ex-paysage .rapport :is(.rp-texte, .rs-prose) { column-count: 2; column-gap: 10mm; }
  html.ex-paysage .rapport :is(.rp-texte, .rs-prose) :is(h2, h3, table, figure) { column-span: all; }
}
