/* Reset and Base Styles - Enhanced Modern Version */
:root {
    --primary-blue: #004282;
    --primary-dark: #002b58;
    --primary-orange: #ee7d20;
    --accent-orange: #ff9b4e;
    --secondary-blue: #667eea;
    --text-dark: #1a1a1a;
    --text-light: #4a5568;
    --bg-light: #ffffff;
    --bg-alt: #f8fafc;
    --border-color: #e2e8f0;
    --shadow-sm: 0 2px 8px rgba(0, 66, 130, 0.06);
    --shadow-md: 0 4px 20px rgba(0, 66, 130, 0.1);
    --shadow-lg: 0 20px 40px rgba(0, 66, 130, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-fast: 0.2s ease;
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 90px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Khmer', sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--bg-light);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* Header Styles - Enhanced with JS Integration */
header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    background-color: rgba(0, 66, 130, 0.98);
    transition: all var(--transition-base);
}

header.scrolled {
    background-color: rgba(0, 66, 130, 0.95);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    min-height: 70px;
    position: relative;
}

.logo-section h1 {
    font-size: 1.5rem;
    color: #fff;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex-shrink: 0;
}

.logo-section .logo {
    height: 45px;
    width: auto;
    transition: transform var(--transition-base);
}

.logo-section .logo:hover {
    transform: scale(1.05);
}

/* Navigation - Enhanced for Mobile Menu */
nav {
    transition: all var(--transition-slow);
}

nav ul {
    display: flex;
    gap: 1.75rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

nav a {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 0;
    position: relative;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
}

nav a:hover,
nav a:focus {
    color: #ffffff;
    outline: none;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-orange) 0%, var(--accent-orange) 100%);
    transition: width var(--transition-base);
    border-radius: 1px;
}

nav a:hover::after,
nav a:focus::after {
    width: 100%;
}

/* Active navigation link */
nav a.active {
    color: var(--primary-orange);
    font-weight: 600;
}

nav a.active::after {
    width: 100%;
    background: var(--primary-orange);
}

.mobile-only {
    display: none;
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
}

/* Hamburger Menu - Enhanced Animation */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
    width: 48px;
    height: 48px;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    background: rgba(255, 255, 255, 0.1);
    position: relative;
}

.hamburger:hover,
.hamburger:focus {
    background: rgba(255, 255, 255, 0.15);
    outline: 2px solid rgba(255, 255, 255, 0.3);
}

.hamburger span {
    width: 24px;
    height: 2px;
    background: #ffffff;
    border-radius: 2px;
    transition: all var(--transition-slow);
    position: relative;
}

.hamburger.active {
    background: rgba(255, 255, 255, 0.2);
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
    width: 24px;
    background: var(--primary-blue);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
    width: 24px;
    background: var(--primary-blue);
}

/* Main Content */
main {
    background: var(--bg-light);
    min-height: calc(100vh - 70px - 250px);
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    padding: 5rem 0;
    scroll-margin-top: 90px;
    opacity: 0;
    transform: translateY(20px);
    animation: slideUp 0.6s ease-out forwards;
}

.section.visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes slideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section:nth-child(even) {
    background: var(--bg-alt);
}

.section h2 {
    color: var(--primary-blue);
    margin-bottom: 2rem;
    font-size: 2.5rem;
    font-weight: 800;
    text-align: center;
    position: relative;
    padding-bottom: 1rem;
    letter-spacing: -0.5px;
}

.section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-orange) 0%, var(--accent-orange) 100%);
    border-radius: 2px;
}

.section p {
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
    color: var(--text-light);
    line-height: 1.7;
    text-align: center;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Hero Section - Enhanced with Dynamic Elements */
.hero {
    color: white;
    text-align: center;
    padding: 0;
    position: relative;
    overflow: hidden;
    min-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 30%, rgba(238, 125, 32, 0.2) 0%, transparent 50%),
                radial-gradient(circle at 80% 70%, rgba(102, 126, 234, 0.15) 0%, transparent 50%);
    pointer-events: none;
    animation: pulse 8s ease-in-out infinite alternate;
}

@keyframes pulse {
    0% {
        opacity: 0.7;
        transform: scale(1);
    }
    100% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Slider Styles */
.slider {
    position: relative;
    width: 100%;
    height: 90vh;
    overflow: hidden;
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s ease, visibility 0.6s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide.active {
    opacity: 1;
    visibility: visible;
}

.slide::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 66, 130, 0.85) 0%, rgba(0, 43, 88, 0.9) 100%);
    z-index: 1;
}

