/**
 * YoureNu Forum - Animations & Effects
 * 
 * Futuristic animations and visual effects for the neural forum
 */

/* Global Animation Settings */
@media (prefers-reduced-motion: no-preference) {
    :root {
        --animation-duration-fast: 0.2s;
        --animation-duration-normal: 0.3s;
        --animation-duration-slow: 0.5s;
        --animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
        --animation-easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    }
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Loading Animations */
@keyframes neural-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
}

@keyframes neural-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes neural-glow {
    0%, 100% {
        box-shadow: 0 0 20px var(--accent-color);
    }
    50% {
        box-shadow: 0 0 40px var(--accent-color), 0 0 60px var(--accent-color);
    }
}

/* Text Animations */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink-cursor {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--accent-color);
    }
}

.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--accent-color);
    white-space: nowrap;
    animation: 
        typewriter 3s steps(40, end),
        blink-cursor 0.75s step-end infinite;
}

@keyframes text-glow {
    0%, 100% {
        text-shadow: 0 0 10px var(--accent-color);
    }
    50% {
        text-shadow: 
            0 0 20px var(--accent-color),
            0 0 30px var(--accent-color),
            0 0 40px var(--accent-color);
    }
}

.text-glow {
    animation: text-glow 2s ease-in-out infinite;
}

/* Hover Animations */
@keyframes hover-float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.hover-float:hover {
    animation: hover-float 1s ease-in-out infinite;
}

@keyframes hover-shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-2px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(2px);
    }
}

.hover-shake:hover {
    animation: hover-shake 0.5s ease-in-out;
}

/* Button Animations */
@keyframes button-press {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

.btn-animated:active {
    animation: button-press 0.1s ease-in-out;
}

@keyframes button-ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: scale(0);
    pointer-events: none;
}

.btn-ripple:active::after {
    animation: button-ripple 0.6s ease-out;
}

/* Card Animations */
@keyframes card-slide-in {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.card-animated {
    animation: card-slide-in 0.6s var(--animation-easing);
}

@keyframes card-flip {
    0% {
        transform: rotateY(0);
    }
    50% {
        transform: rotateY(-90deg);
    }
    100% {
        transform: rotateY(0);
    }
}

.card-flip:hover {
    animation: card-flip 0.8s ease-in-out;
}

/* Neural Pattern Animations */
@keyframes pattern-draw {
    from {
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dashoffset: 0;
    }
}

.pattern-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: pattern-draw 2s ease-in-out forwards;
}

@keyframes pattern-node-pulse {
    0%, 100% {
        r: 4;
        fill-opacity: 1;
    }
    50% {
        r: 8;
        fill-opacity: 0.7;
    }
}

.pattern-node {
    animation: pattern-node-pulse 1.5s ease-in-out infinite;
}

@keyframes complexity-fill {
    from {
        width: 0%;
    }
    to {
        width: var(--target-width);
    }
}

.complexity-fill-animated {
    animation: complexity-fill 1s ease-out forwards;
}

/* Matrix Effect Animations */
@keyframes matrix-rain {
    0% {
        transform: translateY(-100vh);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(100vh);
        opacity: 0;
    }
}

.matrix-char {
    animation: matrix-rain linear infinite;
    animation-duration: calc(10s + var(--random-delay, 0s));
    animation-delay: calc(-1s * var(--random-delay, 0));
}

/* Glitch Effects */
@keyframes glitch-1 {
    0%, 14%, 15%, 49%, 50%, 99%, 100% {
        transform: translate(0);
        filter: hue-rotate(0deg);
    }
    15%, 49% {
        transform: translate(-2px, 2px);
        filter: hue-rotate(90deg);
    }
}

@keyframes glitch-2 {
    0%, 20%, 21%, 62%, 63%, 99%, 100% {
        transform: translate(0);
        filter: hue-rotate(0deg);
    }
    21%, 62% {
        transform: translate(2px, -2px);
        filter: hue-rotate(180deg);
    }
}

@keyframes glitch-3 {
    0%, 12%, 13%, 45%, 46%, 99%, 100% {
        transform: translate(0);
        filter: hue-rotate(0deg);
    }
    13%, 45% {
        transform: translate(-1px, 1px);
        filter: hue-rotate(270deg);
    }
}

.glitch-effect {
    position: relative;
}

.glitch-effect::before,
.glitch-effect::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-bg);
    clip: rect(0, 900px, 0, 0);
}

.glitch-effect::before {
    animation: glitch-1 2s infinite linear alternate-reverse;
    color: #ff0000;
    z-index: -1;
}

.glitch-effect::after {
    animation: glitch-2 3s infinite linear alternate-reverse;
    color: #00ffff;
    z-index: -2;
}

.glitch-effect:hover::before {
    animation: glitch-1 0.2s infinite linear alternate-reverse;
}

.glitch-effect:hover::after {
    animation: glitch-2 0.3s infinite linear alternate-reverse;
}

/* Holographic Effects */
@keyframes holographic-shift {
    0%, 100% {
        background-position: 0% 50%;
        filter: hue-rotate(0deg);
    }
    25% {
        background-position: 100% 50%;
        filter: hue-rotate(90deg);
    }
    50% {
        background-position: 100% 100%;
        filter: hue-rotate(180deg);
    }
    75% {
        background-position: 0% 100%;
        filter: hue-rotate(270deg);
    }
}

