/* =============================================
   CARTHOGEN - Animations (Enhanced)
   ============================================= */

/* =============================================
   Core Animations
   ============================================= */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    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 fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* =============================================
   Pulse & Glow Animations
   ============================================= */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

@keyframes pulseSoft {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(0, 212, 255, 0.6);
    }
}

@keyframes borderGlow {
    0%, 100% {
        border-color: rgba(0, 212, 255, 0.3);
    }
    50% {
        border-color: rgba(0, 212, 255, 0.6);
    }
}

/* =============================================
   Float Animations
   ============================================= */

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(20px, -20px) rotate(3deg);
    }
    50% {
        transform: translate(30px, 10px) rotate(-2deg);
    }
    75% {
        transform: translate(-10px, 20px) rotate(2deg);
    }
}

@keyframes floatGentle {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes floatRotate {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-15px) rotate(5deg);
    }
}

/* =============================================
   Network Schema Animations
   ============================================= */

/* Node glow animation */
.network-node {
    animation: nodeGlow 3s ease-in-out infinite;
}

.network-node:nth-child(2) { animation-delay: 0.5s; }
.network-node:nth-child(3) { animation-delay: 1s; }
.network-node:nth-child(4) { animation-delay: 1.5s; }
.network-node:nth-child(5) { animation-delay: 2s; }

@keyframes nodeGlow {
    0%, 100% {
        filter: drop-shadow(0 0 5px rgba(0, 212, 255, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 25px rgba(0, 212, 255, 0.8));
    }
}

/* Connection line drawing */
.network-line {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawLine 2s ease forwards;
}

.network-line:nth-child(2) { animation-delay: 0.3s; }
.network-line:nth-child(3) { animation-delay: 0.6s; }
.network-line:nth-child(4) { animation-delay: 0.9s; }
.network-line:nth-child(5) { animation-delay: 1.2s; }
.network-line:nth-child(6) { animation-delay: 1.5s; }

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

/* Data packet movement */
.data-packet {
    animation: movePacket 3s ease-in-out infinite;
}

@keyframes movePacket {
    0% {
        offset-distance: 0%;
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        offset-distance: 100%;
        opacity: 0;
    }
}

/* Node pulse */
@keyframes nodePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 25px rgba(0, 212, 255, 0.5);
    }
}

/* =============================================
   Schema Building Effect Animations
   ============================================= */

/* Connection paths with drawing */
.connection-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawConnection 2s ease-out forwards;
}

.connection-path.delay-1 { animation-delay: 0.1s; }
.connection-path.delay-2 { animation-delay: 0.2s; }
.connection-path.delay-3 { animation-delay: 0.4s; }
.connection-path.delay-4 { animation-delay: 0.5s; }
.connection-path.delay-5 { animation-delay: 0.7s; }
.connection-path.delay-6 { animation-delay: 0.9s; }
.connection-path.delay-7 { animation-delay: 1.1s; }

@keyframes drawConnection {
    to {
        stroke-dashoffset: 0;
    }
}

/* Node appearance */
.schema-node {
    opacity: 0;
    animation: nodeAppear 0.5s ease-out forwards;
}

.schema-node.delay-1 { animation-delay: 0.2s; }
.schema-node.delay-2 { animation-delay: 0.4s; }
.schema-node.delay-3 { animation-delay: 0.6s; }
.schema-node.delay-4 { animation-delay: 0.8s; }
.schema-node.delay-5 { animation-delay: 1.0s; }
.schema-node.delay-6 { animation-delay: 1.2s; }
.schema-node.delay-7 { animation-delay: 1.4s; }
.schema-node.delay-8 { animation-delay: 1.6s; }

@keyframes nodeAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Label fade in */
.schema-label {
    opacity: 0;
    animation: labelFadeIn 0.4s ease-out forwards;
}

.schema-label.delay-1 { animation-delay: 0.4s; }
.schema-label.delay-2 { animation-delay: 0.6s; }
.schema-label.delay-3 { animation-delay: 0.8s; }
.schema-label.delay-4 { animation-delay: 1.0s; }
.schema-label.delay-5 { animation-delay: 1.2s; }
.schema-label.delay-6 { animation-delay: 1.4s; }
.schema-label.delay-7 { animation-delay: 1.6s; }
.schema-label.delay-8 { animation-delay: 1.8s; }

