/* ==========================================================================
   Animated "Add to Cart" Button (Truck & Box Slide Animation)
   Reference: @codewith_muhilan Add to Cart Animation
   ========================================================================== */

:root {
    --cart-btn-bg: var(--color-primary, #0758A2);
    --cart-btn-color: #ffffff;
    --cart-btn-hover-bg: var(--color-primary-hover, #054178);
    --cart-btn-box-color: #ffb136; /* gold/amber */
    --cart-btn-height: 42px;
}

/* Base button styling */
.cart-button,
.aac-btn {
    position: relative;
    padding: 10px 16px;
    width: 100%;
    min-height: var(--cart-btn-height, 42px);
    height: var(--cart-btn-height, 42px);
    border: 0;
    border-radius: var(--radius-default, 6px);
    background-color: var(--cart-btn-bg, #0758A2);
    outline: none;
    cursor: pointer;
    color: var(--cart-btn-color, #ffffff);
    transition: background-color 0.25s ease-in-out, transform 0.15s ease-in-out, box-shadow 0.2s ease-in-out;
    overflow: hidden;
    font-weight: 600;
    font-size: 13.5px;
    letter-spacing: 0.2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.cart-button:hover,
.aac-btn:hover {
    background-color: var(--cart-btn-hover-bg, #054178);
    color: var(--cart-btn-color, #ffffff);
}

.cart-button:active,
.aac-btn:active {
    transform: scale(0.96);
}

/* Optional Cyan / Neon theme variant */
.cart-button.cart-button--cyan,
.cart-button-cyan {
    background-color: #00fffc;
    color: #000000;
}
.cart-button.cart-button--cyan:hover,
.cart-button-cyan:hover {
    background-color: #00e0dd;
    color: #000000;
}
.cart-button.cart-button--cyan span,
.cart-button-cyan span {
    color: #000000;
}
.cart-button.cart-button--cyan .fa-cart-shopping,
.cart-button-cyan .fa-cart-shopping {
    color: #000000;
}

/* Shopping cart icon (starts hidden off-screen left) */
.cart-button .fa-cart-shopping,
.cart-button .aac-cart,
.aac-btn .fa-cart-shopping,
.aac-btn .aac-cart {
    position: absolute;
    z-index: 2;
    top: 50%;
    left: -15%;
    font-size: 1.7em;
    transform: translate(-50%, -50%);
    color: currentColor;
    pointer-events: none;
}

/* Box icon (starts hidden off-screen above) */
.cart-button .fa-box,
.cart-button .aac-box,
.aac-btn .fa-box,
.aac-btn .aac-box {
    position: absolute;
    z-index: 3;
    top: -30%;
    left: 52%;
    font-size: 1.15em;
    transform: translate(-50%, -50%);
    color: var(--cart-btn-box-color, gold);
    pointer-events: none;
}

/* Centered text spans */
.cart-button span,
.aac-btn span {
    position: absolute;
    z-index: 3;
    left: 50%;
    top: 50%;
    font-size: 1em;
    color: inherit;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}

.cart-button span.add-to-cart,
.cart-button span.aac-label,
.aac-btn span.add-to-cart,
.aac-btn span.aac-label {
    opacity: 1;
}

.cart-button span.added,
.cart-button span.aac-added,
.aac-btn span.added,
.aac-btn span.aac-added {
    opacity: 0;
}

.cart-button span.added i,
.aac-btn span.added i {
    font-size: 1.1em;
    color: #10b981; /* check green */
}

/* ==========================================================================
   Animation Trigger (.clicked / .is-animated)
   ========================================================================== */

.cart-button.clicked .fa-cart-shopping,
.cart-button.is-animated .fa-cart-shopping,
.aac-btn.clicked .fa-cart-shopping,
.aac-btn.is-animated .fa-cart-shopping,
.cart-button.clicked .aac-cart,
.cart-button.is-animated .aac-cart,
.aac-btn.clicked .aac-cart,
.aac-btn.is-animated .aac-cart {
    animation: truck 2s ease-in-out forwards;
}

.cart-button.clicked .fa-box,
.cart-button.is-animated .fa-box,
.aac-btn.clicked .fa-box,
.aac-btn.is-animated .fa-box,
.cart-button.clicked .aac-box,
.cart-button.is-animated .aac-box,
.aac-btn.clicked .aac-box,
.aac-btn.is-animated .aac-box {
    animation: box 2s ease-in-out forwards;
}

.cart-button.clicked span.add-to-cart,
.cart-button.is-animated span.add-to-cart,
.cart-button.clicked span.aac-label,
.cart-button.is-animated span.aac-label,
.aac-btn.clicked span.add-to-cart,
.aac-btn.is-animated span.add-to-cart,
.aac-btn.clicked span.aac-label,
.aac-btn.is-animated span.aac-label {
    animation: txt1 2s ease-in-out forwards;
}

.cart-button.clicked span.added,
.cart-button.is-animated span.added,
.cart-button.clicked span.aac-added,
.cart-button.is-animated span.aac-added,
.aac-btn.clicked span.added,
.aac-btn.is-animated span.added,
.aac-btn.clicked span.aac-added,
.aac-btn.is-animated span.aac-added {
    animation: txt2 2s ease-in-out forwards;
}

/* Keyframes */
@keyframes truck {
    0% {
        left: -15%;
    }
    40%,
    55% {
        left: 50%;
    }
    100% {
        left: 115%;
    }
}

@keyframes box {
    0%,
    40% {
        top: -30%;
        left: -5%;
    }
    55% {
        top: 36%;
        left: 52%;
    }
    100% {
        top: 36%;
        left: 115%;
    }
}

@keyframes txt1 {
    0% {
        opacity: 1;
    }
    20%,
    100% {
        opacity: 0;
    }
}

@keyframes txt2 {
    0%,
    80% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* ==========================================================================
   Header Cart Badge Pop Animation
   ========================================================================== */
@keyframes cart-badge-pop {
    0% {
        transform: scale(1);
    }
    40% {
        transform: scale(1.5);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

.cart-badge-pop {
    animation: cart-badge-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

/* Prefers-reduced-motion fallback */
@media (prefers-reduced-motion: reduce) {
    .cart-button.clicked .fa-cart-shopping,
    .cart-button.clicked .fa-box,
    .aac-btn.clicked .fa-cart-shopping,
    .aac-btn.clicked .fa-box {
        display: none;
    }
    .cart-button.clicked span.add-to-cart,
    .aac-btn.clicked span.add-to-cart {
        opacity: 0;
        transition: opacity 0.2s ease;
    }
    .cart-button.clicked span.added,
    .aac-btn.clicked span.added {
        opacity: 1;
        transition: opacity 0.3s ease;
    }
}
