/* ==========================================================================
   Advanced Animations - Tesla Style
   ========================================================================== */

/* Glitch Effect */
@keyframes glitch {
    0%, 100% { transform: translate(0); }
    10% { transform: translate(-2px, 2px); }
    20% { transform: translate(2px, -2px); }
    30% { transform: translate(-2px, -2px); }
    40% { transform: translate(2px, 2px); }
    50% { transform: translate(-2px, 2px); }
    60% { transform: translate(2px, -2px); }
    70% { transform: translate(-2px, -2px); }
    80% { transform: translate(2px, 2px); }
    90% { transform: translate(-2px, 2px); }
}

.glitch {
    position: relative;
    animation: glitch 4s infinite;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    color: var(--color-accent);
    animation: glitch 4s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
    transform: translateX(-2px);
}

.glitch::after {
    color: var(--color-accent-2);
    animation: glitch 4s infinite reverse;
    clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
    transform: translateX(2px);
}

/* Holographic Text */
@keyframes holographic {
    0%, 100% {
        background-position: 0% 50%;
        filter: hue-rotate(0deg);
    }
    50% {
        background-position: 100% 50%;
        filter: hue-rotate(180deg);
    }
}

.holographic {
    background: linear-gradient(90deg, #00d4ff, #7c3aed, #ec4899, #00d4ff);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: holographic 6s ease-in-out infinite;
}

/* Neon Pulse */
@keyframes neonPulse {
    0%, 100% {
        text-shadow:
            0 0 10px var(--color-accent),
            0 0 20px var(--color-accent),
            0 0 40px var(--color-accent);
    }
    50% {
        text-shadow:
            0 0 5px var(--color-accent),
            0 0 10px var(--color-accent),
            0 0 20px var(--color-accent),
            0 0 40px var(--color-accent);
    }
}

.neon-text {
    color: var(--color-accent);
    animation: neonPulse 2s ease-in-out infinite;
}

/* Border Glow Animation */
@keyframes borderGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 212, 255, 0.3), inset 0 0 20px rgba(0, 212, 255, 0.1); }
    50% { box-shadow: 0 0 40px rgba(0, 212, 255, 0.6), inset 0 0 30px rgba(0, 212, 255, 0.2); }
}

.glow-border {
    animation: borderGlow 3s ease-in-out infinite;
}

/* Slide-in animations */
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-60px); }
    to { opacity: 1; transform: translateX(0); }
}

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

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

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

.slide-in-left { animation: slideInLeft 0.8s ease-out both; }
.slide-in-right { animation: slideInRight 0.8s ease-out both; }
.slide-in-up { animation: slideInUp 0.8s ease-out both; }
.slide-in-down { animation: slideInDown 0.8s ease-out both; }

/* 3D Tilt on hover */
.tilt-3d {
    transition: transform 0.5s ease;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.tilt-3d:hover {
    transform: rotateY(5deg) rotateX(5deg) scale(1.02);
}

/* Magnetic Effect */
.magnetic {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Marquee */
@keyframes marquee {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

.marquee {
    display: flex;
    overflow: hidden;
    user-select: none;
}

.marquee-track {
    display: flex;
    gap: var(--space-12);
    animation: marquee 30s linear infinite;
    flex-shrink: 0;
    padding-right: var(--space-12);
}

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

/* Aurora background animation */
@keyframes aurora {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(50px, -30px) rotate(120deg); }
    66% { transform: translate(-30px, 40px) rotate(240deg); }
}

.aurora {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.aurora::before,
.aurora::after {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
    animation: aurora 20s ease-in-out infinite;
}

.aurora::before {
    background: radial-gradient(circle, var(--color-accent) 0%, transparent 70%);
    top: -30%;
    left: -20%;
}

.aurora::after {
    background: radial-gradient(circle, var(--color-accent-2) 0%, transparent 70%);
    bottom: -30%;
    right: -20%;
    animation-delay: -10s;
}

/* Particle Burst */
@keyframes particleBurst {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(var(--x, 0), var(--y, 0)) scale(1);
        opacity: 0;
    }
}

.particle-burst {
    position: relative;
}

.particle-burst::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: var(--color-accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow:
        20px 0 0 var(--color-accent),
        -20px 0 0 var(--color-accent),
        0 20px 0 var(--color-accent),
        0 -20px 0 var(--color-accent),
        14px 14px 0 var(--color-accent-2),
        -14px 14px 0 var(--color-accent-2),
        14px -14px 0 var(--color-accent-2),
        -14px -14px 0 var(--color-accent-2);
    opacity: 0;
    animation: particleBurst 2s ease-out infinite;
}

/* Wave animation */
@keyframes wave {
    0%, 100% { transform: translateY(0) scaleY(1); }
    50% { transform: translateY(-10px) scaleY(1.1); }
}

.wave > * {
    animation: wave 2s ease-in-out infinite;
}

.wave > *:nth-child(1) { animation-delay: 0s; }
.wave > *:nth-child(2) { animation-delay: 0.1s; }
.wave > *:nth-child(3) { animation-delay: 0.2s; }
.wave > *:nth-child(4) { animation-delay: 0.3s; }
.wave > *:nth-child(5) { animation-delay: 0.4s; }
.wave > *:nth-child(6) { animation-delay: 0.5s; }
.wave > *:nth-child(7) { animation-delay: 0.6s; }
.wave > *:nth-child(8) { animation-delay: 0.7s; }

/* Shimmer */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.shimmer {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.05) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

/* Morph Blob */
@keyframes morphBlob {
    0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
    25% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
    50% { border-radius: 50% 60% 30% 60% / 30% 60% 70% 40%; }
    75% { border-radius: 60% 40% 60% 30% / 60% 40% 30% 70%; }
}

.morph-blob {
    animation: morphBlob 12s ease-in-out infinite;
}

/* Flip Card */
.flip-card {
    perspective: 1000px;
    height: 320px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

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

.flip-card-front,
.flip-card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    flex-direction: column;
}

.flip-card-back {
    transform: rotateY(180deg);
    background: var(--color-bg-tertiary);
}

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

.count-up {
    animation: countUp 1s ease-out forwards;
}

/* Loading Skeleton */
@keyframes skeleton {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-bg-tertiary) 0%,
        var(--color-surface) 50%,
        var(--color-bg-tertiary) 100%
    );
    background-size: 200px 100%;
    background-repeat: no-repeat;
    animation: skeleton 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* Underline animation */
.link-underline {
    position: relative;
    display: inline-block;
}

.link-underline::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.link-underline:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* Dot pulse loader */
@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.dots-loader {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dots-loader span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-accent);
    animation: dotPulse 1.4s ease-in-out infinite;
}

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

