/* =======================================================
   VARIABLES Y ESTILOS BASE
   ======================================================= */
:root {
    --primary-color: #FF9500;
    --primary-color-dark: #e68600;
}

.page-header {
    text-align: center;
    padding: 60px 20px 40px;
    position: relative;
    z-index: 2;
}

.page-header h1 {
    font-size: 3.2rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 15px;
    letter-spacing: -1px;
}

.page-header p {
    font-size: 1.15rem;
    color: var(--text-muted);
    max-width: 650px;
    margin: 0 auto 30px;
    line-height: 1.6;
}

.header-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    display: inline-block;
    filter: drop-shadow(0 10px 15px rgba(255, 149, 0, 0.4));
    animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0); }
}

/* Botón superior de regreso a cultura */
.btn-back {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    background: var(--glass-bg, rgba(255, 255, 255, 0.6));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.3));
    padding: 8px 16px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    z-index: 10;
}

.btn-back:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 149, 0, 0.3);
}

/* =======================================================
   BOTÓN WHATSAPP Y MUSEO VIRTUAL
   ======================================================= */
.action-container {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.btn-neon {
    background: rgba(255, 149, 0, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(255, 149, 0, 0.3);
    padding: 15px 35px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    box-shadow: 0 8px 32px rgba(255, 149, 0, 0.1);
}

.btn-neon:hover {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 15px 35px rgba(255, 149, 0, 0.5), 0 0 20px rgba(255, 149, 0, 0.8);
    transform: translateY(-3px);
    border-color: var(--primary-color);
}

.btn-iniciar-museo {
    background: linear-gradient(135deg, var(--primary-color), #FFB75E);
    color: white;
    padding: 15px 40px;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 800;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(255, 149, 0, 0.4);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.btn-iniciar-museo:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 35px rgba(255, 149, 0, 0.6);
}

/* =======================================================
   MASONRY GALLERY (GLASSMORPHISM)
   ======================================================= */
.gallery-masonry {
    column-count: 3;
    column-gap: 25px;
    padding: 0 40px 80px;
    max-width: 1300px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

@media (max-width: 1024px) {
    .gallery-masonry {
        column-count: 2;
    }
}

@media (max-width: 768px) {
    .gallery-masonry {
        column-count: 1;
        padding: 0 20px 60px;
    }
}

.gallery-item {
    /* FIX APPLE/WEBKIT MASONRY BUG DEFINITIVO */
    display: inline-block;
    width: 100%;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    break-inside: avoid;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform; /* Obliga al renderizado por hardware en WebKit */
    
    margin-bottom: 25px;
    background: var(--glass-bg, rgba(255, 255, 255, 0.6));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.3));
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    transition: all 0.4s ease;
    position: relative;
    cursor: pointer;
}

[data-theme="dark"] .gallery-item {
    background: rgba(20, 20, 25, 0.6);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.gallery-item:hover {
    -webkit-transform: translateY(-8px) scale(1.01) translateZ(0);
    transform: translateY(-8px) scale(1.01) translateZ(0);
    border-color: rgba(255, 149, 0, 0.6);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 0 25px rgba(255, 149, 0, 0.2);
}

[data-theme="dark"] .gallery-item:hover {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 149, 0, 0.3);
}

.gallery-img {
    width: 100%;
    display: block;
    object-fit: cover;
    border-bottom: 1px solid rgba(150, 150, 150, 0.1);
    transition: transform 0.6s ease;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.gallery-item:hover .gallery-img {
    transform: scale(1.03);
}

.gallery-info {
    padding: 20px;
}

.gallery-info h3 {
    font-size: 1.25rem;
    color: var(--text-main);
    margin: 0 0 8px;
    font-weight: 700;
}

.gallery-info p.author {
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: 600;
    margin: 0 0 12px;
}

.gallery-info p.desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =======================================================
   MODAL DE GALERÍA VIRTUAL (FULLSCREEN + SLIDESHOW)
   ======================================================= */
.galeria-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 99999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden;
}

.galeria-modal.activo {
    display: flex;
    opacity: 1;
}

/* Controles Superiores Flotantes */
.modal-top-controls {
    position: absolute;
    top: 20px;
    right: 25px;
    display: flex;
    gap: 15px;
    z-index: 120;
}

.btn-modal-control {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.btn-modal-control:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.btn-modal-control.btn-close:hover {
    background: #ef4444;
    border-color: #ef4444;
    transform: rotate(90deg);
}

/* Flechas de Navegación */
.nav-museo {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 55px;
    height: 55px;
    border-radius: 50%;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 110;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.nav-museo:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 5px 20px rgba(255, 149, 0, 0.4);
}

.prev-museo { left: 25px; }
.next-museo { right: 25px; }

/* Contenedor central */
.modal-content-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 80px 20px 40px;
    box-sizing: border-box;
    z-index: 10;
}

.img-and-btn-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
    position: relative;
}

.modal-image-center {
    display: inline-block;
    position: relative;
    max-width: 100%;
    max-height: calc(100% - 60px); 
    margin-bottom: 20px;
}

.modal-image-center img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 180px);
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: zoom-in;
    user-select: none;
    -webkit-user-drag: none;
    /* Permite hacer pinch-to-zoom pero deshabilita la recarga o retroceso lateral de navegadores moviles */
    touch-action: pan-y pinch-zoom; 
}

/* Botón Inferior para ver Descripción */
.btn-ver-desc {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 12px 28px;
    border-radius: 50px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

.btn-ver-desc:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-5px);
}

/* Panel Flotante de Descripción */
.desc-panel {
    position: absolute;
    bottom: 95px; 
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    width: 90%;
    max-width: 800px;
    max-height: 60vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 35px;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 110;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
    color: white;
}

.desc-panel.mostrar {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.desc-panel .galeria-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 12px;
    color: white;
    line-height: 1.2;
}

.desc-panel .galeria-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 25px;
}

.desc-panel .meta-item {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.desc-panel .galeria-desc {
    font-size: 1.1rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.85);
    white-space: pre-line;
}

/* Responsive */
@media (max-width: 768px) {
    .page-header { padding: 40px 20px 10px; display: flex; flex-direction: column; align-items: center; }
    .page-header h1 { font-size: 2.5rem; }
    .btn-back { position: relative; top: 0; left: 0; margin: 0 auto 20px auto; width: max-content; }
    .action-container { margin-bottom: 30px; }
    .btn-iniciar-museo { font-size: 1rem; padding: 12px 30px; }
    
    /* Ajustes Modal Móvil */
    .modal-content-wrapper { padding: 60px 10px 30px; }
    .modal-top-controls { top: 10px; right: 10px; gap: 10px; }
    .btn-modal-control { width: 40px; height: 40px; font-size: 1.1rem; }
    
    .nav-museo { width: 40px; height: 40px; font-size: 1.2rem; }
    .prev-museo { left: 5px; }
    .next-museo { right: 5px; }

    .desc-panel { width: 95%; bottom: 80px; padding: 25px; max-height: 55vh; }
    .desc-panel .galeria-title { font-size: 1.6rem; }
    .btn-ver-desc { font-size: 1rem; padding: 10px 22px; margin-bottom: 10px; }
    
    .modal-image-center { max-height: calc(100% - 50px); }
    .modal-image-center img { max-height: calc(100vh - 160px); }
}