/* Core Web Vitals Optimizations */

/* Prevent layout shift for images */
img {
    max-width: 100%;
    height: auto;
}

/* Reserve space for lazy-loaded images */
img[loading="lazy"] {
    background-color: #f0f0f0;
}

/* Font display swap to prevent FOIT */
@font-face {
    font-display: swap;
}

/* Smooth animations */
* {
    scroll-behavior: smooth;
}

/* Prevent layout shift for buttons and links */
a, button {
    min-height: 44px;
    min-width: 44px;
}

/* Skeleton loaders for dynamic content */
.skeleton {
    animation: skeleton-loading 1s linear infinite alternate;
    background-color: #eee;
    background-image: linear-gradient(
        90deg,
        #eee,
        #f5f5f5,
        #eee
    );
    background-size: 200px 100%;
    background-repeat: no-repeat;
}

@keyframes skeleton-loading {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

/* Optimize form inputs */
input, textarea, select {
    font-size: 16px; /* Prevent zoom on iOS */
}

/* Reduce CLS for modals and popups */
.modal, .popup {
    position: fixed;
    transform: translateZ(0);
    will-change: transform;
}

/* Optimize animations */
.animate {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Reserve space for ads if any */
.ad-container {
    min-height: 250px;
    background: #f9f9f9;
}

/* Optimize video embeds */
.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
}

.video-container iframe,
.video-container object,
.video-container embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Improve touch targets */
@media (pointer: coarse) {
    button, a, input, select, textarea {
        min-height: 48px;
        padding: 12px;
    }
}

/* Reduce reflow for dynamic content */
.dynamic-content {
    contain: layout style paint;
}

/* Optimize table rendering */
table {
    table-layout: fixed;
}

/* Prevent FOUC (Flash of Unstyled Content) */
html {
    visibility: visible;
    opacity: 1;
}

/* Critical font loading */
.fonts-loaded body {
    font-family: 'Philosopher', 'Figtree', sans-serif;
}

/* Optimize hover effects */
@media (hover: hover) {
    a:hover, button:hover {
        transition: all 0.3s ease;
    }
}

/* Reduce paint areas */
.card, .box {
    will-change: transform;
    transform: translateZ(0);
}