/**
 * Animações e Micro-interações
 * Animações suaves para melhorar UX e percepção de qualidade
 * 
 * Desenvolvido por: Victor Penter
 * Versão: 2.3.6
 */

/* ============================================
   SCROLL-TRIGGERED ANIMATIONS
   ============================================ */

/* Fade in from bottom */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px) translateZ(0); /* Force GPU acceleration */
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    will-change: opacity, transform; /* Otimizar para composição GPU */
    /* FIX: Garantir espaço reservado para prevenir layout shift */
    min-height: 1px; /* Reserve space even when invisible */
    contain: layout; /* Prevent layout shift */
}

.fade-in-up.visible {
    opacity: 1;
    transform: translateY(0) translateZ(0);
    will-change: auto; /* Remover will-change após animação */
}

/* Mobile: Force visible immediately (no animation) */
@media (max-width: 768px) {
    .fade-in-up {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        will-change: auto !important;
    }
}

/* Fade in from left */
.fade-in-left {
    opacity: 0;
    transform: translateX(-30px) translateZ(0); /* Force GPU acceleration */
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    will-change: opacity, transform;
    /* FIX: Garantir espaço reservado para prevenir layout shift */
    min-height: 1px; /* Reserve space even when invisible */
    contain: layout; /* Prevent layout shift */
}

/* Mobile: Force visible immediately (no animation) */
@media (max-width: 768px) {
    .fade-in-left {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        will-change: auto !important;
    }
}

.fade-in-left.visible {
    opacity: 1;
    transform: translateX(0) translateZ(0);
    will-change: auto;
}

/* Fade in from right */
.fade-in-right {
    opacity: 0;
    transform: translateX(30px) translateZ(0); /* Force GPU acceleration */
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    will-change: opacity, transform;
    /* FIX: Garantir espaço reservado para prevenir layout shift */
    min-height: 1px; /* Reserve space even when invisible */
    contain: layout; /* Prevent layout shift */
}

/* Mobile: Force visible immediately (no animation) */
@media (max-width: 768px) {
    .fade-in-right {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        will-change: auto !important;
    }
}

.fade-in-right.visible {
    opacity: 1;
    transform: translateX(0) translateZ(0);
    will-change: auto;
}

/* Scale in */
.scale-in {
    opacity: 0;
    transform: scale(0.9) translateZ(0); /* Force GPU acceleration */
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    will-change: opacity, transform;
    /* FIX: Garantir espaço reservado para prevenir layout shift */
    min-height: 1px; /* Reserve space even when invisible */
    contain: layout; /* Prevent layout shift */
}

.scale-in.visible {
    opacity: 1;
    transform: scale(1) translateZ(0);
    will-change: auto; /* Remover will-change após animação */
}

/* Fade in (simple) */
.fade-in {
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.fade-in.visible {
    opacity: 1;
}

/* ============================================
   HOVER EFFECTS
   ============================================ */

/* Card hover effect - GPU accelerated */
.card-hover {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
    transform: translateZ(0); /* Force GPU acceleration */
}

.card-hover:hover {
    transform: translateY(-5px) translateZ(0);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
}

.card-hover:not(:hover) {
    will-change: auto; /* Remove will-change when not hovering */
}

/* Button hover effect - GPU accelerated */
.btn-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    will-change: transform;
    transform: translateZ(0);
}

