/* Retreat Gallery Block Styles */

.retreat-gallery-block {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Prevent layout shift during loading */
    min-height: 500px;
}

.gallery-container {
    position: relative;
    display: flex;
    /* gap: 10px; */
    padding: 10px;
    height: 500px;
    border-radius: 12px;
    overflow: hidden;
    /* box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); */
    background-color: transparent;
}

/* Two main large images (50% total) */
.gallery-main-images {
    flex: 50% 0;
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.gallery-main-item {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.gallery-main-item .gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.gallery-main-item .gallery-image:hover {
    transform: scale(1.05);
}

/* Secondary images grid (right side) */
.gallery-secondary-images {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.gallery-secondary-images p {
    display: none;
}

.gallery-grid {
    display: grid;
    gap: 10px;
    height: 100%;
}

/* Grid layouts */
.gallery-grid.grid-2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.gallery-grid.grid-2x2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.gallery-grid.grid-2x3 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.gallery-item .gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.gallery-item .gallery-image:hover {
    transform: scale(1.05);
}

/* View All Button */
.gallery-view-all {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 10;
}

.view-all-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.view-all-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-2px);
}

.view-all-icon {
    font-size: 16px;
    font-weight: bold;
}

/* Lightbox Styles */
.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

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

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-navigation {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

.lightbox-prev,
.lightbox-next {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    pointer-events: auto;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-image-container {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gallery-container {
        flex-direction: column;
        height: auto;
        gap: 8px;
    }
    
    .gallery-main-images {
        flex: none;
        height: 300px;
    }
    
    .gallery-secondary-images {
        flex: none;
    }
    
    .gallery-grid {
        height: auto;
    }
    
    .gallery-grid.grid-2x2 {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    
    .gallery-item {
        height: 120px;
    }
    
    .gallery-view-all {
        bottom: 10px;
        right: 10px;
    }
    
    .view-all-btn {
        padding: 8px 16px;
        font-size: 12px;
    }
    
    .lightbox-content {
        padding: 20px;
    }
    
    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .lightbox-prev,
    .lightbox-next {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .gallery-container {
        gap: 6px;
    }
    
    .gallery-main-images {
        height: 250px;
    }
    
    .gallery-item {
        height: 100px;
    }
    
    .gallery-grid {
        gap: 6px;
    }
    
    .view-all-btn {
        padding: 6px 12px;
        font-size: 11px;
    }
}

/* Loading Animation - Prevent initial glitch */
.gallery-image {
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    background: #f8f8f8;
}

.gallery-image.loading {
    opacity: 0.3;
    position: relative;
}

.gallery-image.loading,
.gallery-image.loaded {
    opacity: 1;
}

.gallery-image.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ccc;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.gallery-image.loaded {
    opacity: 1;
    /* animation: subtleFadeIn 0.4s ease forwards; */
}

.gallery-image.error {
    opacity: 0.5;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-image.error::after {
    content: "⚠️";
    font-size: 24px;
    color: #999;
}

@keyframes subtleFadeIn {
    from {
        opacity: 0.3;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Focus styles for accessibility */
.gallery-image:focus,
.view-all-btn:focus,
.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .view-all-btn {
        background: #000;
        border: 2px solid #fff;
    }
    
    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        background: #000;
        border: 2px solid #fff;
    }
}
