
import React from 'react';
import { motion } from 'framer-motion';
import { VisualProps } from '../types';

// ============================================================================
// 🔒 BASELINE CONFIGURATION - DO NOT REDUCE 🔒
// ============================================================================
// STATUS: GOLD STANDARD (51 Metaphors)
// STYLE: Cinematic / Operational Swiss (High Fidelity)
// LAYERS: BlurObject, Atmosphere, ParticleSystem, CinemaDefs (Glow/Noise)
//
// RULE: Future updates may ADD new metaphors or TWEAK styling, 
// but MUST NOT reduce the metaphor count or remove the complex rendering layers.
// This file represents the minimum acceptable quality bar.
// ============================================================================

// --- PHYSICS CONFIG ---
const SPIN_SLOW = { duration: 10, repeat: Infinity, ease: "linear" as const };
const SPIN_MID = { duration: 4, repeat: Infinity, ease: "linear" as const };
const SPIN_FAST = { duration: 1.5, repeat: Infinity, ease: "linear" as const };
const PULSE_FAST = { duration: 0.6, repeat: Infinity, repeatType: "mirror" as const, ease: "easeInOut" as const }; 
const PULSE_SLOW = { duration: 2, repeat: Infinity, repeatType: "mirror" as const, ease: "easeInOut" as const };
const FLOAT = { duration: 3, repeat: Infinity, repeatType: "mirror" as const, ease: "easeInOut" as const };
const SCAN_X = { duration: 2, repeat: Infinity, repeatType: "mirror" as const, ease: "linear" as const };
const SCAN_Y = { duration: 2.5, repeat: Infinity, repeatType: "mirror" as const, ease: "linear" as const };

const RED = "var(--accent-red, #FF00E5)"; // Neon Magenta
const BLUE = "var(--accent-blue, #00F2FF)"; // Neon Cyan
const LIME = "#C1FF00"; // Acid Lime
const PURPLE = "#9D00FF"; // Cyber Purple
const DARK = "#050508"; // Deep Space Background

// --- PARAMETRIC UTILS ---

const ParametricSurface: React.FC<{ 
    points: number; 
    segments: number; 
    fn: (u: number, v: number, t: number) => { x: number, y: number, z: number };
    color?: string;
    opacity?: number;
    strokeWidth?: number;
    fill?: boolean;
    animate?: boolean;
}> = ({ points = 10, segments = 10, fn, color = BLUE, opacity = 0.6, strokeWidth = 0.3, fill = false, animate = true }) => {
    const [t, setT] = React.useState(0);
    
    React.useEffect(() => {
        if (!animate) return;
        let frame = 0;
        const loop = () => {
            setT(prev => prev + 0.02);
            frame = requestAnimationFrame(loop);
        };
        loop();
        return () => cancelAnimationFrame(frame);
    }, [animate]);

    const paths: string[] = [];
    for (let i = 0; i <= points; i++) {
        let d = "";
        for (let j = 0; j <= segments; j++) {
            const u = i / points;
            const v = j / segments;
            const { x, y } = fn(u, v, t);
            d += (j === 0 ? "M" : "L") + ` ${x} ${y}`;
        }
        paths.push(d);
    }

    const crossPaths: string[] = [];
    for (let j = 0; j <= segments; j++) {
        let d = "";
        for (let i = 0; i <= points; i++) {
            const u = i / points;
            const v = j / segments;
            const { x, y } = fn(u, v, t);
            d += (i === 0 ? "M" : "L") + ` ${x} ${y}`;
        }
        crossPaths.push(d);
    }

    return (
        <g className="parametric-surface" style={{ pointerEvents: 'none' }}>
            {paths.map((d, i) => (
                <path key={`u-${i}`} d={d} fill="none" stroke={color} strokeWidth={strokeWidth} opacity={opacity} />
            ))}
            {crossPaths.map((d, i) => (
                <path key={`v-${i}`} d={d} fill="none" stroke={color} strokeWidth={strokeWidth} opacity={opacity * 0.5} />
            ))}
        </g>
    );
};

// --- CINEMATIC UTILS ---

const ParticleSystem: React.FC<{ count: number; spread: number; color?: string }> = ({ count, spread, color = RED }) => (
    <g className="particles" style={{ mixBlendMode: 'screen' }}>
        {Array.from({ length: count }).map((_, i) => {
            const r = Math.random() * 1.5 + 0.5; 
            const x = 50 + (Math.random() - 0.5) * spread;
            const y = 50 + (Math.random() - 0.5) * spread;
            return (
                <motion.circle 
                    key={i} cx={x} cy={y} r={r} fill={Math.random() > 0.8 ? color : "currentColor"}
                    opacity={Math.random() * 0.5}
                    animate={{ y: [y, y - 10, y], opacity: [0, 0.8, 0] }}
                    transition={{ duration: 3 + Math.random() * 4, delay: Math.random() * 5, repeat: Infinity, ease: "easeInOut" }}
                />
            );
        })}
    </g>
);

const BlurObject: React.FC<{ children: React.ReactNode }> = ({ children }) => (
    <g filter="url(#blur-heavy)" opacity="0.4" style={{ mixBlendMode: 'screen' }}>
        {children}
    </g>
);

const AtmosphereLayer: React.FC<{ color?: string }> = ({ color = RED }) => {
    const colorId = color.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <g className="atmosphere" pointerEvents="none">
            <motion.circle cx="50" cy="50" r="45" fill={`url(#grad-glow-radial-${colorId})`} opacity="0.2" animate={{ scale: [1, 1.2, 1], opacity: [0.1, 0.3, 0.1] }} transition={PULSE_SLOW} />
            <rect x="0" y="0" width="100" height="100" fill="url(#grad-corner)" opacity="0.2" />
        </g>
    );
};

const CinemaDefs: React.FC<{ color?: string }> = ({ color = RED }) => {
    const colorId = color.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <defs>
            <filter id="glow-layer" x="-50%" y="-50%" width="200%" height="200%">
                <feGaussianBlur stdDeviation="1.5" result="blur" />
                <feComposite in="SourceGraphic" in2="blur" operator="over" />
            </filter>
            <filter id="blur-heavy" x="-50%" y="-50%" width="200%" height="200%">
                <feGaussianBlur stdDeviation="6" />
            </filter>
            
            {/* Cyber Bloom Filter */}
            <filter id="cyber-bloom" x="-100%" y="-100%" width="300%" height="300%">
                <feGaussianBlur stdDeviation="2" result="blur" />
                <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 2.5 0" />
                <feMerge>
                    <feMergeNode />
                    <feMergeNode in="SourceGraphic" />
                </feMerge>
            </filter>

            {/* Tangible Shading Filter */}
            <filter id="tangible-shading" x="-20%" y="-20%" width="140%" height="140%">
                <feGaussianBlur stdDeviation="1" result="blur" />
                <feSpecularLighting surfaceScale="8" specularConstant="1.2" specularExponent="30" lightingColor="white" in="blur" result="specular">
                    <fePointLight x="20" y="20" z="80" />
                </feSpecularLighting>
                <feComposite in="specular" in2="SourceGraphic" operator="in" result="specularOut" />
                <feComposite in="SourceGraphic" in2="specularOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" />
            </filter>

            <filter id="inner-glow" x="-20%" y="-20%" width="140%" height="140%">
                <feGaussianBlur stdDeviation="1" result="blur" />
                <feComposite in="SourceGraphic" in2="blur" operator="out" />
            </filter>

            {/* Holographic Gradients */}
            <linearGradient id={`grad-holo-${colorId}`} x1="0%" y1="0%" x2="100%" y2="100%">
                <stop offset="0%" stopColor={color} stopOpacity="1" />
                <stop offset="50%" stopColor={PURPLE} stopOpacity="0.8" />
                <stop offset="100%" stopColor={BLUE} stopOpacity="1" />
            </linearGradient>

            <radialGradient id={`grad-cyber-sphere-${colorId}`} cx="30%" cy="30%" r="70%">
                <stop offset="0%" stopColor="white" stopOpacity="0.6" />
                <stop offset="40%" stopColor={color} stopOpacity="0.4" />
                <stop offset="100%" stopColor="black" stopOpacity="0.9" />
            </radialGradient>

            <linearGradient id={`grad-radar-${colorId}`} x1="0%" y1="0%" x2="100%" y2="0%">
                <stop offset="0%" stopColor={color} stopOpacity="0" />
                <stop offset="100%" stopColor={color} stopOpacity="0.6" />
            </linearGradient>
            
            <radialGradient id={`grad-glow-radial-${colorId}`} cx="50%" cy="50%" r="50%">
                <stop offset="0%" stopColor={color} stopOpacity="0.3" />
                <stop offset="100%" stopColor="transparent" stopOpacity="0" />
            </radialGradient>

            <radialGradient id="grad-corner" cx="0%" cy="0%" r="90%">
                <stop offset="0%" stopColor={BLUE} stopOpacity="0.1" />
                <stop offset="100%" stopColor="transparent" stopOpacity="0" />
            </radialGradient>
            
            {/* Digital Grid Pattern */}
            <pattern id="cyber-grid" x="0" y="0" width="10" height="10" patternUnits="userSpaceOnUse">
                <path d="M 10 0 L 0 0 0 10" fill="none" stroke="currentColor" strokeWidth="0.1" opacity="0.2" />
            </pattern>
            {/* Chromatic Aberration Filter */}
            <filter id="chromatic-aberration" x="-10%" y="-10%" width="120%" height="120%">
                <feOffset in="SourceGraphic" dx="0.5" dy="0" result="red" />
                <feOffset in="SourceGraphic" dx="-0.5" dy="0" result="blue" />
                <feColorMatrix in="red" type="matrix" values="1 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 0" result="redOnly" />
                <feColorMatrix in="blue" type="matrix" values="0 0 0 0 0  0 0 0 0 0  0 0 1 0 0  0 0 0 1 0" result="blueOnly" />
                <feBlend in="redOnly" in2="blueOnly" mode="screen" result="aberration" />
                <feBlend in="aberration" in2="SourceGraphic" mode="screen" />
            </filter>
        </defs>
    );
};

