/**
 * Performance Optimization CSS
 * Optimized styles for smooth scrolling and fast rendering
 */

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Enable hardware acceleration for smooth scrolling */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    /* Enable GPU acceleration */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    
    /* Optimize text rendering */
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    
    /* Reduce layout thrashing */
    contain: layout style paint;
}

/* ===== OPTIMIZED CARD ANIMATIONS ===== */
.modern-card {
    /* Use transform instead of backdrop-filter for better performance */
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    
    /* Optimize animations */
    will-change: transform, box-shadow;
    transform: translateZ(0);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
    
    /* Remove expensive backdrop-filter */
    /* backdrop-filter: blur(10px); - REMOVED FOR PERFORMANCE */
}

.modern-card:hover {
    transform: translateY(-4px) translateZ(0);
    box-shadow: 0 8px 25px -8px rgba(0, 0, 0, 0.2);
    /* Remove background change to prevent repaints */
}

[data-theme="dark"] .modern-card {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(71, 85, 105, 0.3);
}

/* ===== SCROLL PERFORMANCE OPTIMIZATIONS ===== */
.moon-results-container,
.tool-container,
.main-content {
    /* Enable smooth scrolling with GPU acceleration */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    
    /* Optimize scroll performance */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    
    /* Contain layout changes */
    contain: layout style paint;
}

/* ===== OPTIMIZED TRANSITIONS ===== */
/* Remove global transitions that cause performance issues */
* {
    /* Remove expensive global transitions */
    transition: none;
}

/* Apply targeted transitions only where needed */
.btn-primary,
.btn-secondary,
.btn-outline,
.modern-card,
.tool-card,
.nav-link {
    transition: transform 0.15s ease-out, 
                background-color 0.15s ease-out,
                color 0.15s ease-out,
                border-color 0.15s ease-out;
}

/* ===== FORM INPUT OPTIMIZATIONS ===== */
.moon-input,
.form-input {
    /* Remove expensive backdrop-filter */
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    
    /* Optimize focus transitions */
    transition: border-color 0.15s ease-out, background-color 0.15s ease-out;
    
    /* Enable hardware acceleration */
    transform: translateZ(0);
    will-change: border-color, background-color;
}

.moon-input:focus,
.form-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    /* Remove expensive box-shadow */
}

/* ===== BUTTON OPTIMIZATIONS ===== */
.moon-calculate-btn {
    /* Optimize gradient rendering */
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    
    /* Enable hardware acceleration */
    will-change: transform;
    transform: translateZ(0);
    
    /* Faster transitions */
    transition: transform 0.15s ease-out;
}

.moon-calculate-btn:hover {
    transform: translateY(-2px) translateZ(0);
    /* Remove expensive box-shadow changes */
}

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

/* ===== LAYOUT OPTIMIZATIONS ===== */
.container,
.moon-calendar-container {
    /* Optimize layout calculations */
    contain: layout style;
}

/* ===== ANIMATION PERFORMANCE ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px) translateZ(0);
    }
    to {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-20px) translateZ(0);
        opacity: 0;
    }
    to {
        transform: translateX(0) translateZ(0);
        opacity: 1;
    }
}

/* Apply optimized animations */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* ===== SCROLL SNAP FOR SMOOTH NAVIGATION ===== */
.scroll-container {
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
}

.scroll-item {
    scroll-snap-align: start;
}

/* ===== REDUCE PAINT COMPLEXITY ===== */
.gradient-text {
    /* Optimize gradient text rendering */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    
    /* Enable GPU acceleration */
    transform: translateZ(0);
    will-change: transform;
}

/* ===== LOADING STATE OPTIMIZATIONS ===== */
.loading-spinner {
    /* Use transform for rotation instead of changing properties */
    animation: spin 1s linear infinite;
    will-change: transform;
}

@keyframes spin {
    from {
        transform: rotate(0deg) translateZ(0);
    }
    to {
        transform: rotate(360deg) translateZ(0);
    }
}

/* ===== MOBILE PERFORMANCE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    /* Reduce animations on mobile for better performance */
    .modern-card:hover {
        transform: translateY(-2px) translateZ(0);
    }
    
    /* Optimize touch scrolling */
    body {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* Reduce transition durations on mobile */
    .btn-primary,
    .btn-secondary,
    .modern-card {
        transition-duration: 0.1s;
    }
}

/* ===== ACCESSIBILITY WITH PERFORMANCE ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== CRITICAL RENDERING PATH OPTIMIZATIONS ===== */
/* Ensure above-the-fold content renders quickly */
.header,
.hero-section,
.tool-grid {
    contain: layout style paint;
    will-change: auto;
}

/* ===== MEMORY OPTIMIZATION ===== */
/* Limit will-change to actively animating elements only */
.modern-card:not(:hover) {
    will-change: auto;
}

.moon-calculate-btn:not(:hover):not(:active) {
    will-change: auto;
}

/* ===== FONT LOADING OPTIMIZATION ===== */
@font-face {
    font-family: 'system-ui';
    font-display: swap; /* Ensure text remains visible during font load */
}

/* Use system fonts for better performance */
body {
    font-family: 
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        Roboto,
        'Helvetica Neue',
        Arial,
        sans-serif;
}
