/**
 * Photo Gallery Images component
 */

/* Gallery Wrapper */
.photo-gallery-wrapper {
    width: 100%;
}

/* Gallery Grid */
.photo-gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--photo-gallery-gap);
    align-items: center;
    justify-content: center;
}

/* Grid Column Variations */
.photo-gallery-cols-2 .photo-gallery-item {
    flex: 0 0 calc(50% - (var(--photo-gallery-gap) / 2));
    max-width: calc(50% - (var(--photo-gallery-gap) / 2));
}

.photo-gallery-cols-3 .photo-gallery-item {
    flex: 0 0 calc(33.333% - (var(--photo-gallery-gap) * 2 / 3));
    max-width: calc(33.333% - (var(--photo-gallery-gap) * 2 / 3));
}

.photo-gallery-cols-4 .photo-gallery-item {
    flex: 0 0 calc(25% - (var(--photo-gallery-gap) * 3 / 4));
    max-width: calc(25% - (var(--photo-gallery-gap) * 3 / 4));
}

.photo-gallery-cols-5 .photo-gallery-item {
    flex: 0 0 calc(20% - (var(--photo-gallery-gap) * 4 / 5));
    max-width: calc(20% - (var(--photo-gallery-gap) * 4 / 5));
}

/* Gallery Item */
.photo-gallery-item {
    position: relative;
    overflow: hidden;
    background-color: #f0f0f0;
}

/* Aspect Ratio Control */
.photo-gallery-ratio-original .photo-gallery-item {
    height: auto;
}

.photo-gallery-ratio-1-1 .photo-gallery-item {
    aspect-ratio: 1 / 1;
}

.photo-gallery-ratio-4-3 .photo-gallery-item {
    aspect-ratio: 4 / 3;
}

.photo-gallery-ratio-3-2 .photo-gallery-item {
    aspect-ratio: 3 / 2;
}

.photo-gallery-ratio-16-9 .photo-gallery-item {
    aspect-ratio: 16 / 9;
}

/* Gallery Link/Image Container */
.photo-gallery-link,
.photo-gallery-image {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.photo-gallery-link {
    cursor: pointer;
}

/* Images */
.photo-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease, filter 0.3s ease;
}

/* Hover Effects */
.photo-gallery-link:hover img {
    transform: scale(1.05);
}

.photo-gallery-link:focus img {
    transform: scale(1.05);
}

/* Overlay */
.photo-gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.photo-gallery-link:hover .photo-gallery-overlay,
.photo-gallery-link:focus .photo-gallery-overlay {
    opacity: 1;
}

.photo-gallery-overlay i {
    color: #ffffff;
    font-size: 32px;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.photo-gallery-link:hover .photo-gallery-overlay i,
.photo-gallery-link:focus .photo-gallery-overlay i {
    transform: scale(1);
}

/* Responsive Styles */

/* Tablets */
@media (max-width: 1200px) {
    .photo-gallery-cols-4 .photo-gallery-item,
    .photo-gallery-cols-5 .photo-gallery-item {
        flex: 0 0 calc(33.333% - (var(--photo-gallery-gap) * 2 / 3));
        max-width: calc(33.333% - (var(--photo-gallery-gap) * 2 / 3));
    }
}

@media (max-width: 992px) {
    .photo-gallery-cols-3 .photo-gallery-item,
    .photo-gallery-cols-4 .photo-gallery-item,
    .photo-gallery-cols-5 .photo-gallery-item {
        flex: 0 0 calc(50% - (var(--photo-gallery-gap) / 2));
        max-width: calc(50% - (var(--photo-gallery-gap) / 2));
    }
}

/* Mobile */
@media (max-width: 768px) {
    .photo-gallery-cols-2 .photo-gallery-item,
    .photo-gallery-cols-3 .photo-gallery-item,
    .photo-gallery-cols-4 .photo-gallery-item,
    .photo-gallery-cols-5 .photo-gallery-item {
        flex: 0 0 calc(50% - (var(--photo-gallery-gap) / 2));
        max-width: calc(50% - (var(--photo-gallery-gap) / 2));
    }
}

@media (max-width: 480px) {
    .photo-gallery-cols-2 .photo-gallery-item,
    .photo-gallery-cols-3 .photo-gallery-item,
    .photo-gallery-cols-4 .photo-gallery-item,
    .photo-gallery-cols-5 .photo-gallery-item {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Lightbox Styles */
.photo-gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.photo-gallery-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.photo-gallery-lightbox-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.photo-gallery-lightbox-title {
    color: #ffffff;
    font-size: 18px;
    margin-top: 20px;
    text-align: center;
    max-width: 100%;
}

.photo-gallery-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 40px;
    cursor: pointer;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    z-index: 100000;
}

.photo-gallery-lightbox-close:hover {
    transform: scale(1.1);
}

.photo-gallery-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: #ffffff;
    font-size: 32px;
    cursor: pointer;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.photo-gallery-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.05);
}

.photo-gallery-lightbox-nav.prev {
    left: 20px;
}

.photo-gallery-lightbox-nav.next {
    right: 20px;
}

.photo-gallery-lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.photo-gallery-lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #ffffff;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
}

/* Accessibility */
.photo-gallery-link:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: -2px;
}

.photo-gallery-lightbox-close:focus-visible,
.photo-gallery-lightbox-nav:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 4px;
}

/* Loading State */
.photo-gallery-item.loading {
    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;
    }
}

/* Print styles */
@media print {
    .photo-gallery-overlay,
    .photo-gallery-lightbox {
        display: none !important;
    }
    
    .photo-gallery-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .photo-gallery-item {
        break-inside: avoid;
    }
}
