/* ========================================
   Global Animations
   ======================================== */

/* Glitch Effect for Hero Title */
.glitch {
    position: relative;
    text-shadow:
        0.05em 0 0 rgba(255, 0, 0, 0.75),
        -0.025em -0.05em 0 rgba(0, 255, 0, 0.75),
        0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    animation: glitch 500ms infinite;
}

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

.glitch::before {
    animation: glitch-before 300ms infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    transform: translate(-0.025em, -0.0125em);
}

.glitch::after {
    animation: glitch-after 300ms infinite;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    transform: translate(0.0125em, 0.025em);
}

@keyframes glitch {
    0% {
        text-shadow:
            0.05em 0 0 rgba(255, 0, 0, 0.75),
            -0.05em -0.025em 0 rgba(0, 255, 0, 0.75),
            -0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    }
    14% {
        text-shadow:
            0.05em 0 0 rgba(255, 0, 0, 0.75),
            -0.05em -0.025em 0 rgba(0, 255, 0, 0.75),
            -0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    }
    15% {
        text-shadow:
            -0.05em -0.025em 0 rgba(255, 0, 0, 0.75),
            0.025em 0.025em 0 rgba(0, 255, 0, 0.75),
            -0.05em -0.05em 0 rgba(0, 0, 255, 0.75);
    }
    49% {
        text-shadow:
            -0.05em -0.025em 0 rgba(255, 0, 0, 0.75),
            0.025em 0.025em 0 rgba(0, 255, 0, 0.75),
            -0.05em -0.05em 0 rgba(0, 0, 255, 0.75);
    }
    50% {
        text-shadow:
            0.025em 0.05em 0 rgba(255, 0, 0, 0.75),
            0.05em 0 0 rgba(0, 255, 0, 0.75),
            0 -0.05em 0 rgba(0, 0, 255, 0.75);
    }
    99% {
        text-shadow:
            0.025em 0.05em 0 rgba(255, 0, 0, 0.75),
            0.05em 0 0 rgba(0, 255, 0, 0.75),
            0 -0.05em 0 rgba(0, 0, 255, 0.75);
    }
    100% {
        text-shadow:
            -0.025em 0 0 rgba(255, 0, 0, 0.75),
            -0.025em -0.025em 0 rgba(0, 255, 0, 0.75),
            -0.025em -0.05em 0 rgba(0, 0, 255, 0.75);
    }
}

@keyframes glitch-before {
    0% {
        clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    }
    10% {
        clip-path: polygon(0 15%, 100% 15%, 100% 50%, 0 50%);
    }
    20% {
        clip-path: polygon(0 60%, 100% 60%, 100% 75%, 0 75%);
    }
    30% {
        clip-path: polygon(0 10%, 100% 10%, 100% 40%, 0 40%);
    }
    40% {
        clip-path: polygon(0 50%, 100% 50%, 100% 70%, 0 70%);
    }
    50% {
        clip-path: polygon(0 25%, 100% 25%, 100% 55%, 0 55%);
    }
    60% {
        clip-path: polygon(0 5%, 100% 5%, 100% 45%, 0 45%);
    }
    70% {
        clip-path: polygon(0 35%, 100% 35%, 100% 65%, 0 65%);
    }
    80% {
        clip-path: polygon(0 20%, 100% 20%, 100% 50%, 0 50%);
    }
    90% {
        clip-path: polygon(0 45%, 100% 45%, 100% 75%, 0 75%);
    }
    100% {
        clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    }
}

@keyframes glitch-after {
    0% {
        clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    }
    10% {
        clip-path: polygon(0 50%, 100% 50%, 100% 85%, 0 85%);
    }
    20% {
        clip-path: polygon(0 25%, 100% 25%, 100% 40%, 0 40%);
    }
    30% {
        clip-path: polygon(0 60%, 100% 60%, 100% 90%, 0 90%);
    }
    40% {
        clip-path: polygon(0 30%, 100% 30%, 100% 50%, 0 50%);
    }
    50% {
        clip-path: polygon(0 45%, 100% 45%, 100% 75%, 0 75%);
    }
    60% {
        clip-path: polygon(0 55%, 100% 55%, 100% 95%, 0 95%);
    }
    70% {
        clip-path: polygon(0 35%, 100% 35%, 100% 65%, 0 65%);
    }
    80% {
        clip-path: polygon(0 50%, 100% 50%, 100% 80%, 0 80%);
    }
    90% {
        clip-path: polygon(0 25%, 100% 25%, 100% 55%, 0 55%);
    }
    100% {
        clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    }
}

