/*
 * 11.11 mega sale — product card + product view.
 * Applies only to products rendered with `.mega-card` / `.mega-*` markup
 * (MegaSaleHelper::isActive). Everything animates transform / opacity /
 * background-position, pauses off-screen (.mega-live is toggled by
 * mega-1111.js) and switches off under prefers-reduced-motion.
 */

@property --mega-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

:root {
    --mega-orange: #ff5a00;
    --mega-pink: #ff2e7e;
    --mega-violet: #8b3dff;
    --mega-blue: #006bff;
    --mega-hot: linear-gradient(100deg, #ff5a00 0%, #ff2e7e 55%, #8b3dff 100%);
    --mega-ring: conic-gradient(from var(--mega-angle), #ff5a00, #ff2e7e, #8b3dff, #006bff, #00c2ff, #ff5a00);
}

/* ---------- Card shell: rotating gradient ring + glow ---------- */

.product__item.mega-card {
    padding: 13px;
    border: 2px solid transparent;
    background:
        linear-gradient(#fff, #fff) padding-box,
        var(--mega-ring) border-box;
    box-shadow: 0 10px 30px rgba(255, 46, 126, .10), 0 2px 8px rgba(20, 33, 61, .05);
    transform-style: preserve-3d;
    transition: transform .35s cubic-bezier(.2, .8, .2, 1), box-shadow .35s ease;
    isolation: isolate;
}

.product__item.mega-card.mega-live {
    animation: mega-spin 6s linear infinite;
}

@keyframes mega-spin {
    to { --mega-angle: 360deg; }
}

/* Cursor-following shine; --mx/--my are set by mega-1111.js on pointer devices */
.product__item.mega-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 9;
    opacity: 0;
    background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 60%);
    mix-blend-mode: soft-light;
    transition: opacity .3s ease;
}

@media (hover: hover) and (pointer: fine) {
    .product__item.mega-card:hover {
        transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-6px);
        box-shadow: 0 22px 44px rgba(255, 46, 126, .22), 0 8px 18px rgba(139, 61, 255, .14);
    }

    .product__item.mega-card:hover::after {
        opacity: 1;
    }

    .product__item.mega-card:hover .product__item-img img {
        transform: scale(1.06) translateZ(0);
    }
}

.product__item.mega-card .product__item-img img {
    transition: transform .5s cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Badge: flowing gradient + shimmer sweep + bolt ---------- */

.pr_flash.mega-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    font-weight: 700;
    letter-spacing: .02em;
    background: linear-gradient(90deg, #ff5a00, #ff2e7e, #8b3dff, #ff2e7e, #ff5a00);
    background-size: 300% 100%;
    box-shadow: 0 4px 14px rgba(255, 46, 126, .35);
    animation: mega-flow 6s linear infinite, mega-pop .55s cubic-bezier(.3, 1.6, .5, 1) both;
}

.pr_flash.mega-badge::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    width: 45%;
    background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .65), rgba(255, 255, 255, 0));
    transform: skewX(-20deg);
    animation: mega-sweep 3.2s ease-in-out infinite;
}

.mega-badge__bolt {
    flex: none;
    color: #fff36b;
    filter: drop-shadow(0 0 4px rgba(255, 243, 107, .9));
    animation: mega-bolt 1.6s ease-in-out infinite;
}

