/*
 * Impression des listes depuis le navigateur (listes publiées, états) :
 * A4, noir sur blanc, sans navigation ni éléments interactifs.
 * Les documents officiels (contrats, reçus) passent par WeasyPrint et
 * pdf.css, pas par ce fichier.
 *
 * Lien dans base.html : <link rel="stylesheet" href="…/print.css" media="print">
 * Le bloc @media print protège aussi un chargement sans attribut media.
 *
 * Classes utiles dans les gabarits :
 *   u-print-hidden        masqué à l'impression
 *   u-print-only          visible seulement à l'impression (masqué à l'écran par base.css)
 *   u-print-break-before  nouvelle page avant l'élément (une page par établissement / genre)
 *   u-print-keep          ne pas couper l'élément entre deux pages
 */

/* Les propriétés personnalisées ne sont pas résolues de façon fiable dans
   @page : la marge (18 mm, docs/04 § 12) est donc écrite ici en clair. */
@page {
  size: A4;
  margin: 18mm;
}

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    box-shadow: none !important;
    color: var(--color-print-ink) !important;
    text-shadow: none !important;
  }

  html,
  body {
    background-color: var(--color-print-paper) !important;
    print-color-adjust: economy;
  }

  body {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-body);
  }

  /* Navigation, signature visuelle et éléments interactifs */
  .u-horizon-line,
  .l-sidebar,
  .l-topbar,
  .c-toast-region,
  .c-dialog,
  .c-button,
  .c-skeleton,
  nav,
  button,
  .u-print-hidden {
    display: none !important;
  }

  /* La coquille se réduit à une seule colonne pleine largeur */
  .l-shell,
  .l-main,
  .l-content {
    display: block !important;
    max-inline-size: none !important;
    margin: var(--space-0) !important;
    padding: var(--space-0) !important;
  }

  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
  }

  h1 {
    font-size: var(--font-size-lg);
    margin-block-end: var(--space-3);
  }

  h2 {
    font-size: var(--font-size-body);
    margin-block-end: var(--space-2);
  }

  p,
  li {
    orphans: 3;
    widows: 3;
  }

  a {
    text-decoration: none;
  }

  /* Tableaux : en-tête répété sur chaque page, lignes jamais coupées */
  table {
    inline-size: 100%;
    border-collapse: collapse;
  }

  thead {
    display: table-header-group;
  }

  tfoot {
    display: table-footer-group;
  }

  tr,
  img,
  svg {
    break-inside: avoid;
  }

  th,
  td {
    padding-block: var(--space-1);
    padding-inline: var(--space-2);
    border: var(--border-width) solid var(--color-print-ink);
    text-align: start;
    vertical-align: top;
  }

  th {
    font-weight: var(--font-weight-semibold);
  }

  /* Rang, n° d'inscription : chiffres alignés */
  td,
  th {
    font-variant-numeric: tabular-nums;
  }

  /* Badges : sans fond, le libellé et l'icône portent l'information */
  .c-badge {
    border: var(--border-width) solid var(--color-print-ink);
  }

  .u-print-break-before {
    break-before: page;
  }

  .u-print-keep {
    break-inside: avoid;
  }
}
