/* Componente global; no depende del proyecto ni del modal que lo abre. */
.proyecto-detalle img {
    cursor: zoom-in;
}

.lightbox {
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    /* Visor flotante: conserva márgenes respecto a la pantalla. */
    width: min(86vw, 1050px);
    height: min(76dvh, 740px);
    max-width: none;
    max-height: none;
    margin: auto;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 20px;
    background: #141820;
    color: #FAFBFB;
    overflow: hidden;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .40);
    opacity: 0;
    transform: scale(.94);
    transition: opacity .25s ease,
                transform .3s cubic-bezier(.2,.8,.2,1),
                overlay .3s allow-discrete,
                display .3s allow-discrete;

    &:not([open]) {
        display: none;
    }

    &[open] {
        display: flex;
        opacity: 1;
        transform: scale(1);
    }

    &::backdrop {
        background: rgba(0, 0, 0, .60);
        transition: background .3s ease;
    }

    .lightbox-barra {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px max(16px, env(safe-area-inset-right));
        flex: 0 0 auto;
        z-index: 3;
    }

    .lightbox-contador {
        font: 500 13px/1.2 'Inter', sans-serif;
    }

    .lightbox-herramientas {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }

    button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        height: 40px;
        padding: 0 10px;
        border: 1px solid rgba(255, 255, 255, .35);
        border-radius: 22px;
        background: transparent;
        color: inherit;
        font: 500 18px/1 'Inter', sans-serif;
        cursor: pointer;

        &:hover,
        &:focus-visible {
            border-color: #BD802C;
            background: #BD802C;
            color: #141820;
        }
    }

    .lightbox-vista {
        display: flex;
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        touch-action: none;
        cursor: zoom-in;

        &.ampliada {
            cursor: grab;
        }

        &:active img {
            transition: none;
        }

        img {
            display: block;
            max-width: 100%;
            max-height: 100%;
            width: auto;
            height: auto;
            object-fit: contain;
            border-radius: 0;
            box-shadow: none;
            user-select: none;
            -webkit-user-drag: none;
            will-change: transform;
            transition: transform .2s ease;
        }
    }

    .lightbox-navegacion {
        display: flex;
        position: absolute;
        z-index: 2;
        top: 50%;
        left: 15px;
        right: 15px;
        transform: translateY(-50%);
        justify-content: space-between;
        pointer-events: none;

        &[hidden] {
            display: none;
        }

        button {
            pointer-events: auto;
            background: rgba(20, 24, 32, .8);
        }
    }
}

/* Animación de entrada sin añadir clases ni tocar el JavaScript. */
@starting-style {
    .lightbox[open] {
        opacity: 0;
        transform: scale(.94);
    }

    .lightbox[open]::backdrop {
        background: rgba(0, 0, 0, 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .lightbox, .lightbox::backdrop, .lightbox-vista img {
        transition: none;
    }
}

@media (max-width: 700px) {
    .lightbox {
        width: 92vw;
        height: 76dvh;
        border-radius: 14px;
        .lightbox-barra {
            padding: 9px 12px;
        }
        .lightbox-herramientas {
            gap: 4px;
        }
        button {
            min-width: 34px;
            height: 34px;
            padding: 0 8px;
        }
        .lightbox-navegacion {
            left: 9px;
            right: 9px;
        }
    }
}
