/* ===========================================
   ENHANCED GALLERY STYLES
   =========================================== */

/* Gallery Grid - Responsive Masonry */
.gallery-grid-enhanced {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

/* Ensure gallery items are properly displayed */
.gallery-grid-enhanced .gallery-item-enhanced {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Gallery Item */
.gallery-item-enhanced {
    position: relative;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(137, 108, 108, 0.1);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    cursor: pointer;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    max-height: 400px;
    will-change: transform, opacity;
    transform-origin: center;
}

.gallery-item-enhanced:active {
    transform: scale(0.98);
}

.gallery-item-visible {
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
}

.gallery-item-enhanced::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(137, 108, 108, 0.1), rgba(229, 190, 181, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.gallery-item-enhanced:hover::before {
    opacity: 1;
}

.gallery-item-enhanced:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 50px rgba(137, 108, 108, 0.3);
    z-index: 10;
}

/* Gallery Image */
.gallery-image-enhanced {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
    position: relative;
    z-index: 0;
    min-height: 200px;
    background: linear-gradient(135deg, rgba(137, 108, 108, 0.1), rgba(229, 190, 181, 0.1));
}

.gallery-item-enhanced:hover .gallery-image-enhanced {
    transform: scale(1.1);
}

.gallery-image-enhanced.loaded {
    animation: fadeInScale 0.5s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Gallery Overlay */
.gallery-overlay-enhanced {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(137, 108, 108, 0.95), rgba(229, 190, 181, 0.85));
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
}

.gallery-item-enhanced:hover .gallery-overlay-enhanced {
    opacity: 1;
    pointer-events: all;
}

/* Zoom Icon */
.gallery-zoom-enhanced {
    width: 3.5rem;
    height: 3.5rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #896C6C;
    font-size: 1.5rem;
    transform: scale(0.8) rotate(-90deg);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.gallery-item-enhanced:hover .gallery-zoom-enhanced {
    transform: scale(1) rotate(0deg);
}

/* Lightbox Styles */
.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s ease;
}

.gallery-lightbox.active {
    opacity: 1;
    visibility: visible;
}

/* Lightbox Image Wrapper */
.lightbox-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Lightbox Loader */
.lightbox-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.lightbox-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-sizing: border-box;
}

.lightbox-info {
    margin-top: 1.5rem;
    text-align: center;
    width: 100%;
    max-width: 800px;
    padding: 0 1rem;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .lightbox-info {
        padding: 0 0.75rem;
    }
}

@media (max-width: 480px) {
    .lightbox-info {
        padding: 0 0.5rem;
    }
}

/* Smooth image transitions */
.lightbox-image-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    cursor: grab;
}

.lightbox-image:active {
    cursor: grabbing;
}

.lightbox-image.loaded {
    opacity: 1;
}

.lightbox-caption {
    color: white;
    text-align: center;
    margin-top: 1.5rem;
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    font-weight: 500;
    max-width: 800px;
    padding: 0 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.6;
    letter-spacing: 0.01em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    hyphens: auto;
}

.lightbox-counter {
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    margin-top: 0.75rem;
    font-size: clamp(0.875rem, 2vw, 0.9rem);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #896C6C;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.lightbox-close {
    top: 1rem;
    right: 1rem;
}

