/* --- ESTILOS PARA EL LIGHTBOX (VISOR) --- */

/* 1. Body cuando el viewer está activo */
body.viewer-active {
    overflow: hidden !important;
}

/* 2. Contenedor del lightbox */
#fullscreen-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    box-sizing: border-box;
    margin: 0;
    padding: 20px; /* Padding para que la imagen no toque los bordes */

    /* Flexbox para centrar la imagen */
    justify-content: center;
    align-items: center;

    /* Cursor para indicar que se puede cerrar */
    cursor: pointer;
}

#fullscreen-viewer.active {
    display: flex !important;
}

/* 3. Imagen del lightbox */
#fullscreen-image {
    display: block;
    max-width: calc(100vw - 40px); /* Ancho máximo menos el padding */
    max-height: calc(100vh - 40px); /* Altura máxima menos el padding */
    width: auto;
    height: auto;
    object-fit: contain; /* Mantiene la proporción y ajusta la imagen */
    cursor: pointer;
    margin: 0;
    padding: 0;

    /* Transición suave al aparecer */
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Imagen visible cuando está cargada */
#fullscreen-image.loaded {
    opacity: 1;
    transform: scale(1);
}

/* 4. Botón de cerrar (opcional) */
.close-button {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    transition: background-color 0.3s ease;
}

.close-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #fullscreen-viewer {
        padding: 10px;
    }

    #fullscreen-image {
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
    }

    .close-button {
        top: 10px;
        right: 15px;
        font-size: 24px;
        width: 35px;
        height: 35px;
    }
}

/* --- ESTILOS DE LA GALERÍA (Miniaturas) --- */
.portfolio-item-inner {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 0;
    padding-bottom: 75%; /* Técnica de aspect ratio */
}

.portfolio-media img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.double-height .portfolio-item-inner {
    padding-bottom: 150%;
}

.double-width .portfolio-item-inner {
    padding-bottom: 37.5%;
}

.double-width.double-height .portfolio-item-inner {
    padding-bottom: 75%;
}

.expandable-image {
    cursor: pointer;
    transition: transform 0.3s ease;
}

.expandable-image:hover {
    transform: scale(1.03);
}

/* Estilos para lazy loading */
img.lazy {
    opacity: 0.5;
    transition: opacity 0.3s ease-in-out;
}

img:not(.lazy) {
    opacity: 1;
}