/* ************************************************************
:: Smooth Enhancements - Inspired by qwetuhealthcare.com
:: Adds smooth animations, better image handling, and performance optimizations
************************************************************ */

/* ******************************
:: CSS CUSTOM PROPERTIES (VARIABLES)
****************************** */
:root {
    /* Colors */
    --primary-color: #7c4fe0;
    --primary-hover: #0449c4;
    --secondary-color: #666;
    --text-color: #222;
    --text-light: #565656;
    --bg-white: #fff;
    --bg-grey: #f8f9fa;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Transitions */
    --transition-fast: 0.2s;
    --transition-normal: 0.3s;
    --transition-slow: 0.5s;
    --easing-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Shadows */
    --shadow-sm: 0 1px 5px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 5px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    
    /* Z-index layers */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 300;
    --z-tooltip: 400;
}

/* ******************************
:: SMOOTH SCROLLING
****************************** */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* ******************************
:: IMAGE OPTIMIZATIONS
****************************** */
img {
    height: auto;
    max-width: 100%;
    display: block;
    /* Prevent layout shift */
    aspect-ratio: attr(width) / attr(height);
}

/* Portfolio images */
.single-case-studies img,
.portfolio-item img {
    width: 100%;
    height: auto;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform var(--transition-slow) var(--easing-smooth);
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

.single-case-studies:hover img {
    transform: translate3d(0, 0, 0) scale(1.05);
}

/* Service/Testimonial images */
.single-service img,
.single-review img,
.reviewer-thumb img,
.avatar-lg,
.avatar-md,
.avatar-sm {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: inherit;
}

/* Blog images */
.blog-thumb img,
.post-thumb img {
    width: 100%;
    height: auto;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Portfolio detail images */
.portfolio-featured-image img,
.portfolio-detail-area img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
    object-position: center;
    display: block;
    margin: 0 auto;
}

/* Service detail images */
.servicedetail-area img {
    width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: cover;
    object-position: center;
    display: block;
    border-radius: 8px;
}

/* Welcome area images */
.welcome-thumb-wrapper img,
.welcome-animation {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block;
    transform: translate3d(0, 0, 0);
    will-change: transform;
}

/* Lazy loading placeholder */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity var(--transition-normal) var(--easing-smooth);
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* ******************************
:: HARDWARE-ACCELERATED ANIMATIONS
****************************** */

/* Fade-in animation */
.fade-in {
    opacity: 0;
    transform: translate3d(0, 30px, 0);
    transition: opacity var(--transition-slow) var(--easing-smooth),
                transform var(--transition-slow) var(--easing-smooth);
    will-change: opacity, transform;
}

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

/* Fly-in animations */
.fly-in-left {
    opacity: 0;
    transform: translate3d(-50px, 0, 0);
    transition: opacity var(--transition-slow) var(--easing-smooth),
                transform var(--transition-slow) var(--easing-smooth);
    will-change: opacity, transform;
}

.fly-in-left.visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

.fly-in-right {
    opacity: 0;
    transform: translate3d(50px, 0, 0);
    transition: opacity var(--transition-slow) var(--easing-smooth),
                transform var(--transition-slow) var(--easing-smooth);
    will-change: opacity, transform;
}

.fly-in-right.visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

.fly-in-up {
    opacity: 0;
    transform: translate3d(0, 50px, 0);
    transition: opacity var(--transition-slow) var(--easing-smooth),
                transform var(--transition-slow) var(--easing-smooth);
    will-change: opacity, transform;
}

.fly-in-up.visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

.fly-in-down {
    opacity: 0;
    transform: translate3d(0, -50px, 0);
    transition: opacity var(--transition-slow) var(--easing-smooth),
                transform var(--transition-slow) var(--easing-smooth);
    will-change: opacity, transform;
}

.fly-in-down.visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

/* Staggered animations for lists */
.stagger-item {
    opacity: 0;
    transform: translate3d(0, 30px, 0);
    transition: opacity var(--transition-slow) var(--easing-smooth),
                transform var(--transition-slow) var(--easing-smooth);
    will-change: opacity, transform;
}

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

/* ******************************
:: BUTTON ENHANCEMENTS
****************************** */
.btn {
    position: relative;
    overflow: hidden;
    transform: translate3d(0, 0, 0);
    will-change: transform;
    transition: all var(--transition-normal) var(--easing-smooth);
}

.btn::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 var(--transition-slow) var(--easing-smooth),
                height var(--transition-slow) var(--easing-smooth);
}

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

