/**
 * Vonome Gallery - Frontend Styles
 * Supports: Grid, Masonry, Carousel, Autoplay Masonry, Preview Slider
 */

:root {
    --vonome-gallery-gap: 16px;
    --vonome-gallery-radius: 8px;
    --vonome-gallery-overlay: rgba(0, 0, 0, 0.5);
    --vonome-gallery-transition: 0.3s ease;
    --vonome-gallery-primary: #c9ab81;
    --vonome-gallery-primary-bg: rgba(201, 171, 129, 0.1);
}

/* BASE CONTAINER */
.vonome-gallery {
    position: relative;
    width: 100%;
}

/* GRID LAYOUT */
.vonome-gallery__grid {
    display: grid;
    grid-template-columns: repeat(var(--columns, 3), 1fr);
    gap: var(--gap, 16px);
}

/* MASONRY LAYOUT */
.vonome-gallery__masonry {
    columns: var(--columns, 3);
    column-gap: var(--gap, 16px);
}

.vonome-gallery__masonry .vonome-gallery__item {
    break-inside: avoid;
    margin-bottom: var(--gap, 16px);
}

/* CAROUSEL LAYOUT */
.vonome-gallery__carousel {
    display: flex;
    overflow-x: auto;
    gap: var(--gap, 16px);
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.vonome-gallery__carousel .vonome-gallery__item {
    flex: 0 0 calc(100% / var(--columns, 3) - var(--gap, 16px));
    scroll-snap-align: start;
}

/* GALLERY ITEM - BASE */
.vonome-gallery__item {
    position: relative;
    overflow: hidden;
    border-radius: var(--vonome-gallery-radius);
    cursor: pointer;
    aspect-ratio: 1;
}

.vonome-gallery__media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--vonome-gallery-transition);
}

/* Video Badge */
.vonome-gallery__video-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

/* Overlay */
.vonome-gallery__overlay {
    position: absolute;
    inset: 0;
    background: var(--vonome-gallery-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--vonome-gallery-transition);
}

.vonome-gallery__item:hover .vonome-gallery__overlay {
    opacity: 1;
}

.vonome-gallery__icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
}

.vonome-gallery__icon svg {
    width: 24px;
    height: 24px;
}

/* Hover Effects */
.vonome-gallery__item--hover-zoom:hover .vonome-gallery__media {
    transform: scale(1.1);
}

.vonome-gallery__item--hover-blur:hover .vonome-gallery__media {
    filter: blur(4px);
}

/* 
   MASONRY AUTOPLAY GALLERY
   True masonry layout with columns: 
   - Vertical images span full height
   - Horizontal images stack in pairs */

.vonome-gallery--masonry-autoplay {
    overflow: hidden;
    position: relative;
    width: 100%;
    height: var(--row-height, 800px);
}

.vonome-gallery__masonry-track {
    display: flex;
    gap: var(--gap, 16px);
    height: 100%;
    animation: vonome-masonry-slide var(--autoplay-speed, 30s) linear infinite;
    will-change: transform;
    width: max-content;
}

.vonome-gallery--masonry-autoplay:hover .vonome-gallery__masonry-track {
    animation-play-state: paused;
}

/* Masonry Column - contains 1 vertical or 2 horizontal stacked images */
.vonome-gallery__masonry-column {
    display: flex;
    flex-direction: column;
    gap: var(--gap, 16px);
    height: 100%;
    flex-shrink: 0;
}

/* Column type: vertical - single item spanning full height */
.vonome-gallery__masonry-column--vertical {
    justify-content: flex-start;
}

/* Column type: stacked - two horizontal images */
.vonome-gallery__masonry-column--stacked {
    justify-content: flex-start;
}

/* Column type: single-horizontal - one horizontal image */
.vonome-gallery__masonry-column--single-horizontal {
    justify-content: flex-start;
}

/* Individual masonry item */
.vonome-gallery__masonry-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--vonome-gallery-radius, 12px);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.vonome-gallery__masonry-item:hover {
    transform: scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.vonome-gallery__masonry-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.vonome-gallery__masonry-item:hover img {
    transform: scale(1.05);
}

/* Video badge for masonry items */
.vonome-gallery__masonry-item .vonome-gallery__video-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    backdrop-filter: blur(4px);
}

/* Hover overlay for masonry items - Dark background with plus icon */
.vonome-gallery__masonry-item .vonome-gallery__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.vonome-gallery__masonry-item:hover .vonome-gallery__overlay {
    opacity: 1;
}

/* Plus icon styling */
.vonome-gallery__icon--plus {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    color: #fff;
    transition: all 0.3s ease;
}

.vonome-gallery__masonry-item:hover .vonome-gallery__icon--plus {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.25);
    border-color: #fff;
}

