/* Animations CSS for Airavat Overseas Website - FIXED */

/* Fade In Animations */
@keyframes fadeIn {
    from { 
        opacity: 0; 
    }
    to { 
        opacity: 1; 
    }
}

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

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

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

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

/* Scale Animations */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* Rotate Animations */
@keyframes rotate {
    from { 
        transform: rotate(0deg); 
    }
    to { 
        transform: rotate(360deg); 
    }
}

/* Bounce Animation */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { 
        transform: translateY(0); 
    }
    40% { 
        transform: translateY(-20px); 
    }
    60% { 
        transform: translateY(-10px); 
    }
}

/* Shake Animation */
@keyframes shake {
    0%, 100% { 
        transform: translateX(0); 
    }
    10%, 30%, 50%, 70%, 90% { 
        transform: translateX(-5px); 
    }
    20%, 40%, 60%, 80% { 
        transform: translateX(5px); 
    }
}

/* Slide In Animations */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

/* Enhanced Scroll Animation Classes - FIXED */
.animate-on-scroll {
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

/* Specific initial states for scroll animations */
.animate-on-scroll[data-animation="fade-in-left"] {
    transform: translateX(-50px);
}

.animate-on-scroll[data-animation="fade-in-right"] {
    transform: translateX(50px);
}

.animate-on-scroll[data-animation="fade-in-up"] {
    transform: translateY(50px);
}

.animate-on-scroll[data-animation="fade-in-down"] {
    transform: translateY(-50px);
}

.animate-on-scroll[data-animation="scale-in"] {
    transform: scale(0.8);
}

.animate-on-scroll[data-animation="slide-in-left"] {
    transform: translateX(-100px);
}

.animate-on-scroll[data-animation="slide-in-right"] {
    transform: translateX(100px);
}

/* When animated class is added */
.animate-on-scroll.animated {
    opacity: 1;
    transform: translate(0, 0) scale(1);
}

/* Animation Classes - FIXED */
.fade-in { 
    animation: fadeIn 1s ease forwards;
}

.fade-in-left { 
    animation: fadeInLeft 1s ease forwards;
}

.fade-in-right { 
    animation: fadeInRight 1s ease forwards;
}

.fade-in-down { 
    animation: fadeInDown 1s ease forwards;
}

.fade-in-up { 
    animation: fadeInUp 1s ease forwards;
}

.scale-in { 
    animation: scaleIn 1s ease forwards;
}

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

.rotate { 
    animation: rotate 10s linear infinite;
}

.bounce { 
    animation: bounce 2s ease infinite;
}

.bounce-in {
    animation: bounce 1s ease forwards;
}

.shake { 
    animation: shake 0.5s ease forwards;
}

.slide-in-left {
    animation: slideInLeft 0.8s ease forwards;
}

.slide-in-right {
    animation: slideInRight 0.8s ease forwards;
}

.rotate-in {
    animation: rotate 1s ease forwards;
}

/* Animation Delays */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; }

/* Element-specific animations - FIXED */
.btn-primary:hover, 
.btn-secondary:hover {
    animation: pulse 0.5s ease;
}

.section-title h2::after {
    animation: scaleIn 1s ease forwards;
}

.product-item:hover img {
    animation: pulse 1s ease;
}

.social-icons a:hover i {
    animation: rotate 0.5s ease;
}

/* Logo animation - FIXED */
.logo h1 {
    position: relative;
    overflow: hidden;
}

.logo h1::before {
    content: '';
    position: absolute;
    left: -100%;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: logo-shine 3s infinite;
}

@keyframes logo-shine {
    0% { left: -100%; }
    50% { left: 100%; }
    100% { left: 100%; }
}

/* Hover effect for navigation links */
#navbar ul li a:hover {
    animation: shake 0.5s ease;
}

/* Animated background for CTA sections - FIXED */
.cta-section {
    position: relative;
    overflow: hidden;
}

.cta-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(39,174,96,0.1) 0%, rgba(39,174,96,0) 70%);
    animation: rotate 30s linear infinite;
    z-index: 1;
    pointer-events: none;
}

.cta-section .container {
    position: relative;
    z-index: 2;
}

/* Additional fixes for common animation issues */
.animate-on-scroll {
    /* Ensure elements are visible once animated */
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Icon animations */
.icon-animation:hover {
    animation: pulse 0.6s ease;
}

.link-animation:hover {
    animation: shake 0.3s ease;
}

.social-icon-animation:hover {
    animation: bounce 0.6s ease;
}

.logo-animation:hover {
    animation: pulse 0.8s ease;
}

/* Loading animations */
.loading-spinner {
    animation: rotate 1s linear infinite;
}

/* Staggered animations for lists */
.staggered-list li {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease forwards;
}

.staggered-list li:nth-child(1) { animation-delay: 0.1s; }
.staggered-list li:nth-child(2) { animation-delay: 0.2s; }
.staggered-list li:nth-child(3) { animation-delay: 0.3s; }
.staggered-list li:nth-child(4) { animation-delay: 0.4s; }
.staggered-list li:nth-child(5) { animation-delay: 0.5s; }

/* Page transition animations */
.page-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Mobile menu animations */
#navbar {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#navbar.active {
    transform: translateX(0);
    opacity: 1;
}

/* Hero section specific animations */
.hero-section .hero-content > * {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease forwards;
}

.hero-section .hero-content h1 {
    animation-delay: 0.2s;
}

.hero-section .hero-content h2 {
    animation-delay: 0.4s;
}

.hero-section .hero-content p {
    animation-delay: 0.6s;
}