.slide .container {
    position: relative;
    z-index: 2;
    max-width: 900px;
    padding: 2rem 1rem;
}

.slider-controls {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 10;
}

.slider-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.slider-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.slider-dots {
    display: flex;
    gap: 0.5rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
}

.dot.active {
    background: white;
    transform: scale(1.2);
}

.dot:hover {
    background: rgba(255, 255, 255, 0.8);
}

.hero h1 {
    font-size: clamp(2.75rem, 6vw, 4rem);
    margin-bottom: 1.75rem;
    color: white;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #ffffff 0%, #e6fffa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: textGlow 3s ease-in-out infinite alternate;
}

@keyframes textGlow {
    from {
        text-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }
    to {
        text-shadow: 0 4px 30px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.1);
    }
}

.hero p {
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
    margin-bottom: 3rem;
    opacity: 0.95;
    color: rgba(255, 255, 255, 0.95);
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    animation: fadeInUp 1s ease-out 0.3s both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Output Display - Enhanced for JS Integration */
.output {
    margin-top: 2rem;
    padding: 1.75rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: var(--radius-lg);
    text-align: center;
    font-size: 1.1rem;
    color: white;
    min-height: 60px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    animation: slideUp var(--transition-base);
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-base);
}

.output.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: slideIn 0.5s ease-out forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.output::before {
    content: '💡';
    display: block;
    font-size: 2rem;
    margin-bottom: 0.75rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* Feature Cards - Enhanced with Hover Effects */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2.5rem;
    margin-top: 3.5rem;
}

.feature-card {
    background: var(--bg-light);
    padding: 2.5rem 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: all var(--transition-slow);
    position: relative;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transition: height var(--transition-base);
}

.feature-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: var(--shadow-lg), 0 8px 30px rgba(0, 0, 0, 0.08);
    border-color: transparent;
}

.feature-card:hover::before {
    height: 6px;
}

.feature-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.75rem;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.feature-icon::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    transition: transform var(--transition-base);
}

.feature-card:hover .feature-icon {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 8px 25px rgba(0, 66, 130, 0.3);
}

.feature-card:hover .feature-icon::after {
    transform: rotate(45deg) translateX(100%);
}

.feature-icon svg {
    color: #ffffff;
    width: 32px;
    height: 32px;
    z-index: 1;
}

.feature-card h3 {
    color: var(--primary-blue);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 800;
    transition: color var(--transition-base);
}

.feature-card:hover h3 {
    color: var(--primary-dark);
}

.feature-card p {
    color: var(--text-light);
    margin: 0 0 1.75rem 0;
    line-height: 1.6;
    font-size: 1.05rem;
    text-align: left;
    flex-grow: 1;
}

.feature-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-orange);
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    transition: all var(--transition-base);
    padding: 0.75rem 0;
    position: relative;
    align-self: flex-start;
}

.feature-link::after {
    content: '→';
    transition: transform var(--transition-base);
    font-weight: bold;
}

.feature-link:hover {
    gap: 0.875rem;
    color: var(--accent-orange);
    transform: translateX(5px);
}

.feature-link:hover::after {
    transform: translateX(4px) scale(1.2);
}

/* Button Styles - Enhanced */
.btn {
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--accent-orange) 100%);
    color: white;
    border: none;
    padding: 1.125rem 2.75rem;
    font-size: 1.125rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-transform: uppercase;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.75px;
    box-shadow: 0 6px 20px rgba(238, 125, 32, 0.4);
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
    min-width: 160px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.7s ease;
}

.btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 30px rgba(238, 125, 32, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn:hover::before {
    left: 100%;
}

.btn:active {
    transform: translateY(-1px) scale(1.02);
}

.btn:focus {
    outline: 2px solid var(--primary-orange);
    outline-offset: 3px;
}

/* Footer - Enhanced with Social Icons */
footer {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #001a33 100%);
    color: white;
    padding: 4rem 0 2.5rem;
    position: relative;
    overflow: hidden;
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-orange) 0%, var(--accent-orange) 100%);
}

footer .container {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4rem;
    align-items: start;
}

footer h3 {
    color: white;
    margin-bottom: 1.25rem;
    font-size: 1.375rem;
    font-weight: 700;
}

