/* ========================================
   ANIMATIONS.CSS - Animations & Effects
   ======================================== */

/* Keyframe Animations */

/* Fade In */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide In Left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide In Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pulse */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* Glow Pulse */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px var(--glow-color);
    }
    50% {
        box-shadow: 0 0 40px var(--glow-color), 0 0 60px var(--glow-color);
    }
}

/* Float */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* Rotate */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Rotate Reverse */
@keyframes rotateReverse {
    from {
        transform: rotate(360deg);
    }
    to {
        transform: rotate(0deg);
    }
}

/* Bounce */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Shake */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Glitch Effect */
@keyframes glitch {
    0% {
        text-shadow: 
            2px 0 var(--accent-primary),
            -2px 0 var(--accent-secondary);
    }
    25% {
        text-shadow: 
            -2px 0 var(--accent-primary),
            2px 0 var(--accent-secondary);
    }
    50% {
        text-shadow: 
            2px 0 var(--accent-secondary),
            -2px 0 var(--accent-primary);
    }
    75% {
        text-shadow: 
            -2px 0 var(--accent-secondary),
            2px 0 var(--accent-primary);
    }
    100% {
        text-shadow: 
            2px 0 var(--accent-primary),
            -2px 0 var(--accent-secondary);
    }
}

/* Typing Effect */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

/* Blink Cursor */
@keyframes blink {
    0%, 100% {
        border-color: transparent;
    }
    50% {
        border-color: var(--accent-primary);
    }
}

/* Gradient Shift */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Ripple Effect */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* Spinner */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Progress Bar */
@keyframes progress {
    from {
        width: 0%;
    }
}

/* Color Cycle */
@keyframes colorCycle {
    0% {
        color: var(--accent-primary);
    }
    25% {
        color: var(--accent-secondary);
    }
    50% {
        color: var(--success);
    }
    75% {
        color: var(--warning);
    }
    100% {
        color: var(--accent-primary);
    }
}

/* Border Dance */
@keyframes borderDance {
    0% {
        border-color: var(--accent-primary);
    }
    25% {
        border-color: var(--accent-secondary);
    }
    50% {
        border-color: var(--success);
    }
    75% {
        border-color: var(--warning);
    }
    100% {
        border-color: var(--accent-primary);
    }
}

/* ========================================
   Animation Classes
   ======================================== */

.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.6s ease-out forwards;
}

.animate-slide-in-left {
    animation: slideInLeft 0.6s ease-out forwards;
}

.animate-slide-in-right {
    animation: slideInRight 0.6s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.6s ease-out forwards;
}

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

.animate-glow {
    animation: glowPulse 2s ease-in-out infinite;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-rotate {
    animation: rotate 2s linear infinite;
}

.animate-rotate-reverse {
    animation: rotateReverse 2s linear infinite;
}

.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

.animate-glitch {
    animation: glitch 0.3s ease-in-out infinite;
}

.animate-gradient {
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

/* Staggered Animations */
.stagger-1 {
    animation-delay: 0.1s;
}

.stagger-2 {
    animation-delay: 0.2s;
}

.stagger-3 {
    animation-delay: 0.3s;
}

.stagger-4 {
    animation-delay: 0.4s;
}

.stagger-5 {
    animation-delay: 0.5s;
}

/* ========================================
   Glitch Text Effect
   ======================================== */

.glitch-text {
    position: relative;
}

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

.glitch-text::before {
    animation: glitch 0.3s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    transform: translate(-2px, -2px);
    opacity: 0.8;
}

.glitch-text::after {
    animation: glitch 0.3s infinite reverse;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    transform: translate(2px, 2px);
    opacity: 0.8;
}

/* ========================================
   Typing Effect
   ======================================== */

.typing-effect {
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid var(--accent-primary);
    animation: typing 3s steps(40) forwards, blink 0.75s step-end infinite;
}

/* ========================================
   Hover Effects
   ======================================== */

.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px var(--shadow-strong);
}

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px var(--glow-color);
}

.hover-scale {
    transition: transform 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-rotate {
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

/* ========================================
   Loading Animations
   ======================================== */

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-dots {
    display: flex;
    gap: 8px;
}

.loading-dots span {
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: pulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ========================================
   Section Transitions
   ======================================== */

.section-enter {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.section-enter-active {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   Particle Animations (for Canvas fallback)
   ======================================== */

@keyframes particleFloat {
    0%, 100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(10px, -10px);
    }
    50% {
        transform: translate(-10px, 10px);
    }
    75% {
        transform: translate(10px, 10px);
    }
}

/* ========================================
   Reduced Motion Support
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .glitch-text::before,
    .glitch-text::after {
        display: none;
    }
}

/* ========================================
   Low-Spec Mode Overrides
   ======================================== */

[data-low-spec="true"] .animate-glitch,
[data-low-spec="true"] .animate-glow,
[data-low-spec="true"] .animate-float,
[data-low-spec="true"] .animate-pulse {
    animation: none !important;
}

[data-low-spec="true"] .glitch-text::before,
[data-low-spec="true"] .glitch-text::after {
    display: none;
}
