/**
 * Performance & Optimization Styles
 * Modern performance improvements and optimizations
 */

/* Critical path optimization */
/* Above the fold styles - load first */
html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    line-height: 1.6;
    color: #333;
    background-color: #fafafa;
}

/* Optimize rendering */
* {
    box-sizing: border-box;
}

*::before,
*::after {
    box-sizing: border-box;
}

/* GPU acceleration for smooth animations */
.iconbox.style3,
.flat-button,
.go-top,
.loader {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Optimize images */
img {
    max-width: 100%;
    height: auto;
    display: block;
    image-rendering: optimizeQuality;
}

/* Lazy loading placeholder */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[data-src].loaded {
    opacity: 1;
}

/* Modern loading states */
.loading-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Optimize font loading */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfAZ9hiJ-Ek-_EeA.woff2') format('woff2');
    unicode-range: U+0000-00FF;
}

/* Content visibility for better performance */
.below-fold {
    content-visibility: auto;
    contain-intrinsic-size: 200px;
}

/* Optimize animations */
@media (prefers-reduced-motion: no-preference) {
    .smooth-animation {
        animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* Reduce layout shifts */
.aspect-ratio-16-9 {
    aspect-ratio: 16 / 9;
    width: 100%;
}

.aspect-ratio-1-1 {
    aspect-ratio: 1 / 1;
    width: 100%;
}

/* Optimize scrolling */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* Modern containment */
.isolated-component {
    contain: layout style paint;
}

/* Optimize repaints */
.transform-optimized {
    transform: translateZ(0);
    will-change: transform;
}

.opacity-optimized {
    will-change: opacity;
}

/* Critical CSS for above-the-fold content */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.rev_slider_wrapper {
    position: relative;
    margin-top: 80px; /* Account for fixed header */
}

/* Optimize critical path */
.above-fold {
    font-display: swap;
}

/* Performance monitoring styles */
.performance-marker {
    position: absolute;
    visibility: hidden;
    opacity: 0;
}

/* Optimize third-party content */
.third-party-container {
    contain: layout style paint;
}

/* Modern grid optimizations */
.modern-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    align-items: start;
}

@media (max-width: 768px) {
    .modern-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Optimize form performance */
.form-control,
input,
textarea {
    contain: layout style;
}

/* Modern intersection observer support */
.fade-in-observer {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in-observer.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Optimize button interactions */
.btn-optimized {
    contain: layout style paint;
    will-change: transform, box-shadow;
}

/* Modern CSS custom properties for theming */
:root {
    --header-height: 80px;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 15px 35px rgba(0, 0, 0, 0.2);
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Optimize critical rendering path */
.critical-css {
    font-family: system-ui, -apple-system, sans-serif;
}

/* Modern container queries support */
@supports (container-type: inline-size) {
    .responsive-container {
        container-type: inline-size;
    }
    
    @container (max-width: 400px) {
        .iconbox.style3 {
            padding: 1.5rem;
        }
    }
}

/* Optimize paint and composite layers */
.layer-optimized {
    transform: translateZ(0);
    will-change: transform, opacity;
    contain: layout style paint;
}

/* Modern scrollbar optimization */
* {
    scrollbar-width: thin;
    scrollbar-color: #667eea #f1f1f1;
}

/* Optimize video and media */
video,
iframe {
    contain: layout style paint;
}

/* Modern focus management */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
}

.skip-link:focus {
    top: 6px;
}

/* Optimize critical resource hints */
.preload-hint::before {
    content: '';
    display: none;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"><rect width="1" height="1" fill="transparent"/></svg>');
}

/* Modern CSS Grid fallback */
@supports not (display: grid) {
    .modern-grid {
        display: flex;
        flex-wrap: wrap;
        margin: -1rem;
    }
    
    .modern-grid > * {
        flex: 1 1 300px;
        margin: 1rem;
    }
}

/* Optimize for different connection speeds */
@media (prefers-reduced-data: reduce) {
    .loading-placeholder {
        animation: none;
        background: #f0f0f0;
    }
    
    .iconbox.style3::before,
    .flat-button::before {
        display: none;
    }
}

/* Modern CSS Houdini support */
@supports (background: paint(circle)) {
    .modern-background {
        background: paint(circle);
    }
}

/* Optimize for print performance */
@media print {
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    .no-print {
        display: none !important;
    }
    
    a[href^="http"]:after {
        content: " (" attr(href) ")";
    }
}

/* Modern accessibility improvements */
@media (prefers-contrast: high) {
    :root {
        --primary-gradient: linear-gradient(135deg, #000080 0%, #000050 100%);
    }
    
    .iconbox.style3 {
        border: 2px solid #000;
    }
}

/* Optimize for touch devices */
@media (hover: none) and (pointer: coarse) {
    .touch-optimized {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Modern color-gamut support */
@media (color-gamut: p3) {
    :root {
        --primary-gradient: linear-gradient(135deg, color(display-p3 0.4 0.5 0.9) 0%, color(display-p3 0.46 0.29 0.64) 100%);
    }
}