/* ==========================================================================
   CV Website - Animation Styles
   Optimized animations for better performance
   ========================================================================== */

/* Base animation classes - Progressive enhancement approach */
.fade-in {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

/* Only hide elements when animations are ready AND element is not visible */
body.animations-ready .fade-in:not(.visible) {
    opacity: 0;
    transform: translateY(20px);
}

.fade-in.visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.slide-in-left {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

body.animations-ready .slide-in-left:not(.visible) {
    opacity: 0;
    transform: translateX(-50px);
}

.slide-in-left.visible {
    opacity: 1 !important;
    transform: translateX(0) !important;
}

.slide-in-right {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

body.animations-ready .slide-in-right:not(.visible) {
    opacity: 0;
    transform: translateX(50px);
}

.slide-in-right.visible {
    opacity: 1 !important;
    transform: translateX(0) !important;
}

/* Ensure loaded state overrides any hidden elements */
body.loaded .fade-in,
body.loaded .slide-in-left,
body.loaded .slide-in-right,
body.loaded .timeline-item {
    opacity: 1 !important;
    transform: none !important;
}

/* Skill progress bar animations */
.skill-progress {
    width: 0;
    transition: width 1.5s ease-out;
    will-change: width;
}

/* Loading spinner - Consolidated and optimized */
.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-bg, #1a1a1a);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease-out;
}

.loading-spinner .spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(0, 212, 170, 0.3);
    border-top: 3px solid var(--accent-color, #00d4aa);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    will-change: transform;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Back to top button */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 212, 170, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
    display: none;
    will-change: transform;
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 212, 170, 0.4);
}

/* Navbar scroll effect */
.navbar {
    transition: all 0.3s ease;
}

.navbar.scrolled {
    background: rgba(26, 32, 44, 0.95) !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

/* Card hover effects */
.card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Profile image glow effect */
.profile-image {
    transition: all 0.3s ease;
}

.profile-image:hover {
    transform: scale(1.05);
}

/* Button hover effects */
.btn {
    transition: all 0.3s ease;
    will-change: transform;
}

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

/* Social links hover */
.social-link {
    transition: all 0.3s ease;
    will-change: transform;
}

.social-link:hover {
    transform: translateY(-3px) scale(1.1);
}

/* Timeline animations */
.timeline-item {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

body.animations-ready .timeline-item:not(.visible) {
    opacity: 0;
    transform: translateY(30px);
}

.timeline-item.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 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;
    }
    
    .fade-in,
    .slide-in-left,
    .slide-in-right,
    .timeline-item {
        opacity: 1;
        transform: none;
    }
}

/* Performance optimizations */
.hero-section {
    will-change: transform;
}

/* Lazy loading image fade-in */
img.lazy {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img.lazy.loaded {
    opacity: 1;
}

/* Form validation animations */
.is-invalid {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.invalid-feedback {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}