/**
 * CartBoost – Progress Reward Bar
 * All colors/dimensions driven by CSS custom properties — zero theme conflicts.
 */

/* ==========================================================================
   Base wrapper
   ========================================================================== */

.cartboost-bar-wrap {
    --cb-bar-color: #2ecc71;
    --cb-bg-color: #f0f0f0;
    --cb-text-color: #333333;
    --cb-percent: 0%;
    --cb-height: 14px;
    --cb-radius: 999px;
    --cb-font-size: 0.95em;
    --cb-align: left;
    --cb-font-family: inherit;
    --cb-font-weight: 500;
    --cb-width: 100%;
    --cb-padding: 16px;
    --cb-gap: 10px;
    --cb-anim-speed: 0.8s;
    --cb-container-bg: transparent;

    box-sizing: border-box;
    width: 100%;
    padding: var(--cb-padding) calc(var(--cb-padding) + 4px);
    margin-bottom: 20px;
    font-family: var(--cb-font-family);
    line-height: 1.5;
    background-color: var(--cb-container-bg);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cartboost-bar-wrap.cartboost-ready {
    opacity: 1;
}

/* ==========================================================================
   Message
   ========================================================================== */

.cartboost-message {
    margin: 0 0 var(--cb-gap) 0;
    padding: 0;
    font-size: var(--cb-font-size);
    font-weight: var(--cb-font-weight);
    color: var(--cb-text-color);
    text-align: var(--cb-align);
}

.cartboost-icon {
    margin-right: 4px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.cartboost-icon-img {
    width: 1.2em;
    height: 1.2em;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
}

/* Bar above message — flip spacing */
.cartboost-bar-above .cartboost-message {
    margin: var(--cb-gap) 0 0 0;
}

/* ==========================================================================
   Progress track + fill
   ========================================================================== */

.cartboost-track {
    position: relative;
    max-width: var(--cb-width);
    height: var(--cb-height);
    background: var(--cb-bg-color);
    border-radius: var(--cb-radius);
    overflow: hidden;
}

.cartboost-fill {
    position: relative;
    height: 100%;
    width: var(--cb-percent);
    background-color: var(--cb-bar-color);
    background-image: none;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    border-radius: var(--cb-radius);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--cb-height);
}

/* Percentage text inside the fill */
.cartboost-percent {
    font-size: 0.65em;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

/* Percentage above bar */
.cartboost-percent-above {
    text-align: var(--cb-align);
    margin-bottom: 4px;
}

.cartboost-percent-above .cartboost-percent {
    color: var(--cb-text-color);
    text-shadow: none;
    font-size: var(--cb-font-size);
}

/* Percentage after message */
.cartboost-percent-after-message .cartboost-message .cartboost-percent {
    color: var(--cb-text-color);
    text-shadow: none;
    font-size: 0.9em;
    opacity: 0.7;
}

/* ==========================================================================
   Multi-tier milestone markers
   ========================================================================== */

.cartboost-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.22);
    z-index: 2;
    pointer-events: none;
}

/* Once the cart passes a tier, its notch sits on the colored fill —
   switch to a light line so it stays visible. */
.cartboost-marker-unlocked {
    background: rgba(255, 255, 255, 0.85);
}

/* ==========================================================================
   Gradient — applied via background (not background-image, to avoid conflict with stripes)
   ========================================================================== */

