/* Shared gallery foundation and viewer. Variant geometry is declared below. */
.perigord-shared-gallery {
    box-sizing:border-box;
    width:100%;
    max-width:1120px;
    margin:0 auto 2.5rem;
}
.perigord-shared-gallery__mosaic {
    display:grid;
    width:100%;
    min-width:0;
    grid-template-columns:minmax(0,2fr) minmax(0,1fr);
    grid-auto-rows:auto;
    align-items:center;
    gap:.6rem;
    overflow:visible;
    border-radius:16px;
}
.perigord-shared-gallery__mosaic:has(> :where(.perigord-shared-gallery__tile:nth-child(1):last-child)) { grid-template-columns:minmax(0,1fr); }
.perigord-shared-gallery__mosaic:has(> :where(.perigord-shared-gallery__tile:nth-child(4):last-child)) { grid-template-columns:minmax(0,3fr) minmax(0,1fr); }
.perigord-shared-gallery__mosaic:has(> :where(.perigord-shared-gallery__tile:nth-child(5):last-child)) { grid-template-columns:minmax(0,4fr) minmax(0,1fr); }
.perigord-shared-gallery__tile {
    position:relative;
    display:flex;
    align-items:center;
    justify-content:center;
    min-width:0;
    min-height:0;
    padding:0;
    overflow:hidden;
    border:0;
    border-radius:9px;
    background:transparent;
    cursor:zoom-in;
}
/* Keep default/Rando placement out of the independent listing grid.
 * :where() adds no specificity to the original tile selectors. */