.lightbox-prev {
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-next {
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.lightbox-prev:hover {
    transform: translateY(-50%) scale(1.1);
}

.lightbox-next:hover {
    transform: translateY(-50%) scale(1.1);
}

/* Gallery Filters */
.gallery-filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.gallery-filter-btn {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(137, 108, 108, 0.2);
    border-radius: 2rem;
    color: #896C6C;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: clamp(0.875rem, 2vw, 0.9rem);
    line-height: 1.4;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.gallery-filter-btn:hover,
.gallery-filter-btn.active {
    background: linear-gradient(135deg, #896C6C, #E5BEB5);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(137, 108, 108, 0.3);
}

/* Loading State */
.gallery-image-enhanced[data-src] {
    background: linear-gradient(
        90deg,
        rgba(137, 108, 108, 0.1) 0%,
        rgba(229, 190, 181, 0.2) 50%,
        rgba(137, 108, 108, 0.1) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .gallery-grid-enhanced {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1.25rem;
    }
}

@media (max-width: 768px) {
    .gallery-grid-enhanced {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
        padding: 0;
    }
    
    .gallery-item-enhanced {
        aspect-ratio: 1;
        border-radius: 0.75rem;
    }
    
    .gallery-item-enhanced:hover {
        transform: translateY(-5px) scale(1.01);
    }
    
    .gallery-filters {
        gap: 0.75rem;
        margin-bottom: 1.5rem;
        padding: 0 0.5rem;
    }
    
    .gallery-filter-btn {
        padding: 0.65rem 1.25rem;
        font-size: clamp(0.8rem, 2.5vw, 0.875rem) !important;
        font-weight: 600;
        line-height: 1.3;
    }
    
    .lightbox-container {
        width: 95%;
        padding: 1rem;
    }
    
    .lightbox-image {
        max-height: 60vh;
        width: 100%;
    }
    
    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .lightbox-close {
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .lightbox-prev {
        left: 0.5rem;
    }
    
    .lightbox-next {
        right: 0.5rem;
    }
    
    .lightbox-content {
        width: 100%;
        padding: 1rem;
    }
    
    .lightbox-info {
        margin-top: 1rem;
        padding: 0 0.5rem;
    }
    
    .lightbox-caption {
        font-size: clamp(0.95rem, 3.5vw, 1.125rem) !important;
        margin-top: 1rem;
        padding: 0 1rem;
        max-width: 100%;
        line-height: 1.6 !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        letter-spacing: 0.01em;
        font-weight: 500 !important;
        color: rgba(255, 255, 255, 0.95) !important;
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .lightbox-counter {
        font-size: clamp(0.85rem, 3vw, 0.95rem) !important;
        margin-top: 0.75rem;
        font-weight: 600 !important;
        color: rgba(255, 255, 255, 0.9) !important;
        letter-spacing: 0.05em;
        text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    }
}

@media (max-width: 480px) {
    .gallery-grid-enhanced {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }
    
    .gallery-item-enhanced {
        border-radius: 0.5rem;
    }
    
    .gallery-zoom-enhanced {
        width: 3rem;
        height: 3rem;
        font-size: 1.25rem;
    }
    
    .gallery-filters {
        gap: 0.5rem;
        margin-bottom: 1.25rem;
        padding: 0 0.25rem;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .gallery-filters::-webkit-scrollbar {
        display: none;
    }
    
    .gallery-filter-btn {
        padding: 0.6rem 1rem;
        font-size: clamp(0.75rem, 3vw, 0.85rem) !important;
        font-weight: 600;
        line-height: 1.3;
        flex-shrink: 0;
    }
    
    .lightbox-container {
        width: 100%;
        padding: 0.5rem;
    }
    
    .lightbox-image {
        max-height: 50vh;
        border-radius: 0.5rem;
        width: 100%;
    }
    
    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    .lightbox-close {
        top: 0.25rem;
        right: 0.25rem;
    }
    
    .lightbox-prev {
        left: 0.25rem;
    }
    
    .lightbox-next {
        right: 0.25rem;
    }
    
    .lightbox-content {
        width: 100%;
        padding: 0.75rem;
    }
    
    .lightbox-info {
        margin-top: 0.75rem;
        padding: 0 0.5rem;
    }
    
    .lightbox-caption {
        font-size: clamp(0.875rem, 4vw, 1rem) !important;
        padding: 0 0.75rem;
        margin-top: 0.75rem;
        line-height: 1.5 !important;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        letter-spacing: 0.01em;
        font-weight: 500 !important;
        color: rgba(255, 255, 255, 0.95) !important;
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    }
    
    .lightbox-counter {
        font-size: clamp(0.8rem, 3.5vw, 0.9rem) !important;
        margin-top: 0.6rem;
        font-weight: 600 !important;
        color: rgba(255, 255, 255, 0.9) !important;
        letter-spacing: 0.05em;
        text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    }
    
    .lightbox-image-wrapper {
        width: 100%;
        height: auto;
    }
}

/* Touch Optimizations */
@media (hover: none) and (pointer: coarse) {
    .gallery-item-enhanced:active {
        transform: scale(0.98);
    }
    
    .gallery-overlay-enhanced {
        opacity: 0.8;
    }
    
    /* Better text visibility on touch devices */
    .lightbox-caption {
        font-size: clamp(0.9rem, 4vw, 1.05rem) !important;
        line-height: 1.5 !important;
    }
    
    .lightbox-counter {
        font-size: clamp(0.8rem, 3.5vw, 0.9rem) !important;
    }
}

/* Extra small devices (360px and below) */
@media (max-width: 360px) {
    .lightbox-caption {
        font-size: clamp(0.8rem, 4.5vw, 0.95rem) !important;
        padding: 0 0.5rem;
        line-height: 1.4 !important;
    }
    
    .lightbox-counter {
        font-size: clamp(0.75rem, 4vw, 0.85rem) !important;
    }
    
    .gallery-filter-btn {
        padding: 0.55rem 0.9rem;
        font-size: clamp(0.7rem, 3.5vw, 0.8rem) !important;
    }
    
    .lightbox-info {
        padding: 0 0.25rem;
    }
}

