/**
 * The Gallery CSS
 */

.wml-the-gallery {
    width: 100%;
}

.wml-the-gallery .wml-gallery-container {
    max-width: var(--wml-gallery-max-width, 1200px);
    margin: 0 auto;
    padding: 0 20px;
}

.wml-the-gallery .wml-gallery-grid {
    display: grid;
    grid-template-columns: repeat(var(--wml-gallery-columns-desktop, 4), 1fr);
    gap: var(--wml-gallery-gap, 10px);
    padding: var(--wml-gallery-padding-vertical, 90px) 0;
}

.wml-the-gallery .wml-gallery-column {
    display: flex;
    flex-direction: column;
    gap: var(--wml-gallery-gap, 10px);
}

.wml-the-gallery .wml-gallery-column.offset-up {
    margin-top: calc(var(--wml-gallery-offset, 90px) * -1);
}

.wml-the-gallery .wml-gallery-column.offset-down {
    margin-top: var(--wml-gallery-offset, 90px);
}

.wml-the-gallery .wml-image-wrapper {
    width: 100%;
    position: relative;
    overflow: hidden;
    border-radius: var(--wml-gallery-border-radius, 8px);
    box-shadow: var(--wml-gallery-box-shadow, 0 2px 8px rgba(0, 0, 0, 0.1));
    transition: transform var(--wml-gallery-transition, 0.3s) ease, box-shadow var(--wml-gallery-transition, 0.3s) ease;
}

.wml-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: background 0.3s ease, transform 0.3s ease;
}

.wml-the-gallery .wml-image-wrapper:hover .wml-play-icon {
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(1.1);
}

.wml-play-icon svg {
    margin-left: 4px;
}

/* Hover effects */
.wml-the-gallery[data-hover="true"] .wml-image-wrapper:hover {
    transform: translateY(var(--wml-gallery-hover-translate, -5px));
    box-shadow: var(--wml-gallery-hover-shadow, 0 4px 16px rgba(0, 0, 0, 0.15));
}

.wml-the-gallery .wml-image-wrapper[data-inline-handler="true"] {
    cursor: pointer;
}

/* Image height */
.wml-the-gallery .wml-image-wrapper {
    height: var(--wml-gallery-image-height, auto);
}

.wml-the-gallery .wml-image-wrapper img,
.wml-the-gallery .wml-image-wrapper video {
    width: 100%;
    height: var(--wml-gallery-img-height, auto);
    /* If wrapper has height, img needs 100% or auto? PHP used 100% if height set */
    object-fit: var(--wml-gallery-object-fit, cover);
    object-position: var(--wml-gallery-object-position, center);
    display: block;
    opacity: 1 !important;
    transition: opacity 0.3s ease-in-out;
}

.wml-the-gallery .wml-image-wrapper img.wml-loaded,
.wml-the-gallery .wml-image-wrapper video.wml-loaded {
    opacity: 1 !important;
}

.wml-the-gallery .wml-image-wrapper:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Lightbox Modal Styles */
.wml-lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.wml-lightbox-modal.wml-lightbox-active {
    opacity: 1;
    visibility: visible;
}

.wml-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    cursor: pointer;
}

.wml-lightbox-content {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.wml-lightbox-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wml-lightbox-image,
.wml-lightbox-video,
.wml-lightbox-iframe {
    max-width: 100%;
    max-height: 100vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.wml-lightbox-iframe {
    width: 90vw;
    height: 50.625vw;
    max-height: 90vh;
    max-width: 160vh;
}

.wml-lightbox-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wml-spin 0.8s linear infinite;
    display: none;
}

@keyframes wml-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.wml-lightbox-caption {
    margin-top: 20px;
    color: #fff;
    text-align: center;
    font-size: 16px;
    max-width: 80vw;
}

.wml-lightbox-counter {
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    font-size: 14px;
}

.wml-lightbox-close,
.wml-lightbox-prev,
.wml-lightbox-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 2;
}

.wml-lightbox-close:hover,
.wml-lightbox-prev:hover,
.wml-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.wml-lightbox-close {
    top: 20px;
    right: 20px;
}

.wml-lightbox-prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.wml-lightbox-prev:hover {
    transform: translateY(-50%) scale(1.1);
}

.wml-lightbox-next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.wml-lightbox-next:hover {
    transform: translateY(-50%) scale(1.1);
}

.wml-lightbox-close svg,
.wml-lightbox-prev svg,
.wml-lightbox-next svg {
    width: 24px;
    height: 24px;
}

/* Responsive styles */
@media (max-width: 1024px) {
    .wml-the-gallery .wml-gallery-grid {
        grid-template-columns: repeat(var(--wml-gallery-columns-tablet, 2), 1fr);
    }
}

@media (max-width: 768px) {

    .wml-lightbox-image,
    .wml-lightbox-video {
        max-height: 100vh;
    }

    .wml-lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }

    .wml-lightbox-prev {
        left: 10px;
        width: 40px;
        height: 40px;
    }

    .wml-lightbox-next {
        right: 10px;
        width: 40px;
        height: 40px;
    }

    .wml-lightbox-caption {
        font-size: 14px;
        margin-top: 15px;
    }
}

@media (max-width: 640px) {
    .wml-the-gallery .wml-gallery-grid {
        grid-template-columns: repeat(var(--wml-gallery-columns-mobile, 1), 1fr);
        padding: 40px 0;
    }

    .wml-the-gallery .wml-gallery-column.offset-up,
    .wml-the-gallery .wml-gallery-column.offset-down {
        margin-top: 0;
    }
}