/* CRITICAL CSS - Optimized for Core Web Vitals */
/* Only above-the-fold styles with CLS prevention */

/* PERFORMANCE: CSS reset with optimizations */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* PERFORMANCE: Optimized font loading to prevent CLS */
body {
    font-family: Georgia, 'Times New Roman', serif; /* Fallback first */
    line-height: 1.6;
    color: #333;
    overflow-x: hidden;
    /* Prevent font swap layout shifts */
    font-display: swap;
    /* Improve text rendering */
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* CLS PREVENTION: Reserve exact space for navigation */
#navigation {
    height: 90px; /* Exact height to prevent layout shifts */
    position: relative;
    /* Ensure proper stacking */
    z-index: 1000;
    /* Prevent any flash of unstyled content */
    min-height: 90px;
}

/* CRITICAL: Navigation - Fixed positioning optimized */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    height: 90px; /* Fixed height prevents CLS */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    padding: 0.5rem 0; /* Slight padding for larger logo */
    /* GPU acceleration for smooth scrolling */
    will-change: transform;
    /* Optimize repaints */
    contain: layout style paint;
}

/* Navigation scrolled state - optimized transitions */
nav.scrolled {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    height: 90px; /* Match parent height exactly */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    /* Prevent layout thrashing */
    contain: layout;
}

/* LOGO FIX: Preserve aspect ratio while preventing layout shifts */
.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    /* Reserve space to prevent shifts - wider for logo aspect ratio */
    min-width: 200px;
    height: 70px;
    flex-shrink: 0; /* Prevent shrinking */
}

.logo img {
    height: 70px;
    width: auto; /* KEY FIX: Preserve aspect ratio */
    min-width: 200px; /* Ensure logo is at least 200px wide */
    /* Prevent image layout shifts */
    object-fit: contain;
    /* GPU acceleration */
    transform: translateZ(0);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
    /* Prevent flex growing/shrinking that could cause shifts */
    flex-shrink: 0;
}

.nav-links a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    /* Optimized transitions for 60fps */
    transition: color 0.2s ease;
    position: relative;
    /* Prevent text shifts */
    white-space: nowrap;
    /* Improve paint performance */
    will-change: color;
}

.nav-links a:hover {
    color: #3498db;
}

/* Optimized underline animation */
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: #3498db;
    transition: width 0.2s ease;
    /* GPU acceleration */
    transform: translateZ(0);
}

.nav-links a:hover::after {
    width: 100%;
}

/* CRITICAL: Hamburger Menu - Optimized for mobile */
.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 8px;
    background: none;
    border: none;
    z-index: 1001;
    /* Reserve exact space */
    width: 41px;
    height: 41px;
    justify-content: center;
    /* Improve touch target */
    touch-action: manipulation;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background: #2c3e50;
    margin: 3px 0;
    border-radius: 2px;
    /* GPU accelerated transitions */
    transition: transform 0.2s ease;
    transform: translateZ(0);
    /* Prevent subpixel rendering issues */
    display: block;
}

/* CRITICAL: Hero Section - CLS Prevention Priority */
.hero {
    /* Fixed viewport height prevents CLS */
    height: 100vh;
    min-height: 600px; /* Fallback for small screens */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
    /* Optimize compositing */
    isolation: isolate;
    /* Improve paint performance */
    contain: layout style paint;
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Prevent shifts during image load */
    overflow: hidden;
}

.hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* CRITICAL: Prevent layout shifts during image loading */
    object-position: center center;
    /* Optimize image rendering */
    image-rendering: -webkit-optimize-contrast;
    /* GPU acceleration */
    transform: translateZ(0);
    /* Improve loading performance */
    filter: brightness(0.6);
    /* Ensure proper aspect ratio */
    aspect-ratio: 16/9;
}

/* Hero overlay - optimized */
.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(44, 62, 80, 0.1);
    z-index: 2;
    /* GPU acceleration */
    transform: translateZ(0);
}

/* CLS PREVENTION: Hero content with reserved space */
.hero-content {
    max-width: 800px;
    padding: 2rem;
    z-index: 3;
    position: relative;
    /* CRITICAL: Reserve space to prevent CLS */
    min-height: 280px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Improve text rendering */
    text-rendering: optimizeLegibility;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
    /* Prevent font loading shifts */
    font-display: swap;
    /* Improve rendering */
    line-height: 1.1;
    /* Optimize paint */
    will-change: auto;
    /* Prevent text shifts */
    text-align: center;
}

.hero .tagline {
    font-size: 1.3rem;
    margin-bottom: 2rem;
    opacity: 0.95;
    line-height: 1.4;
    /* Optimize rendering */
    max-width: 600px;
    text-align: center;
}

