/*
 * File: css/components.css
 * Description: Reusable UI Components, Animations, and Accessibility Utilities
 * Updated: January 2026 - PERFORMANCE OPTIMIZED VERSION
 * 
 * FIXES APPLIED:
 * ✅ FIX #1: Removed excessive will-change from animations
 * ✅ FIX #2: Disabled blur effect on mobile (better performance)
 * ✅ FIX #3: Optimized animation timing for battery life
 * ✅ FIX #4: Better reduced motion support
 */

/* =========================================
   1. ANIMATIONS & TRANSITIONS
   ========================================= */

/* Smooth filtering transitions */
.tool-card[data-category] {
    transition: opacity 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), 
                transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
                box-shadow 0.3s ease;
}

.tool-card.hidden {
    display: none;
}

/* Entry Animation */
.tool-card.fade-in {
    animation: fadeIn 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
    /* ✅ FIX #1: Removed will-change - browser optimizes automatically */
}

/* UX POLISH: Cinematic "Focus" Animation (Desktop Only) */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px) scale(0.98); 
        filter: blur(4px);
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
        filter: blur(0);
    }
}

/* ✅ FIX #2: Mobile Performance - Disable blur on mobile devices */
@media (max-width: 768px) {
    @keyframes fadeIn {
        from { 
            opacity: 0; 
            transform: translateY(15px) scale(0.99); 
            filter: none; /* No blur on mobile for better FPS */
        }
        to { 
            opacity: 1; 
            transform: translateY(0) scale(1); 
            filter: none;
        }
    }
}

/* Dropdown Entrance Logic */
.dropdown-parent .dropdown {
    transition: opacity 0.3s ease, 
                transform 0.3s ease, 
                visibility 0.3s ease;
    transform-origin: top center;
}

/* =========================================
   2. ACCESSIBILITY UTILITIES
   ========================================= */

/* Keyboard Focus Indicators - Vital for Power Users */
a:focus-visible,
button:focus-visible,
.dropdown-toggle:focus-visible,
.upload-area:focus-visible,
.form-input:focus-visible {
    /* Double-Ring for visibility on Dark & Light backgrounds */
    outline: 2px solid white; 
    border-radius: 4px;
    box-shadow: 0 0 0 4px var(--primary-color), 0 0 0 6px rgba(147, 112, 219, 0.2);
    transition: box-shadow 0.2s ease;
}

/* Screen Reader Only - Hides visually but keeps accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================================
   3. HIGH CONTRAST MODE
   ========================================= */
/* Developer Note: This overrides global variables for users 
   who specifically request high contrast via OS settings.
*/
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000080;   /* Navy Blue */
        --secondary-color: #d35400; /* Dark Orange */
        --text-dark: #000000;       /* Pure Black */
        --glass-border: 2px solid #000000;
    }
    
    /* Remove glass effects for clarity */
    .tool-card, 
    .tool-hero,
    .modal-content, 
    .dropdown,
    .step {
        background: #ffffff !important;
        backdrop-filter: none !important;
        border: 2px solid #000000 !important;
        box-shadow: none !important;
    }
    
    .btn, 
    .tool-badge,
    .category-btn {
        background: none !important;
        border: 2px solid currentColor !important;
        color: #000000 !important;
        font-weight: 700 !important;
    }
    
    /* Ensure links are underlined */
    a {
        text-decoration: underline;
    }
}

/* =========================================
   4. REDUCED MOTION
   ========================================= */
/* Respects user settings to disable animations 
   (Vestibular disorders support)
*/
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .tool-card.fade-in {
        animation: none !important;
        opacity: 1;
        transform: none;
        filter: none !important;
    }
    
    /* ✅ FIX #3: Ensure no will-change on reduced motion */
    * {
        will-change: auto !important;
    }
}

/* ✅ FIX #4: Battery Saver Mode - Reduce animations */
@media (prefers-reduced-motion: reduce), (prefers-reduced-data: reduce) {
    .tool-card.fade-in {
        animation-duration: 0.01ms;
    }
    
    .dropdown-parent .dropdown {
        transition-duration: 0.1s;
    }
}