.hero-section .hero-content .btn-primary {
    animation-delay: 0.8s;
}

/* Form element animations */
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    animation: pulse 0.3s ease;
}

/* Card hover animations */
.product-item,
.process-step,
.feature,
.team-member {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product-item:hover,
.process-step:hover,
.feature:hover,
.team-member:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

/* Progress bar animations */
@keyframes progressFill {
    from { width: 0%; }
    to { width: 100%; }
}

.progress-bar {
    animation: progressFill 2s ease-in-out forwards;
}

/* Counter animations */
@keyframes countUp {
    from { 
        transform: translateY(20px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

.counter-animate {
    animation: countUp 1s ease forwards;
}

/* Gradient shift animation for category headers */
@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.brochure-category::before {
    background: linear-gradient(90deg, #27ae60, #2ecc71, #27ae60);
    background-size: 200% 100%;
    animation: gradient-shift 3s ease infinite;
}

/* Floating animation */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.float {
    animation: float 3s ease-in-out infinite;
}

/* Typewriter effect */
@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    0%, 100% { border-color: transparent; }
    50% { border-color: #27ae60; }
}

.typewriter {
    overflow: hidden;
    border-right: 2px solid #27ae60;
    white-space: nowrap;
    animation: typewriter 3s steps(40) 1s forwards, blink 0.75s step-end infinite;
}

/* Ensure animations work on all modern browsers */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles - disable animations */
@media print {
    * {
        animation: none !important;
        transition: none !important;
    }
    
    .animate-on-scroll {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* =========================================
   RESPONSIVE MEDIA QUERIES & ADJUSTMENTS
   ========================================= */

/* Tablet / Small Laptop (Max Width: 1024px) */
@media (max-width: 1024px) {
    /* Reduce slide distances for tablet to prevent cutting off content */
    .animate-on-scroll[data-animation="fade-in-left"] { transform: translateX(-30px); }
    .animate-on-scroll[data-animation="fade-in-right"] { transform: translateX(30px); }
    .animate-on-scroll[data-animation="slide-in-left"] { transform: translateX(-50px); }
    .animate-on-scroll[data-animation="slide-in-right"] { transform: translateX(50px); }
    
    /* Adjust Hero Content spacing */
    .hero-section .hero-content {
        padding: 0 20px;
    }
}

/* Mobile Landscape / Tablets (Max Width: 768px) */
@media (max-width: 768px) {
    
    /* 1. GLOBAL OVERFLOW FIX */
    /* Prevents horizontal scrollbars caused by slide-in animations */
    body, html {
        overflow-x: hidden;
        width: 100%;
    }

    /* 2. REDUCED ANIMATION DISTANCE FOR MOBILE */
    /* Large movements (50px+) look bad on small screens. We redefine specific keyframes locally. */
    
    @keyframes fadeInLeft {
        from { opacity: 0; transform: translateX(-20px); }
        to { opacity: 1; transform: translateX(0); }
    }

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

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

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

    /* Adjust initial states for scroll library */
    .animate-on-scroll[data-animation="fade-in-left"] { transform: translateX(-20px); }
    .animate-on-scroll[data-animation="fade-in-right"] { transform: translateX(20px); }
    .animate-on-scroll[data-animation="slide-in-left"] { transform: translateX(-20px); }
    .animate-on-scroll[data-animation="slide-in-right"] { transform: translateX(20px); }

    /* 3. CTA SECTION FIX */
    /* Reduce the massive rotating background on mobile */
    .cta-section::before {
        width: 150%; 
        height: 150%;
        top: -25%;
        left: -25%;
    }

    /* 4. TYPEWRITER FIX */
    /* Typewriter effect breaks on mobile wrapping. We switch to a simple fade-in. */
    .typewriter {
        white-space: normal; /* Allow text to wrap */
        border-right: none; /* Remove the cursor */
        animation: fadeIn 1s ease forwards; /* Fallback animation */
        width: auto;
    }

    /* 5. CARD HOVER ADJUSTMENTS */
    /* Reduce "lift" effect on touch devices to prevent sticky states */
    .product-item:hover,
    .process-step:hover,
    .feature:hover,
    .team-member:hover {
        transform: translateY(-5px); /* Reduced from -10px */
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    }

    /* 6. HERO TYPOGRAPHY SCALING */
    .hero-section .hero-content h1 {
        font-size: 2rem; /* Adjust based on your specific design needs */
        line-height: 1.2;
    }
    
    .hero-section .hero-content h2 {
        font-size: 1.5rem;
    }
}

/* Small Mobile (Max Width: 480px) */
@media (max-width: 480px) {
    /* Further reduce animation offsets */
    .animate-on-scroll[data-animation="fade-in-up"],
    .animate-on-scroll[data-animation="fade-in-down"] { 
        transform: translateY(20px); 
    }

    /* Stack staggered lists faster on mobile */
    .staggered-list li:nth-child(1) { animation-delay: 0.05s; }
    .staggered-list li:nth-child(2) { animation-delay: 0.1s; }
    .staggered-list li:nth-child(3) { animation-delay: 0.15s; }
    .staggered-list li:nth-child(4) { animation-delay: 0.2s; }
    
    /* Reset logo animation to be subtle */
    .logo h1::before {
        animation: none; /* Disable shine on very small screens for performance */
    }
    
    /* Make buttons full width for easier tapping */
    .hero-section .btn-primary,
    .hero-section .btn-secondary {
        width: 100%;
        margin-bottom: 10px;
        display: block;
    }
}
