/* ==========================================================================
   MÓDULO DE GALERÍA DE INSPIRACIÓN "ESPACIOS REALES" - TUESTANTE
   Estilos inspirados en diseño moderno de interiores con cuadrícula asimétrica
   divivida en 4 columnas iguales, patrón de bloques y visor modal (Lightbox).
   ========================================================================== */

/* Variables locales específicas del módulo de Galería */
:root {
    --gallery-accent: #005187;
    --gallery-accent-hover: #003351;
    --gallery-card-shadow: 0 10px 25px -5px rgba(0, 51, 102, 0.1), 0 8px 10px -6px rgba(0, 51, 102, 0.05);
}

/* ==========================================================================
   1. ENCABEZADO DE LA GALERÍA (HEADER SECTION)
   ========================================================================== */
.gallery-header-section {
    background-color: var(--bg-primary);
    padding: 60px 24px 40px 24px;
    text-align: center;
    border-bottom: 1px solid rgba(203, 213, 225, 0.4);
}

.gallery-header-container {
    max-width: 900px;
    margin: 0 auto;
}

.gallery-tagline {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--primary);
    letter-spacing: 2.5px;
    display: block;
    margin-bottom: 12px;
}

.gallery-main-title {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: 0.5px;
    line-height: 1.25;
    text-transform: uppercase;
}

.gallery-header-divider {
    width: 70px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    margin: 20px auto 24px auto;
    border-radius: 2px;
}

.gallery-header-description {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 16px;
}

.gallery-header-subtext {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.gallery-social-link {
    color: var(--gallery-accent);
    font-weight: 600;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.gallery-social-link:hover {
    color: var(--primary);
}

/* ==========================================================================
   2. BARRA DE FILTROS (FILTER BAR)
   ========================================================================== */
.gallery-section {
    padding: 40px 24px 80px 24px;
    background-color: var(--bg-secondary);
    min-height: 600px;
}

.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
}

.gallery-filter-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 36px;
}

.gallery-filter-btn {
    background-color: var(--bg-primary);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.gallery-filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.gallery-filter-btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 81, 135, 0.25);
}

/* ==========================================================================
   3. CUADRÍCULA DE 4 COLUMNAS IGUALES Y PATRÓN DE LA GALERÍA
   Dividir el ancho de la pantalla entre 4 espacios iguales (repeat(4, 1fr))
   ========================================================================== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 270px;
    gap: 16px;
    margin-bottom: 50px;
}

/* Estilos de las tarjetas de imagen individuales */
.gallery-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-color: #e2e8f0;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--gallery-card-shadow);
}

/* 1. Tarjeta pequeña (Ocupa 1 espacio: 1 columna x 1 fila) */
.gallery-card.small-item {
    grid-column: span 1;
    grid-row: span 1;
}

/* 2. Tarjeta grande (Ocupa el tamaño de 4 pequeñas: 2 columnas de ancho x 2 filas de alto) */
.gallery-card.large-item {
    grid-column: span 2;
    grid-row: span 2;
}

/* Imagen o Video dentro de la tarjeta */
.gallery-card-img,
.gallery-card-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-card:hover .gallery-card-img,
.gallery-card:hover .gallery-card-video {
    transform: scale(1.06);
}

/* Insignia / Badge de Video */
.gallery-card-video-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 5;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    padding: 4px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Capa Oscura / Overlay al pasar el cursor */
.gallery-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0) 40%, rgba(15, 23, 42, 0.8) 100%);
    opacity: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
    transition: opacity 0.3s ease;
}

.gallery-card:hover .gallery-card-overlay {
    opacity: 1;
}

.gallery-card-title {
    color: white;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
    transform: translateY(10px);
    transition: transform 0.3s ease;
}

.gallery-card-author {
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 500;
    transform: translateY(10px);
    transition: transform 0.3s ease 0.05s;
}

.gallery-card:hover .gallery-card-title,
.gallery-card:hover .gallery-card-author {
    transform: translateY(0);
}

/* Icono de zoom en hover */
.gallery-card-zoom-icon {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s ease;
}

.gallery-card:hover .gallery-card-zoom-icon {
    transform: scale(1);
    opacity: 1;
}

/* ==========================================================================
   4. TARJETA DE AÑADIR NUEVA IMAGEN (CTA "COMPARTE TU ESTILO")
   Cuenta como el espacio de una imagen pequeña y es la primera en las pequeñas.
   ========================================================================== */
.gallery-cta-card {
    background-color: var(--gallery-accent);
    color: white;
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    grid-column: span 1;
    grid-row: span 1;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.gallery-cta-card:hover {
    background-color: var(--gallery-accent-hover);
    transform: translateY(-4px);

}

.gallery-cta-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.35;
    margin-bottom: 14px;
    color: white;
}

.gallery-cta-btn {
    background-color: white;
    color: var(--gallery-accent);
    font-family: var(--font-sans);
    font-weight: 800;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
}

.gallery-cta-btn:hover {
    background-color: var(--text-main);
    color: white;
    transform: scale(1.03);
}

/* ==========================================================================
   5. BOTÓN DE CARGA PROGRESIVA ("MOSTRAR MÁS")
   ========================================================================== */
.gallery-actions-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
}

.btn-gallery-load-more {
    background-color: var(--primary);
    color: white;
    padding: 14px 40px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 81, 135, 0.3);
    transition: all 0.3s ease;
    border: none;
}

.btn-gallery-load-more:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(0, 81, 135, 0.4);
}

.btn-gallery-load-more:disabled {
    background-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Animación de entrada para fotos nuevas */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-card.fade-in,
.gallery-cta-card.fade-in {
    animation: fadeInUp 0.45s ease forwards;
}

/* ==========================================================================
   6. VISOR MODAL LIGHTBOX
   ========================================================================== */
.lightbox-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
}

.lightbox-content {
    position: relative;
    z-index: 2;
    background-color: var(--bg-primary);
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

.lightbox-close-btn {
    position: absolute;
    top: 14px;
    right: 18px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.lightbox-close-btn:hover {
    background: var(--gallery-accent);
}

.lightbox-img-wrapper {
    width: 100%;
    max-height: 65vh;
    background-color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lightbox-img-wrapper img,
.lightbox-img-wrapper video,
.lightbox-fullscreen-media {
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
    display: block;
}

.lightbox-caption {
    padding: 20px 24px;
    background-color: var(--bg-primary);
}

.lightbox-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.lightbox-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.lightbox-tag {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gallery-accent);
}

/* ==========================================================================
   7. RESPONSIVIDAD (MEDIA QUERIES)
   ========================================================================== */
@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 240px;
    }
}

@media (max-width: 640px) {
    .gallery-main-title {
        font-size: 1.6rem;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: 250px;
    }

    .gallery-card.large-item,
    .gallery-card.small-item,
    .gallery-cta-card {
        grid-column: span 1;
        grid-row: span 1;
    }
}