/* MEMORA solutions (info@memora.ca) - GNU GPL v3 or later. */
.memoralightbox-dialog[open] {
    box-sizing: border-box;
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-rows: auto minmax(80px, 1fr) auto;
    gap: 12px;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
        max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border: 0;
    background: transparent;
    color: #fff;
    font: 1rem/1.4 system-ui, sans-serif;
    overflow: auto;
    overscroll-behavior: contain;
}
/* Fond volontairement SEMI-transparent : on devine la page dessous, donc on comprend que c'est une
   surcouche (et non un nouvel onglet). Assez sombre pour garder le contraste de l'image. Léger flou
   pour signaler l'arrière-plan sans le rendre lisible (demande fondateur 2026-10-23). */
.memoralightbox-dialog::backdrop {
    background: rgba(10, 14, 20, .72);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    width: 100vw;
    height: 100dvh;
}
.memoralightbox-dialog *, .memoralightbox-dialog *::before { box-sizing: border-box; }
.memoralightbox-dialog [hidden] { display: none !important; }
.memoralightbox-header, .memoralightbox-toolbar, .memoralightbox-pancontrols {
    display: flex;
    align-items: center;
    gap: 8px;
}
.memoralightbox-header { justify-content: space-between; }
.memoralightbox-counter {
    padding: 8px 14px;
    border-radius: 24px;
    background: #fff;
    color: var(--c-accent, #9A2A06);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.memoralightbox-dialog .memoralightbox-button {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    backdrop-filter: blur(8px);
    color: #fff;
    font: inherit;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}
.memoralightbox-dialog .memoralightbox-close,
.memoralightbox-dialog .memoralightbox-prev,
.memoralightbox-dialog .memoralightbox-next { width: 48px; height: 48px; font-size: 2rem; }
.memoralightbox-dialog .memoralightbox-button:hover:not(:disabled) { background: rgba(255, 255, 255, .26); }
.memoralightbox-dialog .memoralightbox-button:disabled { opacity: .4; cursor: default; }
.memoralightbox-dialog :focus-visible {
    outline: 3px solid var(--c-primary, #064E5A);
    outline-offset: 3px;
    box-shadow: 0 0 0 6px #fff;
}
.memoralightbox-figure {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
    gap: 10px;
    margin: 0;
}
.memoralightbox-stage { position: relative; min-height: 0; overflow: hidden; border-radius: 12px; }
/* Le cadre reste visible même lorsque l'image agrandie dépasse la scène. */
.memoralightbox-stage:has(.memoralightbox-image:focus-visible)::after {
    content: '';
    position: absolute;
    inset: 6px;
    z-index: 4;
    border: 3px solid var(--c-primary, #064E5A);
    outline: 3px solid #fff;
    border-radius: 6px;
    pointer-events: none;
}
.memoralightbox-image {
    position: absolute;
    display: block;
    max-width: none;
    max-height: none;
    margin: 0;
    object-fit: contain;
    transform-origin: center;
    cursor: zoom-in;
    user-select: none;
    -webkit-user-select: none;
}
/* Réserver les gestes à la seule image manipulable, sans bloquer le zoom du reste de l'écran. */
.memoralightbox-image.is-ready { touch-action: none; }
.memoralightbox-image.is-preview { filter: blur(3px); }
.memoralightbox-image.is-zoomed { cursor: grab; }
.memoralightbox-image.is-zoomed.is-dragging { cursor: grabbing; }
.memoralightbox-dialog .memoralightbox-prev,
.memoralightbox-dialog .memoralightbox-next {
    position: absolute;
    z-index: 2;
    top: calc(50% - 24px);
    background: rgba(10, 14, 20, .65);
}
.memoralightbox-prev { left: 8px; }
.memoralightbox-next { right: 8px; }
.memoralightbox-caption {
    justify-self: center;
    max-width: min(80ch, 100%);
    max-height: 20vh;
    overflow: auto;
    overflow-wrap: anywhere;
    padding: 10px 16px;
    border-radius: 12px;
    background: rgba(10, 14, 20, .75);
    backdrop-filter: blur(8px);
    color: #fff;
    text-align: center;
}
.memoralightbox-toolbar { justify-content: center; flex-wrap: wrap; }
.memoralightbox-zoomlevel { min-width: 5ch; color: #fff; font-variant-numeric: tabular-nums; }
.memoralightbox-message {
    position: absolute;
    z-index: 3;
    inset: auto 64px 12px;
    text-align: center;
    pointer-events: none;
}
.memoralightbox-message .memoralightbox-button { pointer-events: auto; background: #26313f; }
.memoralightbox-status:not(:empty) {
    display: inline-block;
    margin: 0 0 8px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(10, 14, 20, .85);
    color: #fff;
}
.memoralightbox-status:empty { display: none; }
.memoralightbox-spinner {
    position: absolute;
    left: calc(50% - 18px);
    top: calc(50% - 18px);
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    pointer-events: none;
    animation: memoralightbox-spin 800ms linear infinite;
}
.memoralightbox-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}
@keyframes memoralightbox-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .memoralightbox-dialog *, .memoralightbox-dialog::backdrop {
        animation: none !important;
        transition: none !important;
    }
    /* Les morphs et zooms JavaScript consultent également cette préférence. */
}
@media (forced-colors: active) {
    .memoralightbox-dialog[open], .memoralightbox-dialog::backdrop { background: Canvas; color: CanvasText; }
    .memoralightbox-dialog .memoralightbox-button { border: 2px solid ButtonText; }
}

/* === Refonte sobre de la barre d'outils (demande fondateur 2026-10-23, critique ChatGPT GPT-6.1) ===
   Les commandes flottaient, translucides et peu contrastées. On les regroupe dans UNE capsule
   anthracite OPAQUE, centrée, avec icônes SVG homogènes. Les flèches de déplacement sont retirées
   (le glissement, le pincement et le clavier déplacent déjà l'image zoomée). La navigation inutile
   (bord de galerie ou image unique) est masquée plutôt que grisée. Tout en CSS, aucune modif du JS.
   Icônes = SVG en ligne, sans dépendance externe, recolorées par currentColor via mask. MEMORA. */
.memoralightbox-dialog .memoralightbox-toolbar {
    justify-self: center;
    width: max-content;
    max-width: 100%;
    flex-wrap: nowrap;
    gap: 4px;
    margin-bottom: 4px;
    padding: 6px;
    border-radius: 16px;
    background: rgba(16, 22, 33, .96);
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
/* Ordre lisible : −  pourcentage  +  |  Ajuster */
.memoralightbox-dialog .memoralightbox-zoomout { order: 1; }
.memoralightbox-dialog .memoralightbox-zoomlevel { order: 2; min-width: 4.5ch; padding: 0 4px; text-align: center; }
.memoralightbox-dialog .memoralightbox-zoomin { order: 3; }
.memoralightbox-dialog .memoralightbox-fit {
    order: 4;
    min-width: 44px;
    padding: 8px 16px;
    margin-left: 4px;
    border-radius: 0 999px 999px 0;
    border-left: 1px solid rgba(255, 255, 255, .16);
}
/* Déplacement par flèches retiré de la barre : glisser / pincer / clavier le font déjà. */
.memoralightbox-dialog .memoralightbox-pancontrols { display: none; }
/* Flèche de navigation inutilisable (bord de galerie, ou image unique) : masquée au lieu d'être grisée. */
.memoralightbox-dialog .memoralightbox-prev:disabled,
.memoralightbox-dialog .memoralightbox-next:disabled { display: none; }
/* Boutons de la barre, cohérents sur la capsule : commandes blanc cassé, pastilles nettes, sans bordure. */
.memoralightbox-dialog .memoralightbox-toolbar .memoralightbox-button {
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .08);
    color: #f3f4f6;
}
.memoralightbox-dialog .memoralightbox-toolbar .memoralightbox-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, .18);
}
/* Icônes SVG homogènes à la place des symboles texte, sur zoom / fermer / précédent / suivant.
   Le libellé lu par lecteur d'écran reste porté par aria-label ; on masque seulement le glyphe. */
.memoralightbox-dialog .memoralightbox-zoomout,
.memoralightbox-dialog .memoralightbox-zoomin,
.memoralightbox-dialog .memoralightbox-close,
.memoralightbox-dialog .memoralightbox-prev,
.memoralightbox-dialog .memoralightbox-next { font-size: 0; }
.memoralightbox-dialog .memoralightbox-zoomout::before,
.memoralightbox-dialog .memoralightbox-zoomin::before,
.memoralightbox-dialog .memoralightbox-close::before,
.memoralightbox-dialog .memoralightbox-prev::before,
.memoralightbox-dialog .memoralightbox-next::before {
    content: "";
    width: 22px;
    height: 22px;
    background-color: currentColor;
    -webkit-mask: var(--mlb-icon) center / contain no-repeat;
    mask: var(--mlb-icon) center / contain no-repeat;
}
.memoralightbox-dialog .memoralightbox-zoomout { --mlb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E"); }
.memoralightbox-dialog .memoralightbox-zoomin { --mlb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E"); }
.memoralightbox-dialog .memoralightbox-close { --mlb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E"); }
.memoralightbox-dialog .memoralightbox-prev { --mlb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 18 9 12 15 6'/%3E%3C/svg%3E"); }
.memoralightbox-dialog .memoralightbox-next { --mlb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E"); }
.memoralightbox-dialog .memoralightbox-close::before,
.memoralightbox-dialog .memoralightbox-prev::before,
.memoralightbox-dialog .memoralightbox-next::before { width: 24px; height: 24px; }
/* Fermer reste en haut à DROITE même quand le compteur est masqué (image unique, header à un seul enfant). */
.memoralightbox-dialog .memoralightbox-close { margin-left: auto; }
/* Repli contrastes forcés : pas de mask fiable -> on restaure le symbole texte et on retire l'icône. */
@media (forced-colors: active) {
    .memoralightbox-dialog .memoralightbox-zoomout,
    .memoralightbox-dialog .memoralightbox-zoomin,
    .memoralightbox-dialog .memoralightbox-close,
    .memoralightbox-dialog .memoralightbox-prev,
    .memoralightbox-dialog .memoralightbox-next { font-size: 1.5rem; }
    .memoralightbox-dialog .memoralightbox-zoomout::before,
    .memoralightbox-dialog .memoralightbox-zoomin::before,
    .memoralightbox-dialog .memoralightbox-close::before,
    .memoralightbox-dialog .memoralightbox-prev::before,
    .memoralightbox-dialog .memoralightbox-next::before { display: none; }
}