footer a {
    color: #93c5fd;
    text-decoration: none;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0;
}

footer a:hover,
footer a:focus {
    color: #ffffff;
    gap: 1rem;
    transform: translateX(5px);
}

footer a svg {
    flex-shrink: 0;
}

.social {
    margin: 2rem 0;
    display: flex;
    gap: 1.25rem;
}

.social a {
    color: #fff;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.social a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s ease;
}

.social a:hover {
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--accent-orange) 100%);
    transform: translateY(-5px) rotate(5deg);
    box-shadow: 0 10px 25px rgba(238, 125, 32, 0.4);
}

.social a:hover::before {
    left: 100%;
}

.social a svg {
    width: 22px;
    height: 22px;
    z-index: 1;
}

footer > .container > p:first-of-type {
    grid-column: 1 / -1;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
    margin-top: 3rem;
    padding-top: 2.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

footer > .container > hr + p {
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    font-size: 0.9rem;
    grid-column: 1 / -1;
    margin-top: 1.5rem;
}

/* Enhanced Mobile Header - Focused Improvements */

/* ===== MOBILE HEADER OPTIMIZATION ===== */
@media (max-width: 768px) {
    /* Header container optimization */
    header {
        height: 180px;
        background: linear-gradient(135deg, #004282 0%, #002b58 100%);
        box-shadow: 0 4px 20px rgba(0, 66, 130, 0.15);
        backdrop-filter: blur(15px);
        background-color: rgba(0, 66, 130, 0.98);
        transition: all 0.3s ease;
    }

    /* Disable scrolled effect on mobile */
    header.scrolled {
        background: linear-gradient(135deg, #004282 0%, #002b58 100%);
        box-shadow: 0 4px 20px rgba(0, 66, 130, 0.15);
        background-color: rgba(0, 66, 130, 0.98);
    }

    /* Prevent body scroll when menu is open */
    body.menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
        touch-action: none;
        -webkit-overflow-scrolling: none;
    }
    
    /* Prevent any scrolling within the header itself */
    header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        overflow: visible !important;
        -webkit-overflow-scrolling: auto;
        transform: translateZ(0); /* Hardware acceleration */
        backface-visibility: hidden;
    }
    
    /* Ensure content under fixed header doesn't jump */
    main {
        margin-top: 180px; /* Match header height */
    }
    
    /* When menu is active, add overlay and prevent scrolling */
    nav.active {
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translate3d(0, 0, 0);
        will-change: transform;
    }
    
    /* Add overlay when menu is open */
    .nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: 998;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .nav-overlay.active {
        display: block;
        opacity: 1;
    }
    
    /* Disable scrolling on the entire page when menu is open */
    html.menu-open,
    html.menu-open body {
        overflow: hidden;
        height: 100%;
        position: relative;
    }
    
    /* Enhanced mobile header content alignment - Vertical layout */
    .header-content {
        display: grid;
        grid-template-rows: auto auto;
        grid-template-columns: 1fr;
        align-items: center;
        justify-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        height: 180px;
        max-width: 100%;
        margin: 0;
        position: relative;
        box-sizing: border-box;
        -webkit-overflow-scrolling: auto;
    }

    /* Logo section - full width at top */
    .logo-section {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        grid-row: 1;
        margin-bottom: 0.25rem;
        border-bottom: 1.5px solid rgba(255, 255, 255, 0.2);
        padding-bottom: 0.5rem;
    }

    .logo-section .logo {
        height: 150px;
        width: auto;
        max-width: 200px;
        object-fit: contain;
        flex-shrink: 1;
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    }

    .logo-section h1 {
        display: none !important; /* Always hide on mobile */
    }

    /* Register button and hamburger menu - horizontal row below logo */
    .header-actions {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        width: 100%;
        grid-row: 2;
        margin-top: 0.25rem;
        position: relative;
    }

    .header-actions .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.95rem;
        min-width: 120px;
        min-height: 48px;
        background: linear-gradient(135deg, #ee7d20 0%, #ff9b4e 100%);
        border-radius: 24px;
        box-shadow: 0 4px 16px rgba(238, 125, 32, 0.3);
        font-weight: 600;
        letter-spacing: 0.3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .header-actions .btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 5px 18px rgba(238, 125, 32, 0.4);
    }

    /* Hamburger menu - positioned next to register button */
    .hamburger {
        display: flex;
        width: 52px;
        height: 52px;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.15);
        transition: all 0.3s ease;
        position: relative;
        margin: 0;
        flex-shrink: 0;
        justify-content: center;
        align-items: center;
        z-index: 1001;
        transform: translateZ(0);
        backface-visibility: hidden;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .hamburger:hover {
        background: rgba(255, 255, 255, 0.15);
        transform: scale(1.05);
    }

    .hamburger:active {
        transform: scale(0.95);
    }

    .hamburger span {
        width: 24px;
        height: 3px;
        background: white;
        border-radius: 1.5px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        transform-origin: center;
    }

    /* Active state for hamburger */
    .hamburger.active {
        background: rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.3);
    }

    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(4px, 4px);
        width: 20px;
        background: white;
    }

    .hamburger.active span:nth-child(2) {
        opacity: 0;
        transform: translateX(-8px);
    }

    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(4px, -4px);
        width: 20px;
        background: white;
    }

    /* Mobile navigation menu - enhanced */
    nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        max-width: 300px;
        height: 100vh;
        background: linear-gradient(160deg, #ffffff 0%, #f8fafc 100%);
        backdrop-filter: blur(20px);
        box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
        z-index: 999;
        transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 80px 0 2rem 0;
        display: flex;
        flex-direction: column;
        border-left: 1px solid rgba(0, 0, 0, 0.05);
    }

    /* Mobile menu backdrop overlay */
    nav::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: -1;
    }

    nav.active::before {
        opacity: 1;
        visibility: visible;
    }

    /* Menu items styling */
    nav ul {
        flex-direction: column;
        gap: 0;
        padding: 0;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    nav ul li {
        width: 100%;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        transition: background-color 0.2s ease;
    }

    nav ul li:first-child {
        border-top: 1px solid rgba(0, 0, 0, 0.05);
    }

    nav ul li a {
        display: flex;
        align-items: center;
        padding: 1.25rem 2rem;
        color: #2d3748;
        font-size: 1.05rem;
        font-weight: 600;
        transition: all 0.3s ease;
        min-height: 60px;
        position: relative;
        gap: 1rem;
    }

    /* Menu item icons */
    nav ul li a::before {
        content: '';
        width: 24px;
        height: 24px;
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        opacity: 0.7;
        flex-shrink: 0;
    }

    nav ul li:nth-child(1) a::before {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232d3748'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
    }

    nav ul li:nth-child(2) a::before {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232d3748'%3E%3Cpath d='M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z'/%3E%3C/svg%3E");
    }

    nav ul li:nth-child(3) a::before,
    nav ul li:nth-child(4) a::before {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232d3748'%3E%3Cpath d='M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H8V4h12v12z'/%3E%3C/svg%3E");
    }

    nav ul li:nth-child(5) a::before {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232d3748'%3E%3Cpath d='M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z'/%3E%3C/svg%3E");
    }

    nav ul li a:hover {
        background: linear-gradient(90deg, rgba(0, 66, 130, 0.08) 0%, transparent 100%);
        color: #004282;
        padding-left: 2.25rem;
    }

    nav ul li a:hover::before {
        opacity: 1;
        transform: scale(1.1);
    }

    /* Active menu item */
    nav ul li a.active {
        background: linear-gradient(90deg, rgba(0, 66, 130, 0.1) 0%, transparent 100%);
        color: #ee7d20;
        border-left: 4px solid #ee7d20;
        font-weight: 700;
    }

    nav ul li a.active::before {
        opacity: 1;
        filter: brightness(0) saturate(100%) invert(52%) sepia(95%) saturate(1813%) hue-rotate(350deg) brightness(99%) contrast(93%);
    }

    /* Hide regular Library link, show mobile-only */
    nav ul li:has(a[href='library.html']):not(.mobile-only) {
        display: none;
    }

    .mobile-only {
        display: list-item;
    }

    /* Menu footer section */
    nav::after {
        content: '';
        display: block;
        padding: 1.5rem 2rem;
        border-top: 1px solid rgba(0, 0, 0, 0.05);
        margin-top: auto;
    }

    /* Mobile menu contact info */
    .mobile-menu-footer {
        padding: 1.5rem 2rem;
        background: rgba(0, 66, 130, 0.05);
        border-top: 1px solid rgba(0, 0, 0, 0.05);
        margin-top: auto;
        font-size: 0.9rem;
        color: #4a5568;
    }

    .mobile-menu-footer a {
        color: #004282;
        font-weight: 600;
        text-decoration: none;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
}

/* ===== SMALL MOBILE DEVICES ===== */
@media (max-width: 480px) {
    .header-content {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
        grid-template-rows: auto auto;
        grid-template-columns: 1fr;
        justify-items: center;
        height: 160px;
    }

    .logo-section {
        gap: 0.5rem;
    }

    .logo-section .logo {
        height: 100px;
        max-width: 350px;
    }

    .header-actions .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
        min-width: 100px;
        min-height: 44px;
        border-radius: 22px;
    }

    .hamburger {
        width: 48px;
        height: 48px;
        border-radius: 12px;
    }

    .hamburger span {
        width: 22px;
    }

    nav {
        width: 90%;
        max-width: 280px;
    }

    nav ul li a {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        gap: 0.75rem;
    }

    nav ul li a::before {
        width: 20px;
        height: 20px;
    }

    nav ul li a:hover {
        padding-left: 1.75rem;
    }
    
    /* Adjust main margin for smaller header */
    main {
        margin-top: 160px;
    }
    
    /* More aggressive scroll prevention on very small screens */
    body.menu-open {
        overscroll-behavior: none;
    }
    
    .header-content {
        overscroll-behavior: contain;
    }
}

