/* Performance Optimizations */

/* Lazy loading fade-in animation */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Optimize font loading */
@font-face {
    font-family: 'Inter';
    font-display: swap;
}

@font-face {
    font-family: 'Space Mono';
    font-display: swap;
}

/* Reduce motion for users who prefer it */
@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 images for better performance */
img {
    max-width: 100%;
    height: auto;
}

/* Critical above-the-fold content */
.hero {
    contain: layout style paint;
}

/* Optimize animations for better performance */
.star,
.shooting-star {
    will-change: transform, opacity;
}

/* Optimize scrolling performance */
html {
    scroll-behavior: smooth;
}

/* Optimize repaints */
.nav {
    contain: layout style;
}

/* Optimize audio player performance */
.audio-player-card {
    contain: layout style paint;
}

/* Optimize project cards */
.project-card {
    contain: layout style;
}

/* Optimize skills section */
.skills-container {
    contain: layout style;
}

/* Optimize music section */
.music-item {
    contain: layout style;
}

/* Optimize BB-8 component (don't touch the animations or tooltip) */
.bb8-component {
    /* Removed contain to prevent tooltip clipping */
    overflow: visible !important;
}

/* Ensure BB-8 tooltip has proper space */
.bb8-component .bb8-tooltip {
    overflow: visible !important;
    z-index: 9999 !important;
}

/* Optimize contact form */
.contact-form {
    contain: layout style;
}

/* Optimize footer */
footer {
    contain: layout style;
}