@keyframes labelFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Data flow particles */
.data-flow {
    opacity: 0;
    animation: flowAppear 0.3s ease-out forwards;
}

.data-flow.delay-1 { animation-delay: 1.5s; }
.data-flow.delay-2 { animation-delay: 1.7s; }
.data-flow.delay-3 { animation-delay: 1.9s; }

@keyframes flowAppear {
    to {
        opacity: 1;
    }
}

/* Ping effect on nodes */
.ping-ring {
    animation: pingExpand 2s ease-out infinite;
}

@keyframes pingExpand {
    0% {
        r: 20;
        opacity: 0.6;
    }
    100% {
        r: 35;
        opacity: 0;
    }
}

/* =============================================
   Chat Message Animation
   ============================================= */

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes typingDot {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    50% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* =============================================
   Shimmer & Gradient Animations
   ============================================= */

@keyframes shimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes borderShimmer {
    0% {
        border-color: rgba(0, 212, 255, 0.2);
    }
    50% {
        border-color: rgba(0, 212, 255, 0.5);
    }
    100% {
        border-color: rgba(0, 212, 255, 0.2);
    }
}

/* =============================================
   Rotation Animations
   ============================================= */

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes rotateSlow {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes rotateReverse {
    from {
        transform: rotate(360deg);
    }
    to {
        transform: rotate(0deg);
    }
}

/* =============================================
   Scale Animations
   ============================================= */

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes scaleOut {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0);
        opacity: 0;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-15px);
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* =============================================
   Attention Animations
   ============================================= */

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

@keyframes wiggle {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(3deg);
    }
    75% {
        transform: rotate(-3deg);
    }
}

@keyframes flash {
    0%, 50%, 100% {
        opacity: 1;
    }
    25%, 75% {
        opacity: 0;
    }
}

/* =============================================
   Loading & Progress Animations
   ============================================= */

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes progress {
    from {
        width: 0%;
    }
    to {
        width: 100%;
    }
}

@keyframes dotPulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* =============================================
   Background Animations
   ============================================= */

@keyframes backgroundPan {
    from {
        background-position: 0% 0%;
    }
    to {
        background-position: 100% 100%;
    }
}

@keyframes meshMove {
    0% {
        transform: translate(0, 0);
    }
    50% {
        transform: translate(-30px, -30px);
    }
    100% {
        transform: translate(0, 0);
    }
}

/* =============================================
   SVG Specific Animations
   ============================================= */

@keyframes dashOffset {
    from {
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes pathDraw {
    0% {
        stroke-dashoffset: 1000;
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

@keyframes svgFillIn {
    from {
        fill-opacity: 0;
    }
    to {
        fill-opacity: 1;
    }
}

/* =============================================
   Utility Animation Classes
   ============================================= */

.animate-fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.6s ease forwards;
}

.animate-scale-in {
    animation: scaleIn 0.4s ease forwards;
}

.animate-bounce-in {
    animation: bounceIn 0.6s ease forwards;
}

.animate-float {
    animation: floatGentle 3s ease-in-out infinite;
}

.animate-pulse {
    animation: pulseSoft 2s ease-in-out infinite;
}

.animate-glow {
    animation: glowPulse 2s ease-in-out infinite;
}

.animate-shimmer {
    animation: shimmer 2s linear infinite;
    background-size: 200% auto;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Delay utilities */
.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 utilities */
.duration-fast { animation-duration: 0.2s; }
.duration-normal { animation-duration: 0.4s; }
.duration-slow { animation-duration: 0.8s; }
.duration-slower { animation-duration: 1.2s; }

/* Fill mode utilities */
.fill-forwards { animation-fill-mode: forwards; }
.fill-backwards { animation-fill-mode: backwards; }
.fill-both { animation-fill-mode: both; }

/* =============================================
   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;
    }

    .orb,
    .data-flow,
    .particle {
        animation: none !important;
    }
}