/* ===== EXTRA SMALL DEVICES (360px and below) ===== */
@media (max-width: 360px) {
    .header-content {
        padding: 0.5rem 0.5rem;
        gap: 0.25rem;
        grid-template-rows: auto auto;
        grid-template-columns: 1fr;
        justify-items: center;
        height: 140px;
    }

    .logo-section .logo {
        height: 100px;
        max-width: 140px;
    }

    .header-actions .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        min-width: 90px;
        min-height: 40px;
        border-radius: 20px;
    }

    .hamburger {
        width: 44px;
        height: 44px;
        border-radius: 11px;
    }

    .hamburger span {
        width: 20px;
    }

    nav {
        width: 100%;
        max-width: 100%;
        border-left: none;
    }

    nav ul li a {
        padding: 1rem 1.25rem;
    }
}

/* ===== TABLET OPTIMIZATION (769px - 1024px) ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    .header-content {
        padding: 0.75rem 1.5rem;
        gap: 1.5rem;
    }

    .logo-section .logo {
        height: 42px;
    }

    .header-actions .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
        min-width: 110px;
    }

    nav ul {
        gap: 1rem;
    }

    nav a {
        font-size: 0.9rem;
    }
}

/* ===== DARK MODE SUPPORT FOR MOBILE HEADER ===== */
@media (prefers-color-scheme: dark) {
    @media (max-width: 768px) {
        nav {
            background: linear-gradient(160deg, #1a202c 0%, #2d3748 100%);
            border-left: 1px solid rgba(255, 255, 255, 0.1);
        }

        nav ul li {
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        nav ul li:first-child {
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }

        nav ul li a {
            color: #e2e8f0;
        }

        nav ul li a:hover {
            background: linear-gradient(90deg, rgba(0, 66, 130, 0.2) 0%, transparent 100%);
            color: #ffffff;
        }

        nav ul li a.active {
            background: linear-gradient(90deg, rgba(238, 125, 32, 0.2) 0%, transparent 100%);
            border-left-color: #ee7d20;
        }

        /* Update SVG icons for dark mode */
        nav ul li a::before {
            filter: brightness(0) invert(1);
        }

        nav ul li a.active::before {
            filter: brightness(0) saturate(100%) invert(52%) sepia(95%) saturate(1813%) hue-rotate(350deg) brightness(99%) contrast(93%);
        }

        .mobile-menu-footer {
            background: rgba(0, 0, 0, 0.2);
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            color: #a0aec0;
        }

        .mobile-menu-footer a {
            color: #63b3ed;
        }
    }
}

/* ===== PREVENT SCROLLING DURING MENU ANIMATION ===== */
@media (max-width: 768px) {
    /* Add transition lock to prevent jank */
    nav {
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    /* When transitioning, prevent any scroll */
    .hamburger,
    .header-content {
        pointer-events: auto;
    }
}

/* ===== FIX FOR IOS BOUNCE SCROLL ===== */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        body.menu-open {
            overscroll-behavior-y: none;
            -webkit-overflow-scrolling: none;
        }
        
        html.menu-open {
            position: fixed;
            width: 100%;
            height: 100%;
        }
    }
}

/* ===== ENHANCED TOUCH SCROLL PREVENTION ===== */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    /* For touch devices only */
    body.menu-open {
        touch-action: none;
        overscroll-behavior: none;
    }
    
    /* Allow scrolling only in navigation menu */
    nav.active {
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* Prevent any scroll on header */
    header {
        touch-action: none;
    }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
    @media (max-width: 768px) {
        /* Larger touch targets */
        .hamburger {
            width: 52px;
            height: 52px;
        }

        .header-actions .btn {
            min-height: 48px;
            min-width: 120px;
        }

        nav ul li a {
            min-height: 64px;
            padding: 1.25rem 2rem;
        }

        /* Remove hover effects, keep active states */
        nav ul li a:hover {
            padding-left: 2rem;
            background: transparent;
        }

        nav ul li a:active {
            background: linear-gradient(90deg, rgba(0, 66, 130, 0.1) 0%, transparent 100%);
            padding-left: 2.25rem;
        }

        /* Button active state */
        .header-actions .btn:active {
            transform: scale(0.95);
        }

        .hamburger:active {
            transform: scale(0.95);
        }
    }
}

/* ===== LANDSCAPE MODE OPTIMIZATION ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .header-content {
        height: 90px;
        padding: 0.5rem 1rem;
        grid-template-rows: auto auto;
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 0.25rem;
    }

    nav {
        padding-top: 90px;
        overflow-y: auto;
    }

    nav ul {
        max-height: calc(100vh - 180px);
    }

    .logo-section .logo {
        height: 50px;
        max-width: 120px;
    }

    .header-actions .btn {
        min-height: 32px;
        padding: 0.4rem 0.9rem;
        min-width: 85px;
        font-size: 0.85rem;
    }

    .hamburger {
        width: 40px;
        height: 40px;
    }
    
    main {
        margin-top: 90px; /* Reduced height in landscape */
    }
    
    /* Ensure menu scrolls independently in landscape */
    nav.active {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ===== MOBILE FOOTER OPTIMIZATION ===== */
@media (max-width: 768px) {
    footer {
        padding: 3rem 1rem 2rem;
    }

    footer .container {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    footer h3 {
        margin-bottom: 1rem;
        font-size: 1.25rem;
    }

    .contact-section {
        text-align: left;
    }

    .contact-list {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin-top: 1rem;
    }

    .contact-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem;
        background: rgba(255, 255, 255, 0.05);
        border-radius: var(--radius-md);
        transition: all var(--transition-base);
    }

    .contact-item:hover {
        background: rgba(255, 255, 255, 0.1);
        transform: translateX(5px);
    }

    .contact-item svg {
        flex-shrink: 0;
        color: var(--primary-orange);
    }

    .contact-item span {
        color: rgba(255, 255, 255, 0.9);
        font-size: 0.95rem;
        line-height: 1.4;
    }

    footer a {
        justify-content: center;
        gap: 0.5rem;
        padding: 0.5rem 0;
    }

    footer a:hover,
    footer a:focus {
        gap: 0.75rem;
        transform: none; /* Remove transform on mobile for better touch */
    }

    .social {
        margin: 1.5rem 0;
        gap: 1rem;
        justify-content: center;
        flex-wrap: wrap;
    }

    .social a {
        width: 44px;
        height: 44px;
    }

    .social a:hover {
        transform: translateY(-3px) rotate(3deg);
        box-shadow: 0 8px 20px rgba(238, 125, 32, 0.3);
    }

    footer > .container > p:first-of-type {
        margin-top: 2rem;
        padding-top: 2rem;
        font-size: 0.9rem;
    }

    footer > .container > hr + p {
        margin-top: 1rem;
        font-size: 0.85rem;
    }
}

/* ===== SMALL MOBILE FOOTER (480px and below) ===== */
@media (max-width: 480px) {
    footer {
        padding: 2.5rem 1rem 1.5rem;
    }

    footer .container {
        gap: 1.5rem;
    }

    .contact-list {
        gap: 0.75rem;
    }

    .contact-item {
        padding: 0.6rem;
        gap: 0.6rem;
    }

    .contact-item svg {
        width: 18px;
        height: 18px;
    }

    .contact-item span {
        font-size: 0.9rem;
    }

    .social {
        gap: 0.75rem;
    }

    .social a {
        width: 40px;
        height: 40px;
    }

    .social a svg {
        width: 20px;
        height: 20px;
    }
}
