/**
 * JoomProjects project gallery and lightbox.
 * @package JoomProjects
 * @license GNU General Public License version 2 or later
 */

.joomprojects-gallery-link {
    cursor: zoom-in;
    background: rgba(0, 0, 0, .04);
}

.joomprojects-gallery-image {
    display: block;
    transition: transform .2s ease, opacity .2s ease;
}

.joomprojects-gallery-link:hover .joomprojects-gallery-image,
.joomprojects-gallery-link:focus-visible .joomprojects-gallery-image {
    transform: scale(1.025);
    opacity: .92;
}

.joomprojects-gallery-link:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 2px;
}

.joomprojects-lightbox[hidden] {
    display: none !important;
}

.joomprojects-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.joomprojects-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .88);
}

.joomprojects-lightbox-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(96vw, 1500px);
    height: min(94vh, 1000px);
}

.joomprojects-lightbox-figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: auto;
    max-width: calc(100% - 7rem);
    max-height: 100%;
    min-height: 0;
}

.joomprojects-lightbox-viewport {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: calc(94vh - 3.25rem);
    overflow: hidden;
}

.joomprojects-lightbox-image-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

.joomprojects-lightbox-image {
    display: block;
    max-width: 100%;
    max-height: calc(94vh - 3.25rem);
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, .35);
    cursor: zoom-in;
}

.joomprojects-lightbox-caption {
    box-sizing: border-box;
    flex: 0 0 auto;
    width: 100%;
    max-width: 70rem;
    margin: .35rem 0 0;
    padding: .15rem .75rem 0;
    color: #fff !important;
    font-size: 1rem;
    line-height: 1.45;
}

.joomprojects-lightbox-close,
.joomprojects-lightbox-nav,
.joomprojects-lightbox-zoom {
    position: absolute;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    color: #fff;
    background: rgba(0, 0, 0, .42);
    cursor: pointer;
}

.joomprojects-lightbox-close:hover,
.joomprojects-lightbox-nav:hover,
.joomprojects-lightbox-zoom:hover,
.joomprojects-lightbox-close:focus-visible,
.joomprojects-lightbox-nav:focus-visible,
.joomprojects-lightbox-zoom:focus-visible,
.joomprojects-lightbox-zoom[aria-pressed="true"] {
    background: rgba(0, 0, 0, .7);
}

.joomprojects-lightbox-close {
    top: 0;
    right: 0;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    font-size: 2rem;
    line-height: 1;
}

.joomprojects-lightbox-zoom {
    top: 0;
    right: 3.25rem;
    min-width: 3rem;
    height: 2.75rem;
    padding: 0 .65rem;
    border-radius: .4rem;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1;
}

.joomprojects-lightbox-nav {
    top: 50%;
    width: 3rem;
    height: 4rem;
    transform: translateY(-50%);
    border-radius: .4rem;
    font-size: 2rem;
}

.joomprojects-lightbox-prev { left: 0; }
.joomprojects-lightbox-next { right: 0; }

.joomprojects-lightbox-counter {
    position: absolute;
    left: 50%;
    top: .5rem;
    transform: translateX(-50%);
    padding: .25rem .65rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-size: .875rem;
}

/* 1:1 mode keeps the natural image size and scrolls from the top-left origin. */
.joomprojects-lightbox-actual-size .joomprojects-lightbox-figure {
    width: calc(100% - 7rem);
    height: 100%;
    max-height: 100%;
    justify-content: stretch;
}

.joomprojects-lightbox-actual-size .joomprojects-lightbox-viewport {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    max-height: none;
    min-height: 0;
    display: block;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.joomprojects-lightbox-actual-size .joomprojects-lightbox-image-wrap {
    display: block;
    width: max-content;
    height: max-content;
    min-width: 100%;
    min-height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
}

.joomprojects-lightbox-actual-size .joomprojects-lightbox-image {
    flex: 0 0 auto;
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    object-fit: none;
    margin: 0;
    cursor: zoom-out;
}

html.joomprojects-lightbox-open,
html.joomprojects-lightbox-open body {
    overflow: hidden;
}

@media (max-width: 575.98px) {
    .joomprojects-lightbox {
        padding: .5rem;
    }

    .joomprojects-lightbox-dialog {
        width: 100%;
        height: 100%;
    }

    .joomprojects-lightbox-figure,
    .joomprojects-lightbox-actual-size .joomprojects-lightbox-figure {
        width: auto;
        max-width: calc(100% - 1rem);
    }

    .joomprojects-lightbox-actual-size .joomprojects-lightbox-figure {
        width: calc(100% - 1rem);
        height: calc(100% - 4rem);
    }

    .joomprojects-lightbox-viewport {
        max-height: calc(100vh - 5.5rem);
    }

    .joomprojects-lightbox-image {
        max-height: calc(100vh - 5.5rem);
    }

    .joomprojects-lightbox-nav {
        top: auto;
        bottom: .5rem;
        width: 3.25rem;
        height: 3.25rem;
        transform: none;
        border-radius: 50%;
    }

    .joomprojects-lightbox-prev { left: .75rem; }
    .joomprojects-lightbox-next { right: .75rem; }

    .joomprojects-lightbox-zoom {
        top: .25rem;
        right: 3.5rem;
    }

    .joomprojects-lightbox-close {
        top: .25rem;
        right: .25rem;
    }
}