.cartboost-gradient .cartboost-fill {
    background-color: var(--cb-bar-color);
    background-image: var(--cb-gradient);
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

/* ==========================================================================
   Bar styles — striped
   ========================================================================== */

.cartboost-style-striped .cartboost-fill {
    background-color: var(--cb-bar-color);
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-repeat: repeat;
    background-size: 1rem 1rem;
}

/* Striped + gradient: stripes on top of gradient */
.cartboost-gradient.cartboost-style-striped .cartboost-fill {
    background-color: var(--cb-bar-color);
    background-image:
        linear-gradient(
            45deg,
            rgba(255, 255, 255, 0.15) 25%,
            transparent 25%,
            transparent 50%,
            rgba(255, 255, 255, 0.15) 50%,
            rgba(255, 255, 255, 0.15) 75%,
            transparent 75%,
            transparent
        ),
        var(--cb-gradient);
    background-repeat: repeat, no-repeat;
    background-size: 1rem 1rem, 100% 100%;
}

/* Flat — no radius override (handled by --cb-radius: 0) */

/* ==========================================================================
   Bar shadow
   ========================================================================== */

.cartboost-shadow-subtle .cartboost-track {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cartboost-shadow-medium .cartboost-track {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cartboost-shadow-strong .cartboost-track {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Bar border
   ========================================================================== */

.cartboost-bordered .cartboost-track {
    border: var(--cb-border-width, 1px) solid var(--cb-border-color, #ddd);
}

/* ==========================================================================
   Animation — only on cart changes, not on initial page load
   ========================================================================== */

.cartboost-animated .cartboost-fill {
    transition: width var(--cb-anim-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

/* Striped animation — only the stripe movement uses keyframes */
.cartboost-style-striped .cartboost-fill {
    animation: cartboost-stripe-move 1s linear infinite;
}

@keyframes cartboost-stripe-move {
    0%   { background-position: 0 0; }
    100% { background-position: 1rem 0; }
}

/* ==========================================================================
   States
   ========================================================================== */

.cartboost-state-empty .cartboost-message {
    opacity: 0.85;
}

.cartboost-state-reached .cartboost-fill {
    width: 100%;
}

.cartboost-state-reached .cartboost-message {
    font-weight: 600;
}

/* ==========================================================================
   Celebrations
   ========================================================================== */

/* Pulse */
.cartboost-celebrate-pulse .cartboost-fill {
    animation: cartboost-pulse 0.6s ease-out;
}

@keyframes cartboost-pulse {
    0%  { transform: scaleY(1); }
    50% { transform: scaleY(1.4); }
    100%{ transform: scaleY(1); }
}

/* Glow */
.cartboost-celebrate-glow .cartboost-fill {
    animation: cartboost-glow 1.2s ease-in-out infinite alternate;
}

@keyframes cartboost-glow {
    from { box-shadow: 0 0 4px var(--cb-bar-color); }
    to   { box-shadow: 0 0 16px var(--cb-bar-color), 0 0 24px var(--cb-bar-color); }
}

/* Bounce */
.cartboost-celebrate-bounce .cartboost-fill {
    animation: cartboost-bounce 0.6s ease-out;
}

@keyframes cartboost-bounce {
    0%   { transform: scaleX(0.95) scaleY(1); }
    30%  { transform: scaleX(1.02) scaleY(0.9); }
    50%  { transform: scaleX(0.98) scaleY(1.05); }
    70%  { transform: scaleX(1.01) scaleY(0.98); }
    100% { transform: scaleX(1) scaleY(1); }
}

/* Confetti — pseudo-element sparkle */
.cartboost-celebrate-confetti .cartboost-track {
    position: relative;
    overflow: visible;
}

.cartboost-celebrate-confetti .cartboost-track::after {
    content: '';
    position: absolute;
    inset: -8px -4px;
    background-image:
        radial-gradient(circle, #f1c40f 1px, transparent 1px),
        radial-gradient(circle, #e74c3c 1px, transparent 1px),
        radial-gradient(circle, #3498db 1px, transparent 1px),
        radial-gradient(circle, #2ecc71 1px, transparent 1px),
        radial-gradient(circle, #9b59b6 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 7px 12px, 14px 4px, 3px 16px, 18px 8px;
    animation: cartboost-confetti 1.5s ease-out forwards;
    pointer-events: none;
    border-radius: var(--cb-radius);
}

@keyframes cartboost-confetti {
    0%   { opacity: 1; transform: scale(1); }
    50%  { opacity: 0.8; }
    100% { opacity: 0; transform: scale(1.1) translateY(-4px); }
}

/* ==========================================================================
   RTL support
   ========================================================================== */

.cartboost-rtl {
    direction: rtl;
}

.cartboost-rtl .cartboost-icon {
    margin-right: 0;
    margin-left: 4px;
}

.cartboost-rtl .cartboost-fill {
    margin-left: auto;
    margin-right: 0;
}

/* ==========================================================================
   Dark mode
   ========================================================================== */

/* ==========================================================================
   Dark mode — custom overrides only, default respects CSS vars
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .cartboost-dark-custom .cartboost-fill {
        background-color: var(--cb-dark-bar-color);
    }
    .cartboost-dark-custom .cartboost-track {
        background: var(--cb-dark-bg-color);
    }
    .cartboost-dark-custom .cartboost-message {
        color: var(--cb-dark-text-color);
    }
    .cartboost-dark-custom.cartboost-gradient .cartboost-fill {
        background-color: var(--cb-dark-bar-color);
    }
    .cartboost-dark-custom .cartboost-marker {
        background: rgba(255, 255, 255, 0.3);
    }
}

/* ==========================================================================
   Context — Mini-cart compact
   ========================================================================== */

.cartboost-context-minicart {
    padding: 12px 14px;
    margin-bottom: 12px;
}

.cartboost-context-minicart .cartboost-message {
    font-size: 0.85em;
    margin-bottom: 8px;
}

.cartboost-context-minicart .cartboost-track {
    height: 10px;
}

/* ==========================================================================
   Accessibility — reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .cartboost-fill {
        transition: none;
    }
    .cartboost-animated .cartboost-fill {
        width: var(--cb-percent);
    }
    .cartboost-celebrate-pulse .cartboost-fill,
    .cartboost-celebrate-glow .cartboost-fill,
    .cartboost-celebrate-bounce .cartboost-fill {
        animation: none;
    }
    .cartboost-style-striped .cartboost-fill {
        animation: none;
    }
    .cartboost-celebrate-confetti .cartboost-track::after {
        animation: none;
        display: none;
    }
}