.btn-hover:hover {
    transform: translateY(-2px) translateZ(0);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

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

.btn-hover:active {
    transform: translateY(0);
}

/* Image hover effect - GPU accelerated */
.img-hover {
    transition: transform 0.3s ease, filter 0.3s ease;
    will-change: transform;
    transform: translateZ(0);
}

.img-hover:hover {
    transform: scale(1.05) translateZ(0);
    filter: brightness(1.1);
}

.img-hover:not(:hover) {
    will-change: auto;
}

/* Link hover effect - GPU accelerated */
.link-hover {
    transition: color 0.2s ease, transform 0.2s ease;
    display: inline-block;
    will-change: transform;
    transform: translateZ(0);
}

.link-hover:hover {
    transform: translateX(5px) translateZ(0);
}

.link-hover:not(:hover) {
    will-change: auto;
}

/* Reduce animations on mobile for better performance */
@media (max-width: 768px) {
    .fade-in-up,
    .fade-in-left,
    .fade-in-right,
    .scale-in {
        transition-duration: 0.4s; /* Faster on mobile */
    }
    
    .card-hover:hover,
    .btn-hover:hover {
        transform: translateY(-3px) translateZ(0); /* Smaller movement on mobile */
    }
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .fade-in-up,
    .fade-in-left,
    .fade-in-right,
    .scale-in,
    .fade-in {
        transition: none;
        opacity: 1;
        transform: none;
    }
    
    .card-hover,
    .btn-hover,
    .img-hover,
    .link-hover {
        transition: none;
    }
    
    .card-hover:hover,
    .btn-hover:hover,
    .img-hover:hover,
    .link-hover:hover {
        transform: none;
    }
    
    @keyframes skeleton-loading {
        from, to {
            background-position: 0 0;
        }
    }
}

/* ============================================
   LOADING SKELETONS
   ============================================ */

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

/* Mobile: Disable skeleton animation */
@media (max-width: 768px) {
    .skeleton {
        animation: none !important;
        background: #f0f0f0 !important;
        background-size: 100% 100% !important;
    }
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(
        90deg,
        #2a2a2a 25%,
        #1e1e1e 50%,
        #2a2a2a 75%
    );
    background-size: 200% 100%;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 1em;
}

.skeleton-image {
    width: 100%;
    height: 200px;
    border-radius: 8px;
}

/* ============================================
   SMOOTH SCROLL BEHAVIOR
   ============================================ */

html {
    scroll-behavior: smooth;
}

/* Mobile: Disable smooth scroll for better performance */
@media (max-width: 768px) {
    html {
        scroll-behavior: auto !important;
    }
}

/* ============================================
   PULSE ANIMATION (for CTAs)
   ============================================ */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Mobile: Disable pulse animation */
@media (max-width: 768px) {
    .pulse {
        animation: none !important;
        opacity: 1 !important;
    }
}

/* ============================================
   STAGGER ANIMATIONS (for lists)
   ============================================ */

.stagger-item {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

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

/* Delay for staggered effect */
.stagger-item:nth-child(1) { transition-delay: 0.1s; }
.stagger-item:nth-child(2) { transition-delay: 0.2s; }
.stagger-item:nth-child(3) { transition-delay: 0.3s; }
.stagger-item:nth-child(4) { transition-delay: 0.4s; }
.stagger-item:nth-child(5) { transition-delay: 0.5s; }
.stagger-item:nth-child(6) { transition-delay: 0.6s; }

/* ============================================
   SERVICE CARDS HOVER
   ============================================ */

.content-image {
    transition: transform 0.4s ease, filter 0.4s ease;
}

.content:hover .content-image {
    transform: scale(1.1);
    /* CRITICAL: No filter - overlay will darken the image, keep images vivid */
    filter: none;
}

.content-details {
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* ============================================
   RESPONSIVE: Disable animations on mobile for performance
   ============================================ */

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

@media (max-width: 768px) {
    /* CRITICAL: Disable ALL animations on mobile for better performance (91 → reduce) */
    /* Force all animated elements to be visible immediately */
    .fade-in-up,
    .fade-in-left,
    .fade-in-right,
    .scale-in,
    .fade-in,
    .stagger-item {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        animation: none !important;
        will-change: auto !important;
        /* Force visibility immediately */
        visibility: visible !important;
    }
    
    /* CRITICAL: Carousel testimonials - manter funcionalidade mas sem animações */
    .testimonials-carousel.carousel-fade .carousel-item {
        transition: opacity 0.01s linear !important;
    }
    
    .testimonials-carousel .carousel-item {
        transition: transform 0.01s linear !important;
        opacity: 1 !important;
    }
    
    /* Garantir que indicadores e controles funcionem */
    .testimonials-carousel .carousel-indicators li,
    .testimonials-carousel .carousel-control-prev,
    .testimonials-carousel .carousel-control-next {
        pointer-events: auto !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(58, 80, 90, 0.3) !important;
        z-index: 15 !important;
    }
    
    /* Make sure visible class doesn't trigger animations */
    .fade-in-up.visible,
    .fade-in-left.visible,
    .fade-in-right.visible,
    .scale-in.visible,
    .fade-in.visible,
    .stagger-item.visible {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
    
    /* Disable hover effects on mobile */
    .card-hover:hover,
    .btn-hover:hover,
    .img-hover:hover,
    .link-hover:hover,
    .img-hover:hover {
        transform: none !important;
        filter: none !important;
    }
    
    /* Disable transitions on mobile */
    .card-hover,
    .btn-hover,
    .img-hover,
    .link-hover {
        transition: none !important;
        will-change: auto !important;
    }
    
    /* Disable skeleton animations */
    .skeleton {
        animation: none !important;
        background: #f0f0f0 !important;
        background-size: 100% 100% !important;
    }
    
    /* Disable pulse animations */
    .pulse {
        animation: none !important;
        opacity: 1 !important;
    }
    
    /* Disable smooth scroll on mobile */
    html {
        scroll-behavior: auto !important;
    }
}

