/* Reset body and remove margin */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

/* Background container */
.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    display: flex; /* Align videos side by side */
    justify-content: center; /* Center the main video */
    align-items: center;
}

/* Main background video */
.background-video {
    position: absolute;
    height: 150%; /* Extended height for vertical movement */
    width: auto;
    z-index: -1; /* Ensure it stays behind foreground elements */
    animation: moveVertical 10s infinite alternate; /* Vertical movement animation */
}

/* Fallback image inside video */
.background-video img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
}

/* Left replicated video */
.background-video.left {
    position: absolute;
    transform: translateX(-100%); /* Shift fully to the left */
    height: 150%;
    width: auto;
    z-index: -1; /* Match z-index of main video */
    animation: moveVertical 10s infinite alternate; /* Match the animation for consistency */
}

/* Right replicated video */
.background-video.right {
    position: absolute;
    transform: translateX(100%); /* Shift fully to the right */
    height: 150%;
    width: auto;
    z-index: -1; /* Match z-index of main video */
    animation: moveVertical 10s infinite alternate; /* Match the animation for consistency */
}

/* Vertical movement animation for video */
@keyframes moveVertical {
    0% {
        top: -25%; /* Start slightly above the view */
    }
    100% {
        top: 0%; /* Move fully into view */
    }
}

/* Shared text styles */
.header-text, .center-text, .bottom-text {
    position: fixed;
    width: 100%;
    text-align: center;
    font-size: 5rem; /* Increased font size */
    font-family: 'Great Vibes', cursive; /* Elegant font family */
    color: white;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.7);
    opacity: 0; /* Initially hidden */
    animation: fadeInDown 2s forwards; /* Smooth fade-in animation */
}

/* Top text */
.header-text {
    top: 20px;
}

/* Center text */
.center-text {
    top: 50%;
    transform: translateY(-50%);
    animation-delay: 1s; /* Delay the animation slightly */
}

/* Bottom text */
.bottom-text {
    bottom: 20px;
    animation-delay: 2s; /* Delay the animation further */
}

/* Foreground container */
.foreground {
    display: flex;
    justify-content: center; /* Center items horizontally */
    align-items: center; /* Center items vertically */
    gap: 10px; /* Adjust the gap between the flags */
    height: auto; /* Adjust height to fit content */
    opacity: 0; /* Initially hidden */
    animation: fadeInUp 2s forwards; /* Flag animation */
    animation-delay: 3s; /* Delay flags until after text appears */
}

/* First row of flags */
.first-row {
    position: fixed;
    top: calc(50% - 120px); /* Increase space between header-text and center-text */
    transform: translateY(-50%);
    width: 100%; /* Ensure it takes full width */
}

/* Second row of flags */
.second-row {
    position: fixed;
    top: calc(50% + 120px); /* Increase space between center-text and bottom-text */
    transform: translateY(-50%);
    width: 100%; /* Ensure it takes full width */
}

/* Flag and label container */
.flag-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* Center items vertically */
    position: relative;
    text-align: center;
    opacity: 0; /* Initially hidden */
    animation: fadeInFlag 1s forwards;
}

/* Delay flags individually */
.flag-container:nth-child(1) {
    animation-delay: 3.5s;
}

.flag-container:nth-child(2) {
    animation-delay: 4s;
}

.flag-container:nth-child(3) {
    animation-delay: 4.5s;
}

.flag-container:nth-child(4) {
    animation-delay: 5s;
}

.flag {
    width: 150px;
    height: auto;
    opacity: 0.5;
    transition: transform 0.3s, opacity 0.3s;
    cursor: pointer;
}

.flag:hover {
    transform: scale(1.1);
    opacity: 1;
}

/* Flag labels */
.flag-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-family: 'Great Vibes', cursive; /* Elegant font family */
    color: white;
    text-shadow: 1px 1px 6px rgba(0, 0, 0, 0.8);
    pointer-events: none; /* Ignore clicks on the label */
}

/* Fade-in animation for the header, center, and bottom text */
@keyframes fadeInDown {
    0% {
        opacity: 0;
        transform: translateY(-50px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade-in animation for the flags and flag containers */
@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(50px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade-in animation for the flags */
@keyframes fadeInFlag {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Media queries for responsive design */
@media (max-width: 768px) {
    .header-text, .center-text, .bottom-text {
        font-size: 3rem; /* Smaller font size for mobile */
    }

    .flag {
        width: 100px; /* Smaller flag size for mobile */
    }

    .foreground {
        grid-template-columns: repeat(2, 1fr); /* Maintain 2x2 grid on mobile */
        grid-gap: 10px;
    }

    .flag-container {
        margin-bottom: 10px; /* Add margin between flag containers */
    }

    .first-row {
        top: calc(50% - 60px); /* Adjust position for mobile */
    }

    .second-row {
        top: calc(50% + 60px); /* Adjust position for mobile */
    }
}

@media (max-width: 480px) {
    .header-text, .center-text, .bottom-text {
        font-size: 2rem; /* Smaller font size for very small screens */
    }

    .flag {
        width: 80px; /* Smaller flag size for very small screens */
    }

    .foreground {
        grid-template-columns: repeat(2, 1fr); /* Maintain 2x2 grid on very small screens */
        grid-gap: 5px;
    }

    .flag-container {
        margin-bottom: 5px; /* Add margin between flag containers */
    }

    .first-row {
        top: calc(50% - 50px); /* Adjust position for very small screens */
    }

    .second-row {
        top: calc(50% + 50px); /* Adjust position for very small screens */
    }
}