/**
 * DirectTech E-Commerce
 * Animations & Parallax Effects
 */

/* ============================================
   Scroll-triggered Animations
   ============================================ */

/* Base state for animated elements */
[data-animate] {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-animate].animated {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* Animation delays for staggered effects */
[data-animate-delay="100"] { transition-delay: 0.1s; }
[data-animate-delay="200"] { transition-delay: 0.2s; }
[data-animate-delay="300"] { transition-delay: 0.3s; }
[data-animate-delay="400"] { transition-delay: 0.4s; }
[data-animate-delay="500"] { transition-delay: 0.5s; }
[data-animate-delay="600"] { transition-delay: 0.6s; }
[data-animate-delay="700"] { transition-delay: 0.7s; }
[data-animate-delay="800"] { transition-delay: 0.8s; }

/* Fade animations */
[data-animate="fade-up"] {
    opacity: 0;
    transform: translateY(40px);
}

[data-animate="fade-down"] {
    opacity: 0;
    transform: translateY(-40px);
}

[data-animate="fade-left"] {
    opacity: 0;
    transform: translateX(40px);
}

[data-animate="fade-right"] {
    opacity: 0;
    transform: translateX(-40px);
}

[data-animate="fade-in"] {
    opacity: 0;
    transform: none;
}

[data-animate="zoom-in"] {
    opacity: 0;
    transform: scale(0.9);
}

[data-animate="zoom-out"] {
    opacity: 0;
    transform: scale(1.1);
}

/* When animated */
[data-animate].animated {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
}

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

.parallax-container {
    position: relative;
    overflow: hidden;
}

.parallax-bg {
    position: absolute;
    top: -20%;
    left: 0;
    right: 0;
    bottom: -20%;
    background-size: cover;
    background-position: center;
    will-change: transform;
    transition: transform 0.1s linear;
}

/* Hero parallax enhancement */
.hero {
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(17, 129, 251, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255, 54, 93, 0.2) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
    animation: gradientShift 10s ease infinite alternate;
}

@keyframes gradientShift {
    0% {
        opacity: 0.7;
        transform: scale(1);
    }
    100% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* Floating animation for images */
.float-animation {
    animation: float 6s ease-in-out infinite;
}

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

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

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-10px) rotate(1deg); }
    50% { transform: translateY(-20px) rotate(0deg); }
    75% { transform: translateY(-10px) rotate(-1deg); }
}

/* Pulse animation */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

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

/* Glow effect */
.glow {
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        box-shadow: 0 0 20px rgba(17, 129, 251, 0.3);
    }
    to {
        box-shadow: 0 0 40px rgba(17, 129, 251, 0.6);
    }
}

/* ============================================
   Enhanced Hero Animations
   ============================================ */

.hero-title {
    animation: slideInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.hero-subtitle {
    animation: slideInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.2s forwards;
    opacity: 0;
}

.hero-buttons {
    animation: slideInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.4s forwards;
    opacity: 0;
}

.hero-label {
    animation: popIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s forwards;
    opacity: 0;
    transform: scale(0.8);
}

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

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Hero image enhanced animation */
.hero-image img {
    animation: floatRotate 6s ease-in-out infinite;
}

@keyframes floatRotate {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
        filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.4));
    }
    25% {
        transform: translateY(-15px) rotate(2deg);
        filter: drop-shadow(0 35px 50px rgba(0, 0, 0, 0.3));
    }
    50% {
        transform: translateY(-25px) rotate(0deg);
        filter: drop-shadow(0 45px 60px rgba(0, 0, 0, 0.25));
    }
    75% {
        transform: translateY(-15px) rotate(-2deg);
        filter: drop-shadow(0 35px 50px rgba(0, 0, 0, 0.3));
    }
}

/* ============================================
   Enhanced Button Animations
   ============================================ */

.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

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

.btn:active {
    transform: scale(0.95);
}

/* Shine effect on buttons */
.btn-primary::after,
.btn-accent::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%
    );
    transform: rotate(45deg) translateX(-100%);
    transition: transform 0.6s ease;
}

.btn-primary:hover::after,
.btn-accent:hover::after {
    transform: rotate(45deg) translateX(100%);
}

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