const VisualWrapper: React.FC<{ children: React.ReactNode; variant?: 'simple'|'complex'; accentColor?: string }> = ({ children, variant, accentColor = RED }) => {
    const isComplex = variant === 'complex';
    const colorId = accentColor.replace(/[^a-zA-Z0-9]/g, '');

    return (
        <div className={`relative w-full h-full flex items-center justify-center overflow-hidden rounded-2xl border shadow-2xl transition-colors duration-300 ${
            variant === 'complex' ? 'bg-slate-50 dark:bg-[#050508] border-black/5 dark:border-white/5' : 'bg-transparent border-transparent shadow-none'
        }`}>
            <svg viewBox="0 0 100 100" className="w-full h-full overflow-visible" preserveAspectRatio="xMidYMid meet">
                <CinemaDefs color={accentColor} />
                
                {/* Background Digital Grid */}
                <rect width="100" height="100" fill="url(#cyber-grid)" />
                
                {/* Atmosphere */}
                {isComplex && <AtmosphereLayer color={accentColor} />}

                {/* Perspective Container */}
                <motion.g 
                    initial={{ rotateX: 0, rotateY: 0 }}
                    animate={isComplex ? { 
                        rotateX: [0, 15, -15, 0],
                        rotateY: [0, -15, 15, 0]
                    } : {}}
                    transition={{ duration: 10, repeat: Infinity, ease: "linear" }}
                    style={{ transformStyle: "preserve-3d" }}
                >
                    <g transform="translate(50 50) scale(0.85) translate(-50 -50)" filter={isComplex ? "url(#cyber-bloom)" : "url(#glow-layer)"}>
                        <g filter={isComplex ? "url(#chromatic-aberration)" : "none"}>
                            {children}
                        </g>
                    </g>
                </motion.g>

                {/* Scanning Line for Complex Variant */}
                {isComplex && (
                    <motion.rect 
                        x="0" y="0" width="100" height="2" 
                        fill={accentColor} opacity="0.15"
                        animate={{ y: [-10, 110] }} transition={{ duration: 4, repeat: Infinity, ease: "linear" }}
                    />
                )}
                
                {isComplex && <ParticleSystem count={10} spread={80} color={accentColor} />}
            </svg>
        </div>
    );
};

// ============================================================================
// NEW EXPANSION VISUALS
// ============================================================================

export const BalanceVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={8} segments={20}
                fn={(u, v, t) => ({
                    x: 20 + u * 60 + Math.sin(v * Math.PI * 2 + t) * 2,
                    y: 80 - v * 10 + Math.cos(u * Math.PI * 2 + t) * 2,
                    z: 0
                })}
                color={RED} opacity={0.1}
            />
            
            <motion.g animate={{ rotate: [-5, 5, -5] }} transition={FLOAT} style={{ originX: "50px", originY: "80px" }}>
                <line x1="10" y1="80" x2="90" y2="80" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1" filter="url(#tangible-shading)" />
                <motion.circle cx="25" cy="70" r="8" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={RED} strokeWidth="0.5" filter="url(#tangible-shading)" />
                <motion.circle cx="75" cy="74" r="4" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={RED} strokeWidth="0.5" filter="url(#tangible-shading)" />
            </motion.g>
        </VisualWrapper>
    );
};

export const PerspectiveVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={12} segments={12}
                fn={(u, v, t) => {
                    const x = u * 100;
                    const y = v * 100;
                    const dist = Math.sqrt((x-50)**2 + (y-50)**2);
                    const z = Math.sin(dist * 0.2 - t) * 5;
                    // Project 3D to 2D
                    const scale = 1 / (1 + z * 0.01);
                    return {
                        x: 50 + (x - 50) * scale,
                        y: 50 + (y - 50) * scale,
                        z
                    };
                }}
                color={BLUE} opacity={0.15}
            />
            <motion.g animate={{ scale: [1, 1.1, 1], rotateZ: [0, 5, 0] }} transition={FLOAT}>
                <rect x="35" y="35" width="30" height="30" fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="0.5" filter="url(#tangible-shading)" />
                <rect x="42" y="42" width="16" height="16" fill="none" stroke={BLUE} strokeWidth="1" opacity="0.6" />
            </motion.g>
        </VisualWrapper>
    );
};

export const KnotVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={6} segments={40}
                fn={(u, v, t) => {
                    const angle = v * Math.PI * 2;
                    const r = 20 + Math.sin(angle * 3 + t) * 5;
                    const x = 50 + Math.cos(angle) * r + Math.cos(u * Math.PI * 2) * 2;
                    const y = 50 + Math.sin(angle) * r + Math.sin(u * Math.PI * 2) * 2;
                    return { x, y, z: 0 };
                }}
                color={RED} opacity={0.4}
            />
            <motion.path 
                d="M30 50 Q50 10 70 50 T30 50" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1.5"
                animate={{ pathLength: [0, 1, 0], pathOffset: [0, 0.5, 1] }}
                transition={{ duration: 4, repeat: Infinity, ease: "linear" }}
                filter="url(#tangible-shading)"
            />
        </VisualWrapper>
    );
};

export const VelocityVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={4} segments={30}
                fn={(u, v, t) => ({
                    x: -20 + v * 140,
                    y: 20 + u * 60 + Math.sin(v * 10 + t * 5) * 2,
                    z: 0
                })}
                color={RED} opacity={0.3}
            />
            <motion.circle cx="50" cy="50" r="10" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={RED} strokeWidth="0.5" animate={{ scale: [1, 1.1, 1] }} transition={PULSE_FAST} filter="url(#tangible-shading)" />
            {[10, 30, 70, 90].map((y, i) => (
                <motion.rect 
                    key={i} x="-30" y={y-0.5} width="40" height="1" rx="0.5"
                    fill={`url(#grad-holo-${colorId})`} opacity="0.6"
                    initial={{ x: -100 }}
                    animate={{ x: 200 }}
                    transition={{ duration: 1, repeat: Infinity, ease: "linear", delay: i * 0.2 }}
                />
            ))}
        </VisualWrapper>
    );
};


// ============================================================================
// BODY & MOVEMENT (BLUE SERIES)
// ============================================================================

export const OriginVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={12} segments={12}
                fn={(u, v, t) => {
                    const r = u * 40;
                    const angle = v * Math.PI * 2 + t;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={BLUE} opacity={0.3}
            />
            <circle cx="50" cy="50" r="2" fill={BLUE} filter="url(#glow-layer)" />
            <motion.circle cx="50" cy="50" r="10" fill="none" stroke={BLUE} strokeWidth="0.5" animate={{ scale: [1, 1.5, 1], opacity: [0.5, 0.1, 0.5] }} transition={PULSE_SLOW} filter="url(#tangible-shading)" />
            {[0, 120, 240].map(rot => (
                <motion.g key={rot} transform={`rotate(${rot} 50 50)`}>
                    <motion.line x1="50" y1="50" x2="50" y2="20" stroke={`url(#grad-holo-${colorId})`} strokeWidth="0.5" animate={{ y2: [20, 10, 20] }} transition={FLOAT} filter="url(#tangible-shading)" />
                    <circle cx="50" cy="20" r="1.5" fill={BLUE} />
                </motion.g>
            ))}
        </VisualWrapper>
    );
};

export const PostureVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={5} segments={30}
                fn={(u, v, t) => {
                    const y = 10 + v * 80;
                    const offset = Math.sin(v * Math.PI + t) * 5;
                    return {
                        x: 50 + (u - 0.5) * 10 + offset,
                        y,
                        z: 0
                    };
                }}
                color={BLUE} opacity={0.4}
            />
            <line x1="50" y1="10" x2="50" y2="90" stroke="currentColor" strokeWidth="0.2" strokeDasharray="1 2" opacity="0.3" />
            <motion.path 
                d="M50 10 Q 60 50 50 90" 
                stroke={`url(#grad-holo-${colorId})`} strokeWidth="1" fill="none"
                animate={{ d: ["M50 10 Q 60 50 50 90", "M50 10 Q 40 50 50 90", "M50 10 Q 60 50 50 90"] }} 
                transition={PULSE_SLOW} 
                filter="url(#tangible-shading)"
            />
            <circle cx="50" cy="10" r="2" fill={BLUE} filter="url(#glow-layer)" />
            <circle cx="50" cy="90" r="2" fill={BLUE} filter="url(#glow-layer)" />
        </VisualWrapper>
    );
};

export const RhythmVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={20} segments={4}
                fn={(u, v, t) => {
                    const angle = u * Math.PI * 2;
                    const r = 10 + v * 30 + Math.sin(angle * 4 + t * 2) * 2;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={BLUE} opacity={0.3}
            />
            <circle cx="50" cy="50" r="5" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={BLUE} strokeWidth="0.5" filter="url(#tangible-shading)" />
            {[0, 1, 2, 3].map(i => (
                <motion.circle 
                    key={i} cx="50" cy="50" r="5" 
                    stroke={BLUE} strokeWidth="0.2" fill="none" 
                    animate={{ scale: [1, 8], opacity: [0.8, 0] }} 
                    transition={{ duration: 2, delay: i * 0.5, repeat: Infinity, ease: "easeOut" }} 
                />
            ))}
        </VisualWrapper>
    );
};

export const TensionVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={6} segments={20}
                fn={(u, v, t) => {
                    const x = 20 + v * 60;
                    const tension = Math.sin(t * 2) * 5;
                    const y = 50 + (u - 0.5) * 10 + Math.sin(v * Math.PI) * tension;
                    return { x, y, z: 0 };
                }}
                color={BLUE} opacity={0.4}
            />
            <motion.circle cx="20" cy="50" r="4" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={BLUE} strokeWidth="0.5" animate={{ x: [-2, 2] }} transition={PULSE_FAST} filter="url(#tangible-shading)" />
            <motion.circle cx="80" cy="50" r="4" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={BLUE} strokeWidth="0.5" animate={{ x: [2, -2] }} transition={PULSE_FAST} filter="url(#tangible-shading)" />
            <motion.path 
                d="M24 50 L76 50" 
                stroke={`url(#grad-holo-${colorId})`} strokeWidth="0.5" 
                animate={{ d: ["M24 50 L76 50", "M24 50 Q 50 45 76 50", "M24 50 L76 50"] }} 
                transition={PULSE_FAST} 
                filter="url(#tangible-shading)"
            />
        </VisualWrapper>
    );
};

