/* Alliance Galerie — 7 types d'affichage */
.ag {
  --ag-row: 320; --ag-cols: 4; --ag-gap: 10px; --ag-radius: 0px;
  --ag-overlay: rgba(0,0,0,.45); --ag-overlay-text: #fff; --ag-caption: inherit; --ag-caption-size: 14px; --ag-frame: #fff;
  max-width: var(--ag-maxw, none);
  margin: 1.5em auto;
  box-sizing: border-box;
}
.ag--align-left { margin-left: 0; }
.ag *, .ag *::before, .ag *::after { box-sizing: border-box; }
.ag figure { margin: 0 !important; padding: 0; }
.ag > script { display: none; }
.ag-more, .ag-filtered { display: none !important; }

.ag__item { position: relative; }
.ag__link { position: relative; display: block; overflow: hidden; border-radius: var(--ag-radius); background: rgba(127,127,127,.14); color: inherit; box-shadow: none; border: 0; }
.ag__img { display: block !important; width: 100% !important; height: 100% !important; max-width: none !important; margin: 0 !important; object-fit: cover; border-radius: 0; }
.ag__link:focus-visible { outline: 3px solid #3858e9; outline-offset: 2px; }
.ag__caption { padding: 7px 2px 0; font-size: var(--ag-caption-size); color: var(--ag-caption); line-height: 1.3; }

/* ---- Rangées justifiées (référence « Portraits au flash ») ---- */
.ag--justified .ag__list { display: flex; flex-wrap: wrap; gap: var(--ag-gap); }
.ag--justified .ag__list::after { content: ""; flex-grow: 1000000; }
.ag--justified .ag__item { flex-grow: var(--r); flex-basis: calc(var(--r) * var(--ag-row) * 1px); }
.ag--justified .ag__link { aspect-ratio: var(--r); }

/* ---- Grille / Mosaïque / Polaroïd ---- */
.ag--grid .ag__list, .ag--mosaic .ag__list, .ag--polaroid .ag__list { display: grid; gap: var(--ag-gap); grid-template-columns: repeat(var(--ag-cols), minmax(0, 1fr)); }
.ag--grid .ag__link, .ag--mosaic .ag__link, .ag--polaroid .ag__link, .ag--carousel .ag__link { aspect-ratio: 1; }
.ag--ratio-4-3 .ag__link { aspect-ratio: 4 / 3; }
.ag--ratio-3-2 .ag__link { aspect-ratio: 3 / 2; }
.ag--ratio-16-9 .ag__link { aspect-ratio: 16 / 9; }
.ag--ratio-3-4 .ag__link { aspect-ratio: 3 / 4; }
.ag--ratio-original .ag__link { aspect-ratio: var(--r); }
.ag--ratio-original.ag--grid .ag__list { align-items: start; }
.ag--mosaic .ag__list { grid-auto-flow: dense; }
.ag--mosaic .ag__item--big { grid-column: span 2; grid-row: span 2; }
.ag--mosaic .ag__item--big .ag__img { position: absolute; inset: 0; }
@media (max-width: 600px) { .ag--mosaic .ag__item--big { grid-column: span min(2, var(--ag-cols)); } }

.ag--polaroid .ag__item { padding: 10px 10px 12px; background: var(--ag-frame); box-shadow: 0 2px 12px rgba(0,0,0,.14); border-radius: 2px; transition: transform .3s ease; }
.ag--polaroid .ag__caption { text-align: center; color: #333; padding-top: 9px; }
.ag--polaroid.ag--tilt .ag__item:nth-child(3n+1) { transform: rotate(-1.4deg); }
.ag--polaroid.ag--tilt .ag__item:nth-child(3n+2) { transform: rotate(1.1deg); }
.ag--polaroid .ag__item:hover { transform: rotate(0) scale(1.02); z-index: 2; }

/* ---- Maçonnerie ---- */
.ag--masonry .ag__list { columns: var(--ag-cols); column-gap: var(--ag-gap); }
.ag--masonry .ag__item { break-inside: avoid; margin-bottom: var(--ag-gap) !important; }
.ag--masonry .ag__link { aspect-ratio: var(--r); }

/* ---- Diaporama / Carrousel ---- */
.ag__viewport { position: relative; }
.ag--slider .ag__list, .ag--carousel .ag__list { display: grid; grid-auto-flow: column; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none; overscroll-behavior-x: contain; }
.ag--slider .ag__list::-webkit-scrollbar, .ag--carousel .ag__list::-webkit-scrollbar { display: none; }
.ag--slider .ag__list { grid-auto-columns: 100%; background: #000; border-radius: var(--ag-radius); }
.ag--slider .ag__item { scroll-snap-align: start; height: var(--ag-slider-h); }
.ag--slider .ag__link { height: 100%; background: #000; border-radius: 0; }
.ag--slider .ag__img { object-fit: contain; }
.ag--carousel .ag__list { gap: var(--ag-gap); grid-auto-columns: calc((100% - (var(--ag-cols) - 1) * var(--ag-gap)) / var(--ag-cols)); }
.ag--carousel .ag__item { scroll-snap-align: start; }
.ag__nav { position: absolute; top: 50%; z-index: 3; width: 44px; height: 44px; margin-top: -22px; border: 0; border-radius: 50%; cursor: pointer; background: rgba(255,255,255,.92) no-repeat center/18px; box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.ag__nav--prev { left: 10px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15 4l-8 8 8 8' fill='none' stroke='black' stroke-width='2.5'/%3E%3C/svg%3E"); }
.ag__nav--next { right: 10px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 4l8 8-8 8' fill='none' stroke='black' stroke-width='2.5'/%3E%3C/svg%3E"); }
.ag__nav[disabled] { opacity: 0; pointer-events: none; }
.ag__dots { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.ag__dots button { width: 9px; height: 9px; padding: 0; border: 0; border-radius: 50%; background: rgba(127,127,127,.45); cursor: pointer; }
.ag__dots button.is-active { background: currentColor; }

/* ---- Survol ---- */
.ag__overlay { position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 12px; color: var(--ag-overlay-text); pointer-events: none; opacity: 0; transition: opacity .35s ease; }
.ag__overlay-text { font-size: 13px; letter-spacing: .02em; line-height: 1.25; text-shadow: 0 1px 3px rgba(0,0,0,.4); transition: transform .35s ease; }
.ag--hover-lily .ag__overlay { background: linear-gradient(transparent 40%, var(--ag-overlay)); }
.ag--hover-lily .ag__overlay-text { transform: translateY(14px); }
.ag--hover-lily .ag__img, .ag--hover-zoom .ag__img { transition: transform .5s ease, filter .5s ease; }
.ag--hover-lily .ag__link:hover .ag__img { transform: scale(1.06) translateX(-2%); }
.ag--hover-zoom .ag__link:hover .ag__img { transform: scale(1.07); }
.ag--hover-zoom .ag__overlay { background: var(--ag-overlay); }
.ag--hover-fade .ag__overlay { background: var(--ag-overlay); align-items: center; justify-content: center; }
.ag__link:hover .ag__overlay, .ag__link:focus-visible .ag__overlay { opacity: 1; }
.ag__link:hover .ag__overlay-text { transform: none; }
.ag--hover-none .ag__overlay { display: none; }
@media (hover: none) { .ag__overlay { display: none; } }

/* ---- Filtres & pagination ---- */
.ag__filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.ag .ag__filter { padding: .4em .9em; border: 1px solid rgba(127,127,127,.35); border-radius: 999px; background: transparent; color: inherit; font: inherit; font-size: 13px; cursor: pointer; }
.ag .ag__filter.is-active { background: #1e1e1e; border-color: #1e1e1e; color: #fff; }
.ag__more-wrap { text-align: center; margin-top: 16px; }
.ag .ag__more { padding: .65em 1.4em; border: 0; border-radius: 999px; background: rgba(127,127,127,.16); color: inherit; font: inherit; font-weight: 600; cursor: pointer; }
.ag-empty, .ag-locked { padding: 16px; border: 1px dashed rgba(127,127,127,.5); text-align: center; opacity: .75; }

/* ---- Visionneuse ---- */
.ag-lb { position: fixed; inset: 0; z-index: 100000; display: flex; flex-direction: column; background: var(--lb-bg, #000); color: #fff; }
.ag-lb[hidden], .ag-lb [hidden], .ag [hidden] { display: none !important; }
.ag-lb__bar { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 6px; padding: 10px 12px 10px 18px; background: linear-gradient(rgba(0,0,0,.65), transparent); font: 600 15px/1.2 system-ui, -apple-system, sans-serif; }
.ag-lb__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-lb__count { opacity: .8; font-weight: 500; margin-right: 8px; }
.ag-lb__btn { width: 42px; height: 42px; border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.ag-lb__btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.ag-lb__btn:hover, .ag-lb__btn:focus-visible, .ag-lb__btn.is-on { background: rgba(255,255,255,.16); outline: none; color: #fff; }
.ag-lb__stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 60px 64px 20px; overflow: hidden; touch-action: pan-y; }
.ag-lb__img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; user-select: none; -webkit-user-drag: none; transition: transform .25s ease; cursor: zoom-in; }
.ag-lb.is-zoomed .ag-lb__img { transform: scale(2); cursor: zoom-out; }
.ag-lb__nav { position: absolute; top: 50%; z-index: 3; transform: translateY(-50%); width: 54px; height: 54px; }
.ag-lb__nav svg { width: 30px; height: 30px; }
.ag-lb__prev { left: 6px; } .ag-lb__next { right: 6px; }
@media (max-width: 600px) { .ag-lb__stage { padding: 58px 0 12px; } .ag-lb__nav { background: rgba(0,0,0,.35); } }
html.ag-lb-open, html.ag-lb-open body { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .ag__img, .ag__overlay, .ag__overlay-text, .ag-lb__img, .ag--polaroid .ag__item { transition: none !important; }
  .ag--slider .ag__list, .ag--carousel .ag__list { scroll-behavior: auto; }
}
