/**
 * Gallery — allineata alle Cards (titolo, griglia, scroll + puntini)
 */

.dpb-gallery {
    padding: 4rem 0;
    width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
    background-color: #f8f9fa; /* come .cards-block */
}

.dpb-gallery__header {
    max-width: 1200px;
    margin: 0 auto 2.5rem;
    padding: 0 2rem;
    box-sizing: border-box;
    text-align: center;
}

.dpb-gallery__title {
    font-family: var(--font-title, Georgia, serif);
    font-size: 2.25rem;
    font-weight: normal;
    line-height: 1.25;
    color: #000;
    margin: 0;
}

.dpb-gallery__track {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
    box-sizing: border-box;
    display: grid;
    gap: 2rem;
}

.dpb-gallery--cols-2 { grid-template-columns: repeat(2, 1fr); }
.dpb-gallery--cols-3 { grid-template-columns: repeat(3, 1fr); }
.dpb-gallery--cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .dpb-gallery--cols-3,
    .dpb-gallery--cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 560px) {
    .dpb-gallery__header {
        padding: 0 1.25rem;
        margin-bottom: 1.75rem;
    }

    .dpb-gallery__title {
        font-size: 1.75rem;
    }

    .dpb-gallery__track {
        padding: 0 1.25rem;
        gap: 1.25rem;
        grid-template-columns: 1fr;
    }
}

.dpb-gallery__item {
    appearance: none;
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
    display: block;
}

.dpb-gallery--lightbox .dpb-gallery__item {
    cursor: zoom-in;
}

.dpb-gallery--lightbox .dpb-gallery__item:focus-visible {
    outline: 2px solid #000;
    outline-offset: 3px;
}

.dpb-gallery__figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

/* Media: quadrata come le Cards (minimo 1:1) */
.dpb-gallery__media {
    aspect-ratio: 1 / 1;
    width: 100%;
    overflow: hidden;
    background: #ececec;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dpb-gallery__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dpb-gallery__caption {
    display: block;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #333;
}

/* Scroll = Swiper come Cards */
.dpb-gallery-swiper {
    width: 100% !important;
    max-width: 100%;
    padding-bottom: 0.5rem;
    overflow: hidden;
    box-sizing: border-box;
    margin: 0;
}

@media (min-width: 769px) {
    .dpb-gallery-swiper {
        width: 1264px !important;
        max-width: 1264px;
        margin: 0 auto;
    }
}

.dpb-gallery-swiper .swiper-wrapper {
    display: flex;
    align-items: stretch;
}

.dpb-gallery-swiper .swiper-slide {
    height: auto;
    box-sizing: border-box;
}

.dpb-gallery-swiper .dpb-gallery__item {
    height: 100%;
}

.dpb-gallery__pagination.cards-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 0 2rem;
}

/* Puntini (stesso look Cards se cards.css non c'è) */
.dpb-gallery__pagination .cards-pagination-bullet,
.dpb-gallery .cards-pagination-bullet {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background-color: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;
    outline: none;
}

.dpb-gallery__pagination .cards-pagination-bullet.active,
.dpb-gallery .cards-pagination-bullet.active {
    width: 24px;
    height: 8px;
    border-radius: 4px;
    background-color: #000;
}

/* Lightbox */
.dpb-gallery-lb[hidden] {
    display: none !important;
}

.dpb-gallery-lb {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.dpb-gallery-lb__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 10, 0.88);
}

.dpb-gallery-lb__dialog {
    position: relative;
    max-width: min(1100px, 100%);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.dpb-gallery-lb__img {
    max-width: 100%;
    max-height: min(78vh, 900px);
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.dpb-gallery-lb__caption {
    margin: 0;
    color: #f2f2f2;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.4;
    max-width: 42rem;
}

.dpb-gallery-lb__close,
.dpb-gallery-lb__nav {
    appearance: none;
    border: 0;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    border-radius: 999px;
}

.dpb-gallery-lb__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 42px;
    height: 42px;
    font-size: 1.5rem;
    line-height: 1;
    z-index: 2;
}

.dpb-gallery-lb__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    font-size: 1.35rem;
    z-index: 2;
}

.dpb-gallery-lb__nav--prev { left: 0.75rem; }
.dpb-gallery-lb__nav--next { right: 0.75rem; }

.dpb-gallery-lb__close:hover,
.dpb-gallery-lb__nav:hover {
    background: rgba(255, 255, 255, 0.22);
}

body.dpb-gallery-lb-open {
    overflow: hidden;
}
