/* Neural Nexus Society - Animations */

/* Keyframe Definitions */
@keyframes pulse {
    0%, 100% { 
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1);
    }
    50% { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 
            0 0 20px var(--accent-cyan),
            0 0 40px var(--accent-cyan),
            inset 0 0 20px rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow: 
            0 0 30px var(--accent-cyan),
            0 0 60px var(--accent-cyan),
            inset 0 0 30px rgba(255, 255, 255, 0.3);
    }
}

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

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes nodeActivation {
    0% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        box-shadow: 
            0 0 30px var(--accent-cyan),
            0 0 60px var(--accent-cyan),
            0 0 90px rgba(0, 255, 255, 0.3);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    }
}

@keyframes dataFlow {
    0% {
        opacity: 0;
        transform: translateX(-20px) scale(0);
    }
    20% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    80% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(20px) scale(0);
    }
}

@keyframes statusBlink {
    0%, 90% { opacity: 1; }
    95% { opacity: 0.3; }
    100% { opacity: 1; }
}

@keyframes textGlow {
    0%, 100% {
        text-shadow: 
            0 0 10px var(--accent-cyan),
            0 0 20px var(--accent-cyan),
            0 0 30px var(--accent-cyan);
    }
    50% {
        text-shadow: 
            0 0 20px var(--accent-cyan),
            0 0 30px var(--accent-cyan),
            0 0 40px var(--accent-cyan);
    }
}

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

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

/* Applied Animations */

/* Logo animations */
.logo-node {
    animation: glow 3s ease-in-out infinite;
}

.logo-connections {
    animation: rotate 20s linear infinite;
}

/* Title animations */
.title-line {
    animation: gradientShift 4s ease infinite;
}

.main-title {
    /* Disable heavy glow animation for better readability */
    animation: none;
}

/* Status indicator */
.status-indicator {
    animation: statusBlink 3s infinite;
}

/* Node animations */
.node-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.node-core {
    transition: all var(--transition-medium);
}

/* Hover effects */
.agent-node:hover .node-core {
    animation: nodeActivation 0.8s ease-in-out;
}

.agent-node:hover .node-pulse {
    animation: pulse 1s ease-in-out infinite;
}

/* Active node state */
.agent-node.active .node-core {
    animation: nodeActivation 2s ease-in-out infinite;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-pink));
}

.agent-node.active .node-pulse {
    animation: pulse 0.5s ease-in-out infinite;
    border-color: var(--accent-green);
}

/* Loading spinner */
.loading-spinner {
    animation: spin 1s linear infinite;
}

/* Page load animations */
.hero-section {
    animation: fadeInUp 1s ease-out 0.5s both;
}

.network-section {
    animation: fadeInScale 1s ease-out 0.8s both;
}

.info-panel {
    animation: fadeInUp 1s ease-out 1.1s both;
}

.footer {
    animation: fadeInUp 1s ease-out 1.4s both;
}

/* Stagger animations for agent nodes */
.agent-node[data-agent="language"] {
    animation: fadeInScale 0.8s ease-out 1.2s both;
}

.agent-node[data-agent="vision"] {
    animation: fadeInScale 0.8s ease-out 1.4s both;
}

.agent-node[data-agent="reasoning"] {
    animation: fadeInScale 0.8s ease-out 1.6s both;
}

.agent-node[data-agent="creativity"] {
    animation: fadeInScale 0.8s ease-out 1.8s both;
}

.agent-node[data-agent="memory"] {
    animation: fadeInScale 0.8s ease-out 2s both;
}

/* Communication burst effect */
@keyframes communicationBurst {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

.communication-burst {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 2px solid var(--accent-green);
    border-radius: 12px;
    animation: communicationBurst 0.6s ease-out;
    pointer-events: none;
}

/* Text pulse animation for info values */
@keyframes textPulse {
    0%, 100% { 
        opacity: 0.6;
        transform: scale(1);
    }
    50% { 
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Info value animations */
.info-value {
    transition: all var(--transition-medium);
}

.info-value.updating {
    animation: textPulse 0.5s ease-in-out;
    color: var(--accent-cyan);
}

/* Interactive states */
.clickable {
    cursor: pointer;
    transition: all var(--transition-fast);
}

.clickable:hover {
    /* Removed transform to prevent jumping on positioned elements */
}

.clickable:active {
    /* Removed transform to prevent jumping on positioned elements */
}

/* Smooth transitions for dynamic content */
.fade-transition {
    transition: opacity var(--transition-medium);
}

.fade-transition.fade-out {
    opacity: 0;
}

.fade-transition.fade-in {
    opacity: 1;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading-spinner {
        animation: none;
        border-top-color: var(--accent-cyan);
    }
}

/* Screen-wide pulse for overload */
@keyframes screenPulse {
    0%, 100% { filter: none; }
    50% { filter: brightness(1.2) saturate(1.25); }
}

.screen-pulse {
    animation: screenPulse 0.8s ease-in-out 2;
}

/* Stronger global glow during overload */
body.global-overload .agent-node .node-core {
    box-shadow: 0 0 40px var(--accent-cyan), 0 0 80px rgba(0, 255, 255, 0.35);
}

body.global-overload .node-pulse {
    border-color: var(--accent-green);
    opacity: 1;
    animation-duration: 0.4s;
}

/* Connection packet animation (moves along rotated line width) */
@keyframes moveAlongLine {
    from { left: 0%; }
    to { left: 100%; }
}

/* Small moving dot that travels along each connection */
.connection-packet {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan);
    animation: moveAlongLine 1.5s linear forwards;
    pointer-events: none;
}

/* Label near midpoint describing the signal direction */
.connection-label {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    line-height: 1;
    color: var(--white);
    background: rgba(0, 0, 0, 0.75);
    padding: 2px 6px;
    border: 1px solid var(--accent-cyan);
    border-radius: 6px;
    pointer-events: none;
    z-index: 11;
    white-space: nowrap;
}

/* iOS Overdrive: subtle rainbow hue sweep for overlay */
@keyframes rainbowSweep {
    from { filter: hue-rotate(0deg); }
    to   { filter: hue-rotate(360deg); }
}
.ios-overdrive {
    animation: rainbowSweep 2s linear;
}

/* Samsung Edge Glow: animated edge lighting frame */
@keyframes edgeGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 255, 0.0), inset 0 0 0 0 rgba(0, 255, 255, 0.0);
    }
    50% {
        box-shadow: 0 0 40px 8px rgba(0, 255, 255, 0.35), inset 0 0 30px 6px rgba(0, 255, 255, 0.25);
    }
}
body.samsung-edge::before {
    content: "";
    position: fixed;
    inset: 0;
    border-radius: 16px;
    pointer-events: none;
    z-index: 9996;
    animation: edgeGlow 1.6s ease-in-out 2;
}
