/* Lecteur de PDF : carrousel (documents courts, pages carrées ou paysage), document (A4 ou plus de 10 pages), image seule.
   Couleurs du site (--mnc-*, posées par le module), police de la page. Le plein écran est noir, comme Photos. */
.mnc-pdf {
  --mnc-text: #222; --mnc-muted: #595959; --mnc-brand: #222; --mnc-bar: #222; --mnc-soft: #f2f2f2; --mnc-page: #fff;
  --mnc-ease: cubic-bezier(.2, .8, .2, 1);
  position: relative; margin: 0 auto 32px; font-family: inherit; font-size: 16px; color: var(--mnc-text);
}
.mnc-pdf *, .mnc-lb * { box-sizing: border-box; }
.mnc-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mnc-pdf button, .mnc-lb button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; box-shadow: none; text-transform: none; letter-spacing: 0; -webkit-tap-highlight-color: transparent; }
.mnc-pdf :focus-visible { outline: 2px solid var(--mnc-text); outline-offset: 2px; }
.mnc-pdf button:focus:not(:focus-visible) { outline: 0; }
.mnc-ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Page (commune aux modes) ---------- */
.mnc-pdf__page { display: block; width: 100%; aspect-ratio: var(--mnc-ar); background: var(--mnc-soft); position: relative; cursor: zoom-in; overflow: hidden; }
.mnc-pdf__page img { display: block; width: 100% !important; height: 100% !important; max-width: none !important; margin: 0 !important; object-fit: contain; border-radius: 0; box-shadow: none; }
@media (min-width: 768px) {
  .mnc-pdf__page::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mnc-text) 12%, transparent); pointer-events: none; }
}
/* Une page perdue : le lien du PDF prend sa place dans la case, au même format. */
.mnc-pdf__page.is-error { cursor: default; }
.mnc-pdf__page.is-error img { visibility: hidden; }
.mnc-pdf .mnc-pdf__page a.mnc-pdf__failed, .mnc-lb a.mnc-pdf__failed { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; text-align: center; font-size: 16px; line-height: 1.4; color: var(--mnc-text) !important; text-decoration: none !important; }
.mnc-lb a.mnc-pdf__failed { color: #fff !important; --mnc-brand: #fff; }
.mnc-pdf__failed b { font-weight: 500; border-bottom: 1px solid var(--mnc-brand); }

/* ---------- Carrousel ---------- */
.mnc-pdf__stage { position: relative; }
.mnc-pdf__track {
  display: flex; margin: 0; padding: 0; list-style: none;
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.mnc-pdf__track::-webkit-scrollbar { display: none; }
.mnc-pdf__track:focus-visible { outline: 2px solid var(--mnc-text); outline-offset: 4px; }
.mnc-pdf__slide { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always; }

/* Ordinateur : la page, le compteur et « Télécharger » tiennent ensemble dans l'écran, même sur un portable de 768 px de haut. */
@media (min-width: 768px) {
  .mnc-pdf--carousel, .mnc-pdf--single { max-width: min(100%, max(340px, calc(100svh - 170px))); }
}
/* Téléphone en paysage : la page tient dans la hauteur, sans fond perdu. */
@media (max-width: 767px) and (orientation: landscape) {
  .mnc-pdf--carousel, .mnc-pdf--single { max-width: min(100%, max(340px, calc(100svh - 170px))); }
}

.mnc-pdf__progress { height: 3px; background: var(--mnc-soft); overflow: hidden; }
.mnc-pdf__progress span { display: block; height: 100%; width: 100%; background: var(--mnc-bar); transform-origin: 0 50%; transform: scaleX(var(--mnc-p, .2)); }
[dir="rtl"] .mnc-pdf__progress span { transform-origin: 100% 50%; }

/* Les flèches ne couvrent jamais la page : à côté du compteur, ou dans la marge quand la colonne en laisse une. */
.mnc-pdf__caption { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding-top: 8px; }
.mnc-pdf__caption .mnc-pdf__title { padding-top: 11.5px; }
.mnc-pdf__title { flex: 1; min-width: 0; font-size: 15px; line-height: 1.4; font-weight: 500; color: var(--mnc-text); overflow-wrap: anywhere; }
.mnc-pdf__pager { flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin-inline-end: max(-19px, var(--mnc-br, -19px)); }
.mnc-pdf__count { flex: none; min-width: 3.5ch; text-align: center; font-size: 15px; line-height: 1.4; color: var(--mnc-muted); font-variant-numeric: tabular-nums; }
.mnc-pdf .mnc-pdf__nav {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--mnc-text);
  transition: background-color .15s var(--mnc-ease), opacity .15s var(--mnc-ease);
}
.mnc-pdf .mnc-pdf__nav:disabled { opacity: .28; cursor: default; }
.mnc-pdf .mnc-pdf__nav:focus-visible { outline-offset: -2px; }
.mnc-pdf .mnc-pdf__nav:active:not(:disabled) { background: var(--mnc-soft); }
.mnc-pdf .mnc-pdf__actions a.mnc-pdf__act:active, .mnc-pdf .mnc-pdf__actions button.mnc-pdf__act:active, .mnc-pdf .mnc-pdf__iconbtn:active { opacity: .6; }
@media (hover: hover) and (pointer: fine) {
  .mnc-pdf .mnc-pdf__nav:not(:disabled):hover, .mnc-pdf .mnc-pdf__iconbtn:hover { background: var(--mnc-soft); }
}
.mnc-pdf--margin .mnc-pdf__pager { margin-inline-end: 0; }
.mnc-pdf--margin .mnc-pdf__nav { position: absolute; top: calc(var(--mnc-sh, 0px) / 2 - 22px); }
.mnc-pdf--margin .mnc-pdf__nav--prev { inset-inline-start: -56px; }
.mnc-pdf--margin .mnc-pdf__nav--next { inset-inline-end: -56px; }
.mnc-pdf--margin .mnc-pdf__nav:disabled { visibility: hidden; }

.mnc-pdf__actions { display: flex; flex-wrap: wrap; gap: 0 20px; }
.mnc-pdf .mnc-pdf__act, .mnc-pdf .mnc-pdf__actions a.mnc-pdf__act {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font: inherit; font-size: 15px; font-weight: 500; line-height: 1.3;
  color: var(--mnc-text) !important; text-decoration: none !important;
}
.mnc-pdf__act span { border-bottom: 1px solid var(--mnc-brand); line-height: 1.3; }
.mnc-pdf__act small { font-size: 15px; font-weight: 400; color: var(--mnc-muted); }
.mnc-pdf__act:hover span { border-bottom-color: var(--mnc-text); }
.mnc-pdf__act .mnc-ico { width: 18px; height: 18px; }

/* ---------- Document ---------- */
.mnc-pdf .mnc-pdf__bar {
  position: sticky; top: var(--mnc-top, 0px); z-index: 2; display: flex; align-items: center; gap: 12px; min-height: 52px;
  background: var(--mnc-page); border-bottom: 1px solid var(--mnc-soft); margin: 0;
}
.mnc-pdf--document .mnc-pdf__title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mnc-pdf--document .mnc-pdf__count { color: var(--mnc-text); }
.mnc-pdf .mnc-pdf__iconbtn, .mnc-pdf .mnc-pdf__bar a.mnc-pdf__iconbtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; height: 44px; color: var(--mnc-text) !important; text-decoration: none !important; font-size: 15px; font-weight: 500; }
.mnc-pdf__iconbtn b, .mnc-pdf__iconbtn small { display: none; font-weight: 500; }
.mnc-pdf__iconbtn small { font-size: 15px; font-weight: 400; color: var(--mnc-muted); }
.mnc-pdf--document { container-type: inline-size; }
/* La bascule icônes/texte suit la colonne, pas l'écran : une barre latérale étroite garde son titre. */
@container (min-width: 560px) { .mnc-pdf__iconbtn b, .mnc-pdf__iconbtn small { display: inline; } .mnc-pdf .mnc-pdf__iconbtn { padding-inline: 4px; } }
@container (max-width: 399px) { .mnc-pdf .mnc-l { display: none; } .mnc-pdf .mnc-s { display: inline; } }
@media (max-width: 767px) {
  .mnc-pdf .mnc-pdf__bar { gap: 8px; }
  .mnc-pdf--document .mnc-pdf__title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
  .mnc-pdf__iconbtn + .mnc-pdf__iconbtn { margin-left: -4px; margin-inline-end: max(-12px, var(--mnc-br, -12px)); }
}
.mnc-pdf ol.mnc-pdf__pages { list-style: none !important; margin: 0 !important; padding: 0 !important; display: grid; gap: 12px; }
.mnc-pdf .mnc-pdf__pages > li { margin: 0 !important; padding: 0 !important; }
.mnc-pdf .mnc-pdf__pages > li::before { content: none !important; }
.mnc-pdf .mnc-pdf__bar a.mnc-pdf__skip { position: absolute; left: 0; top: 0; z-index: 3; padding: 12px 16px; background: var(--mnc-text); color: var(--mnc-page) !important; font-size: 15px; text-decoration: none !important; clip-path: inset(50%); }
.mnc-pdf .mnc-pdf__bar a.mnc-pdf__skip:focus { clip-path: none; }
.mnc-pdf--document .mnc-pdf__page img { scroll-margin-top: calc(var(--mnc-top, 0px) + 60px); }
.mnc-pdf__end { display: block; height: 0; outline: 0; scroll-margin-top: calc(var(--mnc-top, 0px) + 16px); }
.mnc-pdf .mnc-s { display: none; }

