/* =============================================
   PERFORMANCE OPTIMIZATION
   Reduce file size and improve loading speed
   ============================================= */

/* === DISABLE HEAVY ANIMATIONS ON LOAD === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* === OPTIMIZE ANIMATIONS === */
.animate-section {
    will-change: opacity, transform;
}

.service-card,
.project-card,
.stat-item {
    will-change: transform;
}

/* === LAZY LOAD IMAGES === */
img {
    loading: lazy;
    decoding: async;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: imageFadeIn 0.4s ease-in-out;
}

@keyframes imageFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* === IMAGE LOADING PLACEHOLDER === */
img[loading="lazy"] {
    background-color: #f0f0f0;
    min-height: 100px;
}

.card-image img,
.gallery-item img {
    background-color: #e8e8e8;
    min-height: 200px;
}

.awards-image img,
.contact-map img {
    background-color: #e8e8e8;
    min-height: 250px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

/* === OPTIMIZE SHADOWS === */
.stat-item {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stat-item:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.service-card {
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.service-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* === REDUCE BACKDROP FILTER === */
.service-card {
    backdrop-filter: blur(8px);
}

/* === OPTIMIZE GRADIENTS === */
.hero-rrd {
    background: linear-gradient(135deg, #003d5c 0%, #0a5f7f 50%, #4fa8c5 100%);
}

/* === REMOVE UNNECESSARY EFFECTS === */
@media (max-width: 768px) {
    .sparkle {
        display: none !important;
    }
    
    .ribbon-glow {
        display: none !important;
    }
    
    .hero-ribbon {
        display: none !important;
    }
    
    .grid-pattern {
        opacity: 0.1;
    }
}

/* === OPTIMIZE FONT LOADING === */
body {
    font-display: swap;
}

/* === REDUCE REPAINTS === */
/* NOTE: navbar cannot use contain:paint because mega menu must overflow it */
.navbar {
    contain: style;
}

.hero-rrd {
    contain: layout style paint;
}

.service-card,
.project-card,
.stat-item {
    contain: layout style paint;
}

/* === OPTIMIZE TRANSITIONS === */
* {
    transition-duration: 0.2s;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

button,
a {
    transition: all 0.2s ease;
}

/* === REMOVE UNUSED STYLES === */
.hero-rrd::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at 70% 50%, rgba(126, 200, 221, 0.1) 0%, transparent 60%);
    z-index: 1;
}

/* === OPTIMIZE IMAGES === */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

.card-image {
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.card-image img,
.gallery-item img,
.awards-image img,
.contact-map img {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.gallery-item {
    aspect-ratio: 4 / 3;
}

.awards-image {
    aspect-ratio: 16 / 9;
}

.contact-map {
    aspect-ratio: 16 / 9;
}

/* === REDUCE FILE SIZE === */
.running-text-section {
    border-top: 2px solid #c53030;
    border-bottom: 2px solid #c53030;
}

/* === OPTIMIZE COLORS === */
:root {
    color-scheme: light;
}

/* === REDUCE MOTION ON MOBILE === */
@media (max-width: 768px) {
    .hero-ribbon {
        animation: none;
    }
    
    .running-text-wrapper {
        animation-duration: 70s !important;
    }
    
    .stat-item::before {
        display: none;
    }
}