export const FlowVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={8} segments={40}
                fn={(u, v, t) => {
                    const x = 10 + v * 80;
                    const y = 50 + Math.sin(v * 5 + t) * 10 + (u - 0.5) * 5;
                    return { x, y, z: 0 };
                }}
                color={BLUE} opacity={0.3}
            />
            <motion.path 
                d="M10 50 Q 30 20 50 50 T 90 50" 
                stroke="currentColor" strokeWidth="0.2" fill="none" opacity="0.3" 
            />
            {[0, 1, 2].map(i => (
                <motion.circle 
                    key={i} r="2" fill={`url(#grad-holo-${colorId})`}
                    animate={{ offsetDistance: ["0%", "100%"] }}
                    style={{ offsetPath: "path('M10 50 Q 30 20 50 50 T 90 50')" }}
                    transition={{ duration: 3, repeat: Infinity, ease: "linear", delay: i * 1 }}
                    filter="url(#tangible-shading)"
                />
            ))}
        </VisualWrapper>
    );
};

export const ResistanceVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={15} segments={15}
                fn={(u, v, t) => {
                    const x = 30 + u * 40;
                    const y = 20 + v * 10 + Math.sin(u * Math.PI + t) * 2;
                    return { x, y, z: 0 };
                }}
                color={BLUE} opacity={0.4}
            />
            {/* Meaning: A wall being pushed against */}
            <motion.rect 
                x="30" y="20" width="40" height="10" 
                fill={`url(#grad-holo-${colorId})`} stroke={BLUE} strokeWidth="1" 
                animate={{ y: [20, 30, 20], scaleX: [1, 1.1, 1] }} 
                transition={PULSE_SLOW} filter="url(#tangible-shading)" 
            />
            <motion.path 
                d="M 20 80 Q 50 60 80 80" 
                stroke="currentColor" strokeWidth="1" fill="none" opacity="0.6" 
                animate={{ d: ["M 20 80 Q 50 60 80 80", "M 20 80 Q 50 40 80 80", "M 20 80 Q 50 60 80 80"] }}
                transition={FLOAT}
            />
            <motion.circle 
                cx="50" cy="80" r="15" 
                fill="none" stroke={BLUE} strokeWidth="0.5" strokeDasharray="2 2" 
                animate={{ r: [15, 25, 15], opacity: [0.2, 0.8, 0.2] }} 
                transition={PULSE_SLOW} 
            />
        </VisualWrapper>
    );
};

export const SymmetryVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={10} segments={20}
                fn={(u, v, t) => {
                    const y = 10 + v * 80;
                    const x = 50 + (u - 0.5) * 5 * Math.sin(v * Math.PI + t);
                    return { x, y, z: 0 };
                }}
                color={BLUE} opacity={0.3}
            />
            <line x1="50" y1="10" x2="50" y2="90" stroke="currentColor" strokeWidth="0.2" strokeDasharray="1 2" opacity="0.3" />
            <motion.g animate={{ x: [-5, 0, -5] }} transition={PULSE_SLOW}>
                <path d="M45 30 L 25 50 L 45 70" fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1" filter="url(#tangible-shading)" />
                <circle cx="25" cy="50" r="2" fill={BLUE} filter="url(#glow-layer)" />
            </motion.g>
            <motion.g animate={{ x: [5, 0, 5] }} transition={PULSE_SLOW}>
                <path d="M55 30 L 75 50 L 55 70" fill="none" stroke={BLUE} strokeWidth="1" opacity="0.6" filter="url(#tangible-shading)" />
                <circle cx="75" cy="50" r="2" fill={BLUE} filter="url(#glow-layer)" />
            </motion.g>
        </VisualWrapper>
    );
};

export const RangeVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={10} segments={10}
                fn={(u, v, t) => {
                    const angle = v * Math.PI;
                    const r = 30 + u * 10 + Math.sin(t) * 2;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 - Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={BLUE} opacity={0.3}
            />
            <circle cx="50" cy="50" r="2" fill={BLUE} filter="url(#glow-layer)" />
            <path d="M20 50 A 30 30 0 0 1 80 50" stroke="currentColor" strokeWidth="0.2" strokeDasharray="1 1" fill="none" opacity="0.3" />
            <motion.line 
                x1="50" y1="50" x2="80" y2="50" 
                stroke={`url(#grad-holo-${colorId})`} strokeWidth="1" 
                animate={{ rotate: [0, 180, 0] }} 
                style={{ originX: "50px", originY: "50px" }} 
                transition={{ duration: 4, repeat: Infinity, ease: "easeInOut" }} 
                filter="url(#tangible-shading)"
            />
        </VisualWrapper>
    );
};

export const RespirationVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={16} segments={16}
                fn={(u, v, t) => {
                    const angle = u * Math.PI * 2;
                    const r = (10 + v * 30) * (1 + Math.sin(t) * 0.2);
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={BLUE} opacity={0.3}
            />
            <motion.circle cx="50" cy="50" r="10" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={BLUE} strokeWidth="0.5" animate={{ scale: [1, 1.5, 1] }} transition={PULSE_SLOW} filter="url(#tangible-shading)" />
            <motion.circle cx="50" cy="50" r="20" stroke={BLUE} strokeWidth="0.2" fill="none" animate={{ scale: [1, 2, 1], opacity: [0.8, 0.2, 0.8] }} transition={PULSE_SLOW} />
        </VisualWrapper>
    );
};

export const ContractionVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={5} segments={20}
                fn={(u, v, t) => {
                    const x = 30 + v * 40;
                    const contraction = Math.sin(t * 2) * 5;
                    const y = 50 + (u - 0.5) * (20 - contraction);
                    return { x, y, z: 0 };
                }}
                color={BLUE} opacity={0.4}
            />
            <g transform="translate(50 50)">
                <motion.line x1="-20" y1="-30" x2="-20" y2="30" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1" animate={{ x: [-20, -10, -20] }} transition={PULSE_FAST} filter="url(#tangible-shading)" />
                <motion.line x1="20" y1="-30" x2="20" y2="30" stroke={BLUE} strokeWidth="1" opacity="0.6" animate={{ x: [20, 10, 20] }} transition={PULSE_FAST} filter="url(#tangible-shading)" />
                <line x1="0" y1="-40" x2="0" y2="40" stroke="currentColor" strokeWidth="0.2" opacity="0.3" />
            </g>
        </VisualWrapper>
    );
};

export const GaitVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={4} segments={40}
                fn={(u, v, t) => {
                    const x = v * 100;
                    const y = 70 + Math.sin(v * 10 + t * 2) * 2;
                    return { x, y, z: 0 };
                }}
                color={BLUE} opacity={0.3}
            />
            <line x1="10" y1="70" x2="90" y2="70" stroke="currentColor" strokeWidth="0.2" opacity="0.3" />
            <motion.g animate={{ x: [0, 40, 0] }} transition={{ duration: 4, repeat: Infinity, ease: "linear" }}>
                <motion.circle cx="30" cy="60" r="4" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={BLUE} strokeWidth="0.5" animate={{ y: [60, 50, 60] }} transition={PULSE_FAST} filter="url(#tangible-shading)" />
                <motion.path d="M 30 60 L 30 70" stroke={BLUE} strokeWidth="0.5" opacity="0.4" animate={{ d: ["M 30 60 L 30 70", "M 30 50 L 30 70", "M 30 60 L 30 70"] }} transition={PULSE_FAST} />
            </motion.g>
        </VisualWrapper>
    );
};

// ============================================================================
// VISUALS (RED SERIES - UTILITIES & LOOPS)
// ============================================================================

export const OrbitVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <ParametricSurface 
                points={12} segments={12}
                fn={(u, v, t) => {
                    const r = 30 + u * 10;
                    const angle = v * Math.PI * 2 + t;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={PURPLE} opacity={0.3}
            />
            <circle cx="50" cy="50" r="30" fill="none" stroke="currentColor" strokeWidth="0.2" opacity="0.3" />
            <motion.circle cx="50" cy="50" r="10" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={PURPLE} strokeWidth="0.5" animate={{ scale: [1, 1.1, 1] }} transition={PULSE_SLOW} filter="url(#tangible-shading)" />
            <motion.g animate={{ rotate: 360 }} transition={SPIN_SLOW} style={{ originX: "50px", originY: "50px" }}>
                <circle cx="80" cy="50" r="2" fill={PURPLE} filter="url(#glow-layer)" />
                <motion.path d="M 50 50 L 80 50" stroke={PURPLE} strokeWidth="0.1" strokeDasharray="1 1" opacity="0.4" />
            </motion.g>
        </VisualWrapper>
    );
};

export const FilterVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={5} segments={20}
                fn={(u, v, t) => {
                    const x = 30 + v * 40;
                    const y = 20 + u * 40 * v;
                    return { x, y, z: 0 };
                }}
                color={LIME} opacity={0.3}
            />
            <motion.path d="M 20 20 L 80 20 L 55 60 L 55 90 L 45 90 L 45 60 Z" fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="0.5" filter="url(#tangible-shading)" />
            {[0, 1, 2].map(i => (
                <motion.circle key={i} cx="50" cy="25" r="1" fill={LIME} filter="url(#glow-layer)" animate={{ y: [0, 60], opacity: [1, 0] }} transition={{ duration: 2, delay: i * 0.6, repeat: Infinity }} />
            ))}
        </VisualWrapper>
    );
};

export const TargetVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={20} segments={4}
                fn={(u, v, t) => {
                    const angle = u * Math.PI * 2;
                    const r = v * 50 + Math.sin(t) * 2;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={RED} opacity={0.2}
            />
            {[20, 35, 50].map((r, i) => (
                <motion.circle 
                    key={i} cx="50" cy="50" r={r} 
                    fill="none" stroke={i === 2 ? RED : "currentColor"} 
                    strokeWidth="0.2" opacity={0.5 - i * 0.1}
                    animate={{ scale: [1, 1.05, 1] }} transition={{ ...PULSE_SLOW, delay: i * 0.2 }}
                    filter="url(#tangible-shading)"
                />
            ))}
            <motion.path d="M 50 20 L 50 80 M 20 50 L 80 50" stroke={RED} strokeWidth="0.1" opacity="0.4" />
            <motion.circle cx="50" cy="50" r="2" fill={RED} filter="url(#glow-layer)" animate={{ scale: [1, 1.5, 1] }} transition={PULSE_FAST} />
        </VisualWrapper>
    );
};

