/* ===================================
   Rapid Writers - Animation Styles
   ================================== */

/* Loading and Initial Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(100px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-100px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Floating and Hover Animations */
@keyframes float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    25% {
        transform: translateY(-15px) rotate(1deg);
    }
    50% {
        transform: translateY(-25px) rotate(0deg);
    }
    75% {
        transform: translateY(-15px) rotate(-1deg);
    }
}

@keyframes floatSlow {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes floatReverse {
    0%, 100% {
        transform: translateY(-10px) rotate(0deg);
    }
    50% {
        transform: translateY(0px) rotate(1deg);
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
        transform: translate3d(0, -30px, 0);
    }
    70% {
        animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
        transform: translate3d(0, -15px, 0);
    }
    90% {
        transform: translate3d(0, -4px, 0);
    }
}

@keyframes wobble {
    from {
        transform: translate3d(0, 0, 0);
    }
    15% {
        transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg);
    }
    30% {
        transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg);
    }
    45% {
        transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg);
    }
    60% {
        transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg);
    }
    75% {
        transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg);
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

/* Pulse and Glow Animations */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 234, 255, 0.7);
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 234, 255, 0);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 234, 255, 0);
        transform: scale(1);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(0, 234, 255, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(0, 234, 255, 0.6);
    }
}

@keyframes glow {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.3;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.05;
    }
}

@keyframes textGlow {
    0%, 100% {
        text-shadow: 0 0 20px rgba(0, 234, 255, 0.5);
    }
    50% {
        text-shadow: 0 0 30px rgba(0, 234, 255, 0.8);
    }
}

