@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-20px);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
    }

    50% {
        box-shadow: 0 0 40px rgba(139, 92, 246, 0.8);
    }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-fadeInUp {
    animation: fadeInUp 0.8s ease-out forwards;
}

.animate-slideInLeft {
    animation: slideInLeft 0.8s ease-out forwards;
}

.animate-slideInRight {
    animation: slideInRight 0.8s ease-out forwards;
}

.animate-pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Prevent horizontal scroll globally */
html, body {
    overflow-x: hidden;
}

.gradient-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-effect {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-x: hidden;
}

.modal.active {
    display: flex;
    opacity: 1;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-sizing: border-box;
}

.modal-content {
    margin: auto;
    max-width: 90%;
    max-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    transform: scale(0.7);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.modal.active .modal-content {
    transform: scale(1);
}

/* Gallery grid inside modal: improved layout, internal scrolling and responsive columns */
.modal .modal-content {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 20px 60px rgba(2, 6, 23, 0.6);
    backdrop-filter: blur(6px);
}

#galleryGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    padding: 0.5rem;
    align-content: start;
    overflow: auto; /* scroll only inside grid */
    max-height: calc(80vh - 4rem);
}

#galleryGrid .gallery-item {
    overflow: hidden;
    border-radius: 0.5rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.02));
    display: block;
}

#galleryGrid img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
    transition: transform 0.35s ease;
}

#galleryGrid img:hover {
    transform: scale(1.03) translateY(-4px);
}

/* Prevent horizontal scroll inside the gallery grid */
#galleryGrid { overflow-x: hidden; }

/* Single-image gallery adjustments */
#galleryGrid.single-item {
    grid-template-columns: 1fr;
    max-width: 920px;
    margin: 0 auto;
}

#galleryGrid.single-item .gallery-item {
    max-width: 840px;
    margin: 0 auto;
}

#galleryGrid.single-item img {
    width: auto;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.modal .modal-content.single-image {
    max-width: 960px;
}

/* Certification modal: center the image and constrain its size */
#certificationModal .modal-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#certificationModal img {
    max-width: min(90vw, 1200px);
    max-height: calc(100vh - 6rem);
    width: auto;
    height: auto;
    object-fit: contain;
}

nav {
    transition: all 0.3s ease;
}

nav.scrolled {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
    border: 3px solid white;
    box-shadow: 0 0 0 3px #667eea;
}

.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

/* Responsive adjustments for small screens */
@media (max-width: 768px) {
    .modal {
        padding: 1rem;
    }

    .modal-content {
        max-width: 95%;
        max-height: calc(100vh - 2rem);
        padding: 0.75rem;
    }

    /* Gallery grid fewer columns and smaller gaps on mobile */
    #galleryGrid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    #galleryGrid img {
        max-height: 30vh;
    }

    /* Make the close button easier to tap */
    .modal > button {
        top: 0.75rem;
        right: 0.75rem;
        font-size: 2rem;
        padding: 0.25rem 0.5rem;
    }
}

@media (max-width: 420px) {
    /* Single column gallery on very small screens */
    #galleryGrid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    #galleryGrid img {
        max-height: 28vh;
    }

    /* Certification modal: keep large image constrained */
    #certificationModal .modal-content {
        padding: 0.5rem;
    }

    #certificationModal img {
        max-width: 100%;
        max-height: calc(100vh - 3.5rem);
    }
}
