/* =========================================================
   🧠 CORTEX COMPUTATIONAL CORE: INLINE SVG SAPPHIRE PHYSICS
   Strict Medical Palette: Cyan, Teal, Sapphire, Pure White
   Engineered for 60fps GPU Hardware Acceleration
   ========================================================= */

/* --- MASTER CONTAINER --- */
.cortex-wrapper {
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate3d(0, 0, 0);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    will-change: transform, left, top;
}

/* --- LAYER 1: AMBIENT SPATIAL LIGHT BLOOM --- */
.cortex-ambient-halo {
    position: absolute;
    width: 145%;
    height: 145%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 229, 255, 0.42) 0%, rgba(0, 82, 255, 0.18) 48%, transparent 72%);
    filter: blur(14px);
    z-index: 1;
    pointer-events: none;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- THE MASTER ANCHOR: CRYSTAL GLASS SHELL --- */
.cortex-glass-shell {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: none;
    outline: none;
    cursor: pointer;
    z-index: 10;
    padding: 0;
    overflow: hidden;
    background: transparent;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transform: translate3d(0, 0, 0);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

/* --- LAYER 3: THE INLINE SVG ENGINE --- */
.cortex-svg-engine {
    width: 100%;
    height: 100%;
    display: block;
    transform: translate3d(0, 0, 0);
    overflow: visible;
}

/* --- LAYER 4: OPTICAL REFRACTION RIM (CSS Glass Lip) --- */
.cortex-refraction-rim {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: 
        inset 0 0 10px rgba(0, 229, 255, 0.4), /* Vibrant inner cyan glow */
        inset 0 2px 4px rgba(255, 255, 255, 0.75), /* Top crystal glint */
        inset 0 -5px 14px rgba(2, 6, 15, 0.9); /* Deep bottom occlusion */
    z-index: 20;
    pointer-events: none;
}

/* =========================================================
   🌊 SVG INTERNAL ANIMATIONS (Pure GPU Math & WebKit Armor)
   ========================================================= */

/* 🚀 WEBKIT ARMOR: Lock all SVG transforms to exact 50x50 center coordinates */
.plasma-swirl-1, .plasma-swirl-2, .arc-1, .arc-2, .arc-3, .svg-central-spark {
    transform-origin: 50px 50px;
    transform-box: view-box;
}

/* Plasma Swirls */
.plasma-swirl-1 { animation: svgSwirl1 8s infinite alternate ease-in-out; }
.plasma-swirl-2 { animation: svgSwirl2 10s infinite alternate-reverse ease-in-out; }

@keyframes svgSwirl1 {
    0% { transform: scale(1) rotate(0deg); }
    100% { transform: scale(1.15) rotate(25deg) translate(3px, 2px); }
}
@keyframes svgSwirl2 {
    0% { transform: scale(1) rotate(0deg); }
    100% { transform: scale(1.2) rotate(-25deg) translate(-3px, -2px); }
}

/* Neural Filaments Breathing Arcs */
.arc-1 { animation: svgArcBreathe1 7s infinite alternate ease-in-out; }
.arc-2 { animation: svgArcBreathe2 9s infinite alternate-reverse ease-in-out; }
.arc-3 { animation: svgArcBreathe3 6s infinite alternate ease-in-out; }

@keyframes svgArcBreathe1 {
    0% { transform: rotate(-25deg) scaleY(1); stroke-opacity: 0.9; }
    100% { transform: rotate(-18deg) scaleY(1.08); stroke-opacity: 0.6; }
}
@keyframes svgArcBreathe2 {
    0% { transform: rotate(40deg) scaleX(1); stroke-opacity: 0.8; }
    100% { transform: rotate(48deg) scaleX(1.1); stroke-opacity: 0.4; }
}
@keyframes svgArcBreathe3 {
    0% { transform: rotate(-60deg) scale(1); stroke-opacity: 0.4; }
    100% { transform: rotate(-50deg) scale(1.05); stroke-opacity: 0.7; }
}

/* Microscopic Data Motes */
.svg-mote { animation: svgMoteFloat 4s infinite linear; transform-origin: 50px 50px; transform-box: view-box; }
.m1 { animation-delay: 0s; animation-duration: 4s; }
.m2 { animation-delay: 1.2s; animation-duration: 5s; }
.m3 { animation-delay: 2.1s; animation-duration: 4.5s; }
.m4 { animation-delay: 3.2s; animation-duration: 5.5s; }
.m5 { animation-delay: 0.7s; animation-duration: 3.8s; }

@keyframes svgMoteFloat {
    0% { transform: translateY(0px) scale(0.6); opacity: 0; }
    25% { opacity: 0.9; }
    75% { opacity: 0.5; }
    100% { transform: translateY(-25px) scale(1.2); opacity: 0; }
}

/* 🚀 REFINEMENT 1: Specular Glint Drift (Occasional Moving Glass Reflection) */
.svg-specular {
    animation: specularDrift 14s infinite alternate ease-in-out;
    transform-origin: 40px 25px;
    transform-box: view-box;
}
@keyframes specularDrift {
    0% { transform: rotate(0deg) scale(1); opacity: 0.35; }
    50% { transform: rotate(3deg) scale(1.05) translate(1px, -1px); opacity: 0.48; }
    100% { transform: rotate(-2deg) scale(0.98); opacity: 0.3; }
}

/* =========================================================
   💓 STATE CONTROLLER: IDLE (7s PEDIATRIC HEARTBEAT)
   ========================================================= */
.state-idle .cortex-glass-shell {
    animation: pediatricHeartbeat 7s cubic-bezier(0.37, 0, 0.63, 1) infinite;
}
.state-idle .cortex-ambient-halo {
    animation: haloHeartbeat 7s cubic-bezier(0.37, 0, 0.63, 1) infinite;
}
.state-idle .svg-central-spark {
    animation: svgSparkHeartbeat 7s cubic-bezier(0.37, 0, 0.63, 1) infinite;
}

@keyframes pediatricHeartbeat {
    0%, 100% { transform: scale3d(1, 1, 1); }
    20%      { transform: scale3d(1.018, 1.018, 1); } /* Systolic Rise */
    35%      { transform: scale3d(1.004, 1.004, 1); } /* Diastolic Settle */
    50%      { transform: scale3d(1.022, 1.022, 1); } /* Secondary Respiratory Wave */
    70%      { transform: scale3d(1.002, 1.002, 1); } /* Resting Expanse */
}

@keyframes haloHeartbeat {
    0%, 100% { transform: scale3d(1, 1, 1); opacity: 0.6; }
    20%      { transform: scale3d(1.15, 1.15, 1); opacity: 0.9; }
    50%      { transform: scale3d(1.2, 1.2, 1); opacity: 1; }
    70%      { transform: scale3d(1.05, 1.05, 1); opacity: 0.7; }
}

@keyframes svgSparkHeartbeat {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    20%      { transform: scale(1.25); opacity: 1; }
    50%      { transform: scale(1.3); opacity: 1; }
    70%      { transform: scale(1.05); opacity: 0.9; }
}

/* =========================================================
   ⚡ STATE CONTROLLER: THINKING (Active Computation)
   🚀 REFINEMENT 2: Full Neural Network Acceleration across ALL 3 Arcs!
   ========================================================= */
.state-thinking .svg-central-spark {
    fill: #FF3366; /* Alerts to pink computational synthesis */
    animation: activeSvgCompute 1.5s ease-in-out infinite;
}
.state-thinking .cortex-glass-shell {
    animation: activeGlassPulse 1.5s ease-in-out infinite;
}
.state-thinking .cortex-refraction-rim {
    box-shadow: inset 0 0 16px rgba(255, 51, 102, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.9);
}
.state-thinking .arc-1 { stroke: #FF3366; animation-duration: 2.2s; }
.state-thinking .arc-2 { stroke: #00E5FF; animation-duration: 2.6s; }
.state-thinking .arc-3 { stroke: #FFFFFF; animation-duration: 3.0s; stroke-opacity: 0.8; }
.state-thinking .svg-mote { animation-duration: 1.8s; fill: #FF3366; }

@keyframes activeSvgCompute {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50%      { transform: scale(1.4); opacity: 1; }
}
@keyframes activeGlassPulse {
    0%, 100% { transform: scale3d(1, 1, 1); }
    50%      { transform: scale3d(1.045, 1.045, 1); }
}

/* =========================================================
   🎙️ STATE CONTROLLER: SPEAKING (Concentric Ripples)
   ========================================================= */
.state-speaking .cortex-glass-shell {
    animation: speechVibration 0.4s ease-in-out infinite alternate;
}
@keyframes speechVibration {
    0% { transform: scale3d(1, 1, 1); }
    100% { transform: scale3d(1.02, 1.02, 1); }
}

/* --- LAYER 2: NOTIFICATION RINGS --- */
.cortex-orbit-track {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.cortex-satellite {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate3d(-50%, -50%, 0);
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 1px solid var(--brand-cyan, #00E5FF);
    box-shadow: 0 0 14px rgba(0, 229, 255, 0.4);
    opacity: 0;
    animation: expandRingNotify 3.2s cubic-bezier(0.16, 1, 0.3, 1) infinite;
    pointer-events: none;
}

@keyframes expandRingNotify {
    0%   { width: 68px; height: 68px; opacity: 0.9; border-width: 2px; }
    100% { width: 160px; height: 160px; opacity: 0; border-width: 0px; }
}

/* =========================================================
   🔄 BIOMIMETIC SYSTEM REACTIONS
   ========================================================= */
.state-react-scrub .svg-central-spark {
    animation: scrubSvgRipple 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes scrubSvgRipple {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.6); filter: brightness(1.8); }
    100% { transform: scale(1); filter: brightness(1); }
}

.state-react-load .svg-filaments {
    animation: svgFilamentReorg 0.6s ease-out forwards;
}
@keyframes svgFilamentReorg {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.2); opacity: 1; }
    100% { transform: rotate(360deg) scale(1); }
}

.state-react-pulse .cortex-glass-shell::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid #00E5FF;
    animation: dosePulseRing 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: none;
}
@keyframes dosePulseRing {
    0% { transform: scale3d(1, 1, 1); opacity: 1; }
    100% { transform: scale3d(1.8, 1.8, 1); opacity: 0; }
}