/* =========================================
   Responsive Media Queries
   ========================================= */

/* Hide mobile elements on desktop by default */
.mobile-close-btn {
    display: none;
}

@media (max-width: 992px) {
    :root {
        --font-size-4xl: 2.5rem;
        --font-size-3xl: 2rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    /* Tablet Portrait Navigation Layout Optimization */
    .nav-bar .container {
        justify-content: space-between;
        gap: 20px;
    }

    .main-nav ul {
        gap: 10px; /* Reduced to fit unwrapped text */
        flex-wrap: nowrap;
    }

    .main-nav ul li a.nav-link {
        white-space: nowrap;
        padding: 0 6px; /* Slightly adjust horizontal padding to prevent crowding */
    }
}

@media (max-width: 768px) {
    html,
    body {
        margin: 0;
        padding: 0;
        overflow-x: hidden;
    }

    html {
        min-height: 100%;
    }

    body {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .site-header {
        position: sticky;
        top: 0;
    }

    main {
        flex: 1 0 auto;
        height: auto !important;
        margin-top: 0;
        min-height: auto !important;
        padding-top: 0;
        padding-bottom: 0;
        overflow-x: hidden;
    }

    /* Mobile Menu Button - White Icon */
    .mobile-menu-btn {
        display: block;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0 1rem;
        z-index: 1001;
    }

    .mobile-menu-btn .bar {
        display: block;
        width: 25px;
        height: 3px;
        margin: 5px auto;
        transition: all 0.3s ease-in-out;
        background-color: #ffffff !important;
        /* Force White Icon */
    }

    /* Active Animation for Hamburger */
    .mobile-menu-btn.active .bar:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-btn.active .bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .mobile-menu-btn.active .bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    /* Mobile Navigation Container */
    .main-nav {
        display: none;
        /* Hidden by default */
        position: absolute;
        top: 100%;
        /* Below nav bar */
        left: 0;
        width: 100%;
        /* Fix Height Issue */
        height: auto !important;
        min-height: 50vh;
        max-height: 90vh;
        overflow-y: auto;

        background-color: var(--color-primary);
        /* Navy BG */
        padding: 0 0 20px 0;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 9999;
    }

    .main-nav.active {
        display: block;
        /* Show when toggled */
    }

    .mobile-close-btn {
        display: block;
        position: absolute;
        top: 15px;
        right: 20px;
        background: transparent;
        border: none;
        color: #ffffff;
        font-size: 2.5rem;
        cursor: pointer;
        z-index: 10000;
        line-height: 1;
        padding: 0;
    }

    .main-nav ul {
        flex-direction: column;
        gap: 0;
        width: 100%;
        height: auto;
        padding-top: 50px;
        /* Reset desktop 100% */
    }

    .nav-item {
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        display: block;
        /* Fix side-by-side mobile layout */
    }

    .nav-link {
        color: #ffffff !important;
        /* White Text */
        padding: 15px 20px;
        display: block;
        width: 100%;
        font-size: 1rem;
    }

    /* Mobile Dropdown (Stacked) */
    .main-nav .dropdown {
        position: static !important;
        /* Stacked naturally */
        float: none !important;
        display: none;
        /* Hidden until clicked */
        width: 100% !important;
        min-width: 100%;
        box-shadow: none !important;
        /* No shadow inside menu */
        border: none !important;
        border-radius: 0 !important;
        background-color: rgba(255, 255, 255, 0.05) !important;
        /* Slightly different background */
        border-left: 3px solid var(--color-secondary) !important;
        /* Subtle border to distinguish nesting */
        padding: 0;
    }

    .main-nav .nav-item.open > .dropdown {
        display: block !important;
        /* Show via JS class */
    }

    .main-nav .dropdown li a {
        padding-left: 40px !important;
        /* Indent sub-items */
        color: #ddd !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    }

    .main-nav .dropdown li a:hover {
        background-color: rgba(255, 255, 255, 0.05) !important;
        color: #fff !important;
    }

    /* Hero Buttons - Mobile Uniformity */
    .hero-actions {
        flex-direction: column;
        width: 100%;
        gap: 15px !important;
    }

    .hero-actions .btn {
        width: 100%;
        display: flex;
        justify-content: center;
        margin: 0 !important;
        /* Override inline styles */
    }

    /* Registration upload controls */
    .file-upload-wrapper {
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }

    .file-upload-wrapper > div[style*="inline-flex"] {
        display: flex !important;
        flex-direction: column;
        align-items: center !important;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        gap: 12px !important;
    }

    .file-upload-wrapper .btn {
        flex: 0 0 auto;
        max-width: 100%;
        justify-content: center;
        white-space: nowrap;
    }

    .file-upload-wrapper span[id$="FileName"] {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0 !important;
        max-width: 100%;
        overflow: visible;
        overflow-wrap: anywhere;
        text-align: center !important;
        text-overflow: clip;
        white-space: normal;
    }

    .file-upload-wrapper span[id$="FileName"]::before {
        content: "Selected file:";
        display: block;
        margin-bottom: 4px;
        font-style: normal;
        font-weight: 600;
    }

    /* Fix for iOS Safari background-attachment bug causing extreme zoom and white gaps */
    .hero {
        background-attachment: scroll !important;
        background-position: center center !important;
        background-repeat: no-repeat !important;
        background-size: cover !important;
        min-height: 0 !important;
        margin: 0 !important;
    }

    /* Mobile Footer Optimization */
    .site-footer {
        flex-shrink: 0;
        margin: 0 !important;
        padding: 2.5rem 0 1.5rem !important;
    }

    .footer-description {
        font-size: 0.95rem;
        line-height: 1.45;
        text-align: left;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 1.5rem !important;
        margin-bottom: 1rem !important;
    }

    .footer-col:first-child {
        grid-column: 1 / -1 !important;
        margin-bottom: 1rem !important;
    }

    .footer-col h4 {
        margin-bottom: 0.75rem !important;
    }

    .footer-links li {
        margin-bottom: 0.5rem !important;
    }

    /* Mobile Horizontal Scroll Container Fixes */
    .horizontal-scroll-container > .card {
        min-width: 250px !important;
        padding: 20px !important;
    }
    .horizontal-scroll-container > .card h3 {
        font-size: 1.25rem !important;
        margin-bottom: 10px !important;
    }
    .horizontal-scroll-container > .card p {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
    }
    .horizontal-scroll-container > .card i {
        font-size: 1.5rem !important;
        margin-bottom: 10px !important;
    }
}
