/* ============================================================= *
 * Agam - Galerie Photos
 * Carousel + miniatures synchronisées + mosaïque + lightbox
 * Charte : noir / blanc / gris (cohérent avec agam-filter-chips)
 * ============================================================= */

.agam-gallery {
    --agam-gallery-accent: #000;
    --agam-gallery-gap: 8px;
    margin: 1.8rem 0;
    position: relative;
}

/* ---------- Barre d'outils (bascule de vue) ---------- */
.agam-gallery-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.agam-gallery-view-controls {
    display: inline-flex;
    border: 1px solid #ccc;
}

.agam-gallery-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 15px;
    background: #fff;
    border: none;
    border-right: 1px solid #ccc;
    color: #888;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background .2s, color .2s;
    line-height: 1.2;
}
.agam-gallery-view-btn:last-child { border-right: none; }
.agam-gallery-view-btn:hover { color: #000; }
.agam-gallery-view-btn.is-active {
    background: var(--agam-gallery-accent);
    color: #fff;
}
.agam-gallery-view-btn svg { flex-shrink: 0; }

.agam-gallery-count {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999;
}

/* ============================================================= *
 *  VUE CAROUSEL
 * ============================================================= */
.agam-gallery-stage {
    position: relative;
    background: #f4f4f4;
}

.agam-gallery-main-slider { margin: 0; }

.agam-gallery-slide { outline: none; }

.agam-gallery-slide-media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f4f4;
    overflow: hidden;
    /* Hauteur fixe : toutes les diapos occupent la même hauteur,
       quelle que soit l'orientation de la photo (réglable via WPBakery). */
    height: var(--agam-gallery-h, 520px);
}

/* Fond flou (mode "Contenue + fond flou") : remplit les bandes
   avec une version agrandie et floutée de la même photo. */
.agam-gallery-slide-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center;
    filter: blur(24px) brightness(.62);
    transform: scale(1.18);
}
.agam-gallery-fit-blur .agam-gallery-slide-media img {
    position: relative;
    z-index: 1;
}

.agam-gallery-slide-media img {
    display: block;
    /* Remplit tout le cadre en gardant les proportions (et agrandit les
       petites images au lieu de les laisser flotter à leur taille native). */
    width: 100%;
    height: 100%;
    margin: 0 auto;
    object-fit: contain;
}

/* Mode plein cadre : la photo remplit la zone et est recadrée */
.agam-gallery-fit-cover .agam-gallery-slide-media img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
}

/* ---------- LÉGENDE : styles sélectionnables ---------- */
.agam-gallery-caption { margin: 0; }

/* 1) EN DESSOUS — gros titre noir sous la photo */
.agam-gallery-cap-below .agam-gallery-caption {
    margin: 16px auto 4px;
    max-width: 760px;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    color: #000;
    text-align: center;
    letter-spacing: 0.01em;
}

/* Base commune aux styles superposés (légende DANS .agam-gallery-slide-media) */
.agam-gallery-cap-overlay .agam-gallery-caption,
.agam-gallery-cap-hover  .agam-gallery-caption,
.agam-gallery-cap-hero   .agam-gallery-caption {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 4;
    color: #fff;
    text-align: center;
}

/* 2) BANDEAU DÉGRADÉ EN BAS — toujours visible */
.agam-gallery-cap-overlay .agam-gallery-caption,
.agam-gallery-cap-hover  .agam-gallery-caption {
    bottom: 0;
    padding: 46px 26px 18px;
    background: linear-gradient(to top, rgba(0,0,0,.82), rgba(0,0,0,0));
    font-size: 19px;
    font-weight: 700;
    line-height: 1.35;
    text-shadow: 0 1px 6px rgba(0,0,0,.4);
}

/* 3) AU SURVOL — masquée puis révélée */
.agam-gallery-cap-hover .agam-gallery-caption {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .3s ease, transform .3s ease;
}
.agam-gallery-cap-hover .agam-gallery-slide-media:hover .agam-gallery-caption {
    opacity: 1;
    transform: translateY(0);
}

/* 4) CENTRÉE PLEIN CADRE — voile sombre + titre centré */
.agam-gallery-cap-hero .agam-gallery-caption {
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: rgba(0,0,0,.45);
    font-size: 26px;
    font-weight: 800;
    line-height: 1.3;
    text-shadow: 0 2px 14px rgba(0,0,0,.55);
}

/* 5) CARTE VERRE DÉPOLI — petite carte floutée translucide, bas-gauche */
.agam-gallery-cap-glass .agam-gallery-caption {
    position: absolute;
    left: 22px;
    bottom: 22px;
    z-index: 4;
    max-width: calc(100% - 44px);
    margin: 0;
    padding: 12px 18px;
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.35;
    text-align: left;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .28);
    box-shadow: 0 6px 26px rgba(0, 0, 0, .32);
    background: rgba(0, 0, 0, .45); /* fallback si backdrop-filter non supporté */
    text-shadow: 0 1px 4px rgba(0, 0, 0, .4);
}
@supports ((backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px))) {
    .agam-gallery-cap-glass .agam-gallery-caption {
        background: rgba(255, 255, 255, .14);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }
}