.mega-badge__text {
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdp-gallery .pr_flash.mega-badge--lg {
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 9px;
}

@keyframes mega-flow {
    to { background-position: 300% 0; }
}

@keyframes mega-sweep {
    0%, 55% { left: -60%; }
    100% { left: 130%; }
}

@keyframes mega-bolt {
    0%, 100% { transform: scale(1) rotate(0deg); }
    15% { transform: scale(1.35) rotate(-12deg); }
    30% { transform: scale(1) rotate(0deg); }
}

@keyframes mega-pop {
    from { transform: scale(.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ---------- Countdown pill over the card image ---------- */

/* The image box is not positioned when Swiper has not initialised it */
.mega-card .product__item-img {
    position: relative;
}

.mega-timer {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px 4px 7px;
    border-radius: 999px;
    color: #fff;
    font: 700 12px/1.2 Inter, system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    background: rgba(20, 16, 40, .72);
    -webkit-backdrop-filter: blur(8px) saturate(160%);
    backdrop-filter: blur(8px) saturate(160%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .14) inset, 0 6px 16px rgba(20, 16, 40, .25);
}

.mega-timer svg {
    color: #ffb36b;
}

.mega-live .mega-timer svg,
.mega-timer--gallery svg {
    animation: mega-tick 1s steps(1) infinite;
}

.mega-timer.is-urgent {
    background: linear-gradient(100deg, rgba(255, 46, 126, .92), rgba(255, 90, 0, .92));
}

.mega-timer.is-urgent svg {
    color: #fff;
}

.mega-timer.is-over {
    display: none;
}

.mega-timer--gallery {
    left: 14px;
    top: 50px;
    bottom: auto;
    font-size: 12px;
    padding: 5px 10px 5px 8px;
}

@keyframes mega-tick {
    50% { transform: rotate(12deg); }
}

/* ---------- Prices ---------- */

.mega-card .product__item-price {
    background: var(--mega-hot);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--mega-pink);
}

.mega-card .product__item-price img {
    -webkit-text-fill-color: initial;
}

/* Strike-through that draws itself in */
.mega-card .product__item-old--price {
    position: relative;
    text-decoration: none !important;
}

.mega-card .product__item-old--price::after {
    content: "";
    position: absolute;
    left: -2px;
    right: -2px;
    top: 52%;
    height: 1.5px;
    border-radius: 2px;
    background: #ff2e7e;
    transform-origin: left center;
    transform: scaleX(1);
}

.mega-card.mega-seen .product__item-old--price::after {
    animation: mega-strike .6s .15s cubic-bezier(.6, 0, .2, 1) both;
}

@keyframes mega-strike {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.mega-off {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    color: #fff;
    font: 800 11px/16px Inter, system-ui, sans-serif;
    background: var(--mega-hot);
    box-shadow: 0 3px 10px rgba(255, 46, 126, .35);
    transform-origin: center;
}

.mega-card.mega-seen .mega-off {
    animation: mega-pop .5s .35s cubic-bezier(.3, 1.6, .5, 1) both, mega-wiggle 4s 1.5s ease-in-out infinite;
}

@keyframes mega-wiggle {
    0%, 88%, 100% { transform: rotate(0deg) scale(1); }
    91% { transform: rotate(-8deg) scale(1.12); }
    94% { transform: rotate(7deg) scale(1.12); }
    97% { transform: rotate(-3deg) scale(1.05); }
}

/* Buy button: shine sweep on hover */
.mega-card .btn-primary-custom {
    position: relative;
    overflow: hidden;
}

.mega-card .btn-primary-custom::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -70%;
    width: 50%;
    background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .45), rgba(255, 255, 255, 0));
    transform: skewX(-20deg);
    pointer-events: none;
}

.mega-card:hover .btn-primary-custom::after {
    animation: mega-sweep-fast .8s ease-out;
}

@keyframes mega-sweep-fast {
    from { left: -70%; }
    to { left: 130%; }
}

/* Add-to-cart particle burst (spawned by mega-1111.js) */
.mega-spark {
    position: fixed;
    z-index: 100000;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    pointer-events: none;
    animation: mega-burst .75s cubic-bezier(.15, .7, .3, 1) forwards;
}

@keyframes mega-burst {
    0% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2) rotate(var(--rot)); opacity: 0; }
}

/* ---------- Product view: deal panel ---------- */

.mega-deal {
    position: relative;
    overflow: hidden;
    margin: 0 0 14px;
    padding: 14px 16px;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(115deg, #ff5a00 0%, #ff2e7e 48%, #8b3dff 100%);
    background-size: 200% 200%;
    box-shadow: 0 14px 34px rgba(255, 46, 126, .28);
    animation: mega-flow-pdp 8s ease-in-out infinite alternate, mega-rise .6s cubic-bezier(.2, .8, .2, 1) both;
}

/* Soft drifting light blobs */
.mega-deal::before,
.mega-deal::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(18px);
    opacity: .55;
}

.mega-deal::before {
    width: 160px;
    height: 160px;
    top: -70px;
    right: -30px;
    background: #ffd36b;
    animation: mega-drift 7s ease-in-out infinite alternate;
}

.mega-deal::after {
    width: 140px;
    height: 140px;
    bottom: -80px;
    left: 20%;
    background: #00c2ff;
    opacity: .35;
    animation: mega-drift 9s ease-in-out infinite alternate-reverse;
}