.cta-button {
    display: inline-block;
    background: #e74c3c;
    color: white;
    padding: 1rem 2rem;
    text-decoration: none;
    border-radius: 50px;
    font-weight: bold;
    /* Optimized transitions */
    transition: transform 0.2s ease, background-color 0.2s ease;
    /* CLS prevention */
    width: auto;
    min-width: 200px;
    text-align: center;
    /* GPU acceleration */
    transform: translateZ(0);
    /* Prevent shifts */
    white-space: nowrap;
    /* Improve touch interaction */
    touch-action: manipulation;
}

.cta-button:hover {
    background: #c0392b;
    transform: translateZ(0) translateY(-2px);
}

/* CRITICAL: Mobile Navigation - Optimized overlay */
.mobile-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(44, 62, 80, 0.98);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 999;
    /* Optimized visibility transitions */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-100%);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    /* Improve compositing performance */
    will-change: transform, opacity;
    /* Optimize paint */
    contain: strict;
}

.mobile-nav.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-nav-links a {
    color: white;
    font-size: 1.5rem;
    text-decoration: none;
    font-weight: 500;
    padding: 1rem 2rem;
    border-radius: 8px;
    /* Optimized transitions */
    transition: background-color 0.2s ease, transform 0.2s ease;
    /* Improve touch targets */
    min-width: 200px;
    text-align: center;
    touch-action: manipulation;
    /* GPU acceleration */
    transform: translateZ(0);
}

.mobile-nav-links a:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateZ(0) translateY(-2px);
}

/* MOBILE OPTIMIZATIONS - Critical viewport styles */
@media (max-width: 768px) {
    /* Navigation adjustments for mobile */
    .nav-links {
        display: none;
    }
    
    .hamburger {
        display: flex;
    }
    
    .nav-container {
        padding: 0 1rem;
    }
    
    /* LOGO FIX: Mobile responsive logo */
    .logo {
        min-width: 160px;
        height: 60px;
    }
    
    .logo img {
        height: 60px;
        width: auto;
        min-width: 160px;
    }
    
    /* Mobile navigation height adjustment */
    #navigation {
        height: 80px;
        min-height: 80px;
    }
    
    nav {
        height: 80px;
    }
    
    .nav-container {
        height: 80px;
    }
    
    /* Hero optimizations for mobile */
    .hero {
        min-height: 100vh;
        padding: 0 1rem;
    }
    
    .hero h1 {
        font-size: 2.3rem;
        line-height: 1.2;
        margin-bottom: 0.8rem;
    }
    
    .hero .tagline {
        font-size: 1.05rem;
        margin-bottom: 1.5rem;
        line-height: 1.4;
    }
    
    .hero-content {
        padding: 1rem;
        min-height: 250px;
        max-width: 100%;
    }
    
    .cta-button {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
        min-width: 180px;
    }
    
    /* Optimize hero image for mobile */
    .hero-img {
        object-position: center top;
        filter: brightness(0.65);
        /* Better aspect ratio for mobile */
        aspect-ratio: 4/3;
    }
}

/* SMALLEST SCREENS - Further optimization */
@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.9rem;
    }
    
    .hero .tagline {
        font-size: 0.95rem;
    }
    
    .nav-container {
        padding: 0 0.5rem;
    }
    
    /* LOGO FIX: Small screen responsive logo */
    .logo {
        min-width: 130px;
        height: 50px;
    }
    
    .logo img {
        height: 50px;
        width: auto;
        min-width: 130px;
    }
    
    /* Small screen navigation height adjustment */
    #navigation {
        height: 70px;
        min-height: 70px;
    }
    
    nav {
        height: 70px;
    }
    
    .nav-container {
        height: 70px;
    }
    
    .cta-button {
        padding: 0.7rem 1.3rem;
        font-size: 0.85rem;
        min-width: 160px;
    }
    
    .hero-content {
        min-height: 220px;
    }
}

/* ACCESSIBILITY & PERFORMANCE OPTIMIZATIONS */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
    
    .hero-img {
        transform: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .hero::before {
        background: rgba(0, 0, 0, 0.7);
    }
    
    .nav-links a:hover {
        color: #000;
        background: #fff;
        padding: 0.2rem 0.5rem;
        border-radius: 3px;
    }
}

/* Dark mode support (system preference) */
@media (prefers-color-scheme: dark) {
    .nav-links a {
        color: #2c3e50;
    }
    
    nav {
        background: rgba(240, 240, 240, 0.95);
    }
}

/* Print optimizations */
@media print {
    .hero {
        height: auto;
        min-height: auto;
        padding: 2rem 0;
    }
    
    nav,
    .mobile-nav,
    .hamburger {
        display: none !important;
    }
    
    #navigation {
        height: auto;
        min-height: auto;
    }
    
    .hero-img {
        filter: none;
    }
    
    .cta-button {
        display: none;
    }
}

/* PERFORMANCE: GPU acceleration for smooth interactions */
.nav-links a,
.cta-button,
.hamburger span,
.mobile-nav-links a {
    backface-visibility: hidden;
    perspective: 1000px;
}

/* PERFORMANCE: Optimize repainting */
nav,
.hero,
.mobile-nav {
    transform: translateZ(0);
}