/* Animated Gradient Background */
.animated-gradient {
    background: linear-gradient(-45deg, #87CEEB, #FFFFFF, #87CEEB, #FFFFFF, #87CEEB);
    background-size: 400% 400%;
    animation: gradient-animation 20s ease infinite;
}

@keyframes gradient-animation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Header Container */
header {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Compact header on mobile */
header .container {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

@media (min-width: 768px) {
    header .container {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
}

/* Navigation Styles */
nav {
    display: flex;
    align-items: center;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-button {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    transition: all 0.3s ease;
    font-weight: 600;
}

/* Hover Effects */
.nav-link:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.nav-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Logo Styles */
.logo-image {
    width: 4rem;
    height: auto;
    transition: all 0.3s ease;
}

@media (min-width: 640px) {
    .logo-image {
        width: 5rem;
    }
}

@media (min-width: 768px) {
    .logo-image {
        width: 7rem;
    }
}

/* Smaller logo on very small screens */
@media (max-width: 360px) {
    .logo-image {
        width: 3.5rem;
    }
}

/* Mobile Menu Button */
#mobileBtn {
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    display: none;
    position: relative;
    z-index: 51;
    cursor: pointer;
    border: none;
    background-color: #f1f5f9;
}

#mobileBtn:hover {
    background-color: #e2e8f0;
}

#mobileBtn.active {
    background-color: #e2e8f0;
}

/* Mobile Navigation */
#mobileNav {
    width: 100%;
    position: absolute;
    top: 100%;
    left: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    z-index: 50;
    overflow: hidden;
    /* Limit height on mobile */
    max-height: 0;
}

/* Mobile Nav States */
.mobile-nav-closed {
    opacity: 0;
    transform: translateY(-10px);
    visibility: hidden;
    pointer-events: none;
    max-height: 0 !important;
}

.mobile-nav-open {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
    max-height: calc(100vh - 80px) !important;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Mobile Menu Items */
#mobileNav nav {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.4rem;
}

#mobileNav a {
    padding: 0.6rem 0.875rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #334155;
    font-size: 0.95rem;
    white-space: nowrap;
}

#mobileNav a:hover {
    background-color: #eff6ff;
    color: #2563eb;
}

/* Compact mobile menu for small screens */
@media (max-height: 600px) {
    #mobileNav nav {
        padding: 0.5rem;
        gap: 0.25rem;
    }
    
    #mobileNav a {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* Extra compact for very small screens */
@media (max-height: 500px) {
    #mobileNav nav {
        padding: 0.4rem;
        gap: 0.2rem;
    }
    
    #mobileNav a {
        padding: 0.4rem 0.6rem;
        font-size: 0.813rem;
    }
    
    .mobile-nav-open {
        max-height: calc(100vh - 60px) !important;
    }
}

/* Hamburger/Close Icon */
#menuIcon {
    width: 24px;
    height: 24px;
    transition: all 0.2s ease;
}

#menuIcon path {
    transition: opacity 0.2s ease;
}

#menuIcon .hidden {
    display: none;
}

/* Responsive Navigation - CRITICAL */
@media (max-width: 767px) {
    #mobileBtn {
        display: block !important;
    }
    
    /* Hide desktop menu on mobile */
    header nav.hidden {
        display: none !important;
    }
}

@media (min-width: 768px) {
    /* Show desktop menu */
    .md\:flex {
        display: flex !important;
    }
    
    /* Hide mobile elements on desktop */
    #mobileBtn {
        display: none !important;
    }
    
    #mobileNav {
        display: none !important;
    }
}

/* Container Padding */
@media (min-width: 640px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 768px) {
    .container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Quiz Form Styles */
#quizForm {
    margin-top: 1rem;
}

#nameInput {
    width: 100%;
    max-width: 300px;
    border-color: #e5e7eb;
}

#quizForm button {
    width: 100%;
    max-width: 300px;
}

/* Prevent body scroll when mobile menu is open */
body.mobile-menu-open {
    overflow: hidden;
}

/* Ensure proper stacking context */
header * {
    box-sizing: border-box;
}

/* Add smooth transition for all interactive elements */
button, a {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Custom scrollbar for mobile menu */
#mobileNav::-webkit-scrollbar {
    width: 6px;
}

#mobileNav::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

#mobileNav::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

#mobileNav::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Smooth scrolling behavior */
#mobileNav {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Add fade effect at bottom of menu when scrolling */
#mobileNav::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(transparent, rgba(255, 255, 255, 0.9));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#mobileNav.mobile-nav-open::after {
    opacity: 1;
}