/* ==========================================================================
   xinghzhe.com - Advanced Animations
   Cyber / Futuristic Effects
   ========================================================================== */

/* Glitch Effect */
.glitch {
    position: relative;
    display: inline-block;
}

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

.glitch::before {
    color: var(--accent-cyan);
    z-index: -1;
    animation: glitch-anim 3s infinite linear alternate-reverse;
}

.glitch::after {
    color: var(--accent-magenta);
    z-index: -2;
    animation: glitch-anim 2.5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
    100% { transform: translate(0); }
}

/* Neon pulse ring */
.neon-ring {
    position: relative;
}

.neon-ring::before {
    content: '';
    position: absolute;
    inset: -4px;
    border: 1px solid var(--accent-cyan);
    border-radius: inherit;
    pointer-events: none;
    animation: neon-pulse 2s ease-in-out infinite;
}

@keyframes neon-pulse {
    0%, 100% {
        opacity: 0.6;
        box-shadow: 0 0 10px var(--accent-cyan);
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 25px var(--accent-cyan), 0 0 40px var(--accent-cyan);
    }
}

/* 3D hover lift */
.lift-3d {
    transform-style: preserve-3d;
    perspective: 1000px;
    transition: transform 0.4s ease;
}

.lift-3d:hover {
    transform: rotateY(2deg) rotateX(-2deg) translateZ(20px);
}

/* Typewriter Effect */
.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--accent-cyan);
    white-space: nowrap;
    margin: 0 auto;
    animation: typewriter 2.5s steps(40, end), blink-caret 0.7s step-end infinite;
    display: inline-block;
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

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

/* Rotating ring loader */
.ring-loader {
    width: 60px;
    height: 60px;
    border: 3px solid transparent;
    border-top-color: var(--accent-cyan);
    border-right-color: var(--accent-magenta);
    border-radius: 50%;
    animation: spin-slow 1s linear infinite;
}

/* Cyberpunk button effect */
.cyber-btn {
    position: relative;
    padding: 0.85rem 1.75rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-cyan);
    background: transparent;
    border: 1px solid var(--accent-cyan);
    cursor: pointer;
    overflow: hidden;
    transition: color 0.3s ease;
}

.cyber-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--accent-cyan);
    transition: left 0.3s ease;
    z-index: -1;
}

.cyber-btn:hover {
    color: var(--bg-primary);
    box-shadow: 0 0 20px var(--accent-cyan);
}

.cyber-btn:hover::before {
    left: 0;
}

/* Magnetic button */
.magnetic {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Holographic card */
.holo-card {
    position: relative;
    background:
        linear-gradient(135deg, rgba(0,240,255,0.05), rgba(168,85,247,0.05)),
        var(--bg-card);
    backdrop-filter: blur(12px);
    overflow: hidden;
}

.holo-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
        transparent 0%,
        rgba(0, 240, 255, 0.03) 30%,
        rgba(255, 0, 170, 0.03) 50%,
        rgba(168, 85, 247, 0.03) 70%,
        transparent 100%);
    mix-blend-mode: overlay;
    pointer-events: none;
    opacity: 0.5;
}

.holo-card:hover::after {
    animation: holo-shift 1.5s ease-in-out infinite;
}

@keyframes holo-shift {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Parallax effect using transform */
.parallax {
    will-change: transform;
}

/* Light beam */
.light-beam {
    position: relative;
    overflow: hidden;
}

.light-beam::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.15), transparent);
    animation: light-beam-move 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes light-beam-move {
    0% { left: -100%; }
    100% { left: 200%; }
}

/* Wave animation */
.wave-animated {
    animation: wave-pulse 2s ease-in-out infinite;
}

@keyframes wave-pulse {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Glow text */
.glow-text {
    text-shadow: 0 0 10px currentColor, 0 0 20px currentColor, 0 0 30px currentColor;
}

/* Hover image zoom */
.zoom-hover {
    overflow: hidden;
}

.zoom-hover > * {
    transition: transform 0.6s ease;
}

.zoom-hover:hover > * {
    transform: scale(1.08);
}

/* Reveal text mask */
.text-reveal {
    overflow: hidden;
    display: inline-block;
    vertical-align: bottom;
}

.text-reveal > span {
    display: inline-block;
    transform: translateY(110%);
    transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

.text-reveal.in > span {
    transform: translateY(0);
}

/* Animated gradient border */
.gradient-border {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-md);
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple), var(--accent-magenta), var(--accent-cyan));
    background-size: 300% 300%;
    z-index: -1;
    animation: gradient-border-shift 4s linear infinite;
    opacity: 0.7;
}

@keyframes gradient-border-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Marquee */
.marquee {
    overflow: hidden;
    white-space: nowrap;
}

.marquee-content {
    display: inline-block;
    animation: marquee 20s linear infinite;
}

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

/* Hover tilt (will be applied by JS) */
.tilt-hover {
    transform-style: preserve-3d;
    transition: transform 0.2s ease;
}

/* Stagger children animations */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    animation: fade-in-up 0.6s forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.35s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.45s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.55s; }

/* Scan animation on cards */
.scan-card {
    position: relative;
    overflow: hidden;
}

.scan-card::after {
    content: '';
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(0, 240, 255, 0.05) 50%,
        transparent 100%);
    transition: top 0.8s ease;
    pointer-events: none;
}

.scan-card:hover::after {
    top: 100%;
}

/* Flicker text effect */
.flicker {
    animation: flicker 4s linear infinite;
}

@keyframes flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        opacity: 1;
        text-shadow: 0 0 10px currentColor, 0 0 20px currentColor;
    }
    20%, 24%, 55% {
        opacity: 0.4;
        text-shadow: none;
    }
}

/* Hexagon pattern animation */
.hex-grid {
    background-image:
        radial-gradient(circle, rgba(0,240,255,0.15) 1px, transparent 1px);
    background-size: 30px 30px;
    animation: hex-shift 8s linear infinite;
}

@keyframes hex-shift {
    from { background-position: 0 0; }
    to { background-position: 30px 30px; }
}

/* Reduce for reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .glitch::before,
    .glitch::after,
    .flicker,
    .neon-ring::before,
    .light-beam::before,
    .holo-card::after,
    .gradient-border::before,
    .ring-loader {
        animation: none !important;
    }
}
