/* ===== ЭФФЕКТЫ ГЛИТЧА И ИСКАЖЕНИЙ ===== */

/* Основной эффект глитча для текста */
.glitch-text {
    position: relative;
    display: inline-block;
    color: var(--primary-neon);
    animation: glitch-skew 4s infinite linear alternate-reverse;
}

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

.glitch-text::before {
    animation: glitch-anim-1 5s infinite linear alternate-reverse;
    color: var(--secondary-neon);
    z-index: -1;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

.glitch-text::after {
    animation: glitch-anim-2 3s infinite linear alternate-reverse;
    color: var(--accent-neon);
    z-index: -2;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

@keyframes glitch-anim-1 {
    0%, 5%, 10%, 15%, 100% {
        transform: translate(0);
    }
    1% {
        transform: translate(-2px, 2px);
    }
    2% {
        transform: translate(-4px, -2px);
    }
    3% {
        transform: translate(4px, 2px);
    }
    4% {
        transform: translate(2px, -2px);
    }
    6% {
        transform: translate(-1px, 1px);
    }
    7% {
        transform: translate(-3px, -1px);
    }
    8% {
        transform: translate(3px, 1px);
    }
    9% {
        transform: translate(1px, -1px);
    }
}

@keyframes glitch-anim-2 {
    0%, 5%, 10%, 15%, 100% {
        transform: translate(0);
    }
    1% {
        transform: translate(2px, -2px);
    }
    2% {
        transform: translate(4px, 2px);
    }
    3% {
        transform: translate(-4px, -2px);
    }
    4% {
        transform: translate(-2px, 2px);
    }
    6% {
        transform: translate(1px, -1px);
    }
    7% {
        transform: translate(3px, 1px);
    }
    8% {
        transform: translate(-3px, -1px);
    }
    9% {
        transform: translate(-1px, 1px);
    }
}

@keyframes glitch-skew {
    0%, 40%, 44%, 58%, 61%, 65%, 69%, 73%, 100% {
        transform: skew(0deg);
    }
    41% {
        transform: skew(10deg);
    }
    42% {
        transform: skew(-10deg);
    }
    59% {
        transform: skew(40deg) scaleY(0.9);
    }
    60% {
        transform: skew(-40deg) scaleY(1.1);
    }
    63% {
        transform: skew(10deg) scaleY(0.9);
    }
    70% {
        transform: skew(-30deg) scaleY(1.1);
    }
    71% {
        transform: skew(30deg) scaleY(0.9);
    }
}

/* Эффект глитча для изображений */
.glitch-image {
    position: relative;
    overflow: hidden;
}

.glitch-image img {
    width: 100%;
    height: auto;
    display: block;
}

.glitch-image::before,
.glitch-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    opacity: 0;
    mix-blend-mode: difference;
}

.glitch-image:hover::before {
    animation: glitch-img-1 0.3s infinite;
    background: rgba(255, 0, 255, 0.3);
}

.glitch-image:hover::after {
    animation: glitch-img-2 0.3s infinite;
    background: rgba(0, 255, 255, 0.3);
}

@keyframes glitch-img-1 {
    0% {
        clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
        transform: translate(0);
    }
    20% {
        clip-path: polygon(0 15%, 100% 15%, 100% 50%, 0 50%);
        transform: translate(-5px, 5px);
    }
    40% {
        clip-path: polygon(0 30%, 100% 30%, 100% 65%, 0 65%);
        transform: translate(5px, -5px);
    }
    60% {
        clip-path: polygon(0 45%, 100% 45%, 100% 80%, 0 80%);
        transform: translate(-5px, 5px);
    }
    80% {
        clip-path: polygon(0 60%, 100% 60%, 100% 95%, 0 95%);
        transform: translate(5px, -5px);
    }
    100% {
        clip-path: polygon(0 75%, 100% 75%, 100% 100%, 0 100%);
        transform: translate(0);
    }
}

@keyframes glitch-img-2 {
    0% {
        clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
        transform: translate(0);
    }
    20% {
        clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
        transform: translate(5px, -5px);
    }
    40% {
        clip-path: polygon(0 50%, 100% 50%, 100% 85%, 0 85%);
        transform: translate(-5px, 5px);
    }
    60% {
        clip-path: polygon(0 35%, 100% 35%, 100% 70%, 0 70%);
        transform: translate(5px, -5px);
    }
    80% {
        clip-path: polygon(0 20%, 100% 20%, 100% 55%, 0 55%);
        transform: translate(-5px, 5px);
    }
    100% {
        clip-path: polygon(0 5%, 100% 5%, 100% 40%, 0 40%);
        transform: translate(0);
    }
}

/* Эффект цифрового шума */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: 
        linear-gradient(90deg, transparent 50%, rgba(255,255,255,.05) 50%),
        linear-gradient(transparent 50%, rgba(255,255,255,.05) 50%);
    background-size: 50px 50px;
    animation: noise-animation 0.2s infinite;
}

