/* Calendrier à imprimer */
.o-calendrier { display: grid; gap: 16px; min-width: 0; }
.o-calendrier [hidden] { display: none !important; }
.o-calendrier .invisible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.o-calendrier-barre, .o-calendrier-impr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.o-calendrier-barre { justify-content: space-between; }
.o-calendrier-vues { display: inline-flex; gap: 0; }
.o-calendrier-vues .btn { min-height: 40px; padding-inline: 18px; }
.o-calendrier-vues .btn:first-child { border-radius: var(--rayon-petit) 0 0 var(--rayon-petit); }
.o-calendrier-vues .btn:last-child { border-radius: 0 var(--rayon-petit) var(--rayon-petit) 0; margin-left: -1px; }
.atelier .o-calendrier-vues .btn[aria-pressed="true"] { background: var(--marque); border-color: var(--marque); color: var(--sur-marque); font-weight: 600; }
.o-calendrier-nav { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.o-calendrier-nav .btn { min-height: 40px; }
.o-calendrier-titre { display: block; text-align: center; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.o-calendrier .reglages { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.o-calendrier .reglages input[type="number"], .o-calendrier .reglages select, .o-calendrier-impr select { width: 100%; min-height: 42px; }
.o-calendrier-impr label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--texte-2); flex: 1 1 260px; }
.o-calendrier-impr .btn { min-height: 42px; align-self: flex-end; }
.o-calendrier-impr .tirage-message { align-self: flex-end; }
.o-calendrier input:focus-visible, .o-calendrier select:focus-visible, .o-calendrier button:focus-visible { outline: 3px solid var(--marque); outline-offset: 1px; }
.o-calendrier > .tirage-message:empty { display: none; }
.o-calendrier > .tirage-message { margin: 0; color: var(--erreur-texte); font-weight: 600; }

/* Tables communes */
.o-calendrier-vue table { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
.o-calendrier-vue th { font-weight: 600; color: var(--texte-2); font-size: .8rem; }
.o-calendrier-vue th.sem, .o-calendrier-vue thead th.sem { width: 2.2em; color: var(--texte-2); font-weight: 500; font-size: .72rem; }
.o-calendrier-vue td.we { background: var(--surface-2); }
.o-calendrier-vue td.fe .num { color: var(--marque-fort); font-weight: 800; text-decoration: underline dotted; text-underline-offset: 3px; }
.o-calendrier-vue td.auj { outline: 2px solid var(--marque); outline-offset: -2px; }

/* Vue année : 12 petits mois */
.o-calendrier-annee { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 18px 22px; }
.o-calendrier-mois h3 { margin: 0 0 4px; font-size: 1rem; }
.o-calendrier-mois h3 button {
  font: inherit; font-weight: 700; color: var(--marque-fort); background: none; border: 0; padding: 2px 4px; margin-left: -4px;
  border-radius: 6px; cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px;
}
.o-calendrier-mois h3 button:hover { text-decoration-color: currentColor; }
.o-calendrier-mois:not(.grand) th, .o-calendrier-mois:not(.grand) td { text-align: center; padding: 3px 0; font-size: .85rem; }
.o-calendrier-mois:not(.grand) td.auj { background: var(--marque); outline: 0; border-radius: 6px; }
.o-calendrier-mois:not(.grand) td.auj .num { color: var(--sur-marque); }

/* Vue mois : grandes cases */
.o-calendrier-mois.grand table { border: 1px solid var(--bord); }
.o-calendrier-mois.grand thead th { padding: 8px 4px; border: 1px solid var(--bord); background: var(--surface-2); }
.o-calendrier-mois.grand td, .o-calendrier-mois.grand tbody th { height: 6.2rem; vertical-align: top; border: 1px solid var(--bord); padding: 6px; text-align: left; }
.o-calendrier-mois.grand tbody th.sem { text-align: center; padding: 6px 0; }
.o-calendrier-mois.grand td.hors { background: none; }
.o-calendrier-mois.grand .num { display: block; font-weight: 700; font-size: 1.05rem; }
.o-calendrier-mois.grand .nom { display: block; margin-top: 4px; font-size: .75rem; line-height: 1.2; color: var(--marque-fort); overflow-wrap: anywhere; hyphens: auto; }
.o-calendrier-mois.grand td.auj .num {
  display: inline-grid; place-items: center; min-width: 1.9em; height: 1.9em; border-radius: 999px; background: var(--marque); color: var(--sur-marque);
}
.o-calendrier-mois.grand td.auj { outline: 0; }
.o-calendrier-mois.grand .court { display: none; }

/* Jours fériés */
.o-calendrier-feries { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--bord); }
.o-calendrier-feries h2 { margin: 0; font-size: 1.1rem; }
.o-calendrier-feries ul { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 4px 20px; }
.o-calendrier-feries li { display: flex; flex-wrap: wrap; gap: 0 8px; padding: 4px 0; border-bottom: 1px dashed var(--bord); }
.o-calendrier-feries li .quand { font-weight: 600; min-width: 11em; }
.o-calendrier-feries li.ce-mois { color: var(--marque-fort); }
.o-calendrier-note { margin: 0; font-size: .9rem; color: var(--texte-2); }
.o-calendrier > .tirage-astuce { text-align: center; }

@media (max-width: 640px) {
  .o-calendrier-titre { font-size: 1.3rem; }
  .o-calendrier .reglages { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
  .o-calendrier .reglages label.case { font-size: .92rem; min-height: 36px; }
  .o-calendrier-nav .btn [data-prec-texte], .o-calendrier-nav .btn [data-suiv-texte] { display: none; }
  .o-calendrier-nav .btn { min-width: 44px; font-size: 1.3rem; }
  .o-calendrier-mois.grand .long { display: none; }
  .o-calendrier-mois.grand .court { display: inline; }
  .o-calendrier-mois.grand thead th { font-size: .72rem; padding: 6px 1px; overflow: hidden; }
  .o-calendrier-mois.grand td, .o-calendrier-mois.grand tbody th { height: 3.6rem; padding: 3px; }
  .o-calendrier-mois.grand .num { font-size: .9rem; }
  .o-calendrier-mois.grand .nom { font-size: .6rem; }
  .o-calendrier-mois.grand th.sem, .o-calendrier-mois.grand thead th.sem { width: 1.8em; font-size: .62rem; }
  .o-calendrier-annee { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 14px; }
  .o-calendrier-mois:not(.grand) th, .o-calendrier-mois:not(.grand) td { font-size: .78rem; padding: 2px 0; }
}

/* Impression : seule la zone d'impression sort, sur fond blanc */
.o-calendrier .o-calendrier-impression { display: none; }
@media print {
  body:has(.o-calendrier-impression) *:not(:has(.o-calendrier-impression)):not(.o-calendrier-impression):not(.o-calendrier-impression *) { display: none !important; }
  html:has(.o-calendrier-impression), body:has(.o-calendrier-impression), body:has(.o-calendrier-impression) *:has(.o-calendrier-impression) {
    display: block !important; margin: 0 !important; padding: 0 !important; border: 0 !important; background: #fff !important;
    box-shadow: none !important; width: auto !important; max-width: none !important; min-height: 0 !important; height: auto !important;
    position: static !important; overflow: visible !important; color: #000 !important;
  }
  .o-calendrier .o-calendrier-impression { display: block !important; color: #000; font-family: var(--police); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .o-calendrier-impression .invisible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .o-calendrier-impression .o-calendrier-feuille { break-after: page; page-break-after: always; }
  .o-calendrier-impression .o-calendrier-feuille:last-child { break-after: auto; page-break-after: auto; }
  .o-calendrier-impression h2 { margin: 0 0 4mm; font-size: 20pt; line-height: 1.1; color: #000; }
  .o-calendrier-impression table { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
  .o-calendrier-impression th { color: #444; font-weight: 600; }
  .o-calendrier-impression td.we { background: #ececec; }
  .o-calendrier-impression td.fe .num { font-weight: 800; text-decoration: underline; }
  .o-calendrier-impression th.sem { color: #777; font-weight: 400; }

  /* Année sur une page A4 paysage */
  .o-calendrier-impression .feuille-annee .o-calendrier-annee { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4mm 7mm; }
  .o-calendrier-impression .feuille-annee h3 { margin: 0 0 1mm; font-size: 10.5pt; }
  .o-calendrier-impression .feuille-annee th, .o-calendrier-impression .feuille-annee td { text-align: center; padding: .5mm 0; font-size: 8.5pt; height: 4.6mm; }
  .o-calendrier-impression .feuille-annee th.sem { width: 6mm; font-size: 6.5pt; }
  .o-calendrier-impression .titre-feries { margin: 4mm 0 1mm; font-size: 8.5pt; font-weight: 700; }
  .o-calendrier-impression .liste-feries { margin: 0; padding: 0; list-style: none; columns: 4; column-gap: 6mm; font-size: 7.5pt; line-height: 1.35; }
  .o-calendrier-impression .liste-feries li { break-inside: avoid; }

  /* Un mois sur une page A4 portrait, cases à écrire */
  .o-calendrier-impression .feuille-mois table { height: 245mm; border: .3mm solid #555; }
  .o-calendrier-impression .feuille-mois thead tr { height: 8mm; }
  .o-calendrier-impression .feuille-mois thead th { font-size: 9.5pt; border: .3mm solid #555; background: #f4f4f4; padding: 1mm; }
  .o-calendrier-impression .feuille-mois thead th.sem { width: 7mm; font-size: 7pt; }
  .o-calendrier-impression .feuille-mois .court { display: none; }
  .o-calendrier-impression .feuille-mois td, .o-calendrier-impression .feuille-mois tbody th { vertical-align: top; text-align: left; border: .3mm solid #555; padding: 1.5mm; }
  .o-calendrier-impression .feuille-mois tbody th.sem { text-align: center; font-size: 8pt; }
  .o-calendrier-impression .feuille-mois .num { display: block; font-size: 13pt; font-weight: 700; }
  .o-calendrier-impression .feuille-mois .nom { display: block; margin-top: 1mm; font-size: 7.5pt; line-height: 1.2; }
}
