/* ===================================
   CRAFT & GADGETS - ANIMATIONS
   Advanced Animation Library
   Developer: Alomgir Hossen
   =================================== */

/* ============ BORDER WAVE ANIMATIONS ============ */
@keyframes borderWave {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.border-wave {
    position: relative;
    overflow: hidden;
}

.border-wave::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(90deg,
            #8B5CF6,
            #EC4899,
            #3B82F6,
            #06B6D4,
            #8B5CF6);
    background-size: 300% 100%;
    animation: borderWave 2s linear infinite;
    z-index: -1;
    opacity: 0;
    transition: opacity var(--transition-base);
    will-change: background-position;
}

.border-wave:hover::before {
    opacity: 1;
}

/* ============ GLOW PULSE ANIMATION ============ */
@keyframes glowPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
    }

    50% {
        box-shadow: 0 0 40px rgba(139, 92, 246, 0.4),
            0 0 60px rgba(236, 72, 153, 0.3);
    }
}

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

.glow-pulse-hover:hover {
    animation: glowPulse 2s ease-in-out infinite;
}

/* Auto-Blink Pulse for Cards - Smooth Version */
@keyframes blinkPulse {

    0%,
    100% {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
        filter: brightness(1);
    }

    50% {
        box-shadow: 0 8px 32px rgba(139, 92, 246, 0.5),
            0 0 40px rgba(236, 72, 153, 0.4);
        filter: brightness(1.1);
    }
}

.blink-pulse {
    animation: blinkPulse 4s ease-in-out infinite;
    will-change: box-shadow, filter;
}

/* Parallax Hover 3D Effect */
.parallax-hover {
    transition: transform var(--transition-base);
    transform-style: preserve-3d;
}

.parallax-hover:hover {
    transform: perspective(1000px) rotateX(2deg) rotateY(5deg) scale(1.05);
}

/* ============ RIPPLE EFFECT ============ */
.ripple {
    position: relative;
    overflow: hidden;
}

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

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

/* ============ FADE ANIMATIONS ============ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.fade-in-up {
    animation: fadeInUp 0.3s ease-out;
}

.fade-in-down {
    animation: fadeInDown 0.3s ease-out;
}

.fade-in-left {
    animation: fadeInLeft 0.3s ease-out;
}

.fade-in-right {
    animation: fadeInRight 0.3s ease-out;
}

/* ============ SCALE ANIMATIONS ============ */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleInBounce {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.95);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

.scale-in-bounce {
    animation: scaleInBounce 0.4s ease-out;
}

.scale-hover {
    transition: transform var(--transition-base);
}

.scale-hover:hover {
    transform: scale(1.05);
}

/* ============ SLIDE ANIMATIONS ============ */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

.slide-in-up {
    animation: slideInUp 0.3s ease-out;
}

.slide-in-down {
    animation: slideInDown 0.3s ease-out;
}

/* ============ ROTATE ANIMATIONS ============ */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-200deg);
    }

    to {
        opacity: 1;
        transform: rotate(0);
    }
}

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

.rotate-in {
    animation: rotateIn 0.3s ease-out;
}

/* ============ BOUNCE ANIMATIONS ============ */
@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

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

.bounce-in {
    animation: bounceIn 0.4s ease-out;
}

.bounce-hover:hover {
    animation: bounce 0.5s ease-in-out;
}

/* ============ TILT ANIMATION ============ */
.tilt-hover {
    transition: transform var(--transition-base);
    transform-style: preserve-3d;
}

.tilt-hover:hover {
    transform: perspective(1000px) rotateX(5deg) rotateY(5deg);
}

/* ============ FLOAT ANIMATION ============ */
@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

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

/* ============ GRADIENT ANIMATION ============ */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.gradient-animate {
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

/* ============ TYPING ANIMATION ============ */
@keyframes typing {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

.typing-effect {
    overflow: hidden;
    border-right: 2px solid var(--color-primary);
    white-space: nowrap;
    animation: typing 3s steps(40) 1s forwards, blink 0.75s step-end infinite;
}

/* ============ PARALLAX EFFECTS ============ */
.parallax-slow {
    transform: translateY(calc(var(--scroll-progress, 0) * -0.3));
    transition: transform 0.1s linear;
}

.parallax-medium {
    transform: translateY(calc(var(--scroll-progress, 0) * -0.5));
    transition: transform 0.1s linear;
}

.parallax-fast {
    transform: translateY(calc(var(--scroll-progress, 0) * -0.8));
    transition: transform 0.1s linear;
}

/* ============ SCROLL REVEAL ANIMATIONS ============ */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    will-change: opacity, transform;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.scroll-reveal-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    will-change: opacity, transform;
}

.scroll-reveal-left.revealed {
    opacity: 1;
    transform: translateX(0);
}

.scroll-reveal-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    will-change: opacity, transform;
}