@keyframes noise-animation {
    0% {
        background-position: 0 0;
    }
    10% {
        background-position: -5% -10%;
    }
    20% {
        background-position: -15% 5%;
    }
    30% {
        background-position: 7% -25%;
    }
    40% {
        background-position: 20% 25%;
    }
    50% {
        background-position: -25% 10%;
    }
    60% {
        background-position: 15% 5%;
    }
    70% {
        background-position: 0% 15%;
    }
    80% {
        background-position: 25% 35%;
    }
    90% {
        background-position: -10% 10%;
    }
    100% {
        background-position: 0 0;
    }
}

/* Эффект сканирования */
.scan-effect {
    position: relative;
    overflow: hidden;
}

.scan-effect::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(
        to bottom,
        transparent,
        var(--primary-neon),
        transparent
    );
    animation: scan 3s linear infinite;
    opacity: 0.5;
    z-index: 10;
}

@keyframes scan {
    0% {
        top: -5px;
    }
    100% {
        top: 100%;
    }
}

/* Эффект искажения данных */
.data-corruption {
    position: relative;
}

.data-corruption::before {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    color: var(--text-muted);
    overflow: hidden;
    animation: corrupt 10s infinite linear;
}

@keyframes corrupt {
    0%, 90%, 100% {
        clip-path: inset(0 0 0 0);
    }
    5% {
        clip-path: inset(10% 0 20% 0);
        content: '01010101';
    }
    10% {
        clip-path: inset(30% 0 10% 0);
        content: '11001010';
    }
    15% {
        clip-path: inset(5% 0 25% 0);
        content: 'ERROR';
    }
    20% {
        clip-path: inset(15% 0 15% 0);
        content: 'CORRUPT';
    }
    25% {
        clip-path: inset(25% 0 5% 0);
        content: '10101010';
    }
    30% {
        clip-path: inset(0 0 30% 0);
        content: 'SYSTEM FAIL';
    }
}

/* Эффект мерцания неона */
.neon-flicker {
    animation: neon-flicker 3s infinite;
}

@keyframes neon-flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        opacity: 1;
        text-shadow: 
            0 0 5px currentColor,
            0 0 10px currentColor,
            0 0 15px currentColor;
    }
    20%, 24%, 55% {
        opacity: 0.8;
        text-shadow: 
            0 0 2px currentColor,
            0 0 5px currentColor,
            0 0 7px currentColor;
    }
}

/* Эффект загрузки данных */
.data-stream {
    position: relative;
    overflow: hidden;
}

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

@keyframes data-stream {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Эффект статического электричества */
.static-electricity {
    position: relative;
}

.static-electricity::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 30% 30%, transparent 10%, rgba(0, 243, 255, 0.1) 20%, transparent 30%),
        radial-gradient(circle at 70% 70%, transparent 10%, rgba(255, 0, 255, 0.1) 20%, transparent 30%);
    animation: static-pulse 2s infinite alternate;
    z-index: -1;
}

@keyframes static-pulse {
    0% {
        opacity: 0.1;
        transform: scale(1);
    }
    100% {
        opacity: 0.3;
        transform: scale(1.05);
    }
}

/* Эффект матрицы (зеленый код) */
.matrix-code {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    opacity: 0.05;
}

/* Эффект разрыва связи */
.connection-lost {
    animation: connection-lost 0.5s infinite alternate;
}

@keyframes connection-lost {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0.3;
        transform: scale(0.95);
    }
}

/* Эффект перезагрузки */
.reboot-effect {
    position: relative;
}

.reboot-effect::before {
    content: 'REBOOTING...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent-neon);
    font-family: var(--font-mono);
    font-size: 2rem;
    opacity: 0;
    animation: reboot 2s infinite;
    text-shadow: 0 0 10px currentColor;
    z-index: 100;
}

@keyframes reboot {
    0%, 100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}