/* 6) ÉTIQUETTE ÉDITORIALE — barre d'accent + label + titre, bas-gauche */
.agam-gallery-cap-editorial .agam-gallery-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    margin: 0;
    padding: 48px 28px 22px;
    text-align: left;
    background: linear-gradient(to top, rgba(0,0,0,.8), rgba(0,0,0,0));
}
.agam-gallery-cap-editorial .agam-gallery-caption-label,
.agam-gallery-cap-editorial .agam-gallery-caption-title {
    display: block;
    padding-left: 14px;
    border-left: 3px solid #fff;
    color: #fff;
}
.agam-gallery-cap-editorial .agam-gallery-caption-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .16em;
    opacity: .9;
    padding-bottom: 5px;
}
.agam-gallery-cap-editorial .agam-gallery-caption-title {
    font-size: 21px;
    font-weight: 800;
    line-height: 1.25;
    padding-top: 5px;
    text-shadow: 0 1px 6px rgba(0,0,0,.4);
}

/* Toute l'image est cliquable pour agrandir (si lightbox activé) */
.has-lightbox .agam-gallery-slide-media { cursor: zoom-in; }

/* Loupe au survol de l'image */
.agam-gallery-zoom-hint {
    position: absolute;
    z-index: 6;
    top: 12px;
    right: 12px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: zoom-in;
    opacity: 0;
    transform: scale(.85);
    transition: opacity .2s, transform .2s, background .2s;
}
.agam-gallery-slide-media:hover .agam-gallery-zoom-hint {
    opacity: 1;
    transform: scale(1);
}
.agam-gallery-zoom-hint:hover { background: #000; }

/* Flèches du carousel */
.agam-gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 44px;
    height: 44px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .9);
    color: #000;
    border: none;
    cursor: pointer;
    transition: background .2s, color .2s;
    padding: 0;
}
.agam-gallery-arrow:hover { background: #000; color: #fff; }
.agam-gallery-arrow-prev { left: 0; }
.agam-gallery-arrow-next { right: 0; }
.agam-gallery-arrow.slick-disabled { opacity: .35; cursor: default; }

/* Points (si pas de miniatures) */
.agam-gallery-main-slider .slick-dots { margin-top: 12px; position: static; }
.agam-gallery-main-slider .slick-dots li button:before { font-size: 9px; color: #bbb; opacity: 1; }
.agam-gallery-main-slider .slick-dots li.slick-active button:before { color: #000; }

/* ---------- Bande de miniatures synchronisées ---------- */
.agam-gallery-thumb-nav {
    margin-top: 10px;
}
.agam-gallery-thumb-nav .slick-slide { margin: 0 4px; }
.agam-gallery-thumb-nav-item {
    cursor: pointer;
    height: 70px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color .2s, opacity .2s;
    opacity: .55;
}
.agam-gallery-thumb-nav-item img {
    display: block;
    height: 70px;
    width: auto;
    object-fit: cover;
}
.agam-gallery-thumb-nav .slick-current .agam-gallery-thumb-nav-item,
.agam-gallery-thumb-nav-item:hover {
    opacity: 1;
    border-color: #000;
}

/* ============================================================= *
 *  VUE MOSAÏQUE (masonry via colonnes CSS)
 * ============================================================= */
.agam-gallery-mosaic-view {
    column-count: 3;
    column-gap: var(--agam-gallery-gap);
}
.agam-gallery[data-columns="2"] .agam-gallery-mosaic-view { column-count: 2; }
.agam-gallery[data-columns="4"] .agam-gallery-mosaic-view { column-count: 4; }
.agam-gallery[data-columns="5"] .agam-gallery-mosaic-view { column-count: 5; }
.agam-gallery[data-columns="6"] .agam-gallery-mosaic-view { column-count: 6; }

.agam-gallery-mosaic-item {
    position: relative;
    display: block;
    width: 100%;
    margin: 0 0 var(--agam-gallery-gap);
    padding: 0;
    border: none;
    background: #f4f4f4;
    cursor: zoom-in;
    overflow: hidden;
    break-inside: avoid;
}
.agam-gallery-mosaic-item img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform .4s ease, filter .3s ease;
}
.agam-gallery-mosaic-item:hover img {
    transform: scale(1.04);
    filter: brightness(.85);
}
.agam-gallery-mosaic-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 18px 12px 10px;
    background: linear-gradient(to top, rgba(0,0,0,.8), rgba(0,0,0,0));
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .25s, transform .25s;
    pointer-events: none;
}
.agam-gallery-mosaic-item:hover .agam-gallery-mosaic-caption,
.agam-gallery-mosaic-item:focus .agam-gallery-mosaic-caption {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================= *
 *  LIGHTBOX
 * ============================================================= */
body.agam-gallery-lb-open { overflow: hidden; }

.agam-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: agam-gallery-lb-in .25s ease;
}
@keyframes agam-gallery-lb-in { from { opacity: 0; } to { opacity: 1; } }

.agam-gallery-lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 8, 8, .94);
    cursor: zoom-out;
}