.btn:hover {
    transform: translate3d(0, -2px, 0);
}

.btn:active {
    transform: translate3d(0, 0, 0);
}

/* ******************************
:: STICKY HEADER ENHANCEMENTS
****************************** */
.navbar {
    transition: all var(--transition-normal) var(--easing-smooth);
    will-change: background-color, box-shadow, transform;
    transform: translate3d(0, 0, 0);
}

.navbar-sticky {
    background-color: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
    transform: translate3d(0, 0, 0);
}

/* ******************************
:: SCROLL PROGRESS INDICATOR
****************************** */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    z-index: var(--z-tooltip);
    transition: width 0.1s linear;
    transform: translate3d(0, 0, 0);
    will-change: width;
}

/* ******************************
:: CARD HOVER EFFECTS
****************************** */
.single-service,
.single-promo,
.single-review,
.contact-info {
    transition: all var(--transition-normal) var(--easing-smooth);
    transform: translate3d(0, 0, 0);
    will-change: transform, box-shadow;
}

.single-service:hover,
.single-promo:hover,
.single-review:hover,
.contact-info:hover {
    transform: translate3d(0, -5px, 0);
    box-shadow: var(--shadow-lg);
}

/* ******************************
:: FIX OVERLAPPING ELEMENTS
****************************** */

/* Portfolio overlay fix */
.single-case-studies {
    position: relative;
    overflow: hidden;
    z-index: var(--z-base);
}

.case-studies-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal) var(--easing-smooth);
    z-index: var(--z-dropdown);
    transform: translate3d(0, 0, 0);
    will-change: opacity;
}

.single-case-studies:hover .case-studies-overlay {
    opacity: 1;
}

.overlay-text {
    padding: var(--spacing-md);
    text-align: center;
    transform: translate3d(0, 20px, 0);
    transition: transform var(--transition-normal) var(--easing-smooth);
    will-change: transform;
}

.single-case-studies:hover .overlay-text {
    transform: translate3d(0, 0, 0);
}

/* Welcome area fix */
.welcome-area {
    position: relative;
    z-index: var(--z-base);
    overflow: hidden;
}

.welcome-thumb-wrapper {
    position: relative;
    z-index: var(--z-base);
}

/* Section spacing fix */
section {
    position: relative;
    z-index: var(--z-base);
}

section + section {
    margin-top: 0;
}

/* Container fix */
.container {
    position: relative;
    z-index: var(--z-base);
}

/* ******************************
:: RESPONSIVE IMAGE FIXES
****************************** */
@media (max-width: 767px) {
    /* Portfolio images on mobile */
    .portfolio-item img,
    .single-case-studies img {
        width: 100%;
        height: 250px;
        object-fit: cover;
    }
    
    /* Service images */
    .single-service img {
        max-height: 200px;
    }
    
    /* Testimonial images */
    .reviewer-thumb img,
    .avatar-lg {
        width: 60px;
        height: 60px;
    }
    
    /* Welcome images */
    .welcome-thumb-wrapper img {
        max-width: 100%;
        margin: 0 auto;
    }
}

@media (max-width: 575px) {
    .portfolio-item img,
    .single-case-studies img {
        height: 200px;
    }
    
    .portfolio-featured-image img {
        max-height: 300px;
    }
}

/* ******************************
:: PERFORMANCE OPTIMIZATIONS
****************************** */

/* Reduce motion for users who prefer it */
@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;
    }
}

/* GPU acceleration for common elements */
.section-heading,
.single-service,
.single-promo,
.single-review,
.portfolio-item,
.btn {
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    perspective: 1000px;
    -webkit-perspective: 1000px;
}

/* ******************************
:: ACCESSIBILITY IMPROVEMENTS
****************************** */
@media (prefers-reduced-motion: no-preference) {
    .fade-in,
    .fly-in-left,
    .fly-in-right,
    .fly-in-up,
    .fly-in-down,
    .stagger-item {
        /* Animations enabled */
    }
}

/* Focus states */
a:focus,
button:focus,
input:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ******************************
:: LOADING STATES
****************************** */
.image-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

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