/* Glitch Effect */
.glitch-text {
    position: relative;
    animation: glitch-skew 2s infinite linear alternate-reverse;
}

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

.glitch-text::before {
    left: 2px;
    text-shadow: -2px 0 var(--secondary);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch-text::after {
    left: -2px;
    text-shadow: -2px 0 var(--accent);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% { clip: rect(31px, 9999px, 94px, 0); transform: skew(0.85deg); }
    5% { clip: rect(70px, 9999px, 71px, 0); transform: skew(0.34deg); }
    10% { clip: rect(29px, 9999px, 24px, 0); transform: skew(0.74deg); }
    15% { clip: rect(63px, 9999px, 93px, 0); transform: skew(0.21deg); }
    20% { clip: rect(5px, 9999px, 28px, 0); transform: skew(0.58deg); }
    25% { clip: rect(45px, 9999px, 59px, 0); transform: skew(0.93deg); }
    30% { clip: rect(93px, 9999px, 4px, 0); transform: skew(0.12deg); }
    35% { clip: rect(80px, 9999px, 61px, 0); transform: skew(0.67deg); }
    40% { clip: rect(40px, 9999px, 76px, 0); transform: skew(0.44deg); }
    45% { clip: rect(20px, 9999px, 19px, 0); transform: skew(0.89deg); }
    50% { clip: rect(74px, 9999px, 87px, 0); transform: skew(0.23deg); }
    55% { clip: rect(11px, 9999px, 36px, 0); transform: skew(0.78deg); }
    60% { clip: rect(56px, 9999px, 49px, 0); transform: skew(0.35deg); }
    65% { clip: rect(88px, 9999px, 15px, 0); transform: skew(0.56deg); }
    70% { clip: rect(34px, 9999px, 82px, 0); transform: skew(0.91deg); }
    75% { clip: rect(62px, 9999px, 38px, 0); transform: skew(0.14deg); }
    80% { clip: rect(9px, 9999px, 67px, 0); transform: skew(0.72deg); }
    85% { clip: rect(47px, 9999px, 52px, 0); transform: skew(0.39deg); }
    90% { clip: rect(78px, 9999px, 23px, 0); transform: skew(0.85deg); }
    95% { clip: rect(16px, 9999px, 91px, 0); transform: skew(0.28deg); }
    100% { clip: rect(53px, 9999px, 44px, 0); transform: skew(0.63deg); }
}

@keyframes glitch-anim2 {
    0% { clip: rect(65px, 9999px, 99px, 0); transform: skew(0.63deg); }
    5% { clip: rect(19px, 9999px, 45px, 0); transform: skew(0.28deg); }
    10% { clip: rect(84px, 9999px, 12px, 0); transform: skew(0.85deg); }
    15% { clip: rect(37px, 9999px, 78px, 0); transform: skew(0.39deg); }
    20% { clip: rect(52px, 9999px, 33px, 0); transform: skew(0.72deg); }
    25% { clip: rect(8px, 9999px, 89px, 0); transform: skew(0.14deg); }
    30% { clip: rect(71px, 9999px, 56px, 0); transform: skew(0.91deg); }
    35% { clip: rect(26px, 9999px, 68px, 0); transform: skew(0.35deg); }
    40% { clip: rect(93px, 9999px, 21px, 0); transform: skew(0.78deg); }
    45% { clip: rect(48px, 9999px, 84px, 0); transform: skew(0.23deg); }
    50% { clip: rect(14px, 9999px, 47px, 0); transform: skew(0.89deg); }
    55% { clip: rect(76px, 9999px, 5px, 0); transform: skew(0.44deg); }
    60% { clip: rect(39px, 9999px, 72px, 0); transform: skew(0.67deg); }
    65% { clip: rect(82px, 9999px, 29px, 0); transform: skew(0.12deg); }
    70% { clip: rect(17px, 9999px, 95px, 0); transform: skew(0.93deg); }
    75% { clip: rect(59px, 9999px, 41px, 0); transform: skew(0.58deg); }
    80% { clip: rect(3px, 9999px, 63px, 0); transform: skew(0.21deg); }
    85% { clip: rect(88px, 9999px, 16px, 0); transform: skew(0.74deg); }
    90% { clip: rect(44px, 9999px, 87px, 0); transform: skew(0.34deg); }
    95% { clip: rect(69px, 9999px, 38px, 0); transform: skew(0.85deg); }
    100% { clip: rect(22px, 9999px, 74px, 0); transform: skew(0.51deg); }
}

@keyframes glitch-skew {
    0% { transform: skew(1deg); }
    10% { transform: skew(-0.5deg); }
    20% { transform: skew(0.8deg); }
    30% { transform: skew(-0.3deg); }
    40% { transform: skew(0.6deg); }
    50% { transform: skew(-0.7deg); }
    60% { transform: skew(0.4deg); }
    70% { transform: skew(-0.2deg); }
    80% { transform: skew(0.9deg); }
    90% { transform: skew(-0.4deg); }
    100% { transform: skew(0.2deg); }
}

/* Neon Glow Pulse */
@keyframes neon-pulse {
    0%, 100% {
        text-shadow: 
            0 0 5px var(--primary),
            0 0 10px var(--primary),
            0 0 20px var(--primary),
            0 0 40px var(--primary);
    }
    50% {
        text-shadow: 
            0 0 2px var(--primary),
            0 0 5px var(--primary),
            0 0 10px var(--primary),
            0 0 20px var(--primary);
    }
}

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

/* Border Glow Animation */
@keyframes border-glow {
    0%, 100% {
        box-shadow: 
            0 0 5px var(--primary-glow),
            inset 0 0 5px var(--primary-glow);
    }
    50% {
        box-shadow: 
            0 0 20px var(--primary-glow),
            inset 0 0 10px var(--primary-glow);
    }
}

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

/* Typing Animation */
@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

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

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

/* Matrix Rain Characters */
.matrix-char {
    position: absolute;
    color: var(--primary);
    font-family: var(--font-mono);
    font-size: 14px;
    text-shadow: 0 0 5px var(--primary);
    animation: matrix-fall linear infinite;
    opacity: 0;
}

@keyframes matrix-fall {
    0% {
        opacity: 1;
        transform: translateY(-100%);
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(100vh);
    }
}

/* Hover Lift Effect */
.hover-lift {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px var(--primary-glow);
}

/* 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 ease-in-out;
}

/* Spin Animation */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin {
    animation: spin 1s linear infinite;
}

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Slide In Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* Flash */
@keyframes flash {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.5; }
}

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

