/* Animation Definitions */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(166, 208, 39, 0.5);
    }
    50% {
        box-shadow: 0 0 40px rgba(166, 208, 39, 0.8);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Memory Bubble Animations */
@keyframes disappearing {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.memory-bubble.disappearing {
    animation: disappearing 2s infinite;
}

.memory-bubble.disappearing:nth-child(2) {
    animation-delay: 0.5s;
}

.memory-bubble.disappearing:nth-child(3) {
    animation-delay: 1s;
}

@keyframes growing {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.memory-bubble.growing {
    animation: growing 2s forwards;
}

.memory-bubble.persistent {
    animation: pulse 3s infinite;
}

/* Data Flow Animations */
@keyframes dataFlow {
    0% {
        transform: translateY(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(100px);
        opacity: 0;
    }
}

.data-flow::before {
    content: '';
    position: absolute;
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, transparent, #a6d027, transparent);
    animation: dataFlow 3s infinite;
}

/* Thought Particle Animations */
@keyframes thoughtFloat {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 0;
    }
    10% {
        transform: translate(10px, -20px) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-20px, -100px) scale(1.2);
        opacity: 0.8;
    }
    90% {
        transform: translate(30px, -180px) scale(0.8);
        opacity: 0.3;
    }
    100% {
        transform: translate(0, -200px) scale(0);
        opacity: 0;
    }
}

.thought-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, #a6d027, transparent);
    border-radius: 50%;
    animation: thoughtFloat 4s infinite;
}

.thought-particle:nth-child(2) {
    animation-delay: 1.3s;
    left: 20px;
}

.thought-particle:nth-child(3) {
    animation-delay: 2.6s;
    left: -20px;
}

/* Synaptic Signal Background Animation */
@keyframes synapticPulse {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
    100% {
        opacity: 0;
        transform: scale(2);
    }
}

@keyframes synapticFlow {
    0% {
        transform: translateX(-200px) translateY(0) rotate(0deg);
        opacity: 0;
    }
    15% {
        opacity: 0.8;
        transform: translateX(15vw) translateY(-30px) rotate(45deg);
    }
    35% {
        transform: translateX(40vw) translateY(40px) rotate(-30deg);
        opacity: 0.9;
    }
    55% {
        transform: translateX(70vw) translateY(-25px) rotate(60deg);
        opacity: 0.7;
    }
    75% {
        transform: translateX(95vw) translateY(35px) rotate(-45deg);
        opacity: 0.5;
    }
    100% {
        transform: translateX(calc(100vw + 200px)) translateY(-50px) rotate(90deg);
        opacity: 0;
    }
}

@keyframes synapticFlowAlt {
    0% {
        transform: translateX(calc(100vw + 200px)) translateY(0) rotate(180deg);
        opacity: 0;
    }
    15% {
        opacity: 0.7;
        transform: translateX(85vw) translateY(45px) rotate(135deg);
    }
    35% {
        transform: translateX(60vw) translateY(-35px) rotate(210deg);
        opacity: 0.8;
    }
    55% {
        transform: translateX(30vw) translateY(30px) rotate(270deg);
        opacity: 0.6;
    }
    75% {
        transform: translateX(5vw) translateY(-40px) rotate(315deg);
        opacity: 0.4;
    }
    100% {
        transform: translateX(-200px) translateY(20px) rotate(360deg);
        opacity: 0;
    }
}

@keyframes synapticFlowCurved {
    0% {
        transform: translateX(-200px) translateY(0) scale(0.5);
        opacity: 0;
    }
    25% {
        transform: translateX(25vw) translateY(-60px) scale(1.2);
        opacity: 0.9;
    }
    50% {
        transform: translateX(50vw) translateY(80px) scale(0.8);
        opacity: 1;
    }
    75% {
        transform: translateX(75vw) translateY(-40px) scale(1.1);
        opacity: 0.7;
    }
    100% {
        transform: translateX(calc(100vw + 200px)) translateY(30px) scale(0.3);
        opacity: 0;
    }
}

@keyframes neuralConnection {
    0% {
        stroke-dashoffset: 1000;
        opacity: 0;
    }
    20% {
        opacity: 0.8;
    }
    80% {
        opacity: 0.8;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 0;
    }
}

@keyframes memoryActivation {
    0% {
        box-shadow: 0 0 10px rgba(166, 208, 39, 0.2);
    }
    50% {
        box-shadow: 0 0 30px rgba(166, 208, 39, 0.6), 0 0 60px rgba(166, 208, 39, 0.3);
    }
    100% {
        box-shadow: 0 0 10px rgba(166, 208, 39, 0.2);
    }
}

/* Synaptic Background Container */
.synaptic-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

/* Body-level Synaptic Background */
.body-synaptic-background {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    overflow: visible;
    pointer-events: none;
    z-index: 1;
    opacity: 0.45;
}

/* Neural Nodes */
.neural-node {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, #a6d027, rgba(166, 208, 39, 0.3));
    border-radius: 50%;
    animation: synapticPulse 3.6s infinite;
}

.neural-node:nth-child(1) { top: 15%; left: 10%; animation-delay: 0s; }
.neural-node:nth-child(2) { top: 25%; left: 85%; animation-delay: 0.5s; }
.neural-node:nth-child(3) { top: 45%; left: 15%; animation-delay: 1s; }
.neural-node:nth-child(4) { top: 35%; left: 70%; animation-delay: 1.5s; }
.neural-node:nth-child(5) { top: 65%; left: 25%; animation-delay: 2s; }
.neural-node:nth-child(6) { top: 75%; left: 80%; animation-delay: 2.5s; }
.neural-node:nth-child(7) { top: 85%; left: 45%; animation-delay: 3s; }
.neural-node:nth-child(8) { top: 55%; left: 90%; animation-delay: 3.5s; }
.neural-node:nth-child(9) { top: 20%; left: 50%; animation-delay: 4s; }
.neural-node:nth-child(10) { top: 90%; left: 15%; animation-delay: 4.5s; }
.neural-node:nth-child(11) { top: 12%; left: 30%; animation-delay: 5s; }
.neural-node:nth-child(12) { top: 38%; left: 95%; animation-delay: 5.5s; }
.neural-node:nth-child(13) { top: 68%; left: 5%; animation-delay: 6s; }
.neural-node:nth-child(14) { top: 82%; left: 65%; animation-delay: 6.5s; }
.neural-node:nth-child(15) { top: 58%; left: 40%; animation-delay: 7s; }

/* Synaptic Signals */
.synaptic-signal {
    position: absolute;
    width: 3px;
    height: 3px;
    background: linear-gradient(45deg, #a6d027, rgba(166, 208, 39, 0.4));
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(166, 208, 39, 0.4);
}

.synaptic-signal:nth-child(16) {
    top: 20%;
    animation: synapticFlow 9.6s infinite linear;
    animation-delay: 0s;
}
.synaptic-signal:nth-child(17) {
    top: 40%;
    animation: synapticFlowAlt 8.4s infinite linear;
    animation-delay: 1s;
}
.synaptic-signal:nth-child(18) {
    top: 60%;
    animation: synapticFlowCurved 10.8s infinite linear;
    animation-delay: 2s;
}
.synaptic-signal:nth-child(19) {
    top: 80%;
    animation: synapticFlow 7.2s infinite linear;
    animation-delay: 3s;
}
.synaptic-signal:nth-child(20) {
    top: 30%;
    animation: synapticFlowAlt 9.6s infinite linear;
    animation-delay: 4s;
}
.synaptic-signal:nth-child(21) {
    top: 70%;
    animation: synapticFlowCurved 8.4s infinite linear;
    animation-delay: 5s;
}
.synaptic-signal:nth-child(22) {
    top: 15%;
    animation: synapticFlow 10.8s infinite linear;
    animation-delay: 6s;
}
.synaptic-signal:nth-child(23) {
    top: 85%;
    animation: synapticFlowAlt 9.6s infinite linear;
    animation-delay: 7s;
}
.synaptic-signal:nth-child(24) {
    top: 50%;
    animation: synapticFlowCurved 12s infinite linear;
    animation-delay: 8s;
}
.synaptic-signal:nth-child(25) {
    top: 65%;
    animation: synapticFlow 8.4s infinite linear;
    animation-delay: 9s;
}

/* Neural Connections SVG */
.neural-connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.3;
}

.connection-line {
    stroke: #a6d027;
    stroke-width: 0.8;
    stroke-dasharray: 4, 4;
    fill: none;
    opacity: 0.5;
    animation: neuralConnection 9.6s infinite linear;
}

.connection-line:nth-child(1) { animation-delay: 0s; }
.connection-line:nth-child(2) { animation-delay: 2s; }
.connection-line:nth-child(3) { animation-delay: 4s; }
.connection-line:nth-child(4) { animation-delay: 6s; }

/* Enhanced Memory Tier Animations */
.tier {
    animation: memoryActivation 4s infinite;
}

.tier:nth-child(1) { animation-delay: 0s; }
.tier:nth-child(2) { animation-delay: 1s; }
.tier:nth-child(3) { animation-delay: 2s; }
.tier:nth-child(4) { animation-delay: 3s; }

/* Phase Flow Animations */
.phase {
    opacity: 0;
    animation: fadeUp 0.6s forwards;
}

.phase:nth-child(1) { animation-delay: 0.1s; }
.phase:nth-child(3) { animation-delay: 0.3s; }
.phase:nth-child(5) { animation-delay: 0.5s; }
.phase:nth-child(7) { animation-delay: 0.7s; }
.phase:nth-child(9) { animation-delay: 0.9s; }
.phase:nth-child(11) { animation-delay: 1.1s; }


/* Stream Animations */
@keyframes streamFlow {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateX(100%);
        opacity: 0;
    }
}

