/**
 * FurryNestLab Module V1:
 * Dynamic Floating Mini-Cart Icon with Live Milestone Glow & Badge Pulse Engine
 *
 * 1. Persistent Luxury Floating Bubble at Bottom-Right Corner
 * 2. Real-Time Badge Count & Keyframe Pulse Animation
 * 3. Radiant Multi-Tier Milestone Glow Rings ($50, $75, $100)
 * 4. Micro Goal-Gradient Tooltip with Real-Time Progress Bar
 * 5. Automatic Mobile Elevation (84px) Above Mobile Sticky Bar on PDP
 * 6. Smooth Concealment when Slide-Out Drawer Cart is Open
 */

/* 1. Main Floating Container */
#fnl-floating-mini-cart {
    position: fixed;
    bottom: 26px;
    right: 26px;
    z-index: 99998;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    font-family: var(--font-body, 'DM Sans', -apple-system, sans-serif);
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), bottom 0.3s ease;
}

/* 2. Floating Action Button */
#fnl-floating-mini-cart .fnl-floating-cart-btn {
    position: relative;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
    color: #ffffff;
    border: none;
    outline: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    pointer-events: auto;
    box-shadow: 0 10px 25px -4px rgba(13, 148, 136, 0.45), 0 4px 12px -2px rgba(0, 0, 0, 0.12);
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s ease, background 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

#fnl-floating-mini-cart .fnl-floating-cart-btn:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 14px 30px -4px rgba(13, 148, 136, 0.55), 0 6px 16px -2px rgba(0, 0, 0, 0.16);
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
}

#fnl-floating-mini-cart .fnl-floating-cart-btn:active {
    transform: scale(0.94);
    box-shadow: 0 4px 12px -2px rgba(13, 148, 136, 0.35);
}

/* 3. SVG Shopping Bag Icon */
#fnl-floating-mini-cart .fnl-cart-svg {
    width: 25px;
    height: 25px;
    stroke: #ffffff;
    stroke-width: 2.2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s ease;
}

#fnl-floating-mini-cart .fnl-floating-cart-btn:hover .fnl-cart-svg {
    transform: rotate(-6deg) scale(1.05);
}

/* 4. Live Quantity Count Badge */
#fnl-floating-mini-cart .fnl-floating-cart-count {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 9999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transform-origin: center;
    pointer-events: none;
    box-sizing: border-box;
}

#fnl-floating-mini-cart.is-empty .fnl-floating-cart-count {
    background: #64748b;
    opacity: 0.9;
}

/* Badge Pulse Animation on Cart Modification */
#fnl-floating-mini-cart .fnl-floating-cart-count.is-pulsing {
    animation: fnlBadgePulsePop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes fnlBadgePulsePop {
    0% { transform: scale(1); }
    40% { transform: scale(1.45); }
    75% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* 5. Radiant Multi-Tier Milestone Glow Ring */
#fnl-floating-mini-cart .fnl-milestone-glow-ring {
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

#fnl-floating-mini-cart.has-milestone-glow .fnl-milestone-glow-ring {
    opacity: 1;
    animation: fnlMilestoneRingPulse 2.4s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

/* Tier 1: $50+ Free US Shipping Unlocked */
#fnl-floating-mini-cart.tier-1 .fnl-milestone-glow-ring {
    border-color: #0d9488;
    box-shadow: 0 0 16px rgba(13, 148, 136, 0.65);
}

/* Tier 2: $75+ Pet Guide & Priority Dispatch Unlocked */
#fnl-floating-mini-cart.tier-2 .fnl-milestone-glow-ring {
    border-color: #06b6d4;
    box-shadow: 0 0 18px rgba(6, 182, 212, 0.75);
}

/* Tier 3: $100+ VIP 5% Extra OFF Unlocked (Luxury Gold) */
#fnl-floating-mini-cart.tier-3 .fnl-milestone-glow-ring {
    border-color: #f59e0b;
    box-shadow: 0 0 22px rgba(245, 158, 11, 0.85);
}

#fnl-floating-mini-cart.tier-3 .fnl-floating-cart-btn {
    background: linear-gradient(135deg, #0d9488 0%, #b45309 100%);
}

@keyframes fnlMilestoneRingPulse {
    0% {
        transform: scale(0.96);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.25;
    }
    100% {
        transform: scale(0.96);
        opacity: 0.9;
    }
}

/* 6. Micro Goal-Gradient Tooltip */
#fnl-floating-mini-cart .fnl-floating-tooltip {
    position: absolute;
    bottom: calc(100% + 14px);
    right: 0;
    min-width: 210px;
    max-width: 270px;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: 0 12px 30px -4px rgba(15, 23, 42, 0.45), 0 4px 10px -2px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10;
}

#fnl-floating-mini-cart .fnl-floating-tooltip::after {
    content: "";
    position: absolute;
    bottom: -5px;
    right: 23px;
    width: 10px;
    height: 10px;
    background: #0f172a;
    transform: rotate(45deg);
    border-radius: 2px;
}

#fnl-floating-mini-cart .fnl-tooltip-text {
    display: block;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    color: #f1f5f9;
    text-align: left;
}

#fnl-floating-mini-cart .fnl-tooltip-progress-track {
    display: block;
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 9999px;
    overflow: hidden;
    margin-top: 8px;
}

#fnl-floating-mini-cart .fnl-tooltip-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #14b8a6 0%, #38bdf8 100%);
    border-radius: 9999px;
    transition: width 0.4s ease;
}

#fnl-floating-mini-cart.tier-3 .fnl-tooltip-progress-bar {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

/* Tooltip Hover and Auto-Display Trigger */
#fnl-floating-mini-cart:hover .fnl-floating-tooltip,
#fnl-floating-mini-cart.show-tooltip .fnl-floating-tooltip {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* 7. Automatic Concealment when Slide-Out Drawer Cart is Open */
body.fnl-drawer-open #fnl-floating-mini-cart {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.85);
}

/* 8. Mobile Responsiveness & Single Product Page (PDP) Elevation */
@media (max-width: 768px) {
    #fnl-floating-mini-cart {
        bottom: 20px;
        right: 16px;
    }
    #fnl-floating-mini-cart .fnl-floating-cart-btn {
        width: 52px;
        height: 52px;
    }
    #fnl-floating-mini-cart .fnl-cart-svg {
        width: 22px;
        height: 22px;
    }
    #fnl-floating-mini-cart .fnl-floating-cart-count {
        min-width: 20px;
        height: 20px;
        font-size: 10px;
        line-height: 20px;
        top: -2px;
        right: -2px;
    }
}

/* PDP Mobile Elevation: 84px to float smoothly ABOVE the Mobile Sticky Bar (bottom: 0, height: ~68px) */
body.single-product #fnl-floating-mini-cart {
    bottom: 84px;
}
