/* ===================================
   MIRAAL TECH - ANIMATIONS
   Advanced scroll and interactive animations
   =================================== */

/* ===================================
   KEYFRAME ANIMATIONS
   =================================== */

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

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

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

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(78, 172, 170, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(78, 172, 170, 0.6);
    }
}

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

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

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.9);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

@keyframes countUp {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===================================
   SCROLL-TRIGGERED ANIMATIONS
   These classes are applied by JavaScript
   =================================== */

.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in-up.visible {
    opacity: 1;
    transform: translateY(0);
    animation: fadeInUp 0.6s ease forwards;
}

.fade-in-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in-left.visible {
    opacity: 1;
    transform: translateX(0);
    animation: fadeInLeft 0.6s ease forwards;
}

.fade-in-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in-right.visible {
    opacity: 1;
    transform: translateX(0);
    animation: fadeInRight 0.6s ease forwards;
}

.scale-in {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.scale-in.visible {
    opacity: 1;
    transform: scale(1);
    animation: scaleIn 0.6s ease forwards;
}

/* ===================================
   CARD ANIMATIONS
   =================================== */

.service-card {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.service-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(78, 172, 170, 0.05);
    transition: left 0.3s ease;
    z-index: -1;
}

.service-card:hover::after {
    left: 100%;
}

.portfolio-card {
    position: relative;
    overflow: hidden;
}

.portfolio-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(78, 172, 170, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.6s ease;
    z-index: 1;
    pointer-events: none;
}

.portfolio-card:hover::before {
    opacity: 1;
}

.why-card {
    position: relative;
    overflow: hidden;
}

.why-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--accent-teal), transparent);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.6s ease;
}

.why-card:hover::before {
    transform: scaleX(1);
}

/* ===================================
   BUTTON ANIMATIONS
   =================================== */

.btn-primary,
.btn-secondary,
.cta-button {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-primary::before,
.btn-secondary::before,
.cta-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    z-index: 0;
}

.btn-primary:active::before,
.btn-secondary:active::before,
.cta-button:active::before {
    width: 300px;
    height: 300px;
}

/* ===================================
   NAVIGATION ANIMATIONS
   =================================== */

.nav-links a {
    position: relative;
}

.nav-links a::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-teal);
    transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-links a:hover::before {
    width: 100%;
}

/* ===================================
   FORM ANIMATIONS
   =================================== */

.form-group input,
.form-group textarea,
.form-group select {
    position: relative;
    transition: all 0.3s ease;
}

.form-group input::placeholder {
    transition: color 0.3s ease;
}

.form-group input:focus::placeholder {
    color: var(--accent-teal);
}

.form-group label {
    transition: color 0.3s ease;
}

.form-group input:focus + label,
.form-group textarea:focus + label {
    color: var(--accent-teal);
}

.success-message {
    animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===================================
   FAQ ANIMATIONS
   =================================== */

.faq-answer {
    animation: slideUp 0.3s ease forwards;
    max-height: 0;
    overflow: hidden;
}

.faq-item.active .faq-answer {
    max-height: 500px;
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.faq-arrow {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===================================
   PARALLAX EFFECT (for hero)
   =================================== */

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

/* ===================================
   STAGGER ANIMATIONS
   For multiple elements in sequence
   =================================== */

.services-grid .service-card:nth-child(1) { animation-delay: 0.1s; }
.services-grid .service-card:nth-child(2) { animation-delay: 0.2s; }
.services-grid .service-card:nth-child(3) { animation-delay: 0.3s; }
.services-grid .service-card:nth-child(4) { animation-delay: 0.4s; }
.services-grid .service-card:nth-child(5) { animation-delay: 0.5s; }
.services-grid .service-card:nth-child(6) { animation-delay: 0.6s; }

.portfolio-grid .portfolio-card:nth-child(1) { animation-delay: 0.1s; }
.portfolio-grid .portfolio-card:nth-child(2) { animation-delay: 0.2s; }
.portfolio-grid .portfolio-card:nth-child(3) { animation-delay: 0.3s; }
.portfolio-grid .portfolio-card:nth-child(4) { animation-delay: 0.4s; }
.portfolio-grid .portfolio-card:nth-child(5) { animation-delay: 0.5s; }
.portfolio-grid .portfolio-card:nth-child(6) { animation-delay: 0.6s; }

.why-choose-grid .why-card:nth-child(1) { animation-delay: 0.1s; }
.why-choose-grid .why-card:nth-child(2) { animation-delay: 0.2s; }
.why-choose-grid .why-card:nth-child(3) { animation-delay: 0.3s; }
.why-choose-grid .why-card:nth-child(4) { animation-delay: 0.4s; }
.why-choose-grid .why-card:nth-child(5) { animation-delay: 0.5s; }
.why-choose-grid .why-card:nth-child(6) { animation-delay: 0.6s; }

.faq-items .faq-item:nth-child(1) { animation-delay: 0.1s; }
.faq-items .faq-item:nth-child(2) { animation-delay: 0.2s; }
.faq-items .faq-item:nth-child(3) { animation-delay: 0.3s; }
.faq-items .faq-item:nth-child(4) { animation-delay: 0.4s; }
.faq-items .faq-item:nth-child(5) { animation-delay: 0.5s; }
.faq-items .faq-item:nth-child(6) { animation-delay: 0.6s; }

/* ===================================
   SMOOTH TRANSITIONS
   =================================== */

* {
    transition: background-color 0.3s ease, color 0.3s ease;
}

a, button {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===================================
   LOADING ANIMATION
   =================================== */

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

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

/* ===================================
   HOVER EFFECTS FOR LINKS
   =================================== */

.footer-section a {
    position: relative;
    transition: color 0.3s ease;
}

.footer-section a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -3px;
    left: 0;
    background-color: var(--accent-teal);
    transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.footer-section a:hover::after {
    width: 100%;
}

/* ===================================
   TEXT SELECTION ANIMATION
   =================================== */

::selection {
    background-color: var(--accent-teal);
    color: white;
}

::-moz-selection {
    background-color: var(--accent-teal);
    color: white;
}

/* ===================================
   SCROLLBAR STYLING
   =================================== */

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-teal);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-teal-light);
}

/* ===================================
   PERFORMANCE OPTIMIZATIONS
   =================================== */

.service-card,
.portfolio-card,
.why-card,
.faq-item {
    will-change: transform, box-shadow;
}

/* ===================================
   ACCESSIBILITY - REDUCED MOTION
   =================================== */

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