/* ============================================
   ANIMATIONS.CSS - Modern Interactions
   NexOrganix Website Enhancement
   ============================================ */

/* ============================================
   1. PREFERS-REDUCED-MOTION GUARD
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .hero-overlay,
    .typing-text,
    .pulse-btn,
    .scroll-animate {
        animation: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
}

/* ============================================
   2. HERO ANIMATIONS
   ============================================ */

/* Hero Overlay with Parallax Effect */
.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(2, 119, 189, 0.88) 0%,
        rgba(69, 90, 100, 0.82) 100%
    );
    z-index: 0;
    transition: transform 0.3s ease-out;
    will-change: transform;
}

/* Typing Animation for Hero Undertext */
.typing-text {
    display: inline-block;
    overflow: hidden;
    border-right: 2px solid rgba(255, 255, 255, 0.75);
    white-space: nowrap;
    animation: typing 3s steps(60, end) 1s forwards,
               blink-caret 0.75s step-end infinite;
    max-width: 0;
    opacity: 0;
}

@keyframes typing {
    from {
        max-width: 0;
        opacity: 1;
    }
    to {
        max-width: 100%;
        opacity: 1;
    }
}

@keyframes blink-caret {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: rgba(255, 255, 255, 0.75);
    }
}

/* Keep text visible and remove border after typing completes */
.typing-text.typing-complete {
    border-right: none;
    animation: none;
    max-width: 100%;
    opacity: 1;
    overflow: visible;
}

/* Pulsating CTA Button */
.pulse-btn {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(255, 111, 0, 0.3),
                    0 0 0 0 rgba(255, 111, 0, 0.7);
    }
    50% {
        box-shadow: 0 4px 12px rgba(255, 111, 0, 0.3),
                    0 0 0 12px rgba(255, 111, 0, 0);
    }
}

.pulse-btn:hover {
    animation: none;
}

/* ============================================
   3. SCROLL REVEAL ANIMATIONS
   ============================================ */

/* Base state for scroll animations */
.scroll-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out,
                transform 0.6s ease-out;
}

.scroll-animate.active {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger delays for child elements */
.scroll-animate:nth-child(2) {
    transition-delay: 0.1s;
}

.scroll-animate:nth-child(3) {
    transition-delay: 0.2s;
}

.scroll-animate:nth-child(4) {
    transition-delay: 0.3s;
}

/* Title Accent Growth Animation */
.title-accent {
    display: block;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    margin: 10px auto 0;
    width: 0;
    transition: width 0.8s ease-out 0.3s;
    max-width: 100px;
}

.section-title.active .title-accent {
    width: 80px;
}

/* ============================================
   4. SERVICE CARD INTERACTIONS
   ============================================ */

/* Service card hover effects */
.service-card {
    position: relative;
    transition: transform 0.3s ease,
                box-shadow 0.3s ease;
}

.service-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

/* Service hover text reveal */
.service-hover {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    text-align: center;
    font-weight: 600;
    color: var(--accent-color);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.service-card:hover .service-hover {
    opacity: 1;
    transform: translateY(0);
}

.service-card:hover .service-main {
    opacity: 0.7;
}

.service-main {
    transition: opacity 0.3s ease;
}

/* ============================================
   5. CASE CHIPS ANIMATIONS
   ============================================ */

.case-chip {
    transition: transform 0.3s ease,
                box-shadow 0.3s ease,
                background-color 0.3s ease;
    cursor: default;
}

.case-chip:hover {
    transform: translateY(-5px) scale(1.03);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    background-color: #f8f9fa;
}

.case-chip h3 {
    transition: color 0.3s ease;
}

.case-chip:hover h3 {
    color: var(--accent-color);
}

/* ============================================
   6. STICKY CTA ANIMATIONS
   ============================================ */

.sticky-cta {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-light));
    color: var(--white);
    padding: 12px 20px;
    border-radius: 50px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(255, 111, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    z-index: 999;
    opacity: 0;
    transform: translateY(100px);
    transition: opacity 0.3s ease,
                transform 0.3s ease,
                box-shadow 0.3s ease;
    pointer-events: none;
}

.sticky-cta.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.sticky-cta:hover {
    box-shadow: 0 6px 20px rgba(255, 111, 0, 0.4);
    transform: translateY(-3px);
}

.sticky-cta-icon {
    font-size: 1.3rem;
}

.sticky-cta-text {
    font-size: 0.95rem;
}

/* ============================================
   7. BACK TO TOP BUTTON
   ============================================ */

.back-to-top {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: var(--text-dark);
    color: var(--white);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(100px);
    transition: opacity 0.3s ease,
                transform 0.3s ease,
                background-color 0.3s ease;
    z-index: 998;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.back-to-top:hover {
    background: var(--accent-color);
    transform: translateY(-3px);
}

.back-to-top:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ============================================
   8. BUTTON ENHANCEMENTS
   ============================================ */

.btn {
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease,
                box-shadow 0.3s ease;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0) scale(1);
}

/* ============================================
   9. FOCUS STATES (Accessibility)
   ============================================ */

*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}

a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}

/* ============================================
   10. FORM ANIMATIONS
   ============================================ */

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(2, 119, 189, 0.1);
    transform: scale(1.01);
    transition: border-color 0.3s ease,
                box-shadow 0.3s ease,
                transform 0.2s ease;
}

.error-message {
    display: block;
    color: #c62828;
    font-size: 0.85rem;
    margin-top: 5px;
    min-height: 1.2rem;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.3s ease,
                transform 0.3s ease;
}

.error-message.visible {
    opacity: 1;
    transform: translateY(0);
}

.form-group.error input,
.form-group.error textarea {
    border-color: #c62828;
}

/* ============================================
   11. RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .sticky-cta {
        bottom: 15px;
        right: 15px;
        padding: 10px 16px;
    }
    
    .sticky-cta-text {
        font-size: 0.85rem;
    }
    
    .back-to-top {
        bottom: 15px;
        left: 15px;
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
    
    .service-card:hover {
        transform: translateY(-5px);
    }
    
    /* Reduce parallax on mobile */
    .hero-overlay {
        transition: none;
    }
}

@media (max-width: 480px) {
    .sticky-cta-text {
        display: none;
    }
    
    .sticky-cta {
        padding: 12px;
        border-radius: 50%;
        width: 50px;
        height: 50px;
        justify-content: center;
    }
}

/* ============================================
   12. LOADING STATES
   ============================================ */

.btn-loading {
    display: inline-block;
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

/* ============================================
   13. HERO UNDERTEXT STYLING
   ============================================ */

.hero-undertext {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    font-weight: 400;
    line-height: 1.6;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 768px) {
    .hero-undertext {
        font-size: 1rem;
    }
    
    .typing-text {
        white-space: normal;
        animation: fadeInUp 1s ease 1.5s forwards;
        border-right: none;
        opacity: 0;
    }
}
