/* =========================================================
   CET Nº1 — GALERÍA (galeria.html)
   Grilla de la página de galería, filtros y lightbox.
   Depende de: css/global.css
   ========================================================= */
/* =========================================================
   GALLERY PAGE (galeria.html) — masonry limpio, sin captions
   ========================================================= */
.gallery-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 56px;
}

.gallery-filter {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 4px;
    margin: 0 6px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.gallery-filter::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 4px;
    width: 0;
    height: 1.5px;
    background: var(--secondary-color);
    transition: width 0.3s ease, left 0.3s ease;
}

.gallery-filter:hover {
    color: var(--secondary-color);
}

.gallery-filter:hover::after,
.gallery-filter.is-active::after {
    width: calc(100% - 12px);
    left: 6px;
}

.gallery-filter.is-active {
    color: var(--secondary-color);
}

/* Masonry con CSS columns */
.gallery-page-grid {
    column-count: 3;
    column-gap: 16px;
}

.gallery-page-item {
    position: relative;
    margin: 0 0 16px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--bg-alt);
    break-inside: avoid;
    display: block;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: 0 1px 2px rgba(10, 37, 64, 0.06);
    transition: box-shadow 0.35s ease;
    /* Reserva de espacio para evitar CLS antes de que carguen las imágenes.
       Cada imagen declara width=800 height=533 (3:2). */
    aspect-ratio: 3 / 2;
}

.gallery-page-item:hover,
.gallery-page-item:focus-visible {
    box-shadow: 0 8px 24px rgba(10, 37, 64, 0.14);
    outline: none;
}

.gallery-page-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-page-item.is-hidden {
    display: none;
}

@media (max-width: 992px) {
    .gallery-page-grid {
        column-count: 2;
        column-gap: 14px;
    }
    .gallery-page-item {
        margin-bottom: 14px;
    }
}

@media (max-width: 600px) {
    .gallery-page-grid {
        column-count: 1;
    }
    .gallery-filters {
        gap: 4px;
        margin-bottom: 40px;
    }
    .gallery-filter {
        font-size: 0.72rem;
        padding: 6px 4px;
        margin: 0 4px;
    }
}

/* =========================================================
   LIGHTBOX
   ========================================================= */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(10, 37, 64, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.22s ease;
}

.lightbox.is-open {
    opacity: 1;
}

.lightbox[hidden] {
    display: none;
}

.lightbox-content {
    position: relative;
    margin: 0;
    max-width: min(1100px, 92vw);
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    transform: scale(0.96);
    transition: transform 0.22s ease;
}

.lightbox.is-open .lightbox-content {
    transform: scale(1);
}

.lightbox-content img {
    display: block;
    max-width: 100%;
    max-height: 76vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
    background: #000;
}

.lightbox-content figcaption {
    color: var(--text-light);
    font-size: 0.95rem;
    text-align: center;
    opacity: 0.92;
}

.lightbox-counter {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-light);
    font-size: 0.78rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.85;
    background: rgba(0, 0, 0, 0.35);
    padding: 6px 12px;
    border-radius: 999px;
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.22);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}

.lightbox-close svg,
.lightbox-nav svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.lightbox-close:hover,
.lightbox-close:focus-visible,
.lightbox-nav:hover,
.lightbox-nav:focus-visible {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
    outline: none;
}

.lightbox-close {
    top: 22px;
    right: 22px;
}

.lightbox-prev {
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
}
.lightbox-prev:hover,
.lightbox-prev:focus-visible {
    transform: translateY(-50%) scale(1.05);
}

.lightbox-next {
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
}
.lightbox-next:hover,
.lightbox-next:focus-visible {
    transform: translateY(-50%) scale(1.05);
}

@media (max-width: 600px) {
    .lightbox {
        padding: 14px;
    }
    .lightbox-close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
    }
    .lightbox-prev {
        left: 8px;
        width: 40px;
        height: 40px;
    }
    .lightbox-next {
        right: 8px;
        width: 40px;
        height: 40px;
    }
    .lightbox-counter {
        top: 12px;
        font-size: 0.7rem;
    }
    .lightbox-content figcaption {
        font-size: 0.85rem;
    }
}

/* =========================================================
   RESPONSIVE (galería)
   ========================================================= */
@media (max-width: 768px) {
    .gallery-grid { display: none; }
    .gallery-item { grid-column: auto !important; grid-row: auto !important; min-height: 180px !important; }
    .gallery-item:nth-child(6) { grid-column: 1 / 3 !important; min-height: 140px !important; }
}

@media (max-width: 480px) {
    .gallery-grid { display: none; }
    .gallery-item { min-height: 220px !important; }
    .gallery-item:nth-child(6) { grid-column: 1 !important; }
}
