/* ======= Screen transitions ======= */
.screen-anim {
    animation: screenIn 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes screenIn {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ======= Staggered card entrance ======= */
.card-in {
    animation: cardIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: var(--stagger, 0ms);
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ======= Section header entrance ======= */
.section-header {
    animation: headerIn 0.3s ease-out backwards;
}

@keyframes headerIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ======= Product add: pop + icon flip ======= */
.product-add-btn.added {
    animation: addPulse 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes addPulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.35) rotate(90deg); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* ======= Fly to cart dot ======= */
.fly-dot {
    position: fixed;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
    z-index: 300;
    pointer-events: none;
    will-change: transform;
}

.fly-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: inherit;
    animation: flyRing 0.55s ease-out forwards;
}

@keyframes flyRing {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2.4); opacity: 0; }
}

/* ======= Cart bar reveal ======= */
.cart-bar {
    animation: cartBarIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cartBarIn {
    from {
        transform: translateY(120%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ======= Cart count bump ======= */
.cart-count.bump {
    animation: bump 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bump {
    0% { transform: scale(1); }
    40% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

/* ======= Cart item entrance ======= */
.cart-item {
    animation: itemIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: var(--stagger, 0ms);
}

@keyframes itemIn {
    from {
        opacity: 0;
        transform: translateX(-16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ======= Quantity pop ======= */
.quantity-value.qty-pop,
.cart-item-qty-value.qty-pop {
    animation: qtyPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes qtyPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* ======= Payment option select ======= */
.payment-option {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, background 0.2s ease;
}

.payment-option:active {
    transform: scale(0.97);
}

.payment-option.selected {
    animation: optionSelect 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes optionSelect {
    0% { transform: scale(1); }
    40% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* ======= Success screen ======= */
.success-icon {
    width: 88px;
    height: 88px;
    position: relative;
}

.success-icon-ring {
    position: absolute;
    inset: -14px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0;
    animation: successRing 1s cubic-bezier(0.22, 1, 0.36, 1) 0.2s forwards;
}

@keyframes successRing {
    0% {
        transform: scale(0.7);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.25);
        opacity: 0;
    }
}

.success-icon svg {
    overflow: visible;
    animation: iconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.success-icon svg path {
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: drawPath 0.5s ease-out 0.35s forwards;
}

.success-icon svg path:last-child {
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
    animation: drawPath 0.4s ease-out 0.6s forwards;
}

@keyframes iconPop {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes drawPath {
    to {
        stroke-dashoffset: 0;
    }
}

/* ======= Profile stagger (only when overlay becomes active) ======= */
.profile-overlay.active .profile-screen .profile-menu-item {
    animation: menuItemIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.profile-overlay.active .profile-screen .profile-menu-item:nth-child(1) { animation-delay: 0.05s; }
.profile-overlay.active .profile-screen .profile-menu-item:nth-child(2) { animation-delay: 0.1s; }
.profile-overlay.active .profile-screen .profile-menu-item:nth-child(3) { animation-delay: 0.15s; }
.profile-overlay.active .profile-screen .profile-menu-item:nth-child(4) { animation-delay: 0.2s; }
.profile-overlay.active .profile-screen .profile-menu-item:nth-child(5) { animation-delay: 0.25s; }

.profile-overlay.active .profile-screen .profile-user {
    animation: profileUserIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.profile-overlay.active .profile-screen .profile-menu,
.profile-overlay.active .profile-screen .profile-section,
.profile-overlay.active .profile-screen .profile-footer {
    animation: profileBlockIn 0.3s ease-out 0.1s both;
}

.profile-overlay.active .profile-screen .profile-section {
    animation-delay: 0.18s;
}

.profile-overlay.active .profile-screen .profile-footer {
    animation-delay: 0.24s;
}

/* ======= Back button icon slide ======= */
.back-btn svg {
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.back-btn:hover svg {
    transform: translateX(-2px);
}

/* ======= Quantity button press ======= */
.quantity-btn,
.cart-item-qty-btn {
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ======= Price highlight flash ======= */
.price-flash {
    animation: priceFlash 0.5s ease-out;
}

@keyframes priceFlash {
    0% { transform: scale(1); }
    30% { transform: scale(1.12); color: var(--accent); }
    100% { transform: scale(1); }
}

/* ======= Success content entrance ======= */
.success-content > * {
    animation: successContentIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.success-content > *:nth-child(1) { animation-delay: 0.05s; }
.success-content > *:nth-child(2) { animation-delay: 0.15s; }
.success-content > *:nth-child(3) { animation-delay: 0.25s; }
.success-content > *:nth-child(4) { animation-delay: 0.35s; }

@keyframes successContentIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001s !important;
        animation-delay: 0s !important;
        transition-duration: 0.001s !important;
    }
}