/* =================================================================
   🎨 CYBER ANIMATIONS - Keyframes & Animations
   ================================================================= */

/* Loading Screen Animations */
@keyframes glitch-anim {
    0% {
        clip: rect(31px, 9999px, 94px, 0);
    }

    5% {
        clip: rect(54px, 9999px, 66px, 0);
    }

    10% {
        clip: rect(28px, 9999px, 92px, 0);
    }

    15% {
        clip: rect(67px, 9999px, 31px, 0);
    }

    20% {
        clip: rect(24px, 9999px, 14px, 0);
    }

    25% {
        clip: rect(91px, 9999px, 98px, 0);
    }

    30% {
        clip: rect(45px, 9999px, 73px, 0);
    }

    35% {
        clip: rect(12px, 9999px, 85px, 0);
    }

    40% {
        clip: rect(78px, 9999px, 22px, 0);
    }

    45% {
        clip: rect(56px, 9999px, 41px, 0);
    }

    50% {
        clip: rect(33px, 9999px, 67px, 0);
    }

    55% {
        clip: rect(89px, 9999px, 15px, 0);
    }

    60% {
        clip: rect(21px, 9999px, 94px, 0);
    }

    65% {
        clip: rect(62px, 9999px, 38px, 0);
    }

    70% {
        clip: rect(47px, 9999px, 71px, 0);
    }

    75% {
        clip: rect(18px, 9999px, 83px, 0);
    }

    80% {
        clip: rect(75px, 9999px, 26px, 0);
    }

    85% {
        clip: rect(39px, 9999px, 58px, 0);
    }

    90% {
        clip: rect(84px, 9999px, 11px, 0);
    }

    95% {
        clip: rect(52px, 9999px, 76px, 0);
    }

    100% {
        clip: rect(27px, 9999px, 95px, 0);
    }
}

@keyframes glitch-anim2 {
    0% {
        clip: rect(65px, 9999px, 100px, 0);
    }

    5% {
        clip: rect(14px, 9999px, 33px, 0);
    }

    10% {
        clip: rect(78px, 9999px, 73px, 0);
    }

    15% {
        clip: rect(3px, 9999px, 79px, 0);
    }

    20% {
        clip: rect(54px, 9999px, 97px, 0);
    }

    25% {
        clip: rect(10px, 9999px, 2px, 0);
    }

    30% {
        clip: rect(48px, 9999px, 61px, 0);
    }

    35% {
        clip: rect(87px, 9999px, 29px, 0);
    }

    40% {
        clip: rect(23px, 9999px, 92px, 0);
    }

    45% {
        clip: rect(69px, 9999px, 44px, 0);
    }

    50% {
        clip: rect(36px, 9999px, 81px, 0);
    }

    55% {
        clip: rect(91px, 9999px, 17px, 0);
    }

    60% {
        clip: rect(58px, 9999px, 71px, 0);
    }

    65% {
        clip: rect(25px, 9999px, 88px, 0);
    }

    70% {
        clip: rect(72px, 9999px, 39px, 0);
    }

    75% {
        clip: rect(42px, 9999px, 64px, 0);
    }

    80% {
        clip: rect(8px, 9999px, 96px, 0);
    }

    85% {
        clip: rect(61px, 9999px, 52px, 0);
    }

    90% {
        clip: rect(19px, 9999px, 86px, 0);
    }

    95% {
        clip: rect(76px, 9999px, 31px, 0);
    }

    100% {
        clip: rect(43px, 9999px, 68px, 0);
    }
}

@keyframes textPulse {

    0%,
    100% {
        text-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
    }

    50% {
        text-shadow: 0 0 30px rgba(239, 68, 68, 1), 0 0 40px rgba(239, 68, 68, 0.5);
    }
}

