.dbtfg-gallery {
    display: grid;
    grid-template-columns: repeat(var(--dbtfg-cols-desktop, 4), minmax(0, 1fr));
    gap: var(--dbtfg-gap, 16px);
    width: 100%;
}

.dbtfg-item {
    min-width: 0;
    margin: 0;
}

.dbtfg-image-wrap {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    color: inherit;
    background: #111;
    border: 0;
    border-radius: 0;
    overflow: hidden;
}

button.dbtfg-image-wrap {
    cursor: zoom-in;
}

.dbtfg-image-wrap:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
}

.dbtfg-image-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: cover;
    transition: transform .2s ease;
}

button.dbtfg-image-wrap:hover img {
    transform: scale(1.025);
}

.dbtfg-ratio-1-1 .dbtfg-image-wrap { aspect-ratio: 1 / 1; }
.dbtfg-ratio-4-3 .dbtfg-image-wrap { aspect-ratio: 4 / 3; }
.dbtfg-ratio-3-2 .dbtfg-image-wrap { aspect-ratio: 3 / 2; }
.dbtfg-ratio-16-9 .dbtfg-image-wrap { aspect-ratio: 16 / 9; }

.dbtfg-ratio-original .dbtfg-image-wrap img {
    height: auto;
    object-fit: contain;
}

.dbtfg-caption {
    display: block;
    padding: .65rem .15rem .25rem;
    line-height: 1.45;
}

.dbtfg-title,
.dbtfg-text {
    display: block;
}

.dbtfg-text {
    margin-top: .25rem;
}

.dbtfg-lightbox {
    position: fixed;
    z-index: 1000000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 4.5rem;
    background: rgba(0, 0, 0, .92);
}

.dbtfg-lightbox[hidden] {
    display: none;
}

.dbtfg-lightbox-dialog {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    width: fit-content;
    max-width: var(--dbtfg-lightbox-width, 90vw);
    max-height: var(--dbtfg-lightbox-height, 85vh);
    color: #fff;
}

.dbtfg-lightbox-image {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: calc(var(--dbtfg-lightbox-height, 85vh) - 7rem);
    margin: auto;
    object-fit: contain;
}

.dbtfg-lightbox-copy {
    max-width: 900px;
    max-height: 24vh;
    margin: .8rem auto 0;
    overflow: auto;
    text-align: center;
    white-space: pre-line;
}

.dbtfg-lightbox-title {
    display: block;
    margin-bottom: .3rem;
    font-size: 1.05rem;
}

.dbtfg-lightbox-caption {
    display: block;
    line-height: 1.45;
}

.dbtfg-lightbox-close,
.dbtfg-lightbox-prev,
.dbtfg-lightbox-next {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #fff;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 50%;
    font: inherit;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}

.dbtfg-lightbox-close:hover,
.dbtfg-lightbox-prev:hover,
.dbtfg-lightbox-next:hover,
.dbtfg-lightbox-close:focus-visible,
.dbtfg-lightbox-prev:focus-visible,
.dbtfg-lightbox-next:focus-visible {
    background: rgba(255, 255, 255, .22);
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.dbtfg-lightbox-close {
    top: 18px;
    right: 18px;
}

.dbtfg-lightbox-prev,
.dbtfg-lightbox-next {
    top: 50%;
    transform: translateY(-50%);
}

.dbtfg-lightbox-prev { left: 18px; }
.dbtfg-lightbox-next { right: 18px; }

body.dbtfg-lightbox-open {
    overflow: hidden;
}

@media (max-width: 1024px) {
    .dbtfg-gallery {
        grid-template-columns: repeat(var(--dbtfg-cols-tablet, 3), minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .dbtfg-gallery {
        grid-template-columns: repeat(var(--dbtfg-cols-mobile, 2), minmax(0, 1fr));
    }

    .dbtfg-lightbox {
        padding: 3.5rem .75rem 4.5rem;
    }

    .dbtfg-lightbox-prev,
    .dbtfg-lightbox-next {
        top: auto;
        bottom: 12px;
        transform: none;
    }

    .dbtfg-lightbox-prev { left: calc(50% - 54px); }
    .dbtfg-lightbox-next { right: calc(50% - 54px); }

    .dbtfg-lightbox-close {
        top: 10px;
        right: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dbtfg-image-wrap img {
        transition: none;
    }
}