/* Floating animation with rotation */
@keyframes floatRotate {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-15px) rotate(3deg); }
    50% { transform: translateY(-25px) rotate(0deg); }
    75% { transform: translateY(-15px) rotate(-3deg); }
}

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

/* Typewriter cursor */
@keyframes typewriter-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Gradient border rotation */
@keyframes gradientBorder {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.gradient-border-animated {
    position: relative;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
}

.gradient-border-animated::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: var(--radius-lg);
    background: linear-gradient(90deg, var(--color-accent), var(--color-accent-2), var(--color-accent));
    background-size: 300% 300%;
    z-index: -1;
    animation: gradientBorder 4s ease infinite;
}

/* Beam sweep */
@keyframes beamSweep {
    0% { transform: translateX(-100%) skewX(-15deg); }
    100% { transform: translateX(300%) skewX(-15deg); }
}

.beam-sweep {
    position: relative;
    overflow: hidden;
}

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

/* Radar */
@keyframes radar {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.radar {
    position: relative;
}

.radar::before {
    content: '';
    position: absolute;
    inset: 0;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        var(--color-accent) 30deg,
        transparent 60deg
    );
    border-radius: 50%;
    animation: radar 4s linear infinite;
    opacity: 0.5;
}

/* Multi-layered shadow */
.lift-on-hover {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.lift-on-hover:hover {
    transform: translateY(-8px);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(0, 212, 255, 0.2),
        0 0 60px rgba(0, 212, 255, 0.15);
}

/* Glitch Reveal */
@keyframes glitchReveal {
    0% {
        clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
        opacity: 1;
    }
    50% {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
        opacity: 1;
    }
    100% {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
        opacity: 1;
    }
}

/* Bounce In */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.bounce-in {
    animation: bounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

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

/* Path drawing animation */
@keyframes drawLine {
    to { stroke-dashoffset: 0; }
}

.draw-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawLine 3s ease-out forwards;
}

/* Circuit board effect */
@keyframes circuitFlow {
    0% { stroke-dashoffset: 100; opacity: 0; }
    10% { opacity: 1; }
    100% { stroke-dashoffset: 0; opacity: 1; }
}

.circuit-line {
    stroke-dasharray: 4 4;
    animation: circuitFlow 3s linear infinite;
}

/* Number ticker */
@keyframes numberFlip {
    0% { transform: translateY(0); opacity: 1; }
    50% { transform: translateY(-100%); opacity: 0; }
    51% { transform: translateY(100%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.number-flip {
    display: inline-block;
    animation: numberFlip 2s ease-in-out;
}

/* Glow line */
@keyframes glowLine {
    0%, 100% {
        opacity: 0.3;
        transform: translateX(-100%);
    }
    50% {
        opacity: 1;
        transform: translateX(100%);
    }
}

.glow-line {
    position: relative;
    overflow: hidden;
}

.glow-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
    animation: glowLine 3s ease-in-out infinite;
}

/* Scan line effect */
@keyframes scanline {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

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

.scanline::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
    animation: scanline 4s linear infinite;
    z-index: 10;
    pointer-events: none;
}

/* Reveal text */
@keyframes revealText {
    0% {
        clip-path: inset(0 100% 0 0);
    }
    100% {
        clip-path: inset(0 0 0 0);
    }
}

.reveal-text {
    animation: revealText 1.2s cubic-bezier(0.77, 0, 0.18, 1) forwards;
}

/* Loading dots */
@keyframes loadDot {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Smooth gradient shift */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.gradient-shift {
    background: linear-gradient(
        90deg,
        var(--color-accent),
        var(--color-accent-2),
        var(--color-accent-3),
        var(--color-accent)
    );
    background-size: 300% 300%;
    animation: gradientShift 8s ease infinite;
}

/* Custom easings */
.ease-bounce {
    transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ease-elastic {
    transition-timing-function: cubic-bezier(0.5, 1.5, 0.5, 1);
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile specific animations */
@media (max-width: 768px) {
    .float-rotate { animation-duration: 12s; }
    .hero-orb { filter: blur(60px); }
}