:where(.perigord-shared-gallery:not(.perigord-shared-gallery--listing)) .perigord-shared-gallery__tile.is-primary { grid-column:1; grid-row:1; }
:where(.perigord-shared-gallery:not(.perigord-shared-gallery--listing)) .perigord-shared-gallery__tile:not(.is-primary) { grid-column:2; }
:where(.perigord-shared-gallery:not(.perigord-shared-gallery--listing)) .perigord-shared-gallery__tile:only-child { grid-column:1 / -1; grid-row:1; }
:where(.perigord-shared-gallery:not(.perigord-shared-gallery--listing)) .perigord-shared-gallery__mosaic:has(> :where(.perigord-shared-gallery__tile:nth-child(3):last-child)) > .perigord-shared-gallery__tile.is-primary { grid-row:1 / span 2; }
:where(.perigord-shared-gallery:not(.perigord-shared-gallery--listing)) .perigord-shared-gallery__mosaic:has(> :where(.perigord-shared-gallery__tile:nth-child(4):last-child)) > .perigord-shared-gallery__tile.is-primary { grid-row:1 / span 3; }
:where(.perigord-shared-gallery:not(.perigord-shared-gallery--listing)) .perigord-shared-gallery__mosaic:has(> :where(.perigord-shared-gallery__tile:nth-child(5):last-child)) > .perigord-shared-gallery__tile.is-primary { grid-row:1 / span 4; }
.perigord-shared-gallery__tile-image { display:block; width:100%; height:auto; overflow:visible; }
.perigord-shared-gallery__tile-image > * { display:block; width:100%; height:auto; min-width:0; min-height:0; }
.perigord-shared-gallery__tile-image picture { display:block; width:100%; height:auto; }
.perigord-shared-gallery__tile-image .sirtaqui-photo-frame { display:block; position:relative; width:100%; height:auto; min-width:0; min-height:0; aspect-ratio:auto; overflow:visible; background:transparent; }
.perigord-shared-gallery__tile-image .sirtaqui-photo-frame[data-image-state="error"] { aspect-ratio:4 / 3; overflow:hidden; }
.perigord-shared-gallery__tile-image img,
.perigord-shared-gallery__tile-image .sirtaqui-photo-frame img { display:block; position:static; inset:auto; width:100%; height:auto; max-width:100%; max-height:none; object-fit:contain; }
.perigord-shared-gallery__tile-image .sirtaqui-photo-frame .sirtaqui-photo-fallback img { position:absolute; inset:0; width:100%; height:100%; object-fit:contain; }
.perigord-shared-gallery__more { position:absolute; inset:auto .65rem .65rem auto; padding:.55rem .75rem; color:#fff; background:rgba(24,36,29,.82); border-radius:6px; font-weight:700; }
.perigord-shared-gallery__lightbox[hidden] { display:none; }
.perigord-shared-gallery__lightbox { position:fixed; z-index:999999; inset:0; display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:1rem; padding:clamp(1rem,4vw,3rem); background:rgba(10,16,12,.94); }
.perigord-shared-gallery__stage { display:grid; place-items:center; min-width:0; }
.perigord-shared-gallery__item { display:none; max-width:min(82vw,1200px); margin:0; text-align:center; }
.perigord-shared-gallery__item.is-active { display:block; }
.perigord-shared-gallery__item img { display:block; max-width:min(82vw,1200px); max-height:82vh; width:auto; height:auto; margin:auto; object-fit:contain; }
.perigord-shared-gallery__rights,.perigord-shared-gallery__counter { max-width:min(82vw,1200px); margin:.45rem auto 0; color:rgba(255,255,255,.86); font-size:.78rem; line-height:1.4; text-align:center; }
.perigord-shared-gallery__source { display:inline-block; margin-top:.4rem; color:#fff; font-size:.8rem; text-decoration:underline; }
.perigord-shared-gallery__lightbox button { color:#fff; border:1px solid rgba(255,255,255,.55); background:rgba(255,255,255,.12); border-radius:50%; width:46px; height:46px; font-size:1.8rem; cursor:pointer; }
.perigord-shared-gallery__close { position:absolute; top:1rem; right:1rem; }
.perigord-shared-gallery :focus-visible { outline:3px solid #c28a38; outline-offset:3px; }
body.perigord-gallery-open { overflow:hidden; }

/* WPJM: historical four-column/two-row mosaic, main image spanning 50%. */
.perigord-shared-gallery--listing { max-width:1120px; }
.perigord-shared-gallery--listing .perigord-shared-gallery__mosaic { display:grid; width:100%; min-width:0; grid-template-columns:repeat(4,minmax(0,1fr)); grid-template-rows:repeat(2,minmax(145px,min(22vw,230px))); grid-auto-flow:row; align-items:stretch; gap:.6rem; overflow:hidden; border-radius:16px; }
.perigord-shared-gallery--listing .perigord-shared-gallery__tile { display:block; min-width:0; min-height:0; background:#e8ede9; border-radius:9px; }
.perigord-shared-gallery--listing .perigord-shared-gallery__tile.is-primary { grid-column:span 2; grid-row:span 2; }
.perigord-shared-gallery--listing .perigord-shared-gallery__tile:not(.is-primary) { grid-column:auto; grid-row:auto; }
.perigord-shared-gallery--listing .perigord-shared-gallery__tile:only-child { grid-column:1 / -1; grid-row:1 / -1; }
.perigord-shared-gallery--listing .perigord-shared-gallery__tile-image,
.perigord-shared-gallery--listing .perigord-shared-gallery__tile-image > *,
.perigord-shared-gallery--listing .perigord-shared-gallery__tile-image picture,
.perigord-shared-gallery--listing .perigord-shared-gallery__tile-image img { display:block; width:100%; height:100%; min-width:0; min-height:0; }
.perigord-shared-gallery--listing .perigord-shared-gallery__tile-image img { max-width:100%; max-height:none; object-fit:cover; transition:transform .25s ease; }
.perigord-shared-gallery--listing .perigord-shared-gallery__tile:hover img { transform:scale(1.025); }

/* Agenda: full-width main photo, then small thumbnails in a wrapping row.
 * The containing 60/40 hero columns remain owned by sirtaqui-agenda/style.css. */
.perigord-shared-gallery--agenda { max-width:none; margin:0; }
.perigord-shared-gallery--agenda .perigord-shared-gallery__mosaic { display:flex; flex-wrap:wrap; align-items:flex-start; }
.perigord-shared-gallery--agenda .perigord-shared-gallery__mosaic > .perigord-shared-gallery__tile { flex:0 0 calc((100% - 1.8rem) / 4); max-width:160px; }
.perigord-shared-gallery--agenda .perigord-shared-gallery__mosaic > .perigord-shared-gallery__tile.is-primary { flex-basis:100%; max-width:none; }

/* Rando: natural image proportions and count-based default grid above. */
.perigord-shared-gallery--rando { max-width:none; margin:0 0 1.5rem; }

/* Responsive: one block per threshold; all validated dimensions retained. */
@media(max-width:800px) {
    .perigord-shared-gallery__mosaic { grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:repeat(2,minmax(105px,28vw)); align-items:start; }
    :where(.perigord-shared-gallery:not(.perigord-shared-gallery--listing)) .perigord-shared-gallery__mosaic > .perigord-shared-gallery__tile.is-primary { grid-column:1 / -1; grid-row:auto; }
    :where(.perigord-shared-gallery:not(.perigord-shared-gallery--listing)) .perigord-shared-gallery__mosaic > .perigord-shared-gallery__tile:not(.is-primary) { grid-column:auto; grid-row:auto; }
    .perigord-shared-gallery--listing { width:calc(100% - 2rem); }
    .perigord-shared-gallery--listing .perigord-shared-gallery__mosaic { grid-template-rows:repeat(2,minmax(105px,28vw)); }
}
@media(max-width:480px) {
    .perigord-shared-gallery__mosaic { grid-template-rows:repeat(2,minmax(88px,28vw)); gap:.35rem; border-radius:10px; }
    .perigord-shared-gallery__tile { border-radius:6px; }
    .perigord-shared-gallery__lightbox { gap:.4rem; padding:.6rem; }
    .perigord-shared-gallery__item img { max-width:74vw; max-height:78vh; }
    .perigord-shared-gallery__lightbox button { width:38px; height:38px; }
    .perigord-shared-gallery--listing { width:calc(100% - 1.25rem); }
    .perigord-shared-gallery--listing .perigord-shared-gallery__mosaic { grid-template-rows:repeat(2,minmax(88px,28vw)); gap:.35rem; border-radius:10px; }
    .perigord-shared-gallery--listing .perigord-shared-gallery__tile { border-radius:6px; }
}
@media(prefers-reduced-motion:reduce) {
    .perigord-shared-gallery__tile img,
    .perigord-shared-gallery--listing .perigord-shared-gallery__tile img { transition:none; }
}