export const EchoVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <ParametricSurface 
                points={10} segments={10}
                fn={(u, v, t) => {
                    const angle = u * Math.PI * 2;
                    const r = v * 50 * (1 + Math.sin(t) * 0.1);
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={PURPLE} opacity={0.3}
            />
            <motion.circle cx="50" cy="50" r="2" fill={PURPLE} filter="url(#glow-layer)" />
            {[1, 2, 3, 4].map(i => (
                <motion.circle 
                    key={i} cx="50" cy="50" r={5} 
                    stroke={`url(#grad-holo-${colorId})`} strokeWidth="0.2" fill="none" 
                    animate={{ scale: [1, 10], opacity: [0.8, 0] }} 
                    transition={{ duration: 3, delay: i * 0.75, repeat: Infinity, ease: "easeOut" }} 
                    filter="url(#tangible-shading)"
                />
            ))}
        </VisualWrapper>
    );
};

export const LayerVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={5} segments={20}
                fn={(u, v, t) => ({
                    x: 20 + v * 60,
                    y: 40 + u * 20 + Math.sin(v * 5 + t) * 5,
                    z: 0
                })}
                color={LIME} opacity={0.3}
            />
            {[0, 1, 2].map(i => (
                <motion.rect 
                    key={i} x={30 - i * 5} y={50 - i * 10} width="40" height="20" 
                    fill="none" stroke={i === 2 ? LIME : "currentColor"} strokeWidth="0.5" 
                    animate={{ y: [0, -10, 0], opacity: [0.3, 1, 0.3] }} 
                    transition={{ duration: 4, delay: i * 0.5, repeat: Infinity, ease: "easeInOut" }} 
                    filter="url(#tangible-shading)"
                />
            ))}
        </VisualWrapper>
    );
};

export const CycleVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={12} segments={12}
                fn={(u, v, t) => {
                    const angle = v * Math.PI * 2 + t;
                    const r = 30 + Math.sin(u * Math.PI) * 5;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={RED} opacity={0.3}
            />
            <motion.path 
                d="M 50 20 A 30 30 0 1 1 49.9 20" 
                stroke={`url(#grad-holo-${colorId})`} strokeWidth="1" fill="none" strokeDasharray="10 5"
                animate={{ rotate: 360 }} transition={SPIN_MID}
                style={{ originX: "50px", originY: "50px" }}
                filter="url(#tangible-shading)"
            />
            <motion.circle cx="50" cy="20" r="3" fill={RED} filter="url(#glow-layer)" animate={{ rotate: 360 }} style={{ originX: "0px", originY: "30px" }} transition={SPIN_MID} />
        </VisualWrapper>
    );
};

export const GrowthVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <ParametricSurface 
                points={5} segments={30}
                fn={(u, v, t) => {
                    const x = 20 + u * 60;
                    const y = 80 - v * 60 * (1 + Math.sin(t) * 0.1);
                    return { x, y, z: 0 };
                }}
                color={PURPLE} opacity={0.3}
            />
            <line x1="10" y1="80" x2="90" y2="80" stroke="currentColor" strokeWidth="0.2" opacity="0.3" />
            {[0, 1, 2, 3].map(i => (
                <motion.rect 
                    key={i} x={20 + i * 18} y={80} width="8" height={0} 
                    fill={i === 3 ? PURPLE : "currentColor"} opacity={0.4 + i * 0.2}
                    animate={{ height: [0, 20 + i * 15], y: [80, 80 - (20 + i * 15)] }} 
                    transition={{ duration: 1.5, delay: i * 0.2, ease: "easeOut", repeat: Infinity, repeatDelay: 1 }} 
                    filter="url(#tangible-shading)"
                />
            ))}
        </VisualWrapper>
    );
};

export const GlobeVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={12} segments={12}
                fn={(u, v, t) => {
                    const phi = u * Math.PI;
                    const theta = v * Math.PI * 2 + t;
                    const r = 35;
                    return {
                        x: 50 + r * Math.sin(phi) * Math.cos(theta),
                        y: 50 + r * Math.sin(phi) * Math.sin(theta),
                        z: r * Math.cos(phi)
                    };
                }}
                color={RED} opacity={0.4}
            />
            <circle cx="50" cy="50" r="35" fill="none" stroke="currentColor" strokeWidth="0.2" opacity="0.3" />
            <motion.g animate={{ rotateY: 360 }} transition={SPIN_SLOW} style={{ originX: "50px", originY: "50px", transformStyle: "preserve-3d" }}>
                {[0, 45, 90, 135].map(rot => (
                    <ellipse key={rot} cx="50" cy="50" rx="35" ry="35" fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="0.5" transform={`rotate(${rot} 50 50)`} opacity="0.4" filter="url(#tangible-shading)" />
                ))}
            </motion.g>
        </VisualWrapper>
    );
};

export const NetworkVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    const nodes = [
        { x: 30, y: 30 }, { x: 70, y: 30 }, { x: 50, y: 70 }, { x: 50, y: 30 }
    ];
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={4} segments={4}
                fn={(u, v, t) => {
                    const p1 = nodes[Math.floor(u * 3.99)];
                    const p2 = nodes[Math.floor(v * 3.99)];
                    return {
                        x: p1.x + (p2.x - p1.x) * Math.sin(t),
                        y: p1.y + (p2.y - p1.y) * Math.cos(t),
                        z: 0
                    };
                }}
                color={LIME} opacity={0.2}
            />
            {nodes.map((p, i) => (
                <g key={i}>
                    {nodes.slice(i + 1).map((p2, j) => (
                        <motion.line 
                            key={j} x1={p.x} y1={p.y} x2={p2.x} y2={p2.y} 
                            stroke={LIME} strokeWidth="0.2" opacity="0.3" 
                        />
                    ))}
                    <motion.circle 
                        cx={p.x} cy={p.y} r="3" 
                        fill={`url(#grad-cyber-sphere-${colorId})`} stroke={LIME} strokeWidth="0.5"
                        animate={{ scale: [1, 1.2, 1] }} transition={{ ...PULSE_FAST, delay: i * 0.2 }}
                        filter="url(#tangible-shading)"
                    />
                </g>
            ))}
        </VisualWrapper>
    );
};

export const WhisperVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <ParametricSurface 
                points={4} segments={40}
                fn={(u, v, t) => {
                    const x = 20 + v * 60;
                    const y = 50 + Math.sin(v * 10 + t) * (u * 5);
                    return { x, y, z: 0 };
                }}
                color={PURPLE} opacity={0.3}
            />
            <motion.path 
                d="M 20 50 Q 35 30 50 50 T 80 50" 
                stroke={`url(#grad-holo-${colorId})`} strokeWidth="0.5" fill="none"
                animate={{ d: ["M 20 50 Q 35 30 50 50 T 80 50", "M 20 50 Q 35 70 50 50 T 80 50", "M 20 50 Q 35 30 50 50 T 80 50"] }}
                transition={PULSE_SLOW}
                filter="url(#tangible-shading)"
            />
            <motion.circle cx="20" cy="50" r="1.5" fill={PURPLE} filter="url(#glow-layer)" />
        </VisualWrapper>
    );
};

export const BatteryVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={4} segments={20}
                fn={(u, v, t) => ({
                    x: 25 + v * 50,
                    y: 35 + u * 30 + Math.sin(v * 10 + t) * 2,
                    z: 0
                })}
                color={RED} opacity={0.3}
            />
            <rect x="25" y="35" width="50" height="30" rx="2" fill="none" stroke="currentColor" strokeWidth="0.5" opacity="0.4" />
            <rect x="75" y="43" width="4" height="14" rx="1" fill="currentColor" opacity="0.4" />
            <motion.rect 
                x="28" y="38" width="44" height="24" rx="1"
                fill={`url(#grad-holo-${colorId})`}
                animate={{ width: [0, 44, 0] }} transition={{ duration: 4, repeat: Infinity, ease: "easeInOut" }}
                filter="url(#tangible-shading)"
            />
        </VisualWrapper>
    );
};

export const ScaleVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={10} segments={20}
                fn={(u, v, t) => {
                    const x = 20 + v * 60;
                    const y = 80 - u * 50 * Math.sin(v * Math.PI + t);
                    return { x, y, z: 0 };
                }}
                color={LIME} opacity={0.3}
            />
            <line x1="20" y1="80" x2="80" y2="80" stroke="currentColor" strokeWidth="0.2" opacity="0.3" />
            {[20, 35, 50, 65, 80].map(x => (
                <line key={x} x1={x} y1="80" x2={x} y2="75" stroke="currentColor" strokeWidth="0.2" opacity="0.3" />
            ))}
            <motion.path 
                d="M 50 80 L 50 30" 
                stroke={`url(#grad-holo-${colorId})`} strokeWidth="1"
                animate={{ d: ["M 50 80 L 50 30", "M 50 80 L 70 30", "M 50 80 L 30 30", "M 50 80 L 50 30"] }}
                transition={FLOAT}
                style={{ originX: "50px", originY: "80px" }}
                filter="url(#tangible-shading)"
            />
            <motion.circle r="2" fill={LIME} filter="url(#glow-layer)" animate={{ offsetDistance: ["0%", "100%"] }} style={{ offsetPath: "path('M 50 80 L 50 30')" }} transition={FLOAT} />
        </VisualWrapper>
    );
};

