/* ==========================================================================
   FlyCrawl Custom Scrollbar & Cyber Beetle Mascot Companion Styles
   ========================================================================== */

/* 1. Custom Sleek Browser Scrollbar (Webkit: Chrome, Edge, Safari, Brave, Opera) */
html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
    width: 10px !important;
    height: 10px !important;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
*::-webkit-scrollbar-track {
    background: #0B0F19 !important;
    border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #10B981 0%, #059669 100%) !important;
    border-radius: 9999px !important;
    border: 2px solid #0B0F19 !important;
    box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.3) !important;
    transition: background 0.15s ease !important;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #34D399 0%, #10B981 100%) !important;
}

html::-webkit-scrollbar-corner,
body::-webkit-scrollbar-corner {
    background: #0B0F19 !important;
}

/* 2. Standard CSS Cross-Browser Scrollbar (Firefox Only - isolated so Webkit is not overridden) */
@supports (-moz-appearance: none) {
    html, body {
        scrollbar-width: thin !important;
        scrollbar-color: #10B981 #0B0F19 !important;
    }
}

/* 3. Floating Cyber Beetle Companion Mascot Container */
#fcScrollCompanion {
    position: fixed !important;
    right: 14px !important;
    left: auto !important;
    top: 0 !important;
    width: 42px !important;
    height: 50px !important;
    z-index: 999999 !important;
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    user-select: none !important;
    touch-action: none !important;
    will-change: transform;
    opacity: 1 !important;
    transition: opacity 0.2s ease;
}

[dir="rtl"] #fcScrollCompanion {
    left: 14px !important;
    right: auto !important;
}

#fcScrollCompanion:hover {
    opacity: 1 !important;
    transform: scale(1.08);
}

#fcScrollCompanion:active {
    transform: scale(0.95);
}

/* SVG Cyber Beetle Artwork Core */
.fc-beetle-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
    transform-origin: 50% 50%;
    transition: transform 0.28s cubic-bezier(0.34, 1.3, 0.64, 1);
    /* Hardware accelerated drop shadow without software canvas rasterization */
    filter: drop-shadow(0 2px 8px rgba(16, 185, 129, 0.5));
}

#fcScrollCompanion:hover .fc-beetle-svg {
    filter: drop-shadow(0 3px 12px rgba(52, 211, 153, 0.85));
}

/* Direction Flip: smooth 180deg flip between heading-down and heading-up */
.fc-crawler-heading-down .fc-beetle-svg {
    transform: rotate(0deg);
}

.fc-crawler-heading-up .fc-beetle-svg {
    transform: rotate(180deg);
}

/* Thruster / Tail Glow Animation */
.fc-beetle-tail {
    transform-origin: 32px 64px;
    transition: opacity 0.2s ease;
}

.fc-scrolling .fc-beetle-tail {
    animation: fcBeetlePulse 0.4s infinite alternate ease-in-out;
}

/* Ladybug Wing Shell Breathing / Hover */
.fc-beetle-wing-left {
    transform-origin: 31px 22px;
    transition: transform 0.2s ease;
}

.fc-beetle-wing-right {
    transform-origin: 33px 22px;
    transition: transform 0.2s ease;
}

.fc-scrolling .fc-beetle-wing-left {
    transform: rotate(-3deg);
}

.fc-scrolling .fc-beetle-wing-right {
    transform: rotate(3deg);
}

/* Cyber Spots Pulse */
.fc-spot {
    transition: opacity 0.2s ease;
}

.fc-scrolling .fc-spot {
    animation: fcSpotGlow 0.6s infinite alternate ease-in-out;
}

/* Legs: Cute, tucked micro-movements on scroll */
.fc-leg-left {
    transform-origin: 22px 38px;
}

.fc-leg-right {
    transform-origin: 42px 38px;
}

.fc-scrolling .fc-leg-left {
    animation: fcLegWiggleL 0.15s infinite alternate ease-in-out;
}

.fc-scrolling .fc-leg-right {
    animation: fcLegWiggleR 0.15s infinite alternate ease-in-out;
}

/* 4. Interactive Scroll HUD Percentage Tooltip */
.fc-crawler-hud {
    position: absolute;
    top: 50%;
    right: calc(100% + 10px);
    transform: translateY(-50%) scale(0.9);
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(52, 211, 153, 0.4);
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    font-family: var(--font-code, 'Fira Code', 'Consolas', monospace);
    color: #34D399;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 4px;
}

[dir="rtl"] .fc-crawler-hud {
    right: auto;
    left: calc(100% + 10px);
}

#fcScrollCompanion:hover .fc-crawler-hud,
#fcScrollCompanion.fc-show-hud .fc-crawler-hud {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* 5. Keyframes (Hardware Accelerated Only) */
@keyframes fcBeetlePulse {
    0% {
        transform: scale(0.95);
        opacity: 0.85;
    }
    100% {
        transform: scale(1.15);
        opacity: 1;
    }
}

@keyframes fcSpotGlow {
    0% {
        opacity: 0.7;
    }
    100% {
        opacity: 1;
    }
}

@keyframes fcLegWiggleL {
    0% { transform: rotate(-4deg); }
    100% { transform: rotate(4deg); }
}

@keyframes fcLegWiggleR {
    0% { transform: rotate(4deg); }
    100% { transform: rotate(-4deg); }
}

/* 6. Adaptive Mobile & Tablet Responsiveness (< 768px) */
@media (max-width: 768px) {
    #fcScrollCompanion {
        width: 26px;
        height: 32px;
        right: 4px;
        opacity: 0.8;
    }
    
    [dir="rtl"] #fcScrollCompanion {
        right: 4px;
    }

    .fc-crawler-hud {
        display: none !important;
    }

    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}

/* 7. Accessibility: Respect User Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    #fcScrollCompanion,
    .fc-beetle-svg,
    .fc-beetle-tail,
    .fc-beetle-wing-left,
    .fc-beetle-wing-right,
    .fc-scrolling .fc-leg-left,
    .fc-scrolling .fc-leg-right,
    .fc-scrolling .fc-spot {
        animation: none !important;
        transition: none !important;
    }
}
