/*
 * Casa Connect - Animations
 * Performance-optimized animations using GPU-accelerated properties
 * To disable: Simply remove the link to this file from your HTML pages
 */

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === FADE IN ANIMATIONS === */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease forwards;
}

.fade-in {
    opacity: 0;
    animation: fadeIn 0.8s ease forwards;
}

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

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Stagger delays for grid items */
.fade-in-up:nth-child(1) { animation-delay: 0.1s; }
.fade-in-up:nth-child(2) { animation-delay: 0.2s; }
.fade-in-up:nth-child(3) { animation-delay: 0.3s; }
.fade-in-up:nth-child(4) { animation-delay: 0.4s; }
.fade-in-up:nth-child(5) { animation-delay: 0.5s; }
.fade-in-up:nth-child(6) { animation-delay: 0.6s; }
.fade-in-up:nth-child(7) { animation-delay: 0.7s; }
.fade-in-up:nth-child(8) { animation-delay: 0.8s; }

/* === HERO ANIMATIONS === */
.hero-content h1 {
    animation: slideInLeft 1s ease forwards;
    opacity: 0;
}

.hero-content p {
    animation: slideInLeft 1.2s ease forwards;
    animation-delay: 0.2s;
    opacity: 0;
}

.hero-buttons {
    animation: slideInLeft 1.4s ease forwards;
    animation-delay: 0.4s;
    opacity: 0;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* === CARD HOVER EFFECTS === */
.feature-card,
.service-card,
.service-detail-card,
.pricing-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover,
.service-card:hover,
.service-detail-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.pricing-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

/* Keep featured card slightly elevated */
.pricing-card.featured {
    animation: pulse-scale 2s ease-in-out infinite;
}

@keyframes pulse-scale {
    0%, 100% {
        transform: scale(1.05);
    }
    50% {
        transform: scale(1.08);
    }
}

.pricing-card.featured:hover {
    animation: none;
    transform: translateY(-10px) scale(1.1);
}

/* === ICON ANIMATIONS === */
.feature-icon i,
.service-card i,
.service-detail-icon i {
    transition: transform 0.3s ease, color 0.3s ease;
}

.feature-card:hover .feature-icon i,
.service-card:hover i,
.service-detail-card:hover .service-detail-icon i {
    transform: scale(1.2) rotate(5deg);
    color: var(--accent-color);
}

/* === BUTTON ANIMATIONS === */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:active {
    transform: scale(0.95);
}

/* === NAVIGATION ANIMATIONS === */
.navbar {
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.nav-menu li {
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
}

.nav-menu li:nth-child(1) { animation-delay: 0.1s; }
.nav-menu li:nth-child(2) { animation-delay: 0.2s; }
.nav-menu li:nth-child(3) { animation-delay: 0.3s; }
.nav-menu li:nth-child(4) { animation-delay: 0.4s; }

.nav-menu a {
    position: relative;
    transition: color 0.3s ease;
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

.nav-menu a:hover::after,
.nav-menu a.active::after {
    width: 100%;
}

/* === STATS COUNTER ANIMATION === */
.stat-number {
    display: inline-block;
    animation: countUp 2s ease-out;
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* === FAQ ACCORDION ANIMATION === */
.faq-question i {
    transition: transform 0.3s ease;
}

.faq-item.active .faq-question i {
    transform: rotate(180deg);
}

.faq-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.faq-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* === TESTIMONIAL CARD ANIMATION === */
.testimonial-card {
    transition: transform 0.3s ease;
}

.testimonial-card:hover {
    transform: scale(1.05);
}

/* === FORM INPUT ANIMATIONS === */
.form-group input,
.form-group textarea,
.form-group select {
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(12, 96, 40, 0.1);
}

/* === LOGO ANIMATION === */
.logo img {
    transition: transform 0.3s ease;
}

.logo a {
    display: block;
}

.logo:hover img {
    transform: scale(1.05);
}

/* === PLATFORM LOGOS ANIMATION === */
.platform-logo {
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
}

.platform-logo:nth-child(1) { animation-delay: 0.2s; }
.platform-logo:nth-child(2) { animation-delay: 0.4s; }
.platform-logo:nth-child(3) { animation-delay: 0.6s; }

/* === SOCIAL LINKS ANIMATION === */
.social-links a,
.social-icons a {
    transition: transform 0.3s ease, color 0.3s ease;
}

.social-links a:hover,
.social-icons a:hover {
    transform: translateY(-5px) scale(1.2);
}

/* === PAGE HEADER ANIMATION === */
.page-header {
    position: relative;
    overflow: hidden;
}

.page-header h1 {
    animation: fadeInUp 0.8s ease forwards;
}

.page-header p {
    animation: fadeInUp 1s ease forwards;
    animation-delay: 0.2s;
    opacity: 0;
}

/* === TEAM MEMBER ANIMATION === */
.team-member {
    transition: transform 0.3s ease;
}

.team-member:hover {
    transform: translateY(-10px);
}

.member-img img {
    transition: transform 0.5s ease;
}

.team-member:hover .member-img img {
    transform: scale(1.1);
}

/* === SCROLL REVEAL (Intersection Observer classes) === */
.scroll-reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.scroll-reveal-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.scroll-reveal-left.revealed {
    opacity: 1;
    transform: translateX(0);
}

.scroll-reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.scroll-reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* === LOADING ANIMATION FOR IMAGES === */
img {
    transition: opacity 0.3s ease;
}

img[loading="lazy"] {
    opacity: 0;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* === COOKIE BANNER ANIMATION === */
.cookie-banner {
    animation: slideUp 0.5s ease forwards;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* === FOOTER ANIMATION === */
.footer {
    animation: fadeIn 1s ease;
}

/* === PERFORMANCE OPTIMIZATION === */
/* Only animate on larger screens to preserve mobile performance */
@media (max-width: 768px) {
    .pricing-card.featured {
        animation: none;
    }

    .feature-card:hover,
    .service-card:hover,
    .pricing-card:hover {
        transform: none;
    }

    /* Reduce animation complexity on mobile */
    .fade-in-up:nth-child(n) {
        animation-delay: 0s;
    }
}

/* Use GPU acceleration for smooth animations */
.feature-card,
.service-card,
.pricing-card,
.btn,
.team-member,
.faq-item {
    will-change: transform;
}

/* Clean up will-change after animation */
.feature-card:hover,
.service-card:hover {
    will-change: auto;
}