export const ShieldVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={10} segments={20}
                fn={(u, v, t) => {
                    const phi = u * Math.PI;
                    const theta = v * Math.PI;
                    const r = 30 + Math.sin(t) * 2;
                    return {
                        x: 50 + r * Math.sin(phi) * Math.cos(theta),
                        y: 50 + r * Math.sin(phi) * Math.sin(theta),
                        z: 0
                    };
                }}
                color={RED} opacity={0.3}
            />
            <motion.path 
                d="M 50 20 C 70 20 80 40 80 60 C 80 80 50 90 50 90 C 50 90 20 80 20 60 C 20 40 30 20 50 20" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1"
                animate={{ scale: [1, 1.05, 1] }} transition={PULSE_SLOW}
                filter="url(#tangible-shading)"
            />
            <motion.path d="M 50 20 L 50 90 M 20 60 L 80 60" stroke="currentColor" strokeWidth="0.2" opacity="0.3" />
        </VisualWrapper>
    );
};

export const AuditVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={5} segments={20}
                fn={(u, v, t) => ({
                    x: 30 + v * 40,
                    y: 20 + u * 60 + Math.sin(v * 10 + t) * 2,
                    z: 0
                })}
                color={RED} opacity={0.3}
            />
            <motion.path 
                d="M 30 20 L 70 20 L 70 80 L 30 80 Z" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="0.5"
                filter="url(#tangible-shading)"
            />
            {[30, 45, 60].map(y => (
                <motion.line key={y} x1="35" y1={y} x2="65" y2={y} stroke="currentColor" strokeWidth="0.2" opacity="0.3" animate={{ opacity: [0.1, 0.5, 0.1] }} transition={{ ...PULSE_SLOW, delay: y * 0.01 }} />
            ))}
            <motion.path d="M 40 70 L 45 75 L 60 60" stroke={RED} strokeWidth="1" fill="none" filter="url(#glow-layer)" animate={{ pathLength: [0, 1] }} transition={{ duration: 2, repeat: Infinity }} />
        </VisualWrapper>
    );
};

export const FactoryVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={5} segments={20}
                fn={(u, v, t) => ({
                    x: 20 + v * 60,
                    y: 30 + u * 40 + Math.sin(v * 10 + t) * 5,
                    z: 0
                })}
                color={LIME} opacity={0.3}
            />
            <rect x="20" y="30" width="60" height="40" fill="none" stroke="currentColor" strokeWidth="0.2" opacity="0.3" />
            {[25, 40, 55, 70].map(x => (
                <motion.rect key={x} x={x} y="40" width="5" height="20" fill={`url(#grad-holo-${colorId})`} animate={{ scaleY: [1, 1.5, 1] }} transition={{ ...PULSE_FAST, delay: x * 0.01 }} filter="url(#tangible-shading)" />
            ))}
        </VisualWrapper>
    );
};

export const SearchVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <ParametricSurface 
                points={12} segments={12}
                fn={(u, v, t) => {
                    const r = 15 + u * 10;
                    const angle = v * Math.PI * 2 + t;
                    return {
                        x: 45 + Math.cos(angle) * r,
                        y: 45 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={PURPLE} opacity={0.3}
            />
            <motion.circle cx="45" cy="45" r="15" fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1" animate={{ scale: [1, 1.1, 1] }} transition={PULSE_SLOW} filter="url(#tangible-shading)" />
            <motion.line x1="55" y1="55" x2="75" y2="75" stroke={PURPLE} strokeWidth="1" strokeLinecap="round" filter="url(#tangible-shading)" />
        </VisualWrapper>
    );
};

export const PenVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={4} segments={40}
                fn={(u, v, t) => {
                    const x = 30 + v * 40;
                    const y = 70 - v * 40 + Math.sin(v * 10 + t) * 2;
                    return { x, y, z: 0 };
                }}
                color={RED} opacity={0.3}
            />
            <motion.path 
                d="M 30 70 L 70 30" 
                stroke={`url(#grad-holo-${colorId})`} strokeWidth="1" strokeLinecap="round"
                animate={{ x: [-2, 2, -2], y: [2, -2, 2] }} transition={FLOAT}
                filter="url(#tangible-shading)"
            />
            <motion.circle cx="70" cy="30" r="2" fill={RED} filter="url(#glow-layer)" animate={{ scale: [1, 1.5, 1] }} transition={PULSE_FAST} />
        </VisualWrapper>
    );
};

export const MeaningVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={10} segments={10}
                fn={(u, v, t) => {
                    const angle = u * Math.PI * 2 + t;
                    const r = v * 40;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={LIME} opacity={0.3}
            />
            <motion.rect 
                x="30" y="30" width="40" height="40" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="0.5"
                animate={{ rotate: 360 }} transition={SPIN_SLOW}
                style={{ originX: "50px", originY: "50px" }}
                filter="url(#tangible-shading)"
            />
            <motion.circle cx="50" cy="50" r="5" fill={LIME} filter="url(#glow-layer)" animate={{ scale: [1, 1.5, 1] }} transition={PULSE_FAST} />
        </VisualWrapper>
    );
};

export const DefenseVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <ParametricSurface 
                points={10} segments={20}
                fn={(u, v, t) => {
                    const phi = u * Math.PI;
                    const theta = v * Math.PI;
                    const r = 30 + Math.sin(t) * 2;
                    return {
                        x: 50 + r * Math.sin(phi) * Math.cos(theta),
                        y: 45 + r * Math.sin(phi) * Math.sin(theta),
                        z: 0
                    };
                }}
                color={PURPLE} opacity={0.3}
            />
            {/* Meaning: Hexagonal shield structure */}
            <motion.path 
                d="M 50 20 L 76 35 L 76 65 L 50 80 L 24 65 L 24 35 Z" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1.5"
                animate={{ scale: [1, 1.05, 1], opacity: [0.4, 0.8, 0.4] }} 
                transition={PULSE_SLOW}
                filter="url(#tangible-shading)"
            />
            <motion.path 
                d="M 50 20 C 70 20 80 40 80 60 C 80 80 50 90 50 90 C 50 90 20 80 20 60 C 20 40 30 20 50 20" 
                fill="none" stroke={PURPLE} strokeWidth="0.5" opacity="0.3"
                animate={{ scale: [1, 1.1, 1] }} transition={PULSE_SLOW}
            />
            <motion.circle cx="50" cy="45" r="6" fill={PURPLE} filter="url(#glow-layer)" animate={{ opacity: [0.3, 1, 0.3], scale: [1, 1.5, 1] }} transition={PULSE_FAST} />
        </VisualWrapper>
    );
};

export const TangleVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={8} segments={40}
                fn={(u, v, t) => {
                    const r = 20 + Math.sin(v * 10 + t) * 5;
                    const angle = v * Math.PI * 2;
                    return {
                        x: 50 + Math.cos(angle) * r + Math.sin(u * Math.PI + t) * 10,
                        y: 50 + Math.sin(angle) * r + Math.cos(u * Math.PI + t) * 10,
                        z: 0
                    };
                }}
                color={RED} opacity={0.3}
            />
            {/* Meaning: Knots and tension points in a complex system */}
            <motion.path 
                d="M 20 20 L 80 80 M 80 20 L 20 80" 
                stroke={RED} strokeWidth="0.5" opacity="0.2" 
            />
            {[0, 1, 2].map(i => (
                <motion.circle 
                    key={i} cx={30 + i * 20} cy={40 + Math.sin(i) * 20} r="2" 
                    fill={RED} filter="url(#glow-layer)"
                    animate={{ scale: [1, 2, 1], opacity: [0.3, 1, 0.3] }}
                    transition={{ duration: 2, delay: i * 0.5, repeat: Infinity }}
                />
            ))}
            <motion.path 
                d="M 30 50 Q 50 20 70 50 T 30 50" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="2"
                animate={{ d: ["M 30 50 Q 50 20 70 50 T 30 50", "M 30 50 Q 50 80 70 50 T 30 50", "M 30 50 Q 50 20 70 50 T 30 50"] }}
                transition={FLOAT}
                filter="url(#tangible-shading)"
            />
            <motion.circle cx="50" cy="50" r="10" fill={RED} filter="url(#glow-layer)" animate={{ scale: [1, 1.5, 1], opacity: [0.4, 0.8, 0.4] }} transition={PULSE_FAST} />
        </VisualWrapper>
    );
};

export const MaskVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={10} segments={10}
                fn={(u, v, t) => ({
                    x: 30 + v * 40,
                    y: 30 + u * 40 + Math.sin(v * 5 + t) * 5,
                    z: 0
                })}
                color={LIME} opacity={0.3}
            />
            <motion.path 
                d="M 30 30 L 70 30 L 70 70 L 30 70 Z" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="0.5"
                animate={{ rotateY: 180 }} transition={{ duration: 4, repeat: Infinity, ease: "easeInOut" }}
                style={{ originX: "50px", originY: "50px" }}
                filter="url(#tangible-shading)"
            />
            <motion.circle cx="50" cy="50" r="3" fill={LIME} filter="url(#glow-layer)" />
        </VisualWrapper>
    );
};

export const BottleneckVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={5} segments={40}
                fn={(u, v, t) => {
                    const x = 20 + v * 60;
                    const width = 30 - Math.sin(v * Math.PI) * 20;
                    const y = 50 + (u - 0.5) * width;
                    return { x, y, z: 0 };
                }}
                color={RED} opacity={0.3}
            />
            <path d="M 20 20 L 40 45 L 40 55 L 20 80" stroke="currentColor" strokeWidth="0.2" fill="none" opacity="0.4" />
            <path d="M 80 20 L 60 45 L 60 55 L 80 80" stroke="currentColor" strokeWidth="0.2" fill="none" opacity="0.4" />
            {[0, 1, 2].map(i => (
                <motion.circle 
                    key={i} cx="50" cy="20" r="1.5" fill={RED} filter="url(#glow-layer)"
                    animate={{ y: [0, 30, 60], opacity: [1, 1, 0], scale: [1, 0.5, 1.2] }} 
                    transition={{ duration: 4, delay: i * 1.3, repeat: Infinity, ease: "linear" }} 
                />
            ))}
        </VisualWrapper>
    );
};

