/**
 * Galería: mosaico, filtros, hover en vídeo y lightbox.
 */

.gallery-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.55rem;
    margin-bottom: 1.75rem;
}

.gallery-filters__btn {
    appearance: none;
    border: 1px solid var(--gk-border-strong);
    background: transparent;
    color: rgba(255, 255, 255, 0.82);
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    cursor: pointer;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.gallery-filters__btn:hover,
.gallery-filters__btn:focus-visible {
    color: #ffffff;
    border-color: #ffffff;
    outline: none;
}

.gallery-filters__btn.is-active {
    background: #ffffff;
    border-color: #ffffff;
    color: #000000;
}

.gallery-masonry {
    column-count: 1;
    column-gap: 1rem;
}

@media (min-width: 576px) {
    .gallery-masonry {
        column-count: 2;
    }
}

@media (min-width: 992px) {
    .gallery-masonry {
        column-count: 3;
        column-gap: 1.15rem;
    }
}

.gallery-tile {
    break-inside: avoid;
    margin: 0 0 1rem;
    position: relative;
}

.gallery-tile.is-filtered-out {
    display: none;
}

.gallery-tile__trigger {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0.85rem;
    overflow: hidden;
    background: #1a1a1a;
    cursor: pointer;
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.45),
        inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    transition:
        border-color 0.25s ease,
        box-shadow 0.25s ease;
}

.gallery-tile__trigger:hover,
.gallery-tile__trigger:focus-visible {
    border-color: rgba(255, 255, 255, 0.38);
    box-shadow:
        0 20px 48px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(69, 201, 138, 0.25);
    outline: none;
}

.gallery-tile__media {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.07), transparent 42%),
        #1c1c1c;
}

.gallery-tile__media--video {
    background:
        linear-gradient(160deg, rgba(69, 201, 138, 0.12), transparent 50%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 40%),
        #222222;
}

.gallery-tile--vertical .gallery-tile__media {
    aspect-ratio: 9 / 16;
    max-width: 100%;
}

.gallery-tile__media > img,
.gallery-tile__media > video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Si el primer fotograma es negro, el vídeo no “desaparece” del todo. */
.gallery-tile__media--video > video {
    mix-blend-mode: normal;
    opacity: 0.92;
    filter: contrast(1.05) brightness(1.08);
}

.gallery-tile__badge {
    position: absolute;
    left: 0.75rem;
    bottom: 0.75rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(0, 0, 0, 0.62);
    color: #ffffff;
    font-size: 0.78rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

.gallery-tile__trigger:hover .gallery-tile__badge,
.gallery-tile__trigger:focus-visible .gallery-tile__badge,
.gallery-tile__trigger.is-hover .gallery-tile__badge {
    opacity: 0;
}

.gallery-tile__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.gallery-tile__trigger:hover .gallery-tile__overlay,
.gallery-tile__trigger:focus-visible .gallery-tile__overlay,
.gallery-tile__trigger.is-hover .gallery-tile__overlay {
    opacity: 1;
}

.gallery-tile__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(0, 0, 0, 0.35);
    color: #ffffff;
    font-size: 0.95rem;
}

.gallery-tile__label {
    max-width: 16rem;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}

.gallery-instagram__link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: #ffffff;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    padding-bottom: 0.15rem;
    transition:
        color 0.2s ease,
        border-color 0.2s ease;
}

.gallery-instagram__link:hover,
.gallery-instagram__link:focus-visible {
    color: var(--gk-accent-sport);
    border-color: var(--gk-accent-sport);
    outline: none;
}

.gallery-instagram__link .fa-instagram {
    font-size: 1.15rem;
}

.gallery-lightbox[hidden] {
    display: none !important;
}

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.gallery-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
}

.gallery-lightbox__dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 68rem);
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
}

.gallery-lightbox__stage {
    width: 100%;
    max-height: calc(100vh - 7rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-lightbox__stage img,
.gallery-lightbox__stage video {
    max-width: 100%;
    max-height: calc(100vh - 7rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.5rem;
    background: #000000;
}

.gallery-lightbox__stage video {
    width: min(100%, 56rem);
}

.gallery-lightbox__caption {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.95rem;
    text-align: center;
    max-width: 40rem;
}

.gallery-lightbox__close,
.gallery-lightbox__nav {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(0, 0, 0, 0.45);
    color: #ffffff;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        background 0.2s ease,
        border-color 0.2s ease;
}

.gallery-lightbox__close:hover,
.gallery-lightbox__nav:hover,
.gallery-lightbox__close:focus-visible,
.gallery-lightbox__nav:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    border-color: #ffffff;
    outline: none;
}

.gallery-lightbox__close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
}

.gallery-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

.gallery-lightbox__nav--prev {
    left: 0.25rem;
}

.gallery-lightbox__nav--next {
    right: 0.25rem;
}

@media (max-width: 767.98px) {
    .gallery-lightbox__nav--prev {
        left: 0;
    }

    .gallery-lightbox__nav--next {
        right: 0;
    }

    .gallery-lightbox__dialog {
        padding-top: 3rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-tile__overlay,
    .gallery-filters__btn,
    .gallery-instagram__link {
        transition: none;
    }
}
