/* ═══════════════════════════════════════════════════════════════════
   print.css — Rapport PDF A4 (gabarit « Diagnostic Mobilité » façon ARC/Compiègne)
   Aperçu à l'écran (pages A4 empilées) + règles d'impression.
   ═══════════════════════════════════════════════════════════════════ */
.pdf-root { display: block; background: #e9ecf1; padding: 0 0 30px; }
.pdf-root[hidden] { display: none; }

/* Barre d'action (écran uniquement) */
.pdf-toolbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--grad-header); color: #fff;
  padding: 12px 20px; display: flex; gap: 14px; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(20,40,77,.25);
}
.pdf-toolbar .t { font-weight: 700; font-size: 14px; margin-right: auto; }
.pdf-toolbar button {
  appearance: none; border: none; cursor: pointer; font-family: var(--font);
  font-size: 13px; font-weight: 700; border-radius: 999px; padding: 9px 18px;
}
.pdf-toolbar .btn-print { background: #fff; color: var(--color-primary-dark); }
.pdf-toolbar .btn-close { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.4); }
.pdf-toolbar .pdf-tip { font-size: 12px; color: rgba(255,255,255,.9); margin-right: 12px; font-style: italic; }
@media (max-width: 820px) { .pdf-toolbar .pdf-tip { display: none; } }

/* Page A4 — hauteur FIXE à 297 mm dès l'aperçu : ce qu'on voit est exactement
   ce qui s'imprime (une page extensible en aperçu décalerait tout à l'impression). */
.pdf-page {
  position: relative; width: 210mm; height: 297mm; background: #fff;
  margin: 22px auto 0; box-shadow: 0 6px 26px rgba(0,0,0,.16);
  padding: 24mm 16mm 20mm; overflow: hidden;
}
.pdf-page > .pdf-layer { position: relative; z-index: 2; }