.mega-deal > * {
    position: relative;
    z-index: 1;
}

.mega-deal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.mega-deal__title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: 800 14px/1.25 Inter, system-ui, sans-serif;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.mega-deal__title svg {
    flex: none;
    color: #fff36b;
    filter: drop-shadow(0 0 6px rgba(255, 243, 107, .9));
    animation: mega-bolt 1.6s ease-in-out infinite;
}

.mega-deal__off {
    flex: none;
    padding: 4px 12px;
    border-radius: 999px;
    color: #ff2e7e;
    background: #fff;
    font: 900 18px/1.1 Inter, system-ui, sans-serif;
    box-shadow: 0 6px 16px rgba(20, 16, 40, .2);
    animation: mega-pop .55s .25s cubic-bezier(.3, 1.6, .5, 1) both, mega-wiggle 4s 2s ease-in-out infinite;
}

.mega-deal__timer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.mega-deal__label {
    font: 600 13px/1.2 Inter, system-ui, sans-serif;
    opacity: .92;
}

.mega-deal__clock {
    display: inline-flex;
    gap: 6px;
}

.mega-seg {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    min-width: 46px;
    padding: 5px 6px 4px;
    border-radius: 10px;
    background: rgba(20, 16, 40, .28);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .22) inset;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.mega-seg b {
    display: block;
    font: 800 20px/1 Inter, system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}

.mega-seg b.is-flip {
    animation: mega-flip .45s cubic-bezier(.3, 1.4, .5, 1);
}

.mega-seg small {
    margin-top: 2px;
    font: 600 10px/1 Inter, system-ui, sans-serif;
    opacity: .85;
    text-transform: lowercase;
}

.mega-deal.is-urgent .mega-seg {
    background: rgba(255, 255, 255, .22);
}

.mega-deal.is-over .mega-deal__timer {
    display: none;
}

@keyframes mega-flip {
    0% { transform: translateY(-55%) rotateX(70deg); opacity: 0; }
    100% { transform: translateY(0) rotateX(0deg); opacity: 1; }
}

@keyframes mega-flow-pdp {
    from { background-position: 0% 50%; }
    to { background-position: 100% 50%; }
}

@keyframes mega-drift {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(-40px, 20px) scale(1.2); }
}

@keyframes mega-rise {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Price under the deal panel */
.mega-price .price-box_new-price {
    background: var(--mega-hot);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--mega-pink);
    animation: mega-rise .6s .15s cubic-bezier(.2, .8, .2, 1) both;
}

.mega-price .price-box_new-price img {
    -webkit-text-fill-color: initial;
}

.mega-price .price-box__saved {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    color: #0b8f6a;
    background: linear-gradient(90deg, #e3fbf2, #d2f7ff, #e3fbf2);
    background-size: 200% 100%;
    font-weight: 700;
    animation: mega-flow 4s linear infinite;
}

@media (max-width: 575.98px) {
    .mega-timer {
        left: 6px;
        bottom: 6px;
        font-size: 11px;
        padding: 3px 7px 3px 6px;
    }

    .mega-deal {
        padding: 12px;
        border-radius: 14px;
    }

    .mega-deal__title {
        font-size: 12px;
    }

    .mega-deal__off {
        font-size: 16px;
        padding: 3px 10px;
    }

    .mega-seg {
        min-width: 40px;
    }

    .mega-seg b {
        font-size: 17px;
    }
}

/* Pause everything that is off-screen (toggled by IntersectionObserver) */
.mega-card:not(.mega-live) .pr_flash.mega-badge,
.mega-card:not(.mega-live) .pr_flash.mega-badge::after,
.mega-card:not(.mega-live) .mega-badge__bolt,
.mega-card:not(.mega-live) .mega-off {
    animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
    .product__item.mega-card,
    .product__item.mega-card.mega-live,
    .mega-card *,
    .mega-card *::before,
    .mega-card *::after,
    .mega-badge,
    .mega-badge::after,
    .mega-badge__bolt,
    .mega-timer svg,
    .mega-deal,
    .mega-deal *,
    .mega-deal::before,
    .mega-deal::after,
    .mega-price .price-box_new-price,
    .mega-price .price-box__saved {
        animation: none !important;
        transition: none !important;
    }

    .product__item.mega-card:hover {
        transform: none;
    }

    .pr_flash.mega-badge::after,
    .mega-spark {
        display: none;
    }
}