.vonome-gallery__icon--plus svg {
    width: 28px;
    height: 28px;
}

/* Keyframe animation for infinite sliding */
@keyframes vonome-masonry-slide {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

/* Responsive adjustments for masonry autoplay */
@media (max-width: 1200px) {
    .vonome-gallery--masonry-autoplay {
        height: calc(var(--row-height, 800px) * 0.75);
    }
}

@media (max-width: 768px) {
    .vonome-gallery--masonry-autoplay {
        height: calc(var(--row-height, 800px) * 0.5);
    }

    .vonome-gallery__icon--plus {
        width: 50px;
        height: 50px;
    }

    .vonome-gallery__icon--plus svg {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    .vonome-gallery--masonry-autoplay {
        height: calc(var(--row-height, 800px) * 0.4);
    }

    .vonome-gallery__icon--plus {
        width: 40px;
        height: 40px;
    }

    .vonome-gallery__icon--plus svg {
        width: 20px;
        height: 20px;
    }
}

/* PREVIEW SLIDER GALLERY (with filters) */
.vonome-gallery--preview-slider {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Filter Header */
.vonome-gallery__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 8px;
}

.vonome-gallery__title {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0;
}

.vonome-gallery__filters {
    display: flex;
    gap: 8px;
}

.vonome-gallery__filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.3s ease;
}

.vonome-gallery__filter-btn:hover {
    border-color: var(--vonome-gallery-primary);
    color: var(--vonome-gallery-primary);
}

.vonome-gallery__filter-btn.active {
    background: var(--vonome-gallery-primary);
    border-color: var(--vonome-gallery-primary);
    color: #fff;
}

.vonome-gallery__filter-btn svg {
    width: 16px;
    height: 16px;
}

/* Main Preview */
.vonome-gallery__preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    background: #f5f5f5;
}

.vonome-gallery__preview-item {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.vonome-gallery__preview-item.active {
    opacity: 1;
    z-index: 1;
}

.vonome-gallery__preview-item img,
.vonome-gallery__preview-item video,
.vonome-gallery__preview-item iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Thumbnails Container */
.vonome-gallery__thumbnails-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.vonome-gallery__thumb-nav {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #e0e0e0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.vonome-gallery__thumb-nav:hover:not(:disabled) {
    border-color: var(--vonome-gallery-primary);
    color: var(--vonome-gallery-primary);
}

.vonome-gallery__thumb-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.vonome-gallery__thumb-nav svg {
    width: 20px;
    height: 20px;
}

.vonome-gallery__thumbnails {
    display: flex;
    gap: 12px;
    flex: 1;
    overflow: hidden;
}

.vonome-gallery__thumb {
    position: relative;
    width: calc(25% - 9px);
    aspect-ratio: 16/10;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.vonome-gallery__thumb:hover {
    border-color: rgba(201, 171, 129, 0.5);
}

.vonome-gallery__thumb.active {
    border-color: var(--vonome-gallery-primary);
}

.vonome-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vonome-gallery__thumb-video-badge {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
}

.vonome-gallery__thumb-video-badge svg {
    width: 24px;
    height: 24px;
    color: #fff;
}

/* MASONRY FILTER GALLERY (with filters and pagination) */
.vonome-gallery--masonry-filter {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Filter Header - Same style as Preview Slider */
.vonome-gallery--masonry-filter .vonome-gallery__header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 8px;
}

.vonome-gallery--masonry-filter .vonome-gallery__filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.vonome-gallery--masonry-filter .vonome-gallery__filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.3s ease;
}

.vonome-gallery--masonry-filter .vonome-gallery__filter-btn:hover {
    border-color: var(--vonome-gallery-primary);
    color: var(--vonome-gallery-primary);
}

.vonome-gallery--masonry-filter .vonome-gallery__filter-btn.active {
    background: var(--vonome-gallery-primary);
    border-color: var(--vonome-gallery-primary);
    color: #fff;
}

.vonome-gallery--masonry-filter .vonome-gallery__filter-btn svg {
    width: 16px;
    height: 16px;
}

/* Masonry Filter Grid */
.vonome-gallery__masonry-filter-grid {
    columns: var(--columns, 3);
    column-gap: var(--gap, 16px);
}

.vonome-gallery__masonry-filter-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--vonome-gallery-radius);
    cursor: pointer;
    break-inside: avoid;
    margin-bottom: var(--gap, 16px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: none;
    /* Hidden by default, shown by JS */
}

/* Show filtered and visible items */
.vonome-gallery__masonry-filter-item.vonome-filter-match.vonome-page-visible {
    display: block;
}

