﻿/* =========================================================
   Charme FX — hiệu ứng storefront
   1) Hiện dần khi cuộn trang (charme-scroll-fx.js, trừ trang chủ)
   2) Nút đang xử lý (charme-cart-fx.js)
   3) Chai nước hoa bay vào giỏ hàng (charme-cart-fx.js)
   ========================================================= */

/* ---------- 1. Hiện dần khi cuộn ---------- */
.sfx {
    opacity: 0;
    transform: translate3d(0, 32px, 0);
    transition: opacity .7s ease, transform .8s cubic-bezier(.2, .65, .25, 1);
    transition-delay: var(--sfx-delay, 0ms);
}

.sfx--zoom {
    transform: translate3d(0, 24px, 0) scale(.94);
}

.sfx--left {
    transform: translate3d(-36px, 0, 0);
}

.sfx--right {
    transform: translate3d(36px, 0, 0);
}

.sfx--fade {
    transform: none;
}

.sfx.sfx-in {
    opacity: 1;
    transform: none;
}

/* Thanh tiến độ đọc (bài viết, mùi hương, chi tiết sản phẩm) */
.sfx-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10050;
    width: 100%;
    height: 3px;
    pointer-events: none;
    transform: scaleX(0);
    transform-origin: 0 50%;
    background: linear-gradient(90deg, var(--home-coupon-light, #f1c150), var(--shop-color-hover, #01123F));
}

/* ---------- 2. Nút đang xử lý ---------- */
.cfx-rel {
    position: relative !important;
}

.cfx-loading {
    pointer-events: none !important;
    color: transparent !important;
    cursor: progress;
}

.cfx-loading > * {
    opacity: 0 !important;
}

.cfx-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid var(--cfx-spin, #fff);
    border-right-color: transparent;
    border-radius: 50%;
    opacity: 1;
    animation: cfx-spin .7s linear infinite;
}

.cfx-loading--done::after {
    border-color: var(--cfx-spin, #fff);
    border-width: 0 2px 2px 0;
    border-radius: 0;
    width: 7px;
    height: 13px;
    margin: -9px 0 0 -4px;
    transform: rotate(45deg);
    animation: cfx-check .3s ease-out both;
}

@keyframes cfx-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes cfx-check {
    from {
        opacity: 0;
        transform: rotate(45deg) scale(.4);
    }

    to {
        opacity: 1;
        transform: rotate(45deg) scale(1);
    }
}

/* ---------- 3. Chai bay vào giỏ ---------- */
.cfx-fly {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2147483000;
    pointer-events: none;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(16, 16, 16, .22), 0 0 0 1px rgba(0, 0, 0, .04);
    overflow: hidden;
    will-change: transform, opacity;
}

.cfx-fly img,
.cfx-fly svg {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cfx-mist {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2147482999;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle, #fff 0, var(--home-coupon-light, #f1c150) 45%, rgba(241, 193, 80, 0) 72%);
    animation: cfx-mist .7s ease-out forwards;
}

@keyframes cfx-mist {
    from {
        opacity: .95;
        transform: translate3d(var(--x), var(--y), 0) scale(1);
    }

    to {
        opacity: 0;
        transform: translate3d(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy)), 0) scale(.2);
    }
}

.cfx-ring {
    position: fixed;
    z-index: 2147482998;
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    border: 2px solid var(--home-coupon-light, #f1c150);
    border-radius: 50%;
    pointer-events: none;
    animation: cfx-ring .55s ease-out forwards;
}

@keyframes cfx-ring {
    from {
        opacity: .9;
        transform: scale(.3);
    }

    to {
        opacity: 0;
        transform: scale(1.5);
    }
}

.cfx-cart-bump {
    animation: cfx-bump .6s cubic-bezier(.36, .07, .19, .97);
}

@keyframes cfx-bump {
    0% {
        transform: scale(1);
    }

    25% {
        transform: scale(1.28) rotate(-8deg);
    }

    50% {
        transform: scale(.92) rotate(6deg);
    }

    75% {
        transform: scale(1.08) rotate(-3deg);
    }

    100% {
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .sfx,
    .sfx--zoom,
    .sfx--left,
    .sfx--right {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .cfx-cart-bump,
    .cfx-loading::after {
        animation-duration: 1.4s;
    }
}