.stream-line {
    position: relative;
    height: 2px;
    background: rgba(166, 208, 39, 0.2);
    margin: 10px 0;
    overflow: hidden;
}

.stream-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 100%;
    background: linear-gradient(90deg, transparent, #a6d027, transparent);
    animation: streamFlow 2s infinite;
}

.stream-line:nth-child(2)::before {
    animation-delay: 0.5s;
}

.stream-line:nth-child(3)::before {
    animation-delay: 1s;
}

/* Agent Swarm Animations */
.agent {
    position: absolute;
    padding: 10px 20px;
    background: rgba(166, 208, 39, 0.1);
    border: 1px solid #a6d027;
    border-radius: 20px;
    animation: float 3s infinite;
}

.agent-1 { animation-delay: 0s; }
.agent-2 { animation-delay: 0.5s; }
.agent-3 { animation-delay: 1s; }
.agent-4 { animation-delay: 1.5s; }
.agent-5 { animation-delay: 2s; }

/* Connection Lines */
.connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.connections::before,
.connections::after {
    content: '';
    position: absolute;
    border: 1px dashed rgba(166, 208, 39, 0.3);
    animation: pulse 2s infinite;
}

/* Logo Animations */
.logo-animation {
    display: flex;
    gap: 2rem;
    align-items: center;
    justify-content: center;
    margin-bottom: 3rem;
}

.robson-logo {
    width: 150px;
    height: 150px;
    background: #000;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 1s forwards;
}

.emily-avatars {
    display: flex;
    gap: 1rem;
}

.emily-avatar {
    width: 150px;
    height: 150px;
    border-radius: 16px;
    border: 3px solid #000;
    opacity: 0;
    animation: fadeUp 1s forwards;
}

/* Title Animations */
.main-title {
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 800;
    margin: 2rem 0;
}

.title-emily {
    color: #ffffff;
    display: inline-block;
    animation: slideInLeft 1s forwards;
}

.title-os {
    color: #a6d027;
    display: inline-block;
    animation: slideInRight 1s forwards;
}

/* Status Indicators */
.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 10px;
}

.status-indicator.online {
    background: #4ade80;
    animation: pulse 2s infinite;
}

/* Memory Level Indicators */
.memory-levels {
    display: flex;
    gap: 10px;
    margin-left: 10px;
}

.level {
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.75rem;
    opacity: 0.5;
    transition: all 0.3s;
}

.level.active {
    background: rgba(166, 208, 39, 0.3);
    opacity: 1;
    animation: pulse 1s;
}

/* Loading Animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(166, 208, 39, 0.3);
    border-top-color: #a6d027;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}