.scroll-reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

.scroll-reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    will-change: opacity, transform;
}

.scroll-reveal-scale.revealed {
    opacity: 1;
    transform: scale(1);
}

/* ============ STAGGER ANIMATIONS ============ */
.stagger-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.3s ease-out forwards;
}

.stagger-item:nth-child(1) {
    animation-delay: 0.1s;
}

.stagger-item:nth-child(2) {
    animation-delay: 0.2s;
}

.stagger-item:nth-child(3) {
    animation-delay: 0.3s;
}

.stagger-item:nth-child(4) {
    animation-delay: 0.4s;
}

.stagger-item:nth-child(5) {
    animation-delay: 0.5s;
}

.stagger-item:nth-child(6) {
    animation-delay: 0.6s;
}

.stagger-item:nth-child(7) {
    animation-delay: 0.7s;
}

.stagger-item:nth-child(8) {
    animation-delay: 0.8s;
}

/* ============ LOADING ANIMATIONS ============ */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes ping {

    75%,
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.ping {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* ============ HOVER LIFT EFFECT ============ */
.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

/* ============ CARD FLIP ANIMATION ============ */
.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
}

.flip-card-back {
    transform: rotateY(180deg);
}

/* ============ SHINE EFFECT ============ */
@keyframes shine {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

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

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

/* ============ GLITCH EFFECT ============ */
@keyframes glitch {
    0% {
        transform: translate(0);
    }

    20% {
        transform: translate(-2px, 2px);
    }

    40% {
        transform: translate(-2px, -2px);
    }

    60% {
        transform: translate(2px, 2px);
    }

    80% {
        transform: translate(2px, -2px);
    }

    100% {
        transform: translate(0);
    }
}

.glitch:hover {
    animation: glitch 0.3s infinite;
}

/* ============ SHAKE ANIMATION ============ */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.5s;
}

/* ============ HEARTBEAT ANIMATION ============ */
@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    10%,
    30% {
        transform: scale(1.1);
    }

    20%,
    40% {
        transform: scale(1);
    }
}

.heartbeat {
    animation: heartbeat 1.3s ease-in-out infinite;
}

/* ============ SLIDE MARQUEE ============ */
@keyframes marqueeLeft {
    from {
        transform: translate3d(0, 0, 0);
    }

    to {
        transform: translate3d(-50%, 0, 0);
    }
}

@keyframes marqueeRight {
    from {
        transform: translate3d(-50%, 0, 0);
    }

    to {
        transform: translate3d(0, 0, 0);
    }
}

.marquee-left {
    animation: marqueeLeft 20s linear infinite;
    will-change: transform;
}

.marquee-right {
    animation: marqueeRight 20s linear infinite;
    will-change: transform;
}

.marquee-slow {
    animation-duration: 40s;
}

.marquee-fast {
    animation-duration: 15s;
}

/* Pause on hover */
.marquee-left:hover,
.marquee-right:hover {
    animation-play-state: paused;
}

/* ============ UTILITY ANIMATION CLASSES ============ */
.animate-delay-1 {
    animation-delay: 0.1s;
}

.animate-delay-2 {
    animation-delay: 0.2s;
}

.animate-delay-3 {
    animation-delay: 0.3s;
}

.animate-delay-4 {
    animation-delay: 0.4s;
}

.animate-delay-5 {
    animation-delay: 0.5s;
}

.animate-duration-fast {
    animation-duration: 0.3s;
}

.animate-duration-normal {
    animation-duration: 0.6s;
}

.animate-duration-slow {
    animation-duration: 1s;
}

/* ============ MOBILE OPTIMIZATIONS ============ */
@media (max-width: 768px) {

    /* Speed up animations on mobile */
    .border-wave::before {
        animation-duration: 4s;
    }

    .marquee-left,
    .marquee-right {
        animation-duration: 30s;
    }

    /* Optimize scroll reveals for mobile */
    .scroll-reveal,
    .scroll-reveal-left,
    .scroll-reveal-right,
    .scroll-reveal-scale {
        transition-duration: 0.2s;
        transform: translateY(15px);
    }

    /* Simplify animations on mobile */
    @media (prefers-reduced-motion: no-preference) {
        .tilt-hover:hover {
            transform: scale(1.02);
        }
    }
}