/* Success Flash */
@keyframes success-flash {
    0% { background-color: transparent; }
    50% { background-color: rgba(0, 255, 0, 0.2); }
    100% { background-color: transparent; }
}

.success-flash {
    animation: success-flash 0.5s ease-out;
}

/* Error Flash */
@keyframes error-flash {
    0% { background-color: transparent; }
    50% { background-color: rgba(255, 0, 64, 0.2); }
    100% { background-color: transparent; }
}

.error-flash {
    animation: error-flash 0.5s ease-out;
}

/* Ripple Effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(0, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.ripple:active::after {
    width: 200px;
    height: 200px;
}

/* Loading Dots */
.loading-dots {
    display: inline-flex;
    gap: 4px;
}

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

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

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

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 2px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

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

/* Terminal Cursor */
.terminal-cursor {
    display: inline-block;
    width: 10px;
    height: 18px;
    background: var(--primary);
    animation: cursor-blink 1s step-end infinite;
    margin-left: 2px;
    vertical-align: text-bottom;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Cyber Scanner Line */
.scanner-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--primary),
        var(--primary),
        transparent
    );
    animation: scan-vertical 3s linear infinite;
}

@keyframes scan-vertical {
    0% { top: 0; opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

/* Hex Grid Animation */
@keyframes hex-pulse {
    0%, 100% {
        opacity: 0.1;
    }
    50% {
        opacity: 0.3;
    }
}

.hex-animated {
    animation: hex-pulse 4s ease-in-out infinite;
}

/* Circuit Trace */
.circuit-trace {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: trace-draw 2s ease-out forwards;
}

@keyframes trace-draw {
    to {
        stroke-dashoffset: 0;
    }
}

/* Data Stream */
.data-stream {
    background: linear-gradient(
        180deg,
        transparent 0%,
        var(--primary-glow) 50%,
        transparent 100%
    );
    background-size: 100% 200%;
    animation: data-flow 1.5s linear infinite;
}

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

/* Disable animations for reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .scan-line {
        display: none;
    }
    
    .matrix-rain {
        display: none;
    }
}

/* Animation disable class */
.no-animations *,
.no-animations *::before,
.no-animations *::after {
    animation: none !important;
    transition: none !important;
}

.no-animations .scan-line,
.no-animations .matrix-rain {
    display: none;
}
