.swjprojects-gallery-grid {
    display: grid;
    grid-template-columns: repeat(var(--swjprojects-gallery-columns, 2), minmax(0, 1fr));
    gap: 1rem;
}

.swjprojects-gallery-item {
    min-width: 0;
    margin: 0;
}

.swjprojects-gallery-link {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 4px;
    background: rgba(0, 0, 0, .04);
    cursor: zoom-in;
    aspect-ratio: var(--swjprojects-gallery-ratio, 16 / 9);
}

.swjprojects-gallery-link img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s ease, opacity .2s ease;
}

.swjprojects-gallery-grid[style*="--swjprojects-gallery-ratio:auto"] .swjprojects-gallery-link,
.swjprojects-gallery-link:has(img[height="auto"]) {
    aspect-ratio: var(--swjprojects-gallery-ratio, 16 / 9);
}

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

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

.swjprojects-gallery-caption {
    display: block;
    margin-top: .45rem;
    padding: 0;
    background: none;
    color: inherit;
    font-size: .925rem;
    line-height: 1.4;
    text-align: left;
}

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

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

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

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

.swjprojects-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;
    margin: 0;
}

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

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

.swjprojects-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;
}

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

.swjprojects-lightbox-close,
.swjprojects-lightbox-nav,
.swjprojects-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;
}

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

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

.swjprojects-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;
}

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

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

.swjprojects-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: show the original image dimensions inside a scrollable viewport. */
.swjprojects-lightbox-actual-size .swjprojects-lightbox-figure {
    width: calc(100% - 7rem);
    height: 100%;
    max-height: 100%;
    justify-content: stretch;
}

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

.swjprojects-lightbox-actual-size .swjprojects-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;
}

.swjprojects-lightbox-actual-size .swjprojects-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.swjprojects-lightbox-open,
html.swjprojects-lightbox-open body {
    overflow: hidden;
}

@media (max-width: 991.98px) {
    .swjprojects-gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .swjprojects-gallery-grid {
        grid-template-columns: 1fr;
    }

    .swjprojects-lightbox {
        padding: .5rem;
    }

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

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

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

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

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

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

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

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

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