/* ========================================
   Scroll Animations
   ======================================== */

.fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.animate-in {
    opacity: 0;
    animation: slideUp 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.animate-in:nth-child(1) {
    animation-delay: 0.2s;
}

.animate-in:nth-child(2) {
    animation-delay: 0.4s;
}

.animate-in:nth-child(3) {
    animation-delay: 0.6s;
}

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

/* ========================================
   Loading Animation
   ======================================== */

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

.loading {
    animation: spin 1s linear infinite;
}

/* ========================================
   Button Hover Animations
   ======================================== */

.btn {
    position: relative;
    overflow: hidden;
}

.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.8s cubic-bezier(0.4, 0, 0.2, 1), 
                height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ========================================
   Card Animations
   ======================================== */

.advantage-card,
.service-card,
.review-card,
.guarantee-item {
    position: relative;
    overflow: hidden;
}

.advantage-card::after,
.service-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.03),
        transparent
    );
    transform: rotate(45deg);
    transition: all 0.5s;
}

.advantage-card:hover::after,
.service-card:hover::after {
    animation: shine 1.5s ease-in-out;
}

@keyframes shine {
    0% {
        top: -50%;
        right: -50%;
    }
    100% {
        top: 150%;
        right: 150%;
    }
}

/* ========================================
   Parallax Effects
   ======================================== */

.hero-bg {
    will-change: transform;
    transition: transform 0.3s ease-out;
}

/* ========================================
   Text Typing Animation
   ======================================== */

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

.typing-text {
    display: inline-block;
    overflow: hidden;
    border-right: 3px solid var(--color-red);
    white-space: nowrap;
    animation: typing 3s steps(40) 1s forwards, blink 0.5s step-end infinite;
}

/* ========================================
   Icon Hover Animations
   ======================================== */

.advantage-icon,
.service-icon,
.guarantee-icon {
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.advantage-card:hover .advantage-icon,
.service-card:hover .service-icon,
.guarantee-item:hover .guarantee-icon {
    transform: scale(1.1) rotate(5deg);
}

/* ========================================
   Slider Animations
   ======================================== */

.portfolio-track {
    will-change: transform;
}

/* ========================================
   Modal Animations
   ======================================== */

.modal.active .modal-content {
    animation: modalSlideIn 0.4s ease forwards;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal.closing .modal-content {
    animation: modalSlideOut 0.3s ease forwards;
}

@keyframes modalSlideOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
}

/* ========================================
   Process Step Animation
   ======================================== */

.process-step::before {
    content: '';
    position: absolute;
    left: 40px;
    top: 100%;
    width: 2px;
    height: 0;
    background: linear-gradient(to bottom, var(--color-red), var(--color-blue));
    transition: height 0.5s ease;
}

.process-step.visible::before {
    height: var(--spacing-lg);
}

.process-step:last-child::before {
    display: none;
}

/* ========================================
   Counter Animation
   ======================================== */

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

.counter {
    animation: countUp 0.5s ease;
}

/* ========================================
   Hover Glow Effects
   ======================================== */

.btn-primary:hover,
.btn-accent:hover {
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(229, 29, 29, 0.4);
    }
    50% {
        box-shadow: 0 8px 32px rgba(229, 29, 29, 0.6);
    }
}

/* ========================================
   Image Zoom on Hover
   ======================================== */

.portfolio-image {
    overflow: hidden;
}

.portfolio-image img {
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.portfolio-item:hover .portfolio-image img {
    transform: scale(1.1);
}

/* ========================================
   Skeleton Loading
   ======================================== */

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

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-black-lighter) 25%,
        var(--color-black-light) 50%,
        var(--color-black-lighter) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

/* ========================================
   Smooth Scroll Indicator
   ======================================== */

@keyframes scroll-bounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(10px);
    }
}

.hero-scroll {
    animation: scroll-bounce 2s ease-in-out infinite;
}

/* ========================================
   FAQ Toggle Animation
   ======================================== */

.faq-item {
    transition: all 0.3s ease;
}

.faq-item.active {
    background: var(--color-black);
}

.faq-answer {
    transition: max-height 0.4s ease, padding 0.4s ease;
}

/* ========================================
   Link Underline Animation
   ======================================== */

.link-animated {
    position: relative;
}

.link-animated::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-red);
    transition: width 0.3s ease;
}

.link-animated:hover::after {
    width: 100%;
}

/* ========================================
   Star Rating Animation
   ======================================== */

.review-rating .star {
    animation: star-pop 0.3s ease;
}

.review-rating .star:nth-child(1) {
    animation-delay: 0s;
}

.review-rating .star:nth-child(2) {
    animation-delay: 0.1s;
}

.review-rating .star:nth-child(3) {
    animation-delay: 0.2s;
}

.review-rating .star:nth-child(4) {
    animation-delay: 0.3s;
}

.review-rating .star:nth-child(5) {
    animation-delay: 0.4s;
}

@keyframes star-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   Gradient Animation
   ======================================== */

@keyframes gradient-shift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.gradient-animated {
    background-size: 200% 200%;
    animation: gradient-shift 3s ease infinite;
}

/* ========================================
   Performance Optimizations
   ======================================== */

.will-animate {
    will-change: transform, opacity;
}

.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
}