export const AlignmentVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <ParametricSurface 
                points={4} segments={40}
                fn={(u, v, t) => ({
                    x: 45 + u * 10,
                    y: 10 + v * 80 + Math.sin(v * 10 + t) * 2,
                    z: 0
                })}
                color={PURPLE} opacity={0.3}
            />
            <motion.line x1="50" y1="10" x2="50" y2="90" stroke={PURPLE} strokeWidth="0.2" strokeDasharray="1 2" opacity="0.5" />
            {[25, 50, 75].map((y, i) => (
                <motion.rect 
                    key={i} x="40" y={y - 5} width="20" height="10" 
                    fill="none" stroke={i === 1 ? PURPLE : "currentColor"} strokeWidth="0.5"
                    animate={{ x: i === 1 ? 0 : [-20, 0, -20] }} 
                    transition={{ duration: 4, repeat: Infinity, ease: "easeInOut" }} 
                    filter="url(#tangible-shading)"
                />
            ))}
        </VisualWrapper>
    );
};

export const FragmentationVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={5} segments={20}
                fn={(u, v, t) => {
                    const r = 10 + v * 30;
                    const angle = u * Math.PI * 2 + t;
                    return {
                        x: 50 + Math.cos(angle) * r * (Math.sin(t) > 0 ? 1 : 0.5),
                        y: 50 + Math.sin(angle) * r * (Math.sin(t) > 0 ? 1 : 0.5),
                        z: 0
                    };
                }}
                color={LIME} opacity={0.3}
            />
            <g transform="translate(50 50)">
                {[
                    { x: -10, y: -10 }, { x: 10, y: -10 }, { x: -10, y: 10 }, { x: 10, y: 10 }
                ].map((p, i) => (
                    <motion.rect 
                        key={i} x={p.x - 4} y={p.y - 4} width="8" height="8" 
                        fill="none" stroke={i === 1 ? LIME : "currentColor"} strokeWidth="0.5"
                        animate={{ 
                            x: [p.x - 4, p.x * 3, p.x - 4], 
                            y: [p.y - 4, p.y * 3, p.y - 4],
                            rotate: [0, 180, 0]
                        }} 
                        transition={{ duration: 5, repeat: Infinity, ease: "easeInOut", delay: i * 0.2 }} 
                        filter="url(#tangible-shading)"
                    />
                ))}
            </g>
        </VisualWrapper>
    );
};

export const GapVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={4} segments={40}
                fn={(u, v, t) => {
                    const x = 10 + v * 80;
                    const y = 70 - (v > 0.4 && v < 0.6 ? 0 : Math.sin(v * Math.PI) * 20) * u;
                    return { x, y, z: 0 };
                }}
                color={RED} opacity={0.3}
            />
            <line x1="10" y1="70" x2="40" y2="70" stroke="currentColor" strokeWidth="1" opacity="0.6" />
            <line x1="60" y1="70" x2="90" y2="70" stroke="currentColor" strokeWidth="1" opacity="0.6" />
            {/* Meaning: Sparks jumping across the gap */}
            {[0, 1, 2].map(i => (
                <motion.line 
                    key={i} x1="40" y1="70" x2="60" y2="70" 
                    stroke={RED} strokeWidth="0.5"
                    animate={{ x1: [40, 60], x2: [40, 60], opacity: [0, 1, 0] }}
                    transition={{ duration: 0.5, delay: i * 0.3, repeat: Infinity }}
                />
            ))}
            <motion.path 
                d="M 40 70 Q 50 30 60 70" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1.5"
                animate={{ d: ["M 40 70 Q 50 30 60 70", "M 40 70 Q 50 80 60 70", "M 40 70 Q 50 30 60 70"] }}
                transition={FLOAT}
                filter="url(#tangible-shading)"
            />
            <motion.circle cx="50" cy="50" r="3" fill={RED} filter="url(#glow-layer)" animate={{ scale: [1, 2, 1] }} transition={PULSE_FAST} />
        </VisualWrapper>
    );
};

export const IntegrationVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <ParametricSurface 
                points={10} segments={10}
                fn={(u, v, t) => ({
                    x: 35 + v * 30 + Math.sin(t) * 5,
                    y: 35 + u * 30 + Math.cos(t) * 5,
                    z: 0
                })}
                color={PURPLE} opacity={0.3}
            />
            <motion.rect 
                x="30" y="35" width="30" height="30" 
                fill="none" stroke="currentColor" strokeWidth="0.5" opacity="0.4"
                animate={{ x: [-5, 5, -5] }} transition={PULSE_SLOW}
            />
            <motion.rect 
                x="40" y="35" width="30" height="30" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1"
                animate={{ x: [5, -5, 5] }} transition={PULSE_SLOW}
                filter="url(#tangible-shading)"
            />
            <motion.circle cx="50" cy="50" r="3" fill={PURPLE} filter="url(#glow-layer)" animate={{ scale: [1, 1.5, 1] }} transition={PULSE_FAST} />
        </VisualWrapper>
    );
};

export const SyncVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={10} segments={10}
                fn={(u, v, t) => {
                    const r = 5 + u * 10;
                    const angle = v * Math.PI * 2 + t;
                    return {
                        x: 35 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={LIME} opacity={0.3}
            />
            <ParametricSurface 
                points={10} segments={10}
                fn={(u, v, t) => {
                    const r = 5 + u * 10;
                    const angle = v * Math.PI * 2 + t;
                    return {
                        x: 65 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={LIME} opacity={0.3}
            />
            <motion.circle cx="35" cy="50" r="5" fill={LIME} filter="url(#glow-layer)" animate={{ scale: [1, 1.2, 1] }} transition={PULSE_SLOW} />
            <motion.circle cx="65" cy="50" r="5" fill={LIME} filter="url(#glow-layer)" animate={{ scale: [1, 1.2, 1] }} transition={PULSE_SLOW} />
            <motion.path 
                d="M 35 50 L 65 50" 
                stroke={`url(#grad-holo-${colorId})`} strokeWidth="0.5" strokeDasharray="2 2"
                animate={{ strokeDashoffset: [0, 10] }} transition={{ duration: 2, repeat: Infinity, ease: "linear" }}
                filter="url(#tangible-shading)"
            />
        </VisualWrapper>
    );
};

export const SignalVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={4} segments={50}
                fn={(u, v, t) => {
                    const x = 10 + v * 80;
                    const y = 50 + Math.sin(v * 10 + t) * (u * 10);
                    return { x, y, z: 0 };
                }}
                color={RED} opacity={0.3}
            />
            <motion.path 
                d="M 10 50 Q 30 20 50 50 T 90 50" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1"
                animate={{ pathLength: [0, 1, 0] }} transition={{ duration: 3, repeat: Infinity }}
                filter="url(#tangible-shading)"
            />
            <motion.circle cx="10" cy="50" r="1.5" fill={RED} filter="url(#glow-layer)" />
        </VisualWrapper>
    );
};

export const PulseVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <ParametricSurface 
                points={10} segments={20}
                fn={(u, v, t) => {
                    const r = 10 + Math.sin(t * 2) * 5 + u * 10;
                    const angle = v * Math.PI * 2;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={PURPLE} opacity={0.3}
            />
            <motion.circle cx="50" cy="50" r="10" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={PURPLE} strokeWidth="0.5" animate={{ scale: [1, 1.5, 1] }} transition={PULSE_FAST} filter="url(#tangible-shading)" />
            <motion.circle cx="50" cy="50" r="20" stroke={PURPLE} strokeWidth="0.2" fill="none" animate={{ scale: [1, 2, 1], opacity: [0.8, 0, 0.8] }} transition={PULSE_FAST} />
        </VisualWrapper>
    );
};

export const BreathVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={10} segments={30}
                fn={(u, v, t) => {
                    const r = 15 + Math.sin(t) * 10 + u * 15;
                    const angle = v * Math.PI * 2;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={LIME} opacity={0.3}
            />
            <motion.circle cx="50" cy="50" r="15" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={LIME} strokeWidth="0.5" animate={{ scale: [1, 1.8, 1] }} transition={PULSE_SLOW} filter="url(#tangible-shading)" />
            <motion.circle cx="50" cy="50" r="30" stroke={LIME} strokeWidth="0.2" fill="none" animate={{ scale: [1, 1.2, 1], opacity: [0.5, 0.1, 0.5] }} transition={PULSE_SLOW} />
        </VisualWrapper>
    );
};

export const StackVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={4} segments={20}
                fn={(u, v, t) => ({
                    x: 30 + v * 40,
                    y: 60 - u * 40 + Math.sin(v * 10 + t) * 2,
                    z: 0
                })}
                color={RED} opacity={0.3}
            />
            {[0, 1, 2].map(i => (
                <motion.rect 
                    key={i} x="30" y={60 - i * 12} width="40" height="8" 
                    fill="none" stroke={i === 2 ? RED : "currentColor"} strokeWidth="0.5"
                    animate={{ y: [60 - i * 12, 55 - i * 12, 60 - i * 12], opacity: [0.4, 1, 0.4] }} 
                    transition={{ duration: 4, delay: i * 0.5, repeat: Infinity }} 
                    filter="url(#tangible-shading)"
                />
            ))}
        </VisualWrapper>
    );
};

export const GridVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <ParametricSurface 
                points={10} segments={10}
                fn={(u, v, t) => ({
                    x: 30 + v * 40,
                    y: 30 + u * 40 + Math.sin(v * 5 + u * 5 + t) * 2,
                    z: 0
                })}
                color={PURPLE} opacity={0.3}
            />
            {/* Meaning: Data packets moving along the grid */}
            <g opacity="0.4">
                {Array.from({ length: 9 }).map((_, i) => (
                    <motion.circle 
                        key={i} cx={30 + (i % 3) * 20} cy={30 + Math.floor(i / 3) * 20} r="1.5" 
                        fill={PURPLE} 
                        animate={{ opacity: [0.2, 1, 0.2] }}
                        transition={{ duration: 2, delay: i * 0.2, repeat: Infinity }}
                    />
                ))}
            </g>
            <motion.rect 
                x="30" y="30" width="20" height="20" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1.5"
                animate={{ x: [0, 20, 20, 0, 0], y: [0, 0, 20, 20, 0] }} 
                transition={{ duration: 8, repeat: Infinity, ease: "linear" }} 
                filter="url(#tangible-shading)"
            />
        </VisualWrapper>
    );
};

