/* =========================
   GALERÍA
========================= */

.gallery-section {
    overflow: hidden;
}

.gallery-section .section-container {
    width: min(1350px, 100%);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: 90px;
    gap: 14px;

    margin-top: 25px;
}

.gallery-item {
    position: relative;

    overflow: hidden;

    background-color: var(--color-accent-light);
}

.gallery-item img {
    width: 100%;
    height: 100%;

    object-fit: cover;

    transition:
        transform 0.6s ease,
        filter 0.6s ease;
}

.gallery-item::after {
    position: absolute;
    inset: 0;

    background:
        linear-gradient(
            to top,
            rgba(20, 20, 19, 0.24),
            transparent 55%
        );

    content: "";

    opacity: 0;

    pointer-events: none;

    transition: opacity 0.45s ease;
}

.gallery-item:hover img {
    transform: scale(1.04);
    filter: brightness(0.9);
}

.gallery-item:hover::after {
    opacity: 1;
}


/* =========================
   DISTRIBUCIÓN EDITORIAL
========================= */

.gallery-item-large {
    grid-column: 1 / span 7;
    grid-row: 1 / span 6;
}

.gallery-item-top {
    grid-column: 8 / span 5;
    grid-row: 1 / span 3;
}

.gallery-item-bottom {
    grid-column: 8 / span 5;
    grid-row: 4 / span 3;
}

.gallery-item-wide-left {
    grid-column: 1 / span 5;
    grid-row: 7 / span 4;
}

.gallery-item-wide-right {
    grid-column: 6 / span 7;
    grid-row: 7 / span 4;
}

.gallery-item-small-left {
    grid-column: 1 / span 6;
    grid-row: 11 / span 4;
}

.gallery-item-small-right {
    grid-column: 7 / span 6;
    grid-row: 11 / span 4;
}


/* =========================
   TABLET
========================= */

@media (max-width: 900px) {

    .gallery-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: auto;

        gap: 12px;
    }

    .gallery-item,
    .gallery-item-large,
    .gallery-item-top,
    .gallery-item-bottom,
    .gallery-item-wide-left,
    .gallery-item-wide-right,
    .gallery-item-small-left,
    .gallery-item-small-right {
        grid-column: auto !important;
        grid-row: auto !important;

        width: 100%;
        min-width: 0;

        aspect-ratio: 4 / 5;
    }

    .gallery-item img {
        width: 100%;
        height: 100%;

        object-fit: cover;
    }

    .gallery-item-large,
    .gallery-item-wide-right,
    .gallery-item-small-right {
        grid-column: span 2 !important;

        aspect-ratio: 16 / 9;
    }
}


/* =========================
   CELULARES
========================= */

/* =========================
   CELULAR - UNA COLUMNA
========================= */

@media (max-width: 600px) {

    .gallery-grid {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .gallery-item {
        width: 100%;
    }

    /* Fotos principales */
    .gallery-item-large,
    .gallery-item-top,
    .gallery-item-small-right {
        aspect-ratio: 3 / 4;
    }

    /* Fotos de detalle */
    .gallery-item-bottom,
    .gallery-item-wide-left,
    .gallery-item-wide-right,
    .gallery-item-small-left {
        aspect-ratio: 16 / 10;
    }

    .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Ajustes finos de encuadre */
    .gallery-item-large img {
        object-position: center 18%;
    }

    .gallery-item-top img {
        object-position: center 25%;
    }

    .gallery-item-bottom img {
        object-position: center 40%;
    }

    .gallery-item-wide-left img {
        object-position: center;
    }

    .gallery-item-wide-right img {
        object-position: center 55%;
    }

    .gallery-item-small-left img {
        object-position: center;
    }

    .gallery-item-small-right img {
        object-position: center 18%;
    }
}

/* =========================
   DISPOSITIVOS SIN HOVER
========================= */

@media (hover: none) {
    .gallery-item:hover img {
        transform: none;
        filter: none;
    }

    .gallery-item:hover::after {
        opacity: 0;
    }
}

/* =========================
   ENCUADRES PERSONALIZADOS
========================= */

/* Foto 5: mostrar la mitad inferior */
.gallery-item-wide-right img {
    object-position: center 80%;
}

/* Foto 7: mostrar la mitad superior */
.gallery-item-small-right img {
    object-position: center 10%;
}

/* =========================
   AJUSTE PARA BOTONES
========================= */

button.gallery-item {
    padding: 0;

    border: 0;

    font: inherit;

    cursor: pointer;
}


/* =========================
   LIGHTBOX
========================= */

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 3000;

    display: flex;
    justify-content: center;
    align-items: center;

    padding: 32px;

    background-color: rgba(16, 16, 15, 0.94);
    backdrop-filter: blur(8px);

    opacity: 0;
    visibility: hidden;

    transition:
        opacity 0.3s ease,
        visibility 0.3s ease;
}

.gallery-lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

.gallery-lightbox-content {
    position: relative;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    width: min(1200px, 100%);
    height: min(88vh, 900px);
}

.gallery-lightbox-image {
    max-width: 100%;
    max-height: calc(100% - 54px);

    object-fit: contain;

    opacity: 0;
    transform: scale(0.97);

    transition:
        opacity 0.3s ease,
        transform 0.3s ease;
}

.gallery-lightbox.is-open .gallery-lightbox-image {
    opacity: 1;
    transform: scale(1);
}

.gallery-lightbox-close,
.gallery-lightbox-nav {
    position: absolute;
    z-index: 2;

    display: flex;
    justify-content: center;
    align-items: center;

    width: 46px;
    height: 46px;

    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 50%;

    color: var(--color-white);
    background-color: rgba(0, 0, 0, 0.28);

    font-family: inherit;
    font-size: 1.5rem;

    cursor: pointer;

    transition:
        background-color 0.25s ease,
        border-color 0.25s ease,
        transform 0.25s ease;
}

.gallery-lightbox-close:hover,
.gallery-lightbox-nav:hover {
    border-color: rgba(255, 255, 255, 0.85);
    background-color: rgba(255, 255, 255, 0.12);
}

.gallery-lightbox-close {
    top: 0;
    right: 0;
}

.gallery-lightbox-close:hover {
    transform: rotate(90deg);
}

.gallery-lightbox-prev {
    top: 50%;
    left: 0;

    transform: translateY(-50%);
}

.gallery-lightbox-next {
    top: 50%;
    right: 0;

    transform: translateY(-50%);
}

.gallery-lightbox-prev:hover,
.gallery-lightbox-next:hover {
    transform: translateY(-50%) scale(1.06);
}

.gallery-lightbox-counter {
    margin-top: 18px;

    color: rgba(255, 255, 255, 0.76);

    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.14rem;
}

body.gallery-open {
    overflow: hidden;
}


/* =========================
   LIGHTBOX EN CELULAR
========================= */

@media (max-width: 600px) {
    .gallery-lightbox {
        padding: 16px;
    }

    .gallery-lightbox-content {
        width: 100%;
        height: 90vh;
    }

    .gallery-lightbox-close,
    .gallery-lightbox-nav {
        width: 42px;
        height: 42px;
    }

    .gallery-lightbox-close {
        top: 4px;
        right: 4px;
    }

    .gallery-lightbox-prev {
        left: 4px;
    }

    .gallery-lightbox-next {
        right: 4px;
    }
}