.category-card,
.product-card,
.feature-card,
.service-card {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 3D tilt effect on hover */
.card-3d {
    transform-style: preserve-3d;
    perspective: 1000px;
}

.card-3d:hover {
    transform: rotateX(5deg) rotateY(5deg) translateZ(10px);
}

/* Reveal animation for product actions */
.product-actions {
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover .product-actions {
    opacity: 1;
    transform: translateX(0);
}

/* Product image zoom with smooth transition */
.product-image img {
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.product-card:hover .product-image img {
    transform: scale(1.08);
}

/* ============================================
   Brand Logo Carousel Animation
   ============================================ */

.brands-section {
    overflow: hidden;
}

.brands-marquee {
    display: flex;
    animation: marquee 30s linear infinite;
    width: max-content;
}

.brands-marquee:hover {
    animation-play-state: paused;
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.brand-item {
    flex-shrink: 0;
    padding: 0 var(--space-8);
    transition: all 0.3s ease;
}

.brand-item:hover {
    filter: grayscale(0%) !important;
    opacity: 1 !important;
    transform: scale(1.15);
}

/* Brand logo enhanced styling */
.brand-logo-card {
    background: var(--white);
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.brand-logo-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(17, 129, 251, 0.15);
}

.brand-logo-card img {
    max-height: 50px;
    width: auto;
    filter: grayscale(100%);
    opacity: 0.6;
    transition: all 0.3s ease;
}

.brand-logo-card:hover img {
    filter: grayscale(0%);
    opacity: 1;
}

/* ============================================
   Section Parallax Backgrounds
   ============================================ */

.parallax-section {
    position: relative;
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

/* For mobile where fixed attachment doesn't work well */
@media (max-width: 991px) {
    .parallax-section {
        background-attachment: scroll;
    }
}

/* Gradient overlay animations */
.gradient-animated {
    background-size: 200% 200%;
    animation: gradientMove 15s ease infinite;
}

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

/* ============================================
   Loading Animations
   ============================================ */

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

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

/* Spinner animation */
.spinner-modern {
    width: 50px;
    height: 50px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinnerRotate 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

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

/* Dots loading animation */
.loading-dots {
    display: flex;
    gap: 8px;
}

.loading-dots span {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ============================================
   Text Animations
   ============================================ */

.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    transform: translateY(100%);
    animation: textReveal 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes textReveal {
    to { transform: translateY(0); }
}

/* Typewriter effect */
.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--primary);
    white-space: nowrap;
    animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
}

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

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--primary); }
}

/* Gradient text animation */
.gradient-text-animated {
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary));
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientTextMove 3s linear infinite;
}

@keyframes gradientTextMove {
    to { background-position: 200% center; }
}

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

.counter-animated {
    display: inline-block;
}

.stats-section .stat-number {
    font-variant-numeric: tabular-nums;
}

/* ============================================
   Notification/Toast Animations
   ============================================ */

.toast-enter {
    animation: toastEnter 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.toast-exit {
    animation: toastExit 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

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

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

.modal-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
}

.modal-content {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

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

.icon-bounce {
    animation: iconBounce 2s ease infinite;
}

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

.icon-spin {
    animation: iconSpin 2s linear infinite;
}

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

.icon-pulse {
    animation: iconPulse 1.5s ease infinite;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

/* ============================================
   Scroll Progress Indicator
   ============================================ */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    z-index: 9999;
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.1s linear;
}

/* ============================================
   Smooth Scroll Enhancements
   ============================================ */

html {
    scroll-behavior: smooth;
}

/* Back to top button animation */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 20px rgba(17, 129, 251, 0.4);
}

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

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(17, 129, 251, 0.5);
}

/* ============================================
   Ripple Effect
   ============================================ */

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

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ============================================
   Image Lazy Load Animation
   ============================================ */

img.lazy {
    opacity: 0;
    transition: opacity 0.5s ease;
}

img.lazy.loaded {
    opacity: 1;
}

/* Blur to sharp transition */
.img-blur-load {
    filter: blur(20px);
    transition: filter 0.5s ease;
}

.img-blur-load.loaded {
    filter: blur(0);
}

/* ============================================
   Reduced Motion Preferences
   ============================================ */

@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;
    }

    .parallax-bg {
        transform: none !important;
    }
}