/* Le thème met des marges et l'italique sur les légendes, un retrait sur les figures : le lecteur les neutralise. */
.mnc-pdf figcaption, .mnc-pdf .mnc-pdf__caption, .mnc-pdf .mnc-pdf__bar { font-style: normal; text-align: start; margin: 0; }

/* Fond perdu sur téléphone : la page va d'un bord à l'autre (le script affine si la colonne n'est pas centrée), les textes restent sur la colonne. */
@media (max-width: 767px) and (orientation: portrait) {
  .mnc-pdf .mnc-pdf__stage, .mnc-pdf .mnc-pdf__progress, .mnc-pdf ol.mnc-pdf__pages, .mnc-pdf .mnc-pdf__bar {
    margin-inline: var(--mnc-bl, calc(50% - 50vw)) var(--mnc-br, calc(50% - 50vw)) !important;
  }
  .mnc-pdf .mnc-pdf__bar { padding-inline: calc(-1 * var(--mnc-bl, calc(50% - 50vw))) calc(-1 * var(--mnc-br, calc(50% - 50vw))); }
  .mnc-pdf__track:focus-visible { outline: 3px solid var(--mnc-text); outline-offset: -3px; }
}
@media (max-width: 767px) {
  .mnc-pdf .mnc-l { display: none; }
  .mnc-pdf .mnc-s { display: inline; }
  .mnc-pdf--carousel .mnc-pdf__title, .mnc-pdf--single .mnc-pdf__title { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
}

/* Sans script (coupé, bloqué, différé) : la page défile seule, le lien reste ; rien d'inerte à l'écran. Sans moteur serveur : le bloc d'origine. */
.mnc-pdf:not(.is-ready) .mnc-pdf__pager, .mnc-pdf:not(.is-ready) [data-open=""] { visibility: hidden; }
@media (scripting: none) {
  .mnc-pdf__pager, .mnc-pdf [data-open=""], .mnc-pdf__progress { display: none !important; }
  .mnc-pdf__page { cursor: default; }
  .mnc-pdf__track { scrollbar-width: auto; }
  .mnc-pdf__title[data-pages]::after { content: " · " attr(data-pages); font-weight: 400; color: var(--mnc-muted); }
  .mnc-pdf--browser > :not(noscript) { display: none !important; }
}

/* ---------- Plein écran ---------- */
.mnc-lb {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: transparent; color: #fff; overflow: hidden; font-family: inherit;
}
.mnc-lb::backdrop { background: transparent; }
.mnc-lb__bg { position: absolute; inset: 0; background: #000; opacity: var(--mnc-bg, 1); }
.mnc-lb :focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.mnc-lb__bar {
  position: absolute; z-index: 2; inset: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
  transition: opacity .2s;
}
.mnc-lb .mnc-lb__btn, .mnc-lb__count { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; height: 44px; padding: 0 12px; border-radius: 22px; color: #fff !important; text-decoration: none !important; font: inherit; font-size: 15px; font-weight: 500; line-height: 1; background: rgba(28, 28, 30, .72) !important; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.mnc-lb .mnc-lb__btn:hover { background: rgba(58, 58, 60, .82) !important; }
.mnc-lb__btn .mnc-ico { width: 20px; height: 20px; }
.mnc-lb__btn b { display: none; font-weight: 500; }
@media (min-width: 768px) { .mnc-lb__btn b { display: inline; } }
.mnc-lb .mnc-lb__head { flex: 1; min-width: 0; margin: 0 !important; display: flex; justify-content: center; }
.mnc-lb__name { display: none; max-width: 48vw; color: rgba(255, 255, 255, .72); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 768px) { .mnc-lb__name { display: inline; } .mnc-lb__name::after { content: "  ·"; white-space: pre; } }
.mnc-lb__count { font-variant-numeric: tabular-nums; height: 32px; min-width: 0; margin-top: 2px; }
.mnc-lb__track { position: absolute; inset: 0; z-index: 1; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior: contain; touch-action: pan-x; }
.mnc-lb__track::-webkit-scrollbar { display: none; }
.mnc-lb__track.is-zoomed { overflow: hidden; touch-action: none; }
.mnc-lb__slide { flex: 0 0 100%; height: 100%; scroll-snap-align: center; scroll-snap-stop: always; display: block; overflow: hidden; padding: 64px 0 40px; }
@media (min-width: 768px) { .mnc-lb__slide { padding: 72px 88px 48px; } }
.mnc-lb__zoom { width: 100%; height: 100%; display: grid; place-items: center; transform-origin: 0 0; will-change: transform; }
.mnc-lb__zoom img { background-color: rgba(255, 255, 255, .08); display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; user-select: none; -webkit-user-drag: none; cursor: zoom-in; }
.mnc-lb__track.is-zoomed img { cursor: grab; }
.mnc-lb .mnc-lb__count[hidden] { display: none; }
.mnc-lb .mnc-lb__nav { position: absolute; z-index: 2; top: 50%; margin-top: -24px; width: 48px; height: 48px; border-radius: 50%; display: grid; clip-path: inset(50%); place-items: center; color: #fff !important; background: rgba(28, 28, 30, .72) !important; transition: opacity .2s; }
.mnc-lb .mnc-lb__nav:hover { background: rgba(58, 58, 60, .82) !important; }
.mnc-lb__nav--prev { left: 20px; } .mnc-lb__nav--next { right: 20px; }
/* Au toucher, on glisse : les flèches restent pour le lecteur d'écran et le clavier. */
.mnc-lb .mnc-lb__nav:focus-visible { clip-path: none; }
@media (hover: hover) and (pointer: fine) { .mnc-lb .mnc-lb__nav { clip-path: none; } }
.mnc-lb .mnc-lb__nav[hidden] { display: none !important; }
.mnc-lb.is-dragging .mnc-lb__bar, .mnc-lb.is-dragging .mnc-lb__nav, .mnc-lb.is-chrome-hidden .mnc-lb__bar, .mnc-lb.is-chrome-hidden .mnc-lb__nav { opacity: 0; pointer-events: none; }
.mnc-lb.is-chrome-hidden .mnc-lb__bar, .mnc-lb.is-chrome-hidden .mnc-lb__nav { visibility: hidden; transition: opacity .2s, visibility 0s .2s; }

@media (prefers-reduced-motion: reduce) {
  .mnc-pdf *, .mnc-lb * { transition: none !important; scroll-behavior: auto !important; }
}

/* À l'impression : le document entier, chaque page sur toute la largeur et jamais coupée, puis l'adresse du PDF. */
@media print {
  .mnc-pdf__progress, .mnc-pdf__pager, .mnc-pdf [data-open=""], .mnc-pdf__skip, .mnc-pdf__count, .mnc-pdf .mnc-ico, .mnc-pdf__act span, .mnc-pdf__iconbtn b, .mnc-lb { display: none !important; }
  /* Chrome ne reporte pas sur la suite le blanc d'une page repoussée dans un conteneur flex ou grille (Elementor) : le pied du site montait sur le texte. */
  body :has(.mnc-pdf) { display: block !important; }
  .mnc-pdf.mnc-pdf--carousel, .mnc-pdf.mnc-pdf--single, .mnc-pdf.mnc-pdf--document { max-width: none; container-type: normal; }
  .mnc-pdf .mnc-pdf__stage, .mnc-pdf ol.mnc-pdf__pages, .mnc-pdf .mnc-pdf__bar { margin-inline: 0 !important; padding-inline: 0; }
  .mnc-pdf .mnc-pdf__track, .mnc-pdf ol.mnc-pdf__pages { display: block; overflow: visible; }
  .mnc-pdf .mnc-pdf__slide, .mnc-pdf .mnc-pdf__pages > li { display: block; margin: 0 0 12px !important; }
  .mnc-pdf .mnc-pdf__page { max-height: 98vh; background: none; break-inside: avoid; }
  .mnc-pdf .mnc-pdf__page::after { content: none; }
  .mnc-pdf .mnc-pdf__bar, .mnc-pdf .mnc-pdf__caption { position: static; display: block; min-height: 0; border: 0; padding: 0; }
  .mnc-pdf .mnc-pdf__title, .mnc-pdf--document .mnc-pdf__title, .mnc-pdf--carousel .mnc-pdf__title, .mnc-pdf--single .mnc-pdf__title { display: block; padding: 0; white-space: normal; overflow: visible; -webkit-line-clamp: none; break-after: avoid; }
  .mnc-pdf .mnc-pdf__actions a.mnc-pdf__act, .mnc-pdf .mnc-pdf__bar a.mnc-pdf__iconbtn { display: block; height: auto; min-height: 0; padding: 0; text-align: start; }
  .mnc-pdf .mnc-pdf__act small, .mnc-pdf .mnc-pdf__iconbtn small { display: inline; color: var(--mnc-text); }
  .mnc-pdf a[download]::after { content: " : " attr(href); font-weight: 400; overflow-wrap: anywhere; }
}