/* ========================================
   Typing Animation
   ======================================== */
.typing-text {
    overflow: hidden;
    border-right: 2px solid var(--neon-cyan);
    white-space: nowrap;
    animation: typing 3s 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(--neon-cyan); }
}

/* ========================================
   Fade In Animations
   ======================================== */
.fade-in {
    animation: fadeIn 0.8s ease forwards;
}

.fade-in-up {
    animation: fadeInUp 0.8s ease forwards;
}

.fade-in-down {
    animation: fadeInDown 0.8s ease forwards;
}

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

/* ========================================
   Neon Glow Pulse
   ======================================== */
.neon-pulse {
    animation: neonPulse 2s ease-in-out infinite;
}

@keyframes neonPulse {
    0%, 100% {
        text-shadow:
            0 0 5px var(--neon-cyan),
            0 0 10px var(--neon-cyan),
            0 0 20px var(--neon-cyan);
    }
    50% {
        text-shadow:
            0 0 10px var(--neon-cyan),
            0 0 20px var(--neon-cyan),
            0 0 30px var(--neon-cyan),
            0 0 40px var(--neon-cyan);
    }
}

/* ========================================
   Floating Animation
   ======================================== */
.float {
    animation: floating 3s ease-in-out infinite;
}

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

/* ========================================
   Rotate Animation
   ======================================== */
.rotate-slow {
    animation: rotateSlow 20s linear infinite;
}

@keyframes rotateSlow {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Scale on Hover
   ======================================== */
.scale-on-hover {
    transition: transform 0.3s ease;
}

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

/* ========================================
   Slide In Animations
   ======================================== */
.slide-in-left {
    animation: slideInLeft 0.6s ease forwards;
}

.slide-in-right {
    animation: slideInRight 0.6s ease forwards;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* ========================================
   Reveal Animation (for scroll)
   ======================================== */
.reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.6s ease;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   Liquid Chrome Text (Ultra Cool)
   ======================================== */
.gradient-text {
    background: linear-gradient(
        90deg,
        #1e3a8a 0%,
        #3b82f6 15%,
        #60a5fa 30%,
        #93c5fd 45%,
        #dbeafe 55%,
        #93c5fd 70%,
        #3b82f6 85%,
        #1e3a8a 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    letter-spacing: -0.02em;
    position: relative;
    animation: liquidChrome 8s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.3));
}

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

/* ========================================
   Shimmer Effect
   ======================================== */
.shimmer {
    background: linear-gradient(
        90deg,
        var(--text-secondary) 0%,
        var(--neon-cyan) 50%,
        var(--text-secondary) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 3s ease-in-out infinite;
}

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

/* ========================================
   Border Glow Animation
   ======================================== */
.border-glow {
    position: relative;
}

.border-glow::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(
        45deg,
        var(--neon-cyan),
        var(--neon-magenta),
        var(--neon-green),
        var(--neon-cyan)
    );
    border-radius: inherit;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
    background-size: 400%;
    animation: borderGlowRotate 3s linear infinite;
}

.border-glow:hover::before {
    opacity: 0.7;
}

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

/* ========================================
   Matrix Rain Effect (Optional Background)
   ======================================== */
.matrix-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.1;
}

/* ========================================
   Loading Spinner
   ======================================== */
.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--neon-cyan);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   Particle Effect (for backgrounds)
   ======================================== */
.particles {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--neon-cyan);
    border-radius: 50%;
    animation: particleFloat 10s linear infinite;
    opacity: 0.5;
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 0.5;
    }
    90% {
        opacity: 0.5;
    }
    100% {
        transform: translateY(-100px) translateX(100px);
        opacity: 0;
    }
}

/* ========================================
   Smooth Transitions
   ======================================== */
.smooth-transition {
    transition: all 0.3s ease;
}

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