/* Base carousel container */
.hcg-carousel {
    position: relative;
    width: 100%;
    margin: 20px 0;
    background-color: #f9f9f9;
    border-radius: 8px;
    overflow: hidden;
}

/* Ensure scrollbar styling for browsers that use overflow-x */
.hcg-carousel::-webkit-scrollbar {
    height: 8px;
}

.hcg-carousel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.hcg-carousel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.hcg-carousel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Gallery items - Flickity will apply flex to carousel */
.hcg-cell {
    display: block;
    flex-shrink: 0;
    cursor: pointer;
    text-decoration: none;
    margin: 0;
    padding: 0;
    scroll-snap-align: start;
}

.hcg-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    margin: 0;
    padding: 0;
}

.hcg-cell:hover .hcg-image {
    transform: scale(1.05);
}

/* ===== ASPECT RATIO DEFINITIONS ===== */
.hcg-ratio-16-9 {
    aspect-ratio: 16 / 9;
}

.hcg-ratio-4-3 {
    aspect-ratio: 4 / 3;
}

.hcg-ratio-1-1 {
    aspect-ratio: 1 / 1;
}

.hcg-ratio-3-2 {
    aspect-ratio: 3 / 2;
}

.hcg-ratio-21-9 {
    aspect-ratio: 21 / 9;
}

.hcg-ratio-9-16 {
    aspect-ratio: 9 / 16;
}

/* ===== MOBILE LAYOUT: 1 item visible ===== */
@media (max-width: 767px) {
    .hcg-carousel {
        margin: 15px 0;
    }
    
    .hcg-cell {
        width: 100vw;
        max-width: 100vw;
        flex-shrink: 0;
    }
    
    /* Hide navigation on mobile */
    .flickity-prev-next-button {
        display: none !important;
    }
}

/* ===== TABLET/DESKTOP LAYOUT: ~3 items visible ===== */
@media (min-width: 768px) {
    .hcg-cell {
        width: calc(33.333% - 10px);
        min-width: calc(33.333% - 10px);
        flex-shrink: 0;
        margin-right: 15px;
    }
    
    .hcg-cell:nth-child(3n) {
        margin-right: 0;
    }
    
    .flickity-prev-next-button {
        display: block !important;
    }
}

/* ===== EXTRA LARGE DESKTOP ===== */
@media (min-width: 1200px) {
    .hcg-cell {
        width: calc(33.333% - 10px);
        min-width: calc(33.333% - 10px);
    }
}

/* ===== FLICKITY OVERRIDES (when initialized) ===== */
.hcg-carousel.flickity-enabled {
    display: block;
    overflow: visible;
}

.hcg-carousel.flickity-enabled .flickity-viewport {
    overflow: hidden;
    height: auto;
}

/* ===== FLICKITY NAVIGATION BUTTONS ===== */
.flickity-prev-next-button {
    background: rgba(0, 0, 0, 0.4);
    border: none;
    color: white;
    cursor: pointer;
    padding: 12px 16px;
    transition: all 0.3s ease;
    font-size: 18px;
    border-radius: 4px;
    opacity: 0.8;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.flickity-prev-next-button:hover {
    background: rgba(0, 0, 0, 0.7);
    opacity: 1;
}

.flickity-prev-next-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.flickity-prev-next-button.previous {
    left: 10px;
}

.flickity-prev-next-button.next {
    right: 10px;
}

/* ===== LIGHTBOX CUSTOMIZATION ===== */
.glightbox .gslide__image img {
    max-width: 95vw;
    max-height: 95vh;
}

/* ===== CUSTOM LIGHTBOX ===== */
.hcg-lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hcg-lightbox-overlay.active {
    display: flex;
    opacity: 1;
}

.hcg-lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
}

.hcg-lightbox-image-container {
    position: relative;
    max-width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.hcg-lightbox-image {
    display: block;
    width: 100%;
    height: auto;
    transform: scale(1);
    transition: transform 0.2s ease;
}

/* ===== LIGHTBOX CONTROLS ===== */
.hcg-lightbox-controls {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    align-items: center;
    justify-content: center;
}

.hcg-lightbox-btn {
    padding: 10px 18px;
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hcg-lightbox-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

.hcg-lightbox-btn:active {
    background-color: rgba(255, 255, 255, 0.4);
}

.hcg-lightbox-btn.close {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 8px 12px;
    font-size: 18px;
    margin-top: 0;
    z-index: 10000;
}

.hcg-zoom-info {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    margin-left: 10px;
}

/* Mobile responsiveness */
@media (max-width: 767px) {
    .hcg-lightbox-image-container {
        max-width: 95vw;
        max-height: 60vh;
    }
    
    .hcg-lightbox-controls {
        flex-wrap: wrap;
        gap: 10px;
        margin-top: 15px;
    }
    
    .hcg-lightbox-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .hcg-lightbox-btn.close {
        padding: 6px 10px;
        font-size: 16px;
    }
}
