/**
 * Gallery Layout Fixes - Makes galleries full width and properly responsive
 */

/* Make galleries use more space */
.container.gallery-container {
    max-width: 100%;
    padding-left: 2rem;
    padding-right: 2rem;
}

/* Gallery grid layout */
.gallery-grid,
.gallery-albums {
    display: grid;
    gap: 2rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Responsive grid columns */
@media (min-width: 576px) {
    .gallery-grid,
    .gallery-albums {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .gallery-grid,
    .gallery-albums {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 992px) {
    .gallery-grid,
    .gallery-albums {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Gallery items */
.gallery-item,
.gallery-album {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease-in-out;
}

.gallery-item:hover,
.gallery-album:hover {
    transform: translateY(-5px);
}

/* Image containers */
.gallery-image-wrapper,
.gallery-album-thumbnail {
    position: relative;
    padding-top: 75%; /* 4:3 aspect ratio */
    overflow: hidden;
}

.gallery-image,
.gallery-album-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Overlay styles */
.gallery-overlay,
.gallery-album-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.gallery-item:hover .gallery-overlay,
.gallery-album:hover .gallery-album-overlay {
    opacity: 1;
}

/* Caption and info styles */
.gallery-caption,
.gallery-album-info {
    padding: 1rem;
    background: #fff;
}

.gallery-album-title {
    font-size: 1.1rem;
    margin: 0 0 0.5rem;
    color: #333;
}

.gallery-album-description {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

.gallery-albums {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 2rem;
    padding: 2rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

@media (min-width: 576px) {
    .gallery-albums {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .gallery-albums {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 992px) {
    .gallery-albums {
        grid-template-columns: repeat(4, 1fr);
    }
}

.gallery-album {
    position: relative;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-album:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.gallery-album-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.gallery-album-thumbnail {
    position: relative;
    padding-top: 75%; /* 4:3 aspect ratio */
    overflow: hidden;
}

.gallery-album-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.gallery-album-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-album:hover .gallery-album-overlay {
    opacity: 1;
}

.gallery-album-overlay i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.gallery-album-info {
    padding: 1rem;
}

.gallery-album-title {
    font-size: 1.25rem;
    margin: 0 0 0.5rem;
    color: #333;
}

.gallery-album-description {
    font-size: 0.875rem;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

/* Lightbox Container Styles */
.lightbox-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1;
}

.lightbox-content {
    position: relative;
    z-index: 2;
    width: 90%;
    max-width: 1200px;
    height: 90%;
    max-height: 900px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.lightbox-image {
    max-width: 100%;
    max-height: 80%;
    object-fit: contain;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.lightbox-caption {
    color: white;
    text-align: center;
    padding: 10px;
    margin-top: 10px;
    max-width: 90%;
    font-size: 16px;
}

.lightbox-counter {
    position: absolute;
    bottom: 5px;
    right: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s ease;
    z-index: 3;
    position: absolute;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(0, 0, 0, 0.8);
}

.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.lightbox-close {
    top: 10px;
    right: 10px;
}

.lightbox-prev {
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-next {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.lightbox-container.closing .lightbox-overlay,
.lightbox-container.closing .lightbox-content {
    animation: fadeOut 0.3s forwards;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Disable buttons */
.lightbox-prev.disabled,
.lightbox-next.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Fix for photo galleries page - ensure popup images work correctly */
.js-open-gallery {
    cursor: pointer;
}

/* Make sure gallery popup doesn't get obscured by other elements */
.lightbox-container {
    isolation: isolate;
}

/* Fix for Safari and mobile browsers */
body.has-lightbox {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Ensure content inside album link doesn't interfere with click behavior */
.gallery-album-link * {
    pointer-events: none;
}

/* Fix for social share that shouldn't trigger gallery */
.gallery-social-share,
.share-button,
.share-options,
.social-share-link {
    pointer-events: auto;
    position: relative;
    z-index: 5;
}

/* Ensure proper z-index stacking for popup */
.lightbox-container {
    z-index: 999999;
}

/* Fix specific issues on photo-gallaries page */
.page-id-photo-gallaries .js-open-gallery,
body[class*="photo-gallaries"] .js-open-gallery {
    display: block;
    position: relative;
    cursor: pointer;
}

/* Make sure click events bubble up properly */
.gallery-album-link {
    cursor: pointer;
    display: block;
    position: relative;
    z-index: 1;
}

/* Prevent specific elements from triggering gallery */
.gallery-social-share {
    z-index: 10;
}

/* Add clear indication that gallery items are clickable */
.gallery-album:hover {
    cursor: pointer;
}

/* Ensure mobile tap works correctly */
@media (max-width: 768px) {
    .gallery-album-link {
        -webkit-tap-highlight-color: rgba(0,0,0,0);
    }
    
    .gallery-album-overlay {
        opacity: 0.3;
    }
    
    .gallery-album:active .gallery-album-overlay {
        opacity: 0.8;
    }
}

/* Additional accessibility improvements */
.lightbox-close:focus-visible,
.lightbox-prev:focus-visible,
.lightbox-next:focus-visible {
    outline: 3px solid #4CAF50;
    outline-offset: 2px;
}

/* Mobile Gallery Album Touch Functionality */
@media (max-width: 768px) {
    .gallery-album-link {
        -webkit-tap-highlight-color: rgba(0,0,0,0);
    }
    
    .gallery-album-overlay {
        opacity: 0.3;
    }
    
    .gallery-album:active .gallery-album-overlay {
        opacity: 0.8;
    }
}

/* Fix for lightbox button visibility on all devices */
.lightbox-close,
.lightbox-prev, 
.lightbox-next {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Ensure lightbox works on touch devices */
.lightbox-container {
    -webkit-overflow-scrolling: touch;
}

/* Fix iOS specific issues */
@media screen and (-webkit-min-device-pixel-ratio: 2) {
    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
} 