export const BridgeVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={4} segments={40}
                fn={(u, v, t) => {
                    const x = 25 + v * 50;
                    const y = 50 + Math.sin(v * Math.PI + t) * (u * 10);
                    return { x, y, z: 0 };
                }}
                color={LIME} opacity={0.3}
            />
            <rect x="20" y="40" width="5" height="20" fill="currentColor" opacity="0.4" />
            <rect x="75" y="40" width="5" height="20" fill="currentColor" opacity="0.4" />
            <motion.path 
                d="M 25 50 L 75 50" 
                stroke={`url(#grad-holo-${colorId})`} strokeWidth="1" strokeDasharray="5 2"
                animate={{ strokeDashoffset: [0, -14] }} transition={{ duration: 2, repeat: Infinity, ease: "linear" }}
                filter="url(#tangible-shading)"
            />
        </VisualWrapper>
    );
};

export const DivergenceVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <ParametricSurface 
                points={4} segments={40}
                fn={(u, v, t) => {
                    const x = 20 + v * 60;
                    const y = 50 + (v > 0.3 ? (v - 0.3) * 50 * Math.sin(t) : 0) * (u - 0.5);
                    return { x, y, z: 0 };
                }}
                color={RED} opacity={0.3}
            />
            <motion.path 
                d="M 20 50 L 40 50" 
                stroke="currentColor" strokeWidth="0.5" opacity="0.4"
            />
            <motion.path 
                d="M 40 50 Q 60 50 80 20" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1"
                animate={{ pathLength: [0, 1] }} transition={{ duration: 2, ease: "easeOut" }}
                filter="url(#tangible-shading)"
            />
            <motion.path 
                d="M 40 50 Q 60 50 80 80" 
                fill="none" stroke="currentColor" strokeWidth="0.5" opacity="0.3"
                animate={{ pathLength: [0, 1] }} transition={{ duration: 2, ease: "easeOut", delay: 0.5 }}
            />
        </VisualWrapper>
    );
};

export const VigorVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={10} segments={30}
                fn={(u, v, t) => {
                    const r = 10 + Math.sin(t * 3) * 3 + u * 15;
                    const angle = v * Math.PI * 2;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={BLUE} opacity={0.3}
            />
            <motion.circle cx="50" cy="50" r="10" fill={`url(#grad-cyber-sphere-${colorId})`} stroke={BLUE} strokeWidth="0.5" animate={{ scale: [1, 1.3, 1] }} transition={PULSE_FAST} filter="url(#tangible-shading)" />
            <motion.path d="M 50 20 L 50 80 M 20 50 L 80 50" stroke="currentColor" strokeWidth="0.2" opacity="0.3" />
        </VisualWrapper>
    );
};

export const DriveVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <ParametricSurface 
                points={5} segments={20}
                fn={(u, v, t) => ({
                    x: 30 + v * 40,
                    y: 30 + u * 40 + Math.sin(v * 5 + t) * 10,
                    z: 0
                })}
                color={BLUE} opacity={0.3}
            />
            <motion.path 
                d="M 30 30 L 70 50 L 30 70 Z" 
                fill="none" stroke={`url(#grad-holo-${colorId})`} strokeWidth="1"
                animate={{ x: [-5, 5, -5] }} transition={PULSE_FAST}
                filter="url(#tangible-shading)"
            />
            <motion.path d="M 20 30 L 20 70" stroke="currentColor" strokeWidth="0.2" opacity="0.3" />
        </VisualWrapper>
    );
};


// --- EXPORT MAP ---

const BULB_FACE_PATH = "M 50 15 C 30 15 22 35 22 55 C 22 75 35 85 50 85 C 65 85 78 75 78 55 C 78 35 70 15 50 15";

export const MetamorphosisVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <motion.path 
                d={BULB_FACE_PATH}
                fill="none" stroke={LIME} strokeWidth="0.5"
                animate={{ 
                    d: [BULB_FACE_PATH, "M 50 15 C 20 15 10 40 10 60 C 10 80 30 90 50 90 C 70 90 90 80 90 60 C 90 40 80 15 50 15", BULB_FACE_PATH],
                    opacity: [0.2, 0.6, 0.2]
                }}
                transition={{ duration: 5, repeat: Infinity, ease: "easeInOut" }}
            />
            <ParametricSurface 
                points={15} segments={15}
                fn={(u, v, t) => {
                    const angle = v * Math.PI * 2;
                    const r = 20 + Math.sin(t + u * 5) * 5;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={LIME} opacity={0.3}
            />
            <motion.circle cx="50" cy="45" r="2" fill={LIME} filter="url(#glow-layer)" animate={{ scale: [1, 3, 1] }} transition={PULSE_SLOW} />
        </VisualWrapper>
    );
};

export const CognitionVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <motion.path d={BULB_FACE_PATH} fill={BLUE} opacity="0.1" />
            <g opacity="0.5">
                {[...Array(12)].map((_, i) => (
                    <motion.path 
                        key={i}
                        d={`M 50 50 L ${50 + Math.cos(i) * 30} ${50 + Math.sin(i) * 30}`}
                        stroke={BLUE} strokeWidth="0.5"
                        animate={{ pathLength: [0, 1, 0], opacity: [0, 1, 0] }}
                        transition={{ duration: 3, delay: i * 0.2, repeat: Infinity }}
                    />
                ))}
            </g>
            <motion.path 
                d={BULB_FACE_PATH} fill="none" stroke={BLUE} strokeWidth="1"
                animate={{ opacity: [0.3, 0.8, 0.3] }} transition={PULSE_SLOW}
            />
            <motion.circle cx="40" cy="45" r="1.5" fill="white" animate={{ opacity: [0.2, 1, 0.2] }} transition={PULSE_FAST} />
            <motion.circle cx="60" cy="45" r="1.5" fill="white" animate={{ opacity: [0.2, 1, 0.2] }} transition={PULSE_FAST} />
        </VisualWrapper>
    );
};

export const ZenithVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <motion.path d={BULB_FACE_PATH} fill="none" stroke={PURPLE} strokeWidth="0.5" opacity="0.2" />
            {[1, 2, 3].map(i => (
                <motion.path 
                    key={i} d={BULB_FACE_PATH}
                    fill="none" stroke={PURPLE} strokeWidth={1 / i}
                    animate={{ scale: [1, 1 + i * 0.1, 1], opacity: [0.4, 0, 0.4] }}
                    transition={{ duration: 4, delay: i * 0.5, repeat: Infinity }}
                />
            ))}
            <motion.circle cx="50" cy="45" r="4" fill={PURPLE} filter="url(#glow-layer)" animate={{ scale: [1, 1.5, 1] }} transition={PULSE_SLOW} />
        </VisualWrapper>
    );
};

export const DualityVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <defs>
                <clipPath id="face-clip-left">
                    <rect x="0" y="0" width="50" height="100" />
                </clipPath>
                <clipPath id="face-clip-right">
                    <rect x="50" y="0" width="50" height="100" />
                </clipPath>
            </defs>
            {/* Left: Solid/Organic */}
            <g clipPath="url(#face-clip-left)">
                <motion.path d={BULB_FACE_PATH} fill={RED} opacity="0.4" />
                <circle cx="40" cy="45" r="4" fill="white" opacity="0.8" />
            </g>
            {/* Right: Digital/Grid */}
            <g clipPath="url(#face-clip-right)">
                <g transform="translate(50, 15)">
                    {[...Array(15)].map((_, row) => (
                        [...Array(8)].map((_, col) => (
                            <motion.rect 
                                key={`${row}-${col}`}
                                x={col * 4} y={row * 5} width="3" height="4"
                                fill={RED}
                                animate={{ opacity: [0.1, 0.9, 0.1], scale: [0.5, 1, 0.5] }}
                                transition={{ duration: 2, delay: (row + col) * 0.05, repeat: Infinity }}
                            />
                        ))
                    ))}
                </g>
            </g>
            <line x1="50" y1="15" x2="50" y2="85" stroke="currentColor" strokeWidth="0.5" strokeDasharray="2 2" />
        </VisualWrapper>
    );
};

export const EntropyVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            {/* The face shatters into fragments and reforms */}
            {[...Array(20)].map((_, i) => (
                <motion.path 
                    key={i}
                    d="M 0 0 L 6 0 L 3 6 Z"
                    fill={LIME}
                    animate={{ 
                        x: [50 + Math.cos(i) * 5, 50 + Math.cos(i) * 45, 50 + Math.cos(i) * 5],
                        y: [50 + Math.sin(i) * 5, 50 + Math.sin(i) * 45, 50 + Math.sin(i) * 5],
                        rotate: [0, 360, 0],
                        opacity: [0.8, 0.2, 0.8]
                    }}
                    transition={{ duration: 6, delay: i * 0.1, repeat: Infinity, ease: "easeInOut" }}
                />
            ))}
            <motion.path 
                d={BULB_FACE_PATH} fill="none" stroke={LIME} strokeWidth="0.5"
                animate={{ opacity: [0, 0.4, 0], scale: [0.9, 1, 0.9] }}
                transition={{ duration: 6, repeat: Infinity }}
            />
        </VisualWrapper>
    );
};

export const ResonanceVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <motion.path d={BULB_FACE_PATH} fill="none" stroke={BLUE} strokeWidth="0.5" opacity="0.3" />
            <ParametricSurface 
                points={40} segments={2}
                fn={(u, v, t) => {
                    const angle = u * Math.PI * 2;
                    const r = 25 + Math.sin(u * 10 + t * 4) * 4;
                    return {
                        x: 50 + Math.cos(angle) * r,
                        y: 50 + Math.sin(angle) * r,
                        z: 0
                    };
                }}
                color={BLUE} opacity={0.4}
            />
            <motion.path 
                d="M 35 45 Q 50 35 65 45" stroke={BLUE} strokeWidth="2" fill="none" strokeLinecap="round"
                animate={{ opacity: [0.4, 1, 0.4] }} transition={PULSE_SLOW}
            />
        </VisualWrapper>
    );
};

