@import url(https://fonts.bunny.net/css?family=cherry-cream-soda:400|dela-gothic-one:400|krona-one:400);

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a0a0a;
    overflow: hidden;
    font-family: "Krona One", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.15) 2px,
        rgba(0, 0, 0, 0.15) 4px
    );
    pointer-events: none;
    z-index: 2;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh;
    width: 100dvw;
    position: relative;
    z-index: 3;
}

.text {
    font-size: clamp(2rem, 6vw, 4rem);
    color: #e0e0e0;
    font-weight: 400;
    letter-spacing: 0.12em;
    position: relative;
    cursor: default;
    user-select: none;
    will-change: transform, text-shadow, filter;
}

.text::before,
.text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.text::before {
    color: #ff0080;
    z-index: -1;
}

.text::after {
    color: #00d4ff;
    z-index: -1;
}

.text.glitch::before {
    opacity: 0.8;
    animation: glitch-layer-1 0.35s linear;
}

.text.glitch::after {
    opacity: 0.8;
    animation: glitch-layer-2 0.35s linear;
}

.cursor {
    display: inline-block;
    animation: blink 1.4s step-end infinite;
}

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

/* Main glitch animation */
.text.glitch {
    animation: glitch-anim 0.35s linear;
}

@keyframes glitch-anim {
    0% {
        transform: translate(0);
        text-shadow: 0 0 0 transparent;
        filter: none;
    }
    5% {
        transform: translate(-8px, 3px) skewX(-4deg);
        text-shadow:
            6px 0 #ff0080,
            -6px 0 #00d4ff;
    }
    10% {
        transform: translate(6px, -2px) skewX(3deg);
        clip-path: inset(15% 0 60% 0);
        opacity: 0.85;
    }
    15% {
        transform: translate(-4px, -4px);
        text-shadow:
            -8px 0 #ff0080,
            8px 0 #00d4ff,
            0 4px rgba(255, 0, 128, 0.4);
        clip-path: inset(65% 0 10% 0);
    }
    20% {
        transform: translate(10px, 2px) skewX(-6deg);
        filter: blur(2px) brightness(1.8);
        clip-path: inset(0);
        opacity: 1;
    }
    25% {
        transform: translate(-2px, 5px);
        text-shadow:
            4px -2px #ff0080,
            -4px 2px #00d4ff;
        filter: none;
    }
    30% {
        transform: translate(0, -6px) skewX(2deg);
        clip-path: inset(40% 0 30% 0);
        opacity: 0;
    }
    35% {
        transform: translate(-6px, 0) skewX(-3deg);
        text-shadow:
            10px 0 #ff0080,
            -10px 0 #00d4ff;
        clip-path: inset(0);
        opacity: 1;
    }
    40% {
        transform: translate(8px, -3px);
        filter: hue-rotate(90deg) brightness(1.4);
    }
    45% {
        transform: translate(-3px, 4px) skewX(5deg);
        text-shadow:
            -5px 3px #ff0080,
            5px -3px #00d4ff;
        filter: none;
        clip-path: inset(10% 0 70% 0);
    }
    50% {
        transform: translate(5px, -5px) skewX(-2deg);
        opacity: 0.7;
        clip-path: inset(0);
    }
    55% {
        transform: translate(-10px, 2px);
        text-shadow:
            8px 0 #ff0080,
            -8px 0 #00d4ff,
            0 -3px rgba(0, 212, 255, 0.5);
        opacity: 1;
    }
    60% {
        transform: translate(3px, 0) skewX(4deg);
        filter: blur(3px);
        clip-path: inset(50% 0 20% 0);
    }
    65% {
        transform: translate(-7px, -3px);
        filter: none;
        clip-path: inset(0);
        opacity: 0;
    }
    70% {
        transform: translate(6px, 4px) skewX(-5deg);
        text-shadow:
            -6px -2px #ff0080,
            6px 2px #00d4ff;
        opacity: 1;
    }
    80% {
        transform: translate(-4px, -2px);
        text-shadow:
            4px 0 #ff0080,
            -4px 0 #00d4ff;
        filter: brightness(2);
    }
    90% {
        transform: translate(2px, 1px) skewX(1deg);
        text-shadow:
            -2px 0 #ff0080,
            2px 0 #00d4ff;
        filter: none;
    }
    100% {
        transform: translate(0);
        text-shadow: 0 0 0 transparent;
        filter: none;
        clip-path: none;
        opacity: 1;
    }
}

/* Magenta layer — shifts left/right with clip slices */
@keyframes glitch-layer-1 {
    0% {
        transform: translate(0);
        clip-path: inset(0);
    }
    10% {
        transform: translate(-8px, -2px);
        clip-path: inset(20% 0 50% 0);
    }
    20% {
        transform: translate(10px, 3px);
        clip-path: inset(60% 0 10% 0);
    }
    30% {
        transform: translate(-6px, 0);
        clip-path: inset(5% 0 75% 0);
    }
    40% {
        transform: translate(12px, -4px);
        clip-path: inset(45% 0 25% 0);
    }
    50% {
        transform: translate(-4px, 5px);
        clip-path: inset(80% 0 5% 0);
    }
    60% {
        transform: translate(8px, -1px);
        clip-path: inset(10% 0 65% 0);
    }
    70% {
        transform: translate(-10px, 2px);
        clip-path: inset(35% 0 40% 0);
    }
    80% {
        transform: translate(5px, -3px);
        clip-path: inset(70% 0 15% 0);
    }
    90% {
        transform: translate(-3px, 1px);
        clip-path: inset(0);
    }
    100% {
        transform: translate(0);
        clip-path: inset(0);
    }
}

/* Cyan layer — opposite offsets for chromatic split */
@keyframes glitch-layer-2 {
    0% {
        transform: translate(0);
        clip-path: inset(0);
    }
    10% {
        transform: translate(7px, 3px);
        clip-path: inset(55% 0 15% 0);
    }
    20% {
        transform: translate(-9px, -2px);
        clip-path: inset(10% 0 60% 0);
    }
    30% {
        transform: translate(5px, 4px);
        clip-path: inset(70% 0 5% 0);
    }
    40% {
        transform: translate(-11px, -1px);
        clip-path: inset(25% 0 50% 0);
    }
    50% {
        transform: translate(6px, -5px);
        clip-path: inset(40% 0 35% 0);
    }
    60% {
        transform: translate(-7px, 2px);
        clip-path: inset(85% 0 0% 0);
    }
    70% {
        transform: translate(9px, -3px);
        clip-path: inset(15% 0 55% 0);
    }
    80% {
        transform: translate(-4px, 4px);
        clip-path: inset(50% 0 30% 0);
    }
    90% {
        transform: translate(2px, -1px);
        clip-path: inset(0);
    }
    100% {
        transform: translate(0);
        clip-path: inset(0);
    }
}

.text:hover {
    text-shadow: 0 0 8px rgba(224, 224, 224, 0.3);
    transition: text-shadow 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
    .cursor {
        animation: none;
        opacity: 1;
    }
    .text.glitch {
        animation: none;
    }
    .text.glitch::before,
    .text.glitch::after {
        animation: none;
        opacity: 0;
    }
    body::after {
        display: none;
    }
}
