/* Listing Gallery Styles */

.listing-gallery {
    display: grid;
    gap: 15px;
    margin: 20px 0;
}

/* Desktop layout: Featured 66% left, Gallery 33% right stacked */
@media (min-width: 992px) {
    .listing-gallery {
        grid-template-columns: 2fr 1fr;
        grid-auto-rows: 1fr;
        align-items: stretch;
    }

    /* Single image case */
    .listing-gallery[data-count="1"] {
        grid-template-columns: 1fr;
    }
    .listing-gallery[data-count="1"] .listing-gallery-item.featured {
        grid-row: span 1;
/*         aspect-ratio: 21 / 9; */
        max-height: 600px;
    }

    /* Two images case */
    .listing-gallery[data-count="2"] {
        grid-template-columns: 1fr 1fr;
    }
    .listing-gallery[data-count="2"] .listing-gallery-item.featured {
        grid-row: span 1;
        aspect-ratio: 3 / 2;
    }
    .listing-gallery[data-count="2"] .listing-gallery-item:not(.featured) {
        aspect-ratio: 3 / 2;
    }

    /* Default (3 or more) featured styling */
    .listing-gallery:not([data-count="1"]):not([data-count="2"]) .listing-gallery-item.featured {
        grid-column: 1;
        grid-row: 1 / span 3;
        height: 100%;
    }

    .listing-gallery-item:not(.featured) {
        grid-column: 2;
        aspect-ratio: 2 / 1;
        height: auto;
    }

    .listing-gallery-item:not(.featured) img {
        height: 100%;
        object-fit: cover;
    }
}

/* Tablet and mobile layout */
@media (max-width: 991px) {
    .listing-gallery {
        grid-template-columns: repeat(2, 1fr);
    }

    .listing-gallery-item {
        height: 220px; /* Fixed height for consistency */
    }

    .listing-gallery-item.featured {
        grid-column: span 2;
    }

    .listing-gallery-item:not(.featured) {
        grid-column: span 1;
    }
}

@media (max-width: 480px) {
    .listing-gallery {
        grid-template-columns: 1fr;
    }

    .listing-gallery-item {
        height: 250px;
    }

    .listing-gallery-item.featured,
    .listing-gallery-item:not(.featured) {
        grid-column: span 1;
    }
}

.listing-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.listing-gallery-link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    cursor: zoom-in;
    text-decoration: none;
}

.listing-gallery-link img {
    width: 100%;
    height: 100% !important;
    object-fit: cover;
	aspect-ratio: 4 / 3;
    display: block;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.listing-gallery-link:hover img {
    transform: scale(1.05);
    filter: brightness(0.9);
}

.listing-gallery-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.listing-gallery-link:hover::after {
    background: rgba(0, 0, 0, 0.2);
}

.listing-gallery-link::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 40px;
    height: 40px;
    z-index: 2;
    transition: transform 0.3s ease;
    opacity: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.listing-gallery-link:hover::before {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Fancybox Customizations */
.fancybox__container {
    --fancybox-bg: rgba(10, 10, 10, 0.96);
    --fancybox-accent-color: #fff;
}

.fancybox__thumbs .f-thumbs__track::before {
    background: rgba(255, 255, 255, 0.1);
}

.fancybox__caption {
    font-size: 15px;
    font-weight: 400;
}

/* Loading state */
.listing-gallery-item.loading {
    min-height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}
