/* ===================================
   PERFORMANCE OPTIMIZATION CSS
   =================================== */

/* GPU Acceleration for Animations */
.gpu-accelerated,
.scroll-reveal,
.scroll-reveal-stagger,
.scroll-reveal-slide,
.scroll-reveal-fade,
.floating-element,
.hero-title,
.hero-subtitle,
.philosophy-card,
.experience-content,
.skills-card {
    will-change: transform, opacity;
    backface-visibility: hidden;
    perspective: 1000px;
    transform: translate3d(0, 0, 0);
}

/* Optimize animations to use only transform and opacity */
.optimized-animation {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Remove will-change after animation completes */
.animation-complete {
    will-change: auto;
}

/* Lazy Loading Styles */
.lazy-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    filter: blur(1px);
    transition: filter 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

.lazy-loaded {
    filter: blur(0);
    opacity: 1;
}

.lazy-error {
    background: #f5f5f5 url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23999"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>') center/24px no-repeat;
    min-height: 100px;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Responsive Images */
img {
    max-width: 100%;
    height: auto;
    loading: lazy;
    decoding: async;
}

/* Critical images should load immediately */
.critical-image {
    loading: eager;
}

/* Modern image containers with aspect ratio */
.image-container {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
}

.image-container::before {
    content: '';
    display: block;
    padding-top: var(--aspect-ratio, 56.25%);
}

.image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease-in-out;
}

/* Reduced Motion Support */
@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;
    }

    .parallax-element {
        transform: none !important;
    }

    .floating-element {
        animation: none !important;
    }
}

/* Performance-optimized scroll animations */
.scroll-optimized {
    transform: translateZ(0);
    will-change: transform;
}

/* Contain layout shifts */
.layout-stable {
    contain: layout style paint;
}

/* Optimize repaints */
.paint-optimized {
    contain: paint;
}

/* Loading states */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.loading-skeleton.text {
    height: 1em;
    margin: 0.5em 0;
}

.loading-skeleton.title {
    height: 2em;
    width: 60%;
    margin: 1em 0;
}

.loading-skeleton.image {
    aspect-ratio: 16/9;
    width: 100%;
}

/* Critical CSS inlining support */
.critical-css-loaded .non-critical {
    display: block;
}

.non-critical {
    display: none;
}

/* Font loading optimization */
@font-face {
    font-family: 'Inter';
    font-display: swap;
    src: url('fonts/inter.woff2') format('woff2');
}

@font-face {
    font-family: 'Source Sans Pro';
    font-display: swap;
    src: url('fonts/source-sans-pro.woff2') format('woff2');
}

/* Preload critical fonts */
.font-preload {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Optimize button interactions */
.btn-optimized {
    transform: translateZ(0);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.btn-optimized:hover {
    transform: translateY(-2px) translateZ(0);
}

.btn-optimized:active {
    transform: translateY(0) translateZ(0);
}

/* Optimize card hover effects */
.card-optimized {
    transform: translateZ(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-optimized:hover {
    transform: translateY(-4px) translateZ(0);
}

/* Scroll performance optimizations */
.scroll-container {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Optimize navigation performance */
.nav-optimized {
    transform: translateZ(0);
    transition: transform 0.3s ease-out, backdrop-filter 0.3s ease-out;
}

.nav-optimized.scrolled {
    transform: translateY(0) translateZ(0);
    backdrop-filter: blur(10px);
}

/* Resource hints for better loading */
.preload-hint::before {
    content: '';
    display: none;
    background-image: url('media/critical-image.jpg');
}

/* Optimize form performance */
.form-optimized input,
.form-optimized textarea {
    will-change: border-color, box-shadow;
    transition: border-color 0.2s ease-out, box-shadow 0.2s ease-out;
}

/* Optimize table performance */
.table-optimized {
    contain: layout;
    table-layout: fixed;
}

/* Critical above-the-fold styles */
.above-fold {
    contain: layout style paint;
}

/* Below-the-fold lazy styles */
.below-fold {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}

/* Optimize video performance */
video {
    loading: lazy;
    preload: metadata;
}

.video-optimized {
    will-change: transform;
    transform: translateZ(0);
}

/* Performance monitoring styles */
.perf-monitor {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    z-index: 9999;
    display: none;
}

.perf-monitor.show {
    display: block;
}

/* Debug mode styles */
.debug-mode .slow-element {
    outline: 2px solid red;
}

.debug-mode .gpu-accelerated {
    outline: 2px solid green;
}

/* Print optimizations */
@media print {
    .no-print {
        display: none !important;
    }

    * {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
}