/**
 * Galerie - carrousel en perspective.
 *
 * Charge uniquement sur les pages qui utilisent page-templates/tpl-galerie.php
 * (voir inc/enqueue.php). Les couleurs reprennent les variables de main.css
 * pour rester alignees sur le Customizer.
 */

.gallery-page {
    --gallery-spacing: 230px;
    --gallery-card-width: 340px;
    --gallery-card-height: 400px;
    --gallery-stage-height: 420px;
}

/* ------------------------------------------------------------------
 * Chapeau
 * ------------------------------------------------------------------ */

.gallery__intro {
    max-width: 720px;
    margin: 0 auto 2.5rem;
    text-align: center;
}

.gallery__intro > *:last-child {
    margin-bottom: 0;
}

.gallery__intro .sub-heading {
    justify-content: center;
}

/* ------------------------------------------------------------------
 * Filtres
 * ------------------------------------------------------------------ */

.gallery__filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.625rem;
    margin: 0 auto 3rem;
    padding: 0;
    list-style: none;
}

.gallery__filter {
    border: 1.5px solid var(--accent-color-3);
    background: var(--secondary);
    color: var(--primary);
    padding: 0.625rem 1.25rem;
    border-radius: 999px;
    font-family: var(--font-family-paragraph);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.gallery__filter:hover,
.gallery__filter:focus-visible {
    border-color: var(--primary);
}

.gallery__filter[aria-pressed="true"] {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--secondary);
}

/* ------------------------------------------------------------------
 * Scene
 * ------------------------------------------------------------------ */

.gallery__stage {
    position: relative;
    max-width: 1080px;
    height: var(--gallery-stage-height);
    margin: 0 auto;
    perspective: 1400px;
}

.gallery__stage:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 8px;
    border-radius: 20px;
}

.gallery__track {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.gallery__card {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--gallery-card-width);
    height: var(--gallery-card-height);
    margin: 0;
    border-radius: 20px;
    overflow: hidden;
    background: var(--accent-color-3);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.25);
    /* Etat initial : le JS prend le relais des le premier layout(). */
    transform: translate(-50%, -50%);
    transition: transform 0.5s cubic-bezier(0.22, 0.68, 0, 1.01),
                opacity 0.5s ease,
                filter 0.5s ease;
}

.gallery__card-link {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.gallery__card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Badge affiche sur les blocs qui pointent vers un lien externe. */
.gallery__badge {
    position: absolute;
    right: 0.875rem;
    bottom: 0.875rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    backdrop-filter: blur(2px);
}

/* Legende : reservee a la carte centrale, pour ne pas surcharger. */
.gallery__caption {
    position: absolute;
    inset: auto 0 0 0;
    padding: 2.5rem 1.25rem 1rem;
    background: linear-gradient(to top, var(--accent-overlay), transparent);
    color: #fff;
    font-family: var(--font-family-paragraph);
    font-size: 0.875rem;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.gallery__card.is-current .gallery__caption {
    opacity: 1;
}

/* ------------------------------------------------------------------
 * Navigation
 * ------------------------------------------------------------------ */

.gallery__nav {
    display: flex;
    justify-content: center;
    gap: 0.875rem;
    margin-top: 2.25rem;
}

.gallery__nav-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1.5px solid var(--primary);
    background: var(--secondary);
    color: var(--primary);
    font-size: 1.125rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.gallery__nav-btn:hover,
.gallery__nav-btn:focus-visible {
    background: var(--primary);
    color: var(--secondary);
}

.gallery__empty {
    text-align: center;
    color: var(--text-color);
}

/* ------------------------------------------------------------------
 * Responsive
 * ------------------------------------------------------------------ */

@media (max-width: 991px) {
    .gallery-page {
        --gallery-spacing: 180px;
        --gallery-card-width: 280px;
        --gallery-card-height: 340px;
        --gallery-stage-height: 360px;
    }
}

@media (max-width: 640px) {
    .gallery-page {
        --gallery-spacing: 130px;
        --gallery-card-width: 220px;
        --gallery-card-height: 300px;
        --gallery-stage-height: 320px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery__card,
    .gallery__caption {
        transition: none;
    }
}
