@keyframes fadeInSlow {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes deluxeGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.gallery-section {
    padding: 5rem 2rem;
    background: linear-gradient(135deg, #0f0f1e 0%, #1a1a2e 50%, #2d2d44 100%);
    content-visibility: auto;
    contain-intrinsic-size: auto 800px;
    position: relative;
    overflow: hidden;
    animation: fadeInSlow 0.8s ease-out forwards;
    opacity: 1;
}

.gallery-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 50%, rgba(212, 175, 55, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(212, 175, 55, 0.12) 0%, transparent 50%);
    pointer-events: none;
    animation: deluxeGradient 8s ease infinite;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(212, 175, 55, 0.2);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95) 0%, rgba(45, 45, 68, 0.95) 100%);
    aspect-ratio: 4/3;
    border: 2px solid rgba(212, 175, 55, 0.3);
    animation: fadeInSlow 0.8s ease-out forwards;
    opacity: 1;
}

/* Staggered animation delays for all gallery items */
.gallery-item:nth-child(1) { animation-delay: 0.1s; }
.gallery-item:nth-child(2) { animation-delay: 0.15s; }
.gallery-item:nth-child(3) { animation-delay: 0.2s; }
.gallery-item:nth-child(4) { animation-delay: 0.25s; }
.gallery-item:nth-child(5) { animation-delay: 0.3s; }
.gallery-item:nth-child(6) { animation-delay: 0.35s; }
.gallery-item:nth-child(7) { animation-delay: 0.4s; }
.gallery-item:nth-child(8) { animation-delay: 0.45s; }
.gallery-item:nth-child(9) { animation-delay: 0.5s; }
.gallery-item:nth-child(10) { animation-delay: 0.55s; }
.gallery-item:nth-child(11) { animation-delay: 0.6s; }
.gallery-item:nth-child(12) { animation-delay: 0.65s; }
.gallery-item:nth-child(13) { animation-delay: 0.7s; }
.gallery-item:nth-child(14) { animation-delay: 0.75s; }
.gallery-item:nth-child(15) { animation-delay: 0.8s; }
.gallery-item:nth-child(16) { animation-delay: 0.85s; }

.gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1) 0%, rgba(255, 193, 7, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
    pointer-events: none;
}

.gallery-item:hover::before {
    opacity: 1;
}

.gallery-item:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 50px rgba(0,0,0,0.25), 0 0 30px rgba(212, 175, 55, 0.4);
    border-color: rgba(212, 175, 55, 0.5);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: block;
    position: relative;
    z-index: 0;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.zoom-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: linear-gradient(135deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.8) 100%);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    opacity: 0;
    transition: all 0.4s ease;
    z-index: 2;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
}

