/* Mouse-Following Background Animation */
.interactive-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

/* Mouse Trail Effect */
.mouse-trail {
    position: fixed;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(45deg, #6366f1, #8b5cf6);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -50%);
    z-index: 9998;
    mix-blend-mode: screen;
    transition: opacity 0.3s ease;
}

/* Particle System */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: linear-gradient(45deg, #6366f1, #ec4899);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* Interactive Grid */
.interactive-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    grid-template-rows: repeat(20, 1fr);
    gap: 2px;
    opacity: 0.1;
}

.grid-cell {
    background: rgba(99, 102, 241, 0.05);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Magnetic Field Lines */
.field-line {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(99, 102, 241, 0.3), 
        rgba(139, 92, 246, 0.3), 
        transparent);
    pointer-events: none;
    opacity: 0.3;
    filter: blur(1px);
}

/* Ripple Effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, 0.3);
    pointer-events: none;
    transform: translate(-50%, -50%);
}

/* Floating Elements that follow mouse */
.floating-element {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(45deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    pointer-events: none;
    opacity: 0.5;
    filter: blur(5px);
    transform: translate(-50%, -50%);
    transition: transform 0.1s linear;
}

/* Connection Lines between cursor and elements */
.connection-line {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, 
        rgba(99, 102, 241, 0.2), 
        rgba(139, 92, 246, 0.2));
    pointer-events: none;
    transform-origin: left center;
    opacity: 0;
}

/* Mouse-Activated Wave */
.mouse-wave {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(99, 102, 241, 0.2);
    pointer-events: none;
    transform: translate(-50%, -50%);
    opacity: 0;
}

/* Interactive Background Gradient */
.bg-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
        rgba(99, 102, 241, 0.1) 0%, 
        rgba(139, 92, 246, 0.05) 25%,
        transparent 50%
    );
    transition: background 0.3s ease;
    opacity: 0.5;
}

/* Light Mode Adjustments */
body.light-mode .mouse-trail {
    mix-blend-mode: multiply;
    opacity: 0.3;
}

body.light-mode .particle {
    background: linear-gradient(45deg, #6366f1, #8b5cf6);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

body.light-mode .grid-cell {
    background: rgba(99, 102, 241, 0.03);
}

body.light-mode .field-line {
    background: linear-gradient(90deg, 
        transparent, 
        rgba(99, 102, 241, 0.2), 
        rgba(139, 92, 246, 0.2), 
        transparent);
}

body.light-mode .ripple {
    border-color: rgba(99, 102, 241, 0.2);
}

body.light-mode .floating-element {
    background: linear-gradient(45deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
}

body.light-mode .connection-line {
    background: linear-gradient(90deg, 
        rgba(99, 102, 241, 0.15), 
        rgba(139, 92, 246, 0.15));
}

body.light-mode .mouse-wave {
    border-color: rgba(99, 102, 241, 0.15);
}

body.light-mode .bg-gradient {
    background: radial-gradient(
        circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
        rgba(99, 102, 241, 0.08) 0%, 
        rgba(139, 92, 246, 0.04) 25%,
        transparent 50%
    );
}

/* Performance Optimizations */
@media (prefers-reduced-motion: reduce) {
    .mouse-trail,
    .particle,
    .grid-cell,
    .field-line,
    .ripple,
    .floating-element,
    .connection-line,
    .mouse-wave {
        animation: none !important;
        transition: none !important;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .interactive-grid {
        grid-template-columns: repeat(15, 1fr);
        grid-template-rows: repeat(15, 1fr);
        gap: 1px;
    }
    
    .mouse-trail {
        width: 15px;
        height: 15px;
    }
    
    .floating-element {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 480px) {
    .interactive-grid {
        grid-template-columns: repeat(10, 1fr);
        grid-template-rows: repeat(10, 1fr);
    }
    
    .mouse-trail {
        width: 10px;
        height: 10px;
    }
    
    .floating-element {
        width: 20px;
        height: 20px;
    }
}