/* 
  OmniFly CSS Premium v3.1: Clarity Tuned High-Fidelity Neon Sovereign
  Optimized for total visibility against cosmic background environments.
*/

.omnifly-container {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    perspective: 1200px;
    contain: strict;
    /* Smooth z-index switch is handled via class toggle */
}

/* FOREGROUND STATE: butterfly has arrived at cursor */
.omnifly-container.butterfly-arrived {
    z-index: 99999;
}

.butterfly-entity {
    position: absolute;
    width: 150px;
    height: 150px;
    transform-style: preserve-3d;
    will-change: transform;

    /* Background state: dim and subtle */
    opacity: 0.4;
    filter: drop-shadow(0 0 20px rgba(0, 212, 255, 0.6)) drop-shadow(0 0 40px rgba(123, 97, 255, 0.3));

    /* Smooth transition when switching between background and foreground */
    transition: opacity 0.7s ease, filter 0.7s ease;
}

/* FOREGROUND STATE: bright glow when sitting at cursor */
.butterfly-arrived .butterfly-entity {
    opacity: 0.90;
    filter: drop-shadow(0 0 30px rgba(0, 212, 255, 0.95)) drop-shadow(0 0 60px rgba(123, 97, 255, 0.6)) drop-shadow(0 0 12px rgba(255, 255, 255, 0.3));
}

/* Refactored High-Fidelity Vector Geometry Support */
.svg-wing {
    width: 100%; height: 100%;
    filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.4));
}

.b-body-svg {
    width: 40px;
    height: 100px;
    filter: drop-shadow(0 0 12px rgba(255,255,255,0.4));
}

/* Body Positioning */
.b-body-wrap {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
}

/* Core SVG Wing Containers */
.wing-set {
    position: absolute;
    top: 50%;
    width: 100px; /* Precision width for standard path mappings */
    height: 150px;
    margin-top: -75px; /* Align exact v-center */
    transform-style: preserve-3d;
}

.wing-set.left-side {
    right: 50%;
    transform-origin: center right;
    /* Assigned custom high-acceleration ease curve to simulate muscular tension */
    animation: realisticFlapLeft var(--flap-ms, 0.26s) cubic-bezier(0.445, 0.05, 0.55, 0.95) infinite alternate;
}

.wing-set.right-side {
    left: 50%;
    transform-origin: center left;
    animation: realisticFlapRight var(--flap-ms, 0.26s) cubic-bezier(0.445, 0.05, 0.55, 0.95) infinite alternate;
}

/* 
   Precision Biological Flap Oscillations 
   Incorporates 3D cupping (rotateX) and pitch-angle shift (rotateZ) for realism.
*/
@keyframes realisticFlapLeft {
    0% { transform: rotateY(5deg) rotateX(0deg) rotateZ(-5deg); }
    100% { transform: rotateY(78deg) rotateX(-15deg) rotateZ(-8deg); }
}

@keyframes realisticFlapRight {
    0% { transform: rotateY(-5deg) rotateX(0deg) rotateZ(5deg); }
    100% { transform: rotateY(-78deg) rotateX(-15deg) rotateZ(8deg); }
}


/* Nano-Ash Cinematic Simulation */
.b-ash-particle {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0; /* Align with active butterfly plane */
    animation: ashDrift 1.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    will-change: transform, opacity;
    box-shadow: 0 0 8px #ff3300, 0 0 15px #ff7700;
    background: radial-gradient(circle, #fff, #ff2200);
}

@keyframes ashDrift {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; }
    100% { transform: translate(var(--xDist), var(--yDist)) scale(0.1) rotate(45deg); opacity: 0; filter: blur(1px); }
}