.gallery-item:hover .zoom-hint {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Fullscreen Modal */
.fullscreen-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    cursor: zoom-out;
    overflow: auto;
    backdrop-filter: blur(3px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fullscreen-modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.fullscreen-img {
    max-width: 95%;
    max-height: 90vh;
    object-fit: contain;
    cursor: zoom-in;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin: auto;
    display: block;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Image transition animations */
.fullscreen-img.fade-in {
    animation: fadeInImage 0.3s ease;
}

.fullscreen-img.slide-left {
    animation: slideLeft 0.3s ease-out;
}

.fullscreen-img.slide-right {
    animation: slideRight 0.3s ease-out;
}

@keyframes fadeInImage {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideLeft {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideRight {
    from {
        transform: translateX(-100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Prevent zoom/transform interference during slide animation */
.fullscreen-img.slide-left,
.fullscreen-img.slide-right {
    transition: none !important;
}

.close-btn {
    position: fixed;
    top: 30px;
    right: 40px;
    color: white;
    font-size: 45px;
    font-weight: 300;
    cursor: pointer;
    z-index: 10000;
    background: linear-gradient(135deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.5) 100%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.close-btn:hover {
    background: linear-gradient(135deg, rgba(255,107,107,0.9) 0%, rgba(238,90,111,0.9) 100%);
    transform: rotate(90deg) scale(1.1);
    border-color: rgba(255,255,255,0.4);
}

/* Navigation Buttons – strelice za premotavanje, tačno u centru kruga */
.nav-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 60px;
    font-weight: 300;
    cursor: pointer;
    z-index: 10000;
    background: linear-gradient(135deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.5) 100%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    user-select: none;
    line-height: 0.85;
    text-align: center;
}

.prev-btn {
    left: 40px;
}

.next-btn {
    right: 40px;
}

.nav-btn:hover {
    background: linear-gradient(135deg, rgba(15,15,30,0.95) 0%, rgba(26,26,46,0.95) 50%, rgba(45,45,68,0.95) 100%);
    transform: translateY(-50%) scale(1.15);
    border-color: rgba(212,175,55,0.6);
    box-shadow: 0 6px 30px rgba(212,175,55,0.4), 0 0 20px rgba(212,175,55,0.2);
    color: #e8c547;
}

.nav-btn:active {
    transform: translateY(-50%) scale(1.05);
}

.zoom-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    z-index: 10000;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.05) 100%);
    padding: 1rem;
    border-radius: 50px;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.2);
}

.zoom-btn {
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.9) 100%);
    border: none;
    padding: 1rem 1.8rem;
    font-size: 1.8rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s ease;
    color: #1a1a2e;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(0,0,0,0.3);
    color: #667eea;
}

.zoom-btn:active {
    transform: translateY(-1px) scale(0.95);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.8rem;
    }
}

@media (max-width: 768px) {
    .gallery-section {
        padding: 3rem 1rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1.5rem;
        margin-top: 2rem;
    }

    .gallery-item {
        border-radius: 15px;
    }

    .zoom-hint {
        font-size: 0.85rem;
        padding: 0.7rem 1.2rem;
        bottom: 15px;
    }

    .close-btn {
        top: 15px;
        right: 20px;
        font-size: 35px;
        width: 50px;
        height: 50px;
    }

    .nav-btn {
        width: 55px;
        height: 55px;
        font-size: 45px;
    }

    .prev-btn {
        left: 15px;
    }

    .next-btn {
        right: 15px;
    }

    .zoom-controls {
        bottom: 25px;
        flex-direction: row;
        gap: 0.8rem;
        padding: 0.8rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .zoom-btn {
        padding: 0.9rem 1.4rem;
        font-size: 1.4rem;
        min-width: 50px;
    }

    .fullscreen-img {
        max-width: 98%;
        max-height: 85vh;
    }
}

@media (max-width: 480px) {
    .gallery-section {
        padding: 2rem 0.8rem;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 1.2rem;
        margin-top: 1.5rem;
    }

    .gallery-item {
        border-radius: 12px;
        aspect-ratio: 4/3;
    }

    .zoom-hint {
        font-size: 0.8rem;
        padding: 0.6rem 1rem;
        bottom: 10px;
    }

    .close-btn {
        top: 10px;
        right: 15px;
        font-size: 30px;
        width: 45px;
        height: 45px;
    }

    .nav-btn {
        width: 50px;
        height: 50px;
        font-size: 40px;
    }

    .prev-btn {
        left: 10px;
    }

    .next-btn {
        right: 10px;
    }

    .zoom-controls {
        bottom: 10px;
        gap: 0.6rem;
        padding: 0.6rem;
        border-radius: 40px;
    }

    .zoom-btn {
        padding: 0.7rem 1.2rem;
        font-size: 1.2rem;
        min-width: 45px;
        border-radius: 40px;
    }

    .fullscreen-img {
        max-width: 100%;
        max-height: 80vh;
        border-radius: 8px;
    }
}

/* Landscape orientation for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .fullscreen-img {
        max-height: 90vh;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .gallery-item:hover {
        transform: none;
    }

    .gallery-item:active {
        transform: scale(0.98);
    }

    .zoom-btn {
        min-width: 48px;
        min-height: 48px;
    }

    .close-btn {
        min-width: 48px;
        min-height: 48px;
    }
}

/* Mobile performance: stop infinite animations and blur */
@media (max-width: 1024px) {
    .gallery-section::before {
        animation: none !important;
    }
    .close-btn,
    .nav-btn,
    .zoom-controls {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    .fullscreen-modal {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
}