.vonome-gallery__masonry-filter-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.vonome-gallery__masonry-filter-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.4s ease;
}

.vonome-gallery__masonry-filter-item:hover img {
    transform: scale(1.05);
}

/* Tall items (vertical/portrait images) */
.vonome-gallery__masonry-filter-item--tall {
    /* Vertical images naturally take more space in masonry */
}

/* Video badge for filter items */
.vonome-gallery__masonry-filter-item .vonome-gallery__video-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    backdrop-filter: blur(4px);
}

/* Overlay for filter items */
.vonome-gallery__masonry-filter-item .vonome-gallery__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.vonome-gallery__masonry-filter-item:hover .vonome-gallery__overlay {
    opacity: 1;
}

/* Pagination */
.vonome-gallery__pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    gap: 8px;
}

.vonome-gallery__pagination-numbers {
    display: flex;
    gap: 8px;
    align-items: center;
}

.vonome-gallery__page-btn {
    min-width: 40px;
    height: 40px;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vonome-gallery__page-btn:hover:not(:disabled) {
    border-color: var(--vonome-gallery-primary);
    color: var(--vonome-gallery-primary);
}

.vonome-gallery__page-btn.active {
    background: var(--vonome-gallery-primary);
    border-color: var(--vonome-gallery-primary);
    color: #fff;
}

.vonome-gallery__page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.vonome-gallery__page-btn--nav {
    padding: 8px;
}

.vonome-gallery__page-btn svg {
    width: 20px;
    height: 20px;
}

.vonome-gallery__page-ellipsis {
    color: #999;
    padding: 0 4px;
    user-select: none;
}

/* Responsive adjustments for masonry filter */
@media (max-width: 1024px) {
    .vonome-gallery--masonry-filter .vonome-gallery__masonry-filter-grid {
        columns: 2;
    }
}

@media (max-width: 768px) {
    .vonome-gallery--masonry-filter .vonome-gallery__header {
        gap: 8px;
    }

    .vonome-gallery--masonry-filter .vonome-gallery__filter-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .vonome-gallery--masonry-filter .vonome-gallery__filter-btn svg {
        width: 14px;
        height: 14px;
    }

    .vonome-gallery__page-btn {
        min-width: 36px;
        height: 36px;
        font-size: 13px;
    }
}

@media (max-width: 640px) {
    .vonome-gallery--masonry-filter .vonome-gallery__masonry-filter-grid {
        columns: 1;
    }

    .vonome-gallery--masonry-filter .vonome-gallery__filters {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .vonome-gallery--masonry-filter .vonome-gallery__filters::-webkit-scrollbar {
        display: none;
    }

    .vonome-gallery--masonry-filter .vonome-gallery__filter-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }
}


/* LIGHTBOX */
.vonome-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--vonome-gallery-transition);
}

.vonome-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.vonome-lightbox__content {
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
}

.vonome-lightbox__media {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
}

.vonome-lightbox__video {
    width: 80vw;
    max-width: 1000px;
    aspect-ratio: 16/9;
}

.vonome-lightbox__video iframe,
.vonome-lightbox__video video {
    width: 100%;
    height: 100%;
}

.vonome-lightbox__close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.vonome-lightbox__close:hover {
    background: var(--vonome-gallery-primary);
    color: #000;
}

.vonome-lightbox__close svg {
    width: 24px;
    height: 24px;
}

.vonome-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vonome-lightbox__nav:hover {
    background: var(--vonome-gallery-primary);
    color: #000;
}

.vonome-lightbox__nav--prev {
    left: 20px;
}

.vonome-lightbox__nav--next {
    right: 20px;
}

.vonome-lightbox__nav svg {
    width: 28px;
    height: 28px;
}

.vonome-lightbox__caption {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 4px;
}

.vonome-lightbox__counter {
    position: absolute;
    top: 20px;
    left: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

/* RESPONSIVE */
@media (max-width: 1024px) {
    .vonome-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .vonome-gallery__masonry {
        columns: 2;
    }

    .vonome-gallery__title {
        font-size: 24px;
    }

    .vonome-gallery__thumb {
        width: calc(33.33% - 8px);
    }
}

@media (max-width: 768px) {
    .vonome-gallery__header {
        flex-direction: column;
        align-items: flex-start;
    }

    .vonome-gallery__filters {
        width: 100%;
        justify-content: flex-start;
    }

    .vonome-gallery__filter-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .vonome-gallery__thumb {
        width: calc(50% - 6px);
    }

    .vonome-gallery__thumb-nav {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 640px) {
    .vonome-gallery__grid {
        grid-template-columns: 1fr;
    }

    .vonome-gallery__masonry {
        columns: 1;
    }

    .vonome-lightbox__nav {
        display: none;
    }
}