export const OverclockVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <motion.path 
                d={BULB_FACE_PATH} fill="none" stroke={RED} strokeWidth="1"
                animate={{ x: [-1, 1, -1], opacity: [0.5, 1, 0.5] }}
                transition={{ duration: 0.1, repeat: Infinity }}
            />
            <g opacity="0.4">
                {[...Array(10)].map((_, i) => (
                    <motion.rect 
                        key={i} x={30 + Math.random() * 40} y={20 + Math.random() * 60} width="10" height="0.5"
                        fill={RED}
                        animate={{ x: [-20, 20], opacity: [0, 1, 0] }}
                        transition={{ duration: 0.2, delay: i * 0.05, repeat: Infinity }}
                    />
                ))}
            </g>
            <motion.circle cx="40" cy="45" r="2" fill={RED} animate={{ scaleY: [1, 0.1, 1] }} transition={{ duration: 2, repeat: Infinity }} />
            <motion.circle cx="60" cy="45" r="2" fill={RED} animate={{ scaleY: [1, 0.1, 1] }} transition={{ duration: 2, repeat: Infinity }} />
        </VisualWrapper>
    );
};

export const VoidVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = PURPLE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={PURPLE}>
            <defs>
                <radialGradient id="void-nebula-face" cx="50%" cy="50%" r="50%">
                    <stop offset="0%" stopColor={PURPLE} stopOpacity="0.8" />
                    <stop offset="100%" stopColor="black" stopOpacity="1" />
                </radialGradient>
            </defs>
            <motion.path 
                d={BULB_FACE_PATH} fill="url(#void-nebula-face)"
                animate={{ scale: [1, 1.05, 1] }} transition={PULSE_SLOW}
            />
            <motion.circle cx="40" cy="45" r="1" fill="white" animate={{ opacity: [0.2, 1, 0.2] }} transition={PULSE_FAST} />
            <motion.circle cx="60" cy="45" r="1" fill="white" animate={{ opacity: [0.2, 1, 0.2] }} transition={PULSE_FAST} />
        </VisualWrapper>
    );
};

export const NexusVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            {/* Multiple overlapping face silhouettes */}
            {[0, 1, 2].map(i => (
                <motion.path 
                    key={i} d={BULB_FACE_PATH}
                    fill="none" stroke={LIME} strokeWidth="0.5"
                    animate={{ 
                        x: [0, (i - 1) * 8, 0],
                        opacity: [0.1, 0.5, 0.1],
                        scale: [1, 0.95 + i * 0.05, 1]
                    }}
                    transition={{ duration: 5, repeat: Infinity, ease: "easeInOut" }}
                />
            ))}
            <motion.circle cx="50" cy="50" r="4" fill={LIME} filter="url(#glow-layer)" />
        </VisualWrapper>
    );
};

export const AuraVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = BLUE.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={BLUE}>
            <motion.path 
                d={BULB_FACE_PATH} fill={BLUE} opacity="0.1"
                animate={{ scale: [1, 1.1, 1] }} transition={PULSE_SLOW}
            />
            <motion.path 
                d={BULB_FACE_PATH} fill="none" stroke={BLUE} strokeWidth="0.2"
                animate={{ scale: [1, 1.4, 1], opacity: [0.5, 0, 0.5] }}
                transition={{ duration: 4, repeat: Infinity }}
            />
            <motion.circle cx="50" cy="45" r="12" fill={BLUE} opacity="0.1" filter="url(#glow-layer)" />
        </VisualWrapper>
    );
};

export const EvolutionVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <defs>
                <clipPath id="evolve-left"><rect x="0" y="0" width="50" height="100" /></clipPath>
                <clipPath id="evolve-right"><rect x="50" y="0" width="50" height="100" /></clipPath>
            </defs>
            {/* Left: Fluid/Chaos */}
            <g clipPath="url(#evolve-left)">
                <ParametricSurface 
                    points={20} segments={40}
                    fn={(u, v, t) => {
                        const angle = v * Math.PI;
                        const r = 25 + Math.sin(t + u * 10) * 5;
                        return { x: 50 - Math.sin(angle) * r, y: 50 + Math.cos(angle) * r, z: 0 };
                    }}
                    color={RED} opacity={0.3}
                />
            </g>
            {/* Right: Rigid/Structure */}
            <g clipPath="url(#evolve-right)">
                <g transform="translate(50, 15)">
                    {[...Array(18)].map((_, row) => (
                        [...Array(10)].map((_, col) => {
                            const x = col * 3.5;
                            const y = row * 4;
                            return (
                                <motion.rect 
                                    key={`${row}-${col}`} x={x} y={y} width="2.5" height="3" fill={RED}
                                    animate={{ 
                                        opacity: [0.2, 1, 0.2],
                                        x: [x, x + (Math.random() - 0.5) * 15, x],
                                        y: [y, y + (Math.random() - 0.5) * 15, y]
                                    }}
                                    transition={{ duration: 8, delay: (row + col) * 0.02, repeat: Infinity }}
                                />
                            );
                        })
                    ))}
                </g>
            </g>
            <motion.path d={BULB_FACE_PATH} fill="none" stroke={RED} strokeWidth="0.5" opacity="0.3" />
            <motion.path d="M 50 15 L 50 85" stroke={RED} strokeWidth="1" strokeDasharray="2 2" />
        </VisualWrapper>
    );
};

export const PresenceVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = RED.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={RED}>
            <motion.path 
                d={BULB_FACE_PATH} fill={RED} opacity="0.1"
                animate={{ scale: [1, 1.05, 1], opacity: [0.1, 0.2, 0.1] }}
                transition={PULSE_SLOW}
            />
            <ParametricSurface 
                points={20} segments={40}
                fn={(u, v, t) => {
                    const angle = v * Math.PI * 2;
                    const r = 22 + Math.sin(t + u * 8) * 4;
                    return { x: 50 + Math.cos(angle) * r, y: 50 + Math.sin(angle) * r, z: 0 };
                }}
                color={RED} opacity={0.3}
            />
            <motion.circle cx="40" cy="45" r="1.5" fill="white" animate={{ opacity: [0.2, 1, 0.2] }} transition={PULSE_FAST} />
            <motion.circle cx="60" cy="45" r="1.5" fill="white" animate={{ opacity: [0.2, 1, 0.2] }} transition={PULSE_FAST} />
            <motion.path 
                d="M 40 65 Q 50 75 60 65" stroke={RED} strokeWidth="1" fill="none" opacity="0.5"
                animate={{ d: ["M 40 65 Q 50 75 60 65", "M 40 68 Q 50 78 60 68", "M 40 65 Q 50 75 60 65"] }}
                transition={FLOAT}
            />
        </VisualWrapper>
    );
};

export const TengeVisual: React.FC<VisualProps> = ({ variant }) => {
    const colorId = LIME.replace(/[^a-zA-Z0-9]/g, '');
    return (
        <VisualWrapper variant={variant} accentColor={LIME}>
            <ParametricSurface 
                points={10} segments={10}
                fn={(u, v, t) => ({
                    x: 35 + v * 30,
                    y: 35 + u * 30 + Math.sin(t) * 2,
                    z: 0
                })}
                color={LIME} opacity={0.3}
            />
            {/* Tenge Symbol (₸) - Meaning: Value and stability */}
            <motion.path 
                d="M 50 30 L 50 80 M 30 30 L 70 30 M 30 45 L 70 45" 
                stroke={`url(#grad-holo-${colorId})`} strokeWidth="4" fill="none" strokeLinecap="round"
                animate={{ opacity: [0.6, 1, 0.6], scale: [1, 1.05, 1] }} transition={PULSE_SLOW}
                filter="url(#tangible-shading)"
            />
            <motion.circle 
                cx="50" cy="50" r="20" fill="none" stroke={LIME} strokeWidth="0.5" strokeDasharray="4 4" 
                animate={{ rotate: [0, 360] }} transition={{ duration: 10, repeat: Infinity, ease: "linear" }} 
            />
        </VisualWrapper>
    );
};

export const VISUAL_MAP: Record<string, React.FC<VisualProps>> = {
  // Originals & Loops
  bottleneck: BottleneckVisual,
  alignment: AlignmentVisual,
  fragmentation: FragmentationVisual,
  integration: IntegrationVisual,
  network: NetworkVisual,
  divergence: DivergenceVisual,
  stack: StackVisual,
  grid: GridVisual,
  bridge: BridgeVisual,
  tangle: TangleVisual,
  tenge: TengeVisual,
  shield: ShieldVisual,
  factory: FactoryVisual,
  whisper: WhisperVisual,
  battery: BatteryVisual,
  pen: PenVisual,
  globe: GlobeVisual,
  scale: ScaleVisual,
  mask: MaskVisual,
  audit: AuditVisual,
  gap: GapVisual,
  sync: SyncVisual,
  signal: SignalVisual,
  pulse: PulseVisual,
  breath: BreathVisual,
  search: SearchVisual,
  meaning: MeaningVisual,
  defense: DefenseVisual,
  
  // Classics
  origin: OriginVisual,
  orbit: OrbitVisual,
  filter: FilterVisual,
  target: TargetVisual,
  echo: EchoVisual,
  layer: LayerVisual,
  cycle: CycleVisual,
  growth: GrowthVisual,
  
  // New Additions
  balance: BalanceVisual,
  perspective: PerspectiveVisual,
  knot: KnotVisual,
  velocity: VelocityVisual,

  // Blue Series
  posture: PostureVisual,
  rhythm: RhythmVisual,
  tension: TensionVisual,
  flow: FlowVisual,
  resistance: ResistanceVisual,
  symmetry: SymmetryVisual,
  range: RangeVisual,
  respiration: RespirationVisual,
  contraction: ContractionVisual,
  gait: GaitVisual,
  
  // Anatomical
  vigor: VigorVisual,
  drive: DriveVisual,
  
  // Human & AI Faces
  metamorphosis: MetamorphosisVisual,
  cognition: CognitionVisual,
  zenith: ZenithVisual,
  duality: DualityVisual,
  entropy: EntropyVisual,
  resonance: ResonanceVisual,
  overclock: OverclockVisual,
  void: VoidVisual,
  nexus: NexusVisual,
  aura: AuraVisual,
  evolution: EvolutionVisual,
  presence: PresenceVisual,
  
  none: () => null
};
