/* Candid Gallery - grid layout */

.cde-gallery {
    gap: var(--cde-gap, 10px);
}

.cde-gallery:not(.cde-gallery--carousel) {
    display: grid;
    grid-template-columns: repeat(var(--cde-columns, 3), minmax(0, 1fr));
}

/* Each thumbnail cell (grid) */

.cde-gallery__item {
    position: relative;
    width: 100%;
    aspect-ratio: var(--cde-aspect-ratio, 1 / 1);
    overflow: hidden;
}

/* Clickable link wrapper */

.cde-gallery__link {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
}

/* Image wrapper */

.cde-gallery__image {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Actual image element - fill the cell and crop nicely */

.cde-gallery__image img,
.cde-gallery img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transform: scale(1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Overlay element controlled from Elementor style tab */

.cde-gallery__overlay {
    position: absolute;
    inset: 0;
    background-color: transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, background-color 0.25s ease;
}

/* Hover state that can be adjusted with selectors from Elementor */

.cde-gallery__item:hover .cde-gallery__overlay {
    opacity: 1;
}

/* Simple responsive helper for grid */

@media (max-width: 767px) {
    .cde-gallery:not(.cde-gallery--carousel) {
        grid-template-columns: repeat(var(--cde-columns-mobile, 1), minmax(0, 1fr));
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .cde-gallery:not(.cde-gallery--carousel) {
        grid-template-columns: repeat(var(--cde-columns-tablet, 2), minmax(0, 1fr));
    }
}

/* Carousel layout */

.cde-gallery--carousel {
    position: relative;
    display: block;
}

/* Viewport behaves like the lightbox frame: one image, clipped */

.cde-gallery__viewport {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* Track slides left/right inside viewport */

.cde-gallery--carousel .cde-gallery__track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.5s ease;
    will-change: transform;
}

.cde-gallery--carousel .cde-gallery__slide {
    position: relative;
    flex: 0 0 100%;
    min-width: 100%;
    aspect-ratio: var(--cde-aspect-ratio, 16 / 9);
    overflow: hidden;
}

/* Carousel navigation arrows - mimic lightbox arrows but inline */

.cde-gallery__nav {
    position: absolute;
    top: 50%;
    border: none;
    background: transparent;
    color: #000;
    font-size: 26px;
    width: 40px;
    height: 40px;
    padding: 0;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sit just outside the image: half in, half out */

.cde-gallery__nav--prev {
    left: 0;
    transform: translate(-100%, -50%);
}

.cde-gallery__nav--next {
    right: 0;
    transform: translate(100%, -50%);
}

.cde-gallery__nav:hover {
    transform: translate(-100%, -50%) scale(1.08);
}

.cde-gallery__nav--next:hover {
    transform: translate(100%, -50%) scale(1.08);
}

/* Candid Lightbox */

.cde-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.cde-lightbox.is-open {
    display: flex;
    pointer-events: auto;
}

.cde-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.cde-lightbox__inner {
    position: relative;
    max-width: 92vw;
    max-height: 92vh;
    width: auto;
    height: auto;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    overflow: visible;
}

/* Image frame */

.cde-lightbox__image-wrap {
    max-width: 100%;
    max-height: 100%;
    overflow: visible;
}

.cde-lightbox__image {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    background-color: #000;
}

/* Controls */

.cde-lightbox__close,
.cde-lightbox__prev,
.cde-lightbox__next {
    position: absolute;
    border: none;
    background: transparent;
    color: #000;
    font-size: 26px;
    line-height: 1;
    width: 40px;
    height: 40px;
    padding: 0;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Close outside top-right */

.cde-lightbox__close {
    top: -48px;
    right: -48px;
}

/* Prev/next outside sides */

.cde-lightbox__prev {
    left: -48px;
    top: 50%;
    transform: translateY(-50%);
}

.cde-lightbox__next {
    right: -48px;
    top: 50%;
    transform: translateY(-50%);
}

.cde-lightbox__prev:hover,
.cde-lightbox__next:hover {
    transform: translateY(-50%) scale(1.1);
}

.cde-lightbox__close:hover {
    transform: scale(1.1);
}