/* Gradient and Color Animations */
@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes rainbowText {
    0% { color: #ff0000; }
    16.66% { color: #ff8000; }
    33.33% { color: #ffff00; }
    50% { color: #00ff00; }
    66.66% { color: #0080ff; }
    83.33% { color: #8000ff; }
    100% { color: #ff0000; }
}

@keyframes backgroundPulse {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.6;
    }
}

@keyframes colorShift {
    0% { background-color: var(--accent-color); }
    25% { background-color: var(--accent-secondary); }
    50% { background-color: var(--primary-bg); }
    75% { background-color: var(--accent-secondary); }
    100% { background-color: var(--accent-color); }
}

/* Shimmer and Loading Effects */
@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes priceShimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes loadingDots {
    0%, 20% {
        color: rgba(0, 0, 0, 0);
        text-shadow: 
            0.25em 0 0 rgba(0, 0, 0, 0),
            0.5em 0 0 rgba(0, 0, 0, 0);
    }
    40% {
        color: var(--text-dark);
        text-shadow: 
            0.25em 0 0 rgba(0, 0, 0, 0),
            0.5em 0 0 rgba(0, 0, 0, 0);
    }
    60% {
        text-shadow: 
            0.25em 0 0 var(--text-dark),
            0.5em 0 0 rgba(0, 0, 0, 0);
    }
    80%, 100% {
        text-shadow: 
            0.25em 0 0 var(--text-dark),
            0.5em 0 0 var(--text-dark);
    }
}

/* Rotation and Transform Animations */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes rotateClockwise {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes rotateCounterClockwise {
    0% {
        transform: rotate(360deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

@keyframes swing {
    20% {
        transform: rotate3d(0, 0, 1, 15deg);
    }
    40% {
        transform: rotate3d(0, 0, 1, -10deg);
    }
    60% {
        transform: rotate3d(0, 0, 1, 5deg);
    }
    80% {
        transform: rotate3d(0, 0, 1, -5deg);
    }
    to {
        transform: rotate3d(0, 0, 1, 0deg);
    }
}

@keyframes flip {
    from {
        transform: perspective(400px) rotate3d(0, 1, 0, -360deg);
        animation-timing-function: ease-out;
    }
    40% {
        transform: perspective(400px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -190deg);
        animation-timing-function: ease-out;
    }
    50% {
        transform: perspective(400px) translate3d(0, 0, 150px) rotate3d(0, 1, 0, -170deg);
        animation-timing-function: ease-in;
    }
    80% {
        transform: perspective(400px) scale3d(.95, .95, .95);
        animation-timing-function: ease-in;
    }
    to {
        transform: perspective(400px);
        animation-timing-function: ease-in;
    }
}

/* Slide Animations */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideLeft {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideRight {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Zoom and Scale Animations */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
    50% {
        opacity: 1;
    }
}

@keyframes zoomOut {
    from {
        opacity: 1;
    }
    50% {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
    to {
        opacity: 0;
    }
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.3);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.3);
    }
    70% {
        transform: scale(1);
    }
}

/* Text Animations */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blinkCursor {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--accent-color);
    }
}

@keyframes textFocus {
    0% {
        filter: blur(12px);
        opacity: 0;
    }
    100% {
        filter: blur(0px);
        opacity: 1;
    }
}

@keyframes textShadow {
    0% {
        text-shadow: 0 0 0 var(--accent-color);
    }
    100% {
        text-shadow: 2px 2px 10px var(--accent-color);
    }
}

/* Navigation Animations */
@keyframes navSlideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes menuSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes menuFade {
    from {
        opacity: 0;
        visibility: hidden;
    }
    to {
        opacity: 1;
        visibility: visible;
    }
}

/* Button Animations */
@keyframes buttonPress {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes buttonShine {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes buttonGlow {
    0%, 100% {
        box-shadow: 0 0 5px var(--accent-color);
    }
    50% {
        box-shadow: 0 0 20px var(--accent-color), 0 0 30px var(--accent-color);
    }
}

/* Card Animations */
@keyframes cardFlip {
    0% {
        transform: rotateY(0);
    }
    50% {
        transform: rotateY(-90deg);
    }
    100% {
        transform: rotateY(0);
    }
}

@keyframes cardSlideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes cardHover {
    0% {
        transform: translateY(0) scale(1);
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    }
    100% {
        transform: translateY(-10px) scale(1.02);
        box-shadow: 0 20px 40px rgba(0, 234, 255, 0.2);
    }
}

/* Modal and Overlay Animations */
@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Particle and Effect Animations */
@keyframes particle {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) rotate(360deg);
        opacity: 0;
    }
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Animation Classes */
.animate-fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

.animate-fade-in-down {
    animation: fadeInDown 0.6s ease-out;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.6s ease-out;
}

.animate-fade-in-right {
    animation: fadeInRight 0.6s ease-out;
}

.animate-scale-in {
    animation: scaleIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-slide-up {
    animation: slideUp 0.6s ease-out;
}

.animate-slide-down {
    animation: slideDown 0.6s ease-out;
}

.animate-float {
    animation: float 6s ease-in-out infinite;
}

.animate-float-slow {
    animation: floatSlow 8s ease-in-out infinite;
}

.animate-float-reverse {
    animation: floatReverse 7s ease-in-out infinite;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.animate-glow {
    animation: pulseGlow 3s ease-in-out infinite;
}

.animate-bounce {
    animation: bounce 2s infinite;
}

.animate-wobble {
    animation: wobble 1s;
}

.animate-swing {
    animation: swing 1s;
}

.animate-flip {
    animation: flip 1s;
}

.animate-rotate {
    animation: rotate 2s linear infinite;
}

.animate-heartbeat {
    animation: heartbeat 1.5s ease-in-out infinite;
}

.animate-zoom-in {
    animation: zoomIn 0.6s;
}

.animate-text-glow {
    animation: textGlow 2s ease-in-out infinite;
}

.animate-gradient {
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

.animate-shimmer {
    position: relative;
    overflow: hidden;
}

.animate-shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

/* Delay Classes */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; }

/* Duration Classes */
.duration-fast { animation-duration: 0.3s; }
.duration-normal { animation-duration: 0.6s; }
.duration-slow { animation-duration: 1s; }
.duration-slower { animation-duration: 2s; }
.duration-slowest { animation-duration: 3s; }

/* Hover Animation Classes */
.hover-lift {
    transition: transform 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
}

.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);
}

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(0, 234, 255, 0.5);
}

/* Page Load Animations */
.page-load {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease-out forwards;
}

.page-load.delay-1 { animation-delay: 0.1s; }
.page-load.delay-2 { animation-delay: 0.2s; }
.page-load.delay-3 { animation-delay: 0.3s; }
.page-load.delay-4 { animation-delay: 0.4s; }
.page-load.delay-5 { animation-delay: 0.5s; }

/* Scroll Triggered Animations */
.scroll-animate {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.6s ease-out;
}

.scroll-animate.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.6s ease-out;
}

.scroll-scale.visible {
    opacity: 1;
    transform: scale(1);
}

.scroll-slide-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.6s ease-out;
}

.scroll-slide-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.scroll-slide-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.6s ease-out;
}

.scroll-slide-right.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 234, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-dots::after {
    content: '...';
    animation: loadingDots 1.4s infinite;
}

.loading-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Stagger Animations */
.stagger-animation > * {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.6s ease-out forwards;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.6s; }
.stagger-animation > *:nth-child(7) { animation-delay: 0.7s; }
.stagger-animation > *:nth-child(8) { animation-delay: 0.8s; }

/* Interactive Animations */
.click-animation:active {
    animation: buttonPress 0.2s ease-in-out;
}

.success-animation {
    animation: bounce 0.6s ease-in-out;
}

.error-animation {
    animation: wobble 0.6s ease-in-out;
}

.notification-slide {
    animation: slideInRight 0.5s ease-out;
}

/* Mobile Specific Animations */
@media (max-width: 768px) {
    .animate-float {
        animation-duration: 4s;
    }
    
    .animate-bounce,
    .animate-wobble,
    .animate-swing {
        animation-duration: 1.5s;
    }
    
    /* Reduce motion for mobile performance */
    .mobile-reduce-motion {
        animation: none !important;
        transition: none !important;
    }
}

/* Accessibility - Respect user 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;
    }
    
    .animate-float,
    .animate-bounce,
    .animate-pulse,
    .animate-glow,
    .animate-rotate,
    .animate-heartbeat {
        animation: none !important;
    }
}

/* Dark Mode Animation Adjustments */
.dark-mode .animate-glow {
    animation: pulseGlow 3s ease-in-out infinite;
    filter: brightness(1.2);
}

.dark-mode .loading-spinner {
    border-color: rgba(0, 234, 255, 0.3);
    border-top-color: var(--accent-color);
}

/* High Performance Animations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

.gpu-accelerated:hover {
    will-change: auto;
}

/* Custom Easing Functions */
.ease-out-back {
    animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.275);
}

.ease-in-back {
    animation-timing-function: cubic-bezier(0.600, -0.280, 0.735, 0.045);
}

.ease-in-out-back {
    animation-timing-function: cubic-bezier(0.680, -0.550, 0.265, 1.550);
}

.ease-out-elastic {
    animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.275);
}

/* Animation Fill Modes */
.fill-forwards {
    animation-fill-mode: forwards;
}

.fill-backwards {
    animation-fill-mode: backwards;
}

.fill-both {
    animation-fill-mode: both;
}

/* Infinite Animations */
.infinite {
    animation-iteration-count: infinite;
}

/* Paused Animations */
.paused {
    animation-play-state: paused;
}

.running {
    animation-play-state: running;
}

/* Animation Direction */
.reverse {
    animation-direction: reverse;
}

.alternate {
    animation-direction: alternate;
}

.alternate-reverse {
    animation-direction: alternate-reverse;
}