/* Barre du haut */
.agam-gallery-lb-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}
.agam-gallery-lb-counter {
    color: #fff;
    font-size: 13px;
    letter-spacing: .08em;
    font-variant-numeric: tabular-nums;
}
.agam-gallery-lb-tools { display: flex; gap: 10px; }

.agam-gallery-lb-close,
.agam-gallery-lb-fs,
.agam-gallery-lb-prev,
.agam-gallery-lb-next {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Fond sombre translucide + icône blanche + ombre : contraste garanti
       sur n'importe quelle photo (claire comme sombre). */
    background: rgba(0, 0, 0, .55);
    border: 1px solid rgba(255, 255, 255, .55);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .45);
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    transition: background .2s, border-color .2s, transform .15s;
    padding: 0;
}
/* Icônes forcées en blanc (le lightbox est dans le <body>, hors du wrapper :
   on ne dépend pas de l'héritage de couleur du thème). */
.agam-gallery-lb-close svg,
.agam-gallery-lb-fs svg,
.agam-gallery-lb-prev svg,
.agam-gallery-lb-next svg {
    stroke: #fff !important;
    color: #fff !important;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .8));
}
.agam-gallery-lb-close, .agam-gallery-lb-fs { width: 44px; height: 44px; }
.agam-gallery-lb-close:hover, .agam-gallery-lb-fs:hover,
.agam-gallery-lb-prev:hover, .agam-gallery-lb-next:hover {
    background: rgba(0, 0, 0, .82);
    border-color: #fff;
    transform: scale(1.06);
}
.agam-gallery-lb-prev:hover, .agam-gallery-lb-next:hover {
    transform: translateY(-50%) scale(1.06);
}

/* Flèches */
.agam-gallery-lb-prev, .agam-gallery-lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 54px;
    height: 54px;
}
.agam-gallery-lb-prev { left: 24px; }
.agam-gallery-lb-next { right: 24px; }

/* Scène (image) */
.agam-gallery-lb-stage {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 88vw;
    height: 76vh;
    margin-top: 10px;
}
.agam-gallery-lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 10px 50px rgba(0, 0, 0, .5);
    transition: opacity .3s ease, transform .25s ease;
    cursor: zoom-in;
    user-select: none;
}
.agam-gallery-lb-img.is-zoomed {
    transform: scale(2.4);
    cursor: zoom-out;
}

/* Spinner */
.agam-gallery-lb-spinner {
    position: absolute;
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: agam-gallery-spin .8s linear infinite;
}
@keyframes agam-gallery-spin { to { transform: rotate(360deg); } }

/* Légende */
.agam-gallery-lb-caption {
    position: relative;
    z-index: 2;
    color: #f0f0f0;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    max-width: 70vw;
    margin: 14px auto 0;
    line-height: 1.4;
}

/* Bande de miniatures du lightbox */
.agam-gallery-lb-thumbs {
    position: relative;
    z-index: 2;
    display: flex;
    gap: 6px;
    max-width: 90vw;
    overflow-x: auto;
    padding: 14px 4px 4px;
    margin-top: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.3) transparent;
}
.agam-gallery-lb-thumbs::-webkit-scrollbar { height: 6px; }
.agam-gallery-lb-thumbs::-webkit-scrollbar-thumb { background: rgba(255,255,255,.3); border-radius: 3px; }
.agam-gallery-lb-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 44px;
    padding: 0;
    border: 2px solid transparent;
    background: none;
    cursor: pointer;
    opacity: .5;
    transition: opacity .2s, border-color .2s;
}
.agam-gallery-lb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.agam-gallery-lb-thumb:hover { opacity: .85; }
.agam-gallery-lb-thumb.is-active {
    opacity: 1;
    border-color: #fff;
}

/* ============================================================= *
 *  RESPONSIVE
 * ============================================================= */
@media (max-width: 782px) {
    .agam-gallery-slide-media { height: 56vw; max-height: var(--agam-gallery-h, 520px); }
    .agam-gallery-caption { font-size: 17px; }
    .agam-gallery-mosaic-view { column-count: 2 !important; }
    .agam-gallery-lb-prev { left: 8px; }
    .agam-gallery-lb-next { right: 8px; }
    .agam-gallery-lb-prev, .agam-gallery-lb-next { width: 44px; height: 44px; }
    .agam-gallery-lb-stage { max-width: 96vw; height: 68vh; }
    .agam-gallery-lb-caption { max-width: 92vw; font-size: 14px; }
}

@media (max-width: 480px) {
    .agam-gallery-mosaic-view { column-count: 1 !important; }
    .agam-gallery-view-btn span { display: none; }
    .agam-gallery-view-btn { padding: 8px 12px; }
}
