/**
 * Masonry Gallery Widget Styles
 * Pinterest-style image gallery with lightbox
 */

/* ===================
   GALLERY CONTAINER
   =================== */
.hmea-masonry-gallery {
    width: 100%;
}

/* Masonry Layout (CSS Columns) */
.hmea-masonry-gallery.layout-masonry {
    column-gap: 16px;
}

/* Grid Layout */
.hmea-masonry-gallery.layout-grid {
    display: grid;
    gap: 16px;
}

/* ===================
   GALLERY ITEM
   =================== */
.hmea-masonry-item {
    position: relative;
    break-inside: avoid;
    overflow: hidden;
    border-radius: 12px;
    background: #f3f4f6;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hmea-masonry-gallery.layout-masonry .hmea-masonry-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 16px;
}

.hmea-masonry-gallery.layout-grid .hmea-masonry-item {
    height: 250px;
}

.hmea-item-link {
    display: block;
    text-decoration: none;
    cursor: zoom-in;
}

.hmea-item-inner {
    position: relative;
    width: 100%;
    height: 100%;
}

.hmea-masonry-item img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.5s ease, filter 0.5s ease;
}

.hmea-masonry-gallery.layout-grid .hmea-masonry-item img {
    height: 100%;
    object-fit: cover;
}

/* ===================
   HOVER EFFECTS
   =================== */

/* Overlay */
.hmea-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.hmea-masonry-item:hover .hmea-item-overlay {
    opacity: 1;
}

/* Hover Icon */
.hmea-hover-icon {
    color: #ffffff;
    font-size: 28px;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.hmea-masonry-item:hover .hmea-hover-icon {
    transform: scale(1);
}

/* Zoom Effect */
.hmea-masonry-gallery.hover-zoom .hmea-masonry-item:hover img {
    transform: scale(1.1);
}

/* Grayscale Effect */
.hmea-masonry-gallery.hover-grayscale .hmea-masonry-item img {
    filter: grayscale(100%);
}

.hmea-masonry-gallery.hover-grayscale .hmea-masonry-item:hover img {
    filter: grayscale(0%);
}

/* Blur Effect */
.hmea-masonry-gallery.hover-blur .hmea-masonry-item img {
    filter: blur(3px);
}

.hmea-masonry-gallery.hover-blur .hmea-masonry-item:hover img {
    filter: blur(0);
}

/* None Effect - still show overlay */
.hmea-masonry-gallery.hover-none .hmea-item-overlay {
    background-color: transparent;
}

/* Overlay Hover Effect */
.hmea-masonry-gallery.hover-overlay .hmea-masonry-item:hover img {
    transform: scale(1.02);
}

/* ===================
   CAPTION
   =================== */
.hmea-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 12px;
    background-color: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Caption Below */
.hmea-masonry-gallery.caption-below .hmea-caption {
    position: relative;
    background-color: transparent;
    color: #374151;
    padding: 10px 0;
}

/* Caption Overlay on Hover */
.hmea-masonry-gallery.caption-overlay_hover .hmea-caption {
    opacity: 0;
    transform: translateY(10px);
}

.hmea-masonry-gallery.caption-overlay_hover .hmea-masonry-item:hover .hmea-caption {
    opacity: 1;
    transform: translateY(0);
}

/* Caption Always Visible */
.hmea-masonry-gallery.caption-overlay_always .hmea-caption {
    opacity: 1;
}

/* ===================
   LOAD MORE BUTTON
   =================== */
.hmea-load-more-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 32px;
}

.hmea-load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 32px;
    background-color: #10b981;
    color: #ffffff;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.hmea-load-more-btn:hover {
    background-color: #059669;
    transform: translateY(-2px);
}

.hmea-load-more-btn:active {
    transform: translateY(0);
}

.hmea-load-more-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.hmea-load-more-btn.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 10px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: hmea-spin 0.8s linear infinite;
}

/* Infinite Scroll Loader */
.hmea-infinite-loader {
    display: flex;
    justify-content: center;
    padding: 32px 0;
}

.hmea-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #10b981;
    border-radius: 50%;
    animation: hmea-spin 0.8s linear infinite;
}

@keyframes hmea-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===================
   LIGHTBOX
   =================== */
.hmea-lightbox {
    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;
}

.hmea-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.hmea-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
}

.hmea-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    opacity: 0.7;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.hmea-lightbox-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

.hmea-lightbox-prev,
.hmea-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

.hmea-lightbox-prev:hover,
.hmea-lightbox-next:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

.hmea-lightbox-prev {
    left: 20px;
}

.hmea-lightbox-next {
    right: 20px;
}

.hmea-lightbox-prev svg,
.hmea-lightbox-next svg {
    width: 24px;
    height: 24px;
}

.hmea-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 80%;
    z-index: 5;
}

.hmea-lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    display: block;
    border-radius: 4px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.4s ease, opacity 0.3s ease;
}

.hmea-lightbox.active .hmea-lightbox-image {
    transform: scale(1);
    opacity: 1;
}

/* Lightbox Animations */
.hmea-lightbox.animation-fade .hmea-lightbox-image {
    transform: none;
}

.hmea-lightbox.animation-slide .hmea-lightbox-image {
    transform: translateX(50px);
}

.hmea-lightbox.animation-slide.active .hmea-lightbox-image {
    transform: translateX(0);
}

.hmea-lightbox-caption {
    position: absolute;
    bottom: -40px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    padding: 10px;
}

.hmea-lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    z-index: 10;
}

/* Thumbnails Strip */
.hmea-lightbox-thumbnails {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    max-width: 80%;
    overflow-x: auto;
    padding: 10px;
    z-index: 10;
}

.hmea-thumb-item {
    flex-shrink: 0;
    width: 60px;
    height: 45px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s ease, border-color 0.3s ease;
    background: none;
}

.hmea-thumb-item:hover,
.hmea-thumb-item.active {
    opacity: 1;
    border-color: #ffffff;
}

.hmea-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===================
   RESPONSIVE
   =================== */
@media (max-width: 1024px) {

    .hmea-lightbox-prev,
    .hmea-lightbox-next {
        width: 40px;
        height: 40px;
    }

    .hmea-lightbox-prev {
        left: 10px;
    }

    .hmea-lightbox-next {
        right: 10px;
    }
}

@media (max-width: 767px) {
    .hmea-lightbox-thumbnails {
        display: none;
    }

    .hmea-lightbox-counter {
        bottom: 60px;
    }

    .hmea-lightbox-prev,
    .hmea-lightbox-next {
        top: auto;
        bottom: 20px;
        transform: none;
    }

    .hmea-lightbox-prev {
        left: calc(50% - 60px);
    }

    .hmea-lightbox-next {
        right: calc(50% - 60px);
    }
}