/* Bandeau navy + pied de page */
.pdf-head {
  position: absolute; top: 0; left: 0; right: 0; height: 15mm; z-index: 3;
  background: var(--grad-header); color: #fff;
  display: flex; align-items: center; justify-content: space-between; padding: 0 16mm;
  font-size: 8.5pt;
}
.pdf-head .r { font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.pdf-foot {
  position: absolute; bottom: 0; left: 0; right: 0; height: 13mm; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; padding: 0 16mm;
  font-size: 7.5pt; color: #8a94a6; border-top: 1px solid #e2e6ec;
}
.pdf-foot strong { color: var(--color-text); font-weight: 700; }
/* Forme arrondie grise décorative (bas-droite) */
.pdf-blob {
  position: absolute; right: -75mm; bottom: -75mm; width: 150mm; height: 150mm;
  border-radius: 50%; background: #eef1f6; z-index: 0;
}

/* En-tête de chapitre (gros numéro + titre) */
.pdf-chapter { display: flex; align-items: center; gap: 7mm; margin: 4mm 0 7mm; }
.pdf-num { font-size: 32pt; font-weight: 800; color: #dbe1ec; line-height: 1; }
.pdf-chapter h2 { font-size: 15pt; font-weight: 800; color: var(--color-primary-dark); line-height: 1.1; }
.pdf-suite { font-size: 10pt; color: #8a94a6; font-style: italic; margin: 2mm 0 6mm; }

/* Couverture */
.pdf-cover { display: flex; flex-direction: column; padding: 20mm 18mm; }
.pdf-cover .top { display: flex; justify-content: space-between; align-items: flex-start; }
.pdf-cover-logo { height: 15mm; width: auto; display: block; }
.pdf-cover .brand { font-weight: 800; font-size: 12pt; color: var(--color-primary-dark); }
.pdf-cover .brand small { display: block; font-weight: 500; font-size: 8.5pt; color: #8a94a6; letter-spacing: .04em; margin-top: 2mm; }
.pdf-cover .terr { text-align: right; font-weight: 800; font-size: 11pt; color: var(--color-primary-dark);
  text-transform: uppercase; max-width: 70mm; line-height: 1.3; }
.pdf-cover .title { margin-top: auto; margin-bottom: 26mm; }
.pdf-cover .kicker { font-size: 10.5pt; color: #8a94a6; margin-bottom: 7mm; }
.pdf-cover .title h1 { font-size: 44pt; font-weight: 800; color: var(--color-primary-dark); line-height: 1.04; letter-spacing: -.01em; }
.pdf-cover .title .sub { font-size: 12.5pt; color: #6b7685; font-style: italic; margin-top: 8mm; }
.pdf-cover .foot { font-size: 8.5pt; color: #8a94a6; }

/* Contenu cloné : cartes compactées pour l'impression */
.pdf-layer .card { border: 1px solid #e2e6ec; box-shadow: none; padding: 5mm 6mm; margin: 0 0 5mm; break-inside: avoid; }
.pdf-layer .card-title { font-size: 12pt; }
.pdf-layer .card-sub { font-size: 9pt; margin-bottom: 3mm; }
.pdf-layer .card-source { font-size: 7.5pt; color: #6b7482; margin-top: 2mm; padding-top: 1.5mm; border-top: 0.2mm solid #d9dee6; line-height: 1.35; }
.pdf-layer .pdf-map-fig .card-source { padding: 1.5mm 3mm 0; }
.pdf-layer .callout { break-inside: avoid; margin-bottom: 5mm; }
.pdf-layer .chartbox { max-width: 380px; }         /* réduit proportionnellement les courbes */
.pdf-layer .card-context { break-inside: avoid; font-size: 9pt; }

/* IMPORTANT — mise en page INSENSIBLE au viewport : le viewport d'impression fait
   ~la largeur A4, ce qui déclencherait les variantes responsive (KPI 2×2, split
   1 colonne…) et rendrait les pages PLUS HAUTES à l'impression qu'en aperçu
   (= débordements). On fige ici les variantes « desktop » dans les clones. */
.pdf-layer .metrics { grid-template-columns: repeat(4, 1fr) !important; }
.pdf-layer .deltas { grid-template-columns: repeat(4, 1fr) !important; }
.pdf-layer .card-split { grid-template-columns: 1fr 1fr !important; }
.pdf-layer .compare-row { grid-template-columns: 170px 1fr !important; }
.pdf-layer .bar-row { grid-template-columns: 160px 1fr 88px !important; font-size: 12px !important; }
.pdf-layer .bars--dest .bar-row { grid-template-columns: 160px 1fr 82px !important; }
.pdf-layer .csp-row { grid-template-columns: 12px 180px 1fr 106px !important; }
.pdf-layer .mode-row { grid-template-columns: 28px 160px 1fr 78px !important; }
/* Compaction pour tenir dans l'A4 (chapitres denses type « parc de véhicules ») */
.pdf-layer .subhead { font-size: 10pt; margin: 3mm 0 2mm; }
.pdf-layer .spark { height: 70px; }
.pdf-layer .card-split { gap: 16px; margin-top: 3mm !important; }
.pdf-layer .stackrow .stackbar { height: 16px; }
.pdf-layer .cats-legend { gap: 8px; margin-top: 5px; font-size: 8pt; }
.pdf-layer .delta { padding: 8px 10px; }
.pdf-layer .delta-value { font-size: 16px; }
.pdf-layer .donut-wrap { gap: 12px; }

/* Note remplaçant une carte interactive dans le PDF */
.pdf-layer .pdf-map-note .pdf-map-ph {
  display: flex; align-items: center; gap: 8px; margin-top: 3mm;
  background: #f2f5fa; border: 1px dashed #c3ccdb; border-radius: 6px;
  padding: 6mm; font-size: 9.5pt; color: #4a5566; font-style: italic;
}
.pdf-layer .pdf-map-note .pdf-map-ph span { font-style: normal; font-size: 13pt; }

/* Message d'attente pendant la capture des cartes */
.pdf-status {
  max-width: 210mm; margin: 26px auto; background: #fff; border-radius: 10px;
  box-shadow: 0 6px 26px rgba(0,0,0,.12); padding: 26px 30px; text-align: center;
  font-size: 14px; font-weight: 600; color: var(--color-primary-dark);
}

/* Figures cartes (captures intégrées au rapport). max-height : une figure ne doit
   JAMAIS dépasser le corps de page (fitPages est inopérant sur un ratio d'image fixe). */
.pdf-map-fig img {
  width: 100%; height: auto; max-height: 200mm; object-fit: contain; display: block;
  border: 1px solid #e2e6ec; border-radius: 6px; background: #fff;
}
.pdf-map-fig .card-title { margin-bottom: 3mm; }

/* ── Impression ──────────────────────────────────────────────────── */
@media print {
  /* Impose l'impression des fonds colorés (barres, dégradés, blobs, histogrammes) */
  *, *::before, *::after { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body > *:not(#pdfRoot) { display: none !important; }
  #pdfRoot { position: static; }
  .pdf-root { background: #fff; padding: 0; }
  .pdf-toolbar { display: none !important; }
  .pdf-page { margin: 0; box-shadow: none; page-break-after: always; height: 297mm; min-height: 297mm; }
  .pdf-page:last-child { page-break-after: auto; }
  @page { size: A4 portrait; margin: 0; }
}
/* Aussi hors impression : force l'exactitude des couleurs dans l'aperçu PDF */
.pdf-root, .pdf-root * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
/* Le sélecteur du millésime de comparaison (serie.js) ne s'imprime pas. */
.pdf-layer .png-skip { display: none !important; }