.holographic {
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(0, 255, 65, 0.1) 50%,
        transparent 70%
    );
    background-size: 400% 400%;
    animation: holographic-shift 4s ease-in-out infinite;
}

@keyframes holographic-text {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.holographic-text {
    background: linear-gradient(
        45deg,
        var(--accent-color),
        #00aaff,
        #aa00ff,
        var(--accent-color)
    );
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: holographic-text 3s ease-in-out infinite;
}

/* Cyber Grid Animations */
@keyframes grid-pulse {
    0%, 100% {
        opacity: 0.1;
    }
    50% {
        opacity: 0.3;
    }
}

.cyber-grid {
    background-image: 
        linear-gradient(rgba(0, 255, 65, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 65, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    animation: grid-pulse 3s ease-in-out infinite;
}

@keyframes grid-scan {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 20px 20px;
    }
}

.cyber-grid-animated {
    animation: 
        grid-pulse 3s ease-in-out infinite,
        grid-scan 10s linear infinite;
}

/* Particle Effects */
@keyframes particle-float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translateY(-20px) rotate(180deg);
        opacity: 0.5;
    }
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: particle-float 3s ease-in-out infinite;
    animation-delay: calc(var(--particle-delay, 0) * 0.1s);
}

/* Quantum Effects */
@keyframes quantum-entanglement {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    25% {
        transform: scale(1.2) rotate(90deg);
        opacity: 0.8;
    }
    50% {
        transform: scale(0.8) rotate(180deg);
        opacity: 0.6;
    }
    75% {
        transform: scale(1.1) rotate(270deg);
        opacity: 0.8;
    }
}

.quantum-effect {
    animation: quantum-entanglement 4s ease-in-out infinite;
}

@keyframes quantum-tunnel {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(2) rotate(360deg);
        opacity: 0;
    }
}

.quantum-tunnel {
    animation: quantum-tunnel 2s ease-out infinite;
}

/* Neural Network Animations */
@keyframes neural-connection {
    0%, 100% {
        stroke-dashoffset: 0;
        stroke-opacity: 1;
    }
    50% {
        stroke-dashoffset: 20;
        stroke-opacity: 0.5;
    }
}

.neural-connection {
    stroke-dasharray: 5, 5;
    animation: neural-connection 2s ease-in-out infinite;
}

@keyframes neural-activation {
    0%, 100% {
        fill: var(--accent-color);
        r: 4;
    }
    50% {
        fill: #ffffff;
        r: 8;
    }
}

.neural-node {
    animation: neural-activation 1.5s ease-in-out infinite;
    animation-delay: calc(var(--node-delay, 0) * 0.2s);
}

/* Scroll Animations */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-down {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-left {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fade-in-right {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-on-scroll {
    opacity: 0;
    transition: all 0.6s var(--animation-easing);
}

.animate-on-scroll.in-view {
    opacity: 1;
}

.animate-fade-up.in-view {
    animation: fade-in-up 0.6s var(--animation-easing) forwards;
}

.animate-fade-down.in-view {
    animation: fade-in-down 0.6s var(--animation-easing) forwards;
}

.animate-fade-left.in-view {
    animation: fade-in-left 0.6s var(--animation-easing) forwards;
}

.animate-fade-right.in-view {
    animation: fade-in-right 0.6s var(--animation-easing) forwards;
}

/* Loading States */
@keyframes skeleton-loading {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--secondary-bg) 25%,
        var(--hover-bg) 50%,
        var(--secondary-bg) 75%
    );
    background-size: 200px 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes pulse-loading {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse-loading {
    animation: pulse-loading 2s ease-in-out infinite;
}

/* Success/Error Animations */
@keyframes success-checkmark {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.success-checkmark {
    stroke-dasharray: 100;
    animation: success-checkmark 0.5s ease-in-out forwards;
}

@keyframes error-shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.error-shake {
    animation: error-shake 0.5s ease-in-out;
}

/* Notification Animations */
@keyframes notification-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes notification-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.notification-enter {
    animation: notification-slide-in 0.3s ease-out forwards;
}

.notification-exit {
    animation: notification-slide-out 0.3s ease-in forwards;
}

/* Modal Animations */
@keyframes modal-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modal-scale-in {
    from {
        transform: scale(0.7);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-backdrop {
    animation: modal-fade-in 0.3s ease-out;
}

.modal-content {
    animation: modal-scale-in 0.3s var(--animation-easing-bounce);
}

/* Utility Animation Classes */
.animate-spin {
    animation: neural-spin 1s linear infinite;
}

.animate-pulse {
    animation: neural-pulse 2s ease-in-out infinite;
}

.animate-bounce {
    animation: hover-float 1s ease-in-out infinite;
}

.animate-glow {
    animation: neural-glow 2s ease-in-out infinite;
}

.animate-delayed {
    animation-delay: 0.5s;
}

.animate-delayed-2 {
    animation-delay: 1s;
}

.animate-delayed-3 {
    animation-delay: 1.5s;
}

/* Performance Optimizations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Dark Mode Specific Animations */
@media (prefers-color-scheme: dark) {
    .auto-glow {
        animation: neural-glow 3s ease-in-out infinite;
    }
    
    .auto-pulse {
        animation: neural-pulse 2s ease-in-out infinite;
    }
}