@keyframes percentPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes shine {

    0%,
    90% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

/* Glitch Animations for Buttons */
@keyframes glitch-cyan {

    0%,
    90%,
    100% {
        transform: translate(0);
        opacity: 0;
    }

    92%,
    94% {
        transform: translate(-2px, 1px);
        opacity: 0.7;
    }
}

@keyframes glitch-magenta {

    0%,
    85%,
    100% {
        transform: translate(0);
        opacity: 0;
    }

    87%,
    89% {
        transform: translate(2px, -1px);
        opacity: 0.7;
    }
}

@keyframes glitch-cyan-strong {
    0% {
        transform: translate(0);
        opacity: 0.8;
        clip-path: polygon(0 0, 100% 0, 100% 20%, 0 20%);
    }

    20% {
        transform: translate(-4px, 2px);
        opacity: 0.9;
        clip-path: polygon(0 15%, 100% 15%, 100% 40%, 0 40%);
    }

    40% {
        transform: translate(3px, -2px);
        opacity: 0.85;
        clip-path: polygon(0 30%, 100% 30%, 100% 65%, 0 65%);
    }

    60% {
        transform: translate(-2px, 3px);
        opacity: 0.9;
        clip-path: polygon(0 50%, 100% 50%, 100% 75%, 0 75%);
    }

    80% {
        transform: translate(4px, -1px);
        opacity: 0.8;
        clip-path: polygon(0 70%, 100% 70%, 100% 95%, 0 95%);
    }

    100% {
        transform: translate(0);
        opacity: 0.85;
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
}

@keyframes glitch-magenta-strong {
    0% {
        transform: translate(0);
        opacity: 0.8;
        clip-path: polygon(0 80%, 100% 80%, 100% 100%, 0 100%);
    }

    25% {
        transform: translate(3px, -3px);
        opacity: 0.9;
        clip-path: polygon(0 60%, 100% 60%, 100% 85%, 0 85%);
    }

    50% {
        transform: translate(-4px, 2px);
        opacity: 0.85;
        clip-path: polygon(0 35%, 100% 35%, 100% 70%, 0 70%);
    }

    75% {
        transform: translate(2px, 3px);
        opacity: 0.9;
        clip-path: polygon(0 25%, 100% 25%, 100% 50%, 0 50%);
    }

    100% {
        transform: translate(0);
        opacity: 0.8;
        clip-path: polygon(0 5%, 100% 5%, 100% 30%, 0 30%);
    }
}

@keyframes text-flicker {

    0%,
    19.9%,
    22%,
    62.9%,
    64%,
    64.9%,
    70%,
    100% {
        opacity: 1;
    }

    20%,
    21.9%,
    63%,
    63.9%,
    65%,
    69.9% {
        opacity: 0.8;
    }
}

@keyframes button-pulse {

    0%,
    100% {
        box-shadow:
            inset 0 0 0 2px #ef4444,
            inset 0 0 0 4px #000,
            inset 0 0 0 6px #dc2626,
            0 0 20px rgba(239, 68, 68, 0.8),
            0 0 40px rgba(239, 68, 68, 0.5),
            0 0 60px rgba(239, 68, 68, 0.3),
            0 4px 8px rgba(0, 0, 0, 0.8);
    }

    50% {
        box-shadow:
            inset 0 0 0 2px #ff6b6b,
            inset 0 0 0 4px #000,
            inset 0 0 0 6px #ef4444,
            0 0 30px rgba(255, 107, 107, 1),
            0 0 60px rgba(239, 68, 68, 0.8),
            0 0 90px rgba(239, 68, 68, 0.6),
            0 4px 8px rgba(0, 0, 0, 0.8);
    }
}

@keyframes btn-shine {

    0%,
    90% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

@keyframes text-glitch-1 {

    0%,
    100% {
        transform: translate(0);
        text-shadow: -2px 0 #00ffff;
        clip-path: polygon(0 0, 100% 0, 100% 30%, 0 30%);
    }

    33% {
        transform: translate(-2px, 1px);
        text-shadow: -3px 0 #00ffff;
        clip-path: polygon(0 20%, 100% 20%, 100% 60%, 0 60%);
    }

    66% {
        transform: translate(2px, -1px);
        text-shadow: -2px 0 #00ffff;
        clip-path: polygon(0 50%, 100% 50%, 100% 80%, 0 80%);
    }
}

@keyframes text-glitch-2 {

    0%,
    100% {
        transform: translate(0);
        text-shadow: 2px 0 #ff00ff;
        clip-path: polygon(0 60%, 100% 60%, 100% 100%, 0 100%);
    }

    33% {
        transform: translate(2px, -1px);
        text-shadow: 3px 0 #ff00ff;
        clip-path: polygon(0 10%, 100% 10%, 100% 50%, 0 50%);
    }

    66% {
        transform: translate(-2px, 1px);
        text-shadow: 2px 0 #ff00ff;
        clip-path: polygon(0 70%, 100% 70%, 100% 90%, 0 90%);
    }
}

@keyframes cyber-pulse {

    0%,
    100% {
        box-shadow:
            inset 0 0 0 2px #ef4444,
            inset 0 0 0 4px #000,
            inset 0 0 0 6px #dc2626,
            0 0 15px rgba(239, 68, 68, 0.6),
            0 0 30px rgba(239, 68, 68, 0.4),
            0 4px 8px rgba(0, 0, 0, 0.8);
    }

    50% {
        box-shadow:
            inset 0 0 0 2px #ff6b6b,
            inset 0 0 0 4px #000,
            inset 0 0 0 6px #ef4444,
            0 0 20px rgba(255, 107, 107, 0.8),
            0 0 40px rgba(239, 68, 68, 0.6),
            0 4px 8px rgba(0, 0, 0, 0.8);
    }
}

/* Avatar Animations */
@keyframes spin-segments {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes spin-segments-reverse {
    from {
        transform: rotate(360deg);
    }

    to {
        transform: rotate(0deg);
    }
}

@keyframes glitch-avatar-1 {

    0%,
    95%,
    100% {
        opacity: 0;
        transform: translate(0);
        filter: none;
    }

    96%,
    97% {
        opacity: 0.8;
        transform: translate(-3px, 2px);
        filter: hue-rotate(90deg) saturate(3);
        clip-path: polygon(0 0%, 100% 0%, 100% 25%, 0 25%);
    }

    98%,
    99% {
        opacity: 0.7;
        transform: translate(4px, -2px);
        filter: hue-rotate(270deg) saturate(2);
        clip-path: polygon(0 60%, 100% 60%, 100% 85%, 0 85%);
    }
}

@keyframes glitch-avatar-2 {

    0%,
    93%,
    100% {
        opacity: 0;
        transform: translate(0);
        filter: none;
    }

    94%,
    95% {
        opacity: 0.7;
        transform: translate(5px, -3px);
        filter: hue-rotate(180deg) saturate(2.5);
        clip-path: polygon(0 30%, 100% 30%, 100% 55%, 0 55%);
    }

    96%,
    97% {
        opacity: 0.8;
        transform: translate(-4px, 3px);
        filter: hue-rotate(45deg) saturate(3);
        clip-path: polygon(0 70%, 100% 70%, 100% 95%, 0 95%);
    }
}

@keyframes scanline-move {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(20px);
    }
}

@keyframes grid-pulse {

    0%,
    100% {
        opacity: 0.15;
    }

    50% {
        opacity: 0.25;
    }
}

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

    100% {
        transform: translateX(100%);
    }
}

/* ============================================
   🎨 CYBER GLITCH TITLE - Chromatic Aberration Effect
   ============================================ */
.cyber-glitch-title {
    position: relative;
    display: inline-block;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    line-height: 1.1;
}

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

/* Red/Magenta offset shadow - top-left */
.cyber-glitch-title::before {
    color: #ff005d;
    text-shadow:
        -3px -2px 0 #ff005d,
        -4px -3px 0 rgba(255, 0, 93, 0.8),
        -5px -4px 0 rgba(255, 0, 93, 0.6);
    clip-path: polygon(0 0, 100% 0, 100% 50%, 0 50%);
    animation: glitch-red 3s infinite;
    z-index: -1;
}

/* Cyan/Blue offset shadow - bottom-right */
.cyber-glitch-title::after {
    color: #00f2ff;
    text-shadow:
        3px 2px 0 #00f2ff,
        4px 3px 0 rgba(0, 242, 255, 0.8),
        5px 4px 0 rgba(0, 242, 255, 0.6);
    clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
    animation: glitch-cyan 3s infinite reverse;
    z-index: -1;
}

@keyframes glitch-red {

    0%,
    90%,
    100% {
        transform: translate(0);
        opacity: 0;
    }

    92% {
        transform: translate(-2px, -1px);
        opacity: 0.8;
    }

    94% {
        transform: translate(2px, 1px);
        opacity: 0.6;
    }

    96% {
        transform: translate(-1px, -2px);
        opacity: 0.7;
    }

    98% {
        transform: translate(0);
        opacity: 0;
    }
}

@keyframes glitch-cyan {

    0%,
    90%,
    100% {
        transform: translate(0);
        opacity: 0;
    }

    92% {
        transform: translate(2px, 1px);
        opacity: 0.8;
    }

    94% {
        transform: translate(-2px, -1px);
        opacity: 0.6;
    }

    96% {
        transform: translate(1px, 2px);
        opacity: 0.7;
    }

    98% {
        transform: translate(0);
        opacity: 0;
    }
}

/* Cyber Title with Red Background */
.cyber-title-red-bg {
    position: relative;
    display: inline-block;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    padding: 0.15em 0.3em;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
    box-shadow:
        0 0 20px rgba(239, 68, 68, 0.6),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    animation: glitch-bg 4s infinite;
}

.cyber-title-red-bg .cyber-glitch-title {
    color: white;
    position: relative;
    z-index: 1;
}

/* White text glitch */
.cyber-title-white {
    position: relative;
    display: inline-block;
    color: white;
}

@keyframes glitch-bg {

    0%,
    90%,
    100% {
        transform: translate(0);
        filter: hue-rotate(0deg);
    }

    92% {
        transform: translate(-1px, 1px);
        filter: hue-rotate(5deg);
    }

    94% {
        transform: translate(1px, -1px);
        filter: hue-rotate(-5deg);
    }

    96% {
        transform: translate(0);
        filter: hue-rotate(0deg);
    }
}

/* ============================================
   🎨 CYBER TYPING ANIMATION STYLES - Hài Hòa & Hợp Lý
   ============================================ */

/* Glitch text effect for main title */
.glitch-text {
    text-shadow: 2px 0 #00F0FF, -2px 0 #FF00FF;
}

.animate-glitch {
    animation: glitch 1s infinite linear alternate-reverse;
}

@keyframes glitch {
    0% {
        transform: translate(0) skew(0deg);
    }

    20% {
        transform: translate(-2px, 2px) skew(-6deg);
    }

    40% {
        transform: translate(-2px, -2px) skew(-6deg);
    }

    60% {
        transform: translate(2px, 2px) skew(-6deg);
    }

    80% {
        transform: translate(2px, -2px) skew(-6deg);
    }

    100% {
        transform: translate(0) skew(-6deg);
    }
}

/* ============================================
   🎯 TYPING SECTION - Thiết Kế Hài Hòa
   ============================================ */

.cyber-typing-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.cyber-typing-line {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: 'JetBrains Mono', monospace;
}

/* Prefix Style - "HI, I'M" và "I'M A" */
.cyber-prefix {
    font-size: 1.25rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .cyber-prefix {
        font-size: 1.5rem;
        letter-spacing: 0.2em;
    }
}

@media (min-width: 1024px) {
    .cyber-prefix {
        font-size: 1.75rem;
    }
}

/* Name/Role Box Style - Border đỏ 2 bên */
.cyber-name-box {
    position: relative;
    display: inline-block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ef4444;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.5rem 1rem;
    min-width: 140px;
    text-align: center;

    /* Border đỏ chỉ 2 bên */
    border-left: 3px solid #ef4444;
    border-right: 3px solid #ef4444;
    border-top: none;
    border-bottom: none;

    /* Neon glow nhẹ */
    text-shadow:
        0 0 8px rgba(239, 68, 68, 0.6),
        0 0 16px rgba(239, 68, 68, 0.3);

    /* Background subtle */
    background: rgba(239, 68, 68, 0.05);

    /* Box shadow nhẹ */
    box-shadow:
        0 0 15px rgba(239, 68, 68, 0.2),
        inset 0 0 10px rgba(239, 68, 68, 0.05);

    transition: all 0.3s ease;
}

.cyber-name-box:hover {
    background: rgba(239, 68, 68, 0.1);
    box-shadow:
        0 0 20px rgba(239, 68, 68, 0.4),
        inset 0 0 15px rgba(239, 68, 68, 0.1);
}

@media (min-width: 768px) {
    .cyber-name-box {
        font-size: 1.75rem;
        padding: 0.6rem 1.25rem;
        min-width: 180px;
        border-left-width: 4px;
        border-right-width: 4px;
    }
}

@media (min-width: 1024px) {
    .cyber-name-box {
        font-size: 2rem;
        padding: 0.75rem 1.5rem;
        min-width: 220px;
    }
}

/* Cyber cursor - Hài hòa với design */
.cyber-cursor {
    display: inline-block;
    width: 3px;
    height: 1.2em;
    background: #ef4444;
    box-shadow:
        0 0 6px rgba(239, 68, 68, 0.9),
        0 0 12px rgba(239, 68, 68, 0.5);
    animation: cyber-cursor-blink 0.9s infinite;
    vertical-align: middle;
    margin-left: 6px;
}

@keyframes cyber-cursor-blink {

    0%,
    49% {
        opacity: 1;
        background: #ef4444;
        box-shadow:
            0 0 6px rgba(239, 68, 68, 0.9),
            0 0 12px rgba(239, 68, 68, 0.5);
    }

    50%,
    100% {
        opacity: 0.4;
        background: rgba(239, 68, 68, 0.6);
        box-shadow:
            0 0 3px rgba(239, 68, 68, 0.5),
            0 0 6px rgba(239, 68, 68, 0.3);
    }
}

/* Glitch effects khi typing - Nhẹ nhàng */
.glitch-typing {
    animation: typing-glitch-subtle 0.08s;
}

.glitch-deleting {
    animation: deleting-glitch-subtle 0.12s;
}

@keyframes typing-glitch-subtle {

    0%,
    100% {
        transform: translate(0);
        text-shadow:
            0 0 8px rgba(239, 68, 68, 0.6),
            0 0 16px rgba(239, 68, 68, 0.3);
    }

    50% {
        transform: translate(0.5px, 0);
        text-shadow:
            -1px 0 rgba(255, 0, 93, 0.4),
            0 0 8px rgba(239, 68, 68, 0.6),
            0 0 16px rgba(239, 68, 68, 0.3);
    }
}

@keyframes deleting-glitch-subtle {

    0%,
    100% {
        transform: translate(0);
        text-shadow:
            0 0 8px rgba(239, 68, 68, 0.6),
            0 0 16px rgba(239, 68, 68, 0.3);
    }

    25% {
        transform: translate(-1px, 0);
        text-shadow:
            -2px 0 rgba(255, 0, 93, 0.5),
            0 0 8px rgba(239, 68, 68, 0.6);
    }

    75% {
        transform: translate(1px, 0);
        text-shadow:
            2px 0 rgba(0, 242, 255, 0.4),
            0 0 8px rgba(239, 68, 68, 0.6);
    }
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .cyber-typing-section {
        gap: 1rem;
    }

    .cyber-typing-line {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .cyber-prefix {
        font-size: 1rem;
    }

    .cyber-name-box {
        font-size: 1.25rem;
        padding: 0.4rem 0.75rem;
        min-width: 120px;
    }

    .cyber-cursor {
        width: 2px;
        margin-left: 4px;
    }
}

/* ============================================
   🚀 NEW UTILITY ANIMATIONS
   ============================================ */

.animate-spin-slow {
    animation: spin 8s linear infinite;
}

.animate-reverse-spin {
    animation: reverse-spin 12s linear infinite;
}

.animate-slide-in {
    animation: slide-in 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes reverse-spin {
    from {
        transform: rotate(360deg);
    }

    to {
        transform: rotate(0deg);
    }
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes block-pulse {

    0%,
    100% {
        border-color: rgba(239, 68, 68, 0.4);
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.1);
    }

    50% {
        border-color: rgba(239, 68, 68, 0.8);
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
    }
}

/* ============================================
   🎨 WEB BUILDER SIMULATION ANIMATIONS
   ============================================ */

@keyframes mock-dragging {

    0%,
    100% {
        transform: translate(0, 0);
    }

    20% {
        transform: translate(-30px, 40px);
    }

    40% {
        transform: translate(120px, -20px);
    }

    60% {
        transform: translate(60px, 80px);
    }

    80% {
        transform: translate(-80px, 10px);
    }
}

@keyframes float-particle {

    0%,
    100% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }

    25% {
        opacity: 0.5;
    }

    50% {
        transform: translateY(-100px) translateX(20px);
        opacity: 0.8;
    }

    75% {
        opacity: 0.5;
    }
}

@keyframes scanning-glow {
    0% {
        top: -100%;
    }

    100% {
        top: 200%;
    }
}

.animate-mock-drag {
    animation: mock-dragging 15s infinite ease-in-out;
}

.animate-float-1 {
    animation: float-particle 10s infinite;
}

.animate-float-2 {
    animation: float-particle 14s infinite 2s;
}

.animate-float-3 {
    animation: float-particle 18s infinite 4s;
}

.builder-scanline {
    position: absolute;
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(to bottom, transparent, rgba(239, 68, 68, 0.1), transparent);
    animation: scanning-glow 4s infinite linear;
    pointer-events: none;
    z-index: 5;
}