/**
 * 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;
    }
}

/* ==========================================================================
   Inline layout — message and track side by side (used by the sticky bar)
   ========================================================================== */

.cartboost-layout-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
}

.cartboost-inline-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 16px;
}

.cartboost-layout-inline .cartboost-message {
    margin: 0;
    flex: 0 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cartboost-layout-inline .cartboost-track {
    flex: 1 1 160px;
    min-width: 120px;
}

.cartboost-layout-inline.cartboost-bar-above .cartboost-inline-body {
    flex-direction: row-reverse;
}

.cartboost-dismiss {
    flex: 0 0 auto;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--cb-text-color);
    opacity: 0.6;
    font-size: 20px;
    line-height: 1;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 4px;
}

.cartboost-dismiss:hover,
.cartboost-dismiss:focus-visible {
    opacity: 1;
    outline: 2px solid var(--cb-bar-color);
    outline-offset: 1px;
}

@media (max-width: 600px) {
    .cartboost-inline-body {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .cartboost-layout-inline .cartboost-message {
        white-space: normal;
        font-size: 0.85em;
    }
    .cartboost-layout-inline.cartboost-bar-above .cartboost-inline-body {
        flex-direction: column-reverse;
    }
}

/* ==========================================================================
   Sticky site-wide bar
   ========================================================================== */

.cartboost-sticky {
    position: fixed;
    left: 0;
    right: 0;
    z-index: var(--cb-sticky-z, 9990);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    padding-left: max(var(--cb-padding), env(safe-area-inset-left));
    padding-right: max(var(--cb-padding), env(safe-area-inset-right));
}

.cartboost-sticky-bottom {
    bottom: 0;
    padding-bottom: max(var(--cb-padding), env(safe-area-inset-bottom));
}

.cartboost-sticky-top {
    top: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* Sit below the WordPress admin bar when it is present */
body.admin-bar .cartboost-sticky-top {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .cartboost-sticky-top {
        top: 46px;
    }
}

/* Hidden by rule (show_when / dismissed / device) — JS toggles this class */
.cartboost-sticky.cartboost-sticky-off {
    display: none;
}

@media (max-width: 782px) {
    .cartboost-sticky-desktop-only {
        display: none;
    }
}

@media (min-width: 783px) {
    .cartboost-sticky-mobile-only {
        display: none;
    }
}

/* Keep the sticky bar's slide subtle */
.cartboost-sticky.cartboost-ready {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ==========================================================================
   Product page bar
   ========================================================================== */

.cartboost-context-product {
    margin-bottom: 16px;
}

/* ==========================================================================
   Product suggestions — "add one of these to unlock"
   ========================================================================== */

.cartboost-suggestions {
    margin-top: var(--cb-gap);
    font-size: var(--cb-font-size);
    color: var(--cb-text-color);
}

.cartboost-suggestions-title {
    margin: 0 0 8px 0;
    font-weight: var(--cb-font-weight);
    opacity: 0.85;
}

.cartboost-suggestions-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.cartboost-suggestions-grid .cartboost-suggestions-list {
    flex-wrap: wrap;
    overflow: visible;
}

.cartboost-suggestion {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
    max-width: 300px;
    padding: 8px 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: calc(var(--cb-radius) / 2 + 4px);
    background: rgba(255, 255, 255, 0.6);
    margin: 0;
}

.cartboost-suggestions-grid .cartboost-suggestion {
    flex: 1 1 220px;
    max-width: none;
}

.cartboost-suggestion-img {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    background: #f3f3f3;
    display: block;
}

.cartboost-suggestion-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cartboost-suggestion-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.3;
}

.cartboost-suggestion-name {
    font-weight: 600;
    text-decoration: none;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cartboost-suggestion-price {
    font-size: 0.9em;
    opacity: 0.85;
}

.cartboost-suggestion-price del {
    opacity: 0.6;
    margin-right: 4px;
}

.cartboost-suggestion-add {
    flex: 0 0 auto;
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 6px 12px;
    font: inherit;
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    background: var(--cb-bar-color);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: filter 0.15s ease, opacity 0.15s ease;
}

.cartboost-suggestion-add:hover,
.cartboost-suggestion-add:focus-visible {
    filter: brightness(0.92);
    color: #fff;
    text-decoration: none;
}

.cartboost-suggestion-add[disabled],
.cartboost-suggestion-add.is-loading {
    opacity: 0.6;
    cursor: progress;
}

.cartboost-suggestion.is-added {
    border-color: var(--cb-bar-color);
}

.cartboost-context-minicart .cartboost-suggestion {
    min-width: 180px;
}

@media (prefers-color-scheme: dark) {
    .cartboost-dark-custom .cartboost-suggestion {
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.15);
    }
}

/* ==========================================================================
   Free-gift chooser — prompt under the bar + modal
   ========================================================================== */

.cartboost-gift-prompt {
    margin-top: var(--cb-gap);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: var(--cb-font-size);
    color: var(--cb-text-color);
}

.cartboost-gift-prompt-text {
    font-weight: var(--cb-font-weight);
}

.cartboost-gift-choose,
.cartboost-gift-pick {
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 6px 14px;
    font: inherit;
    font-size: 0.85em;
    font-weight: 600;
    color: #fff;
    background: var(--cb-bar-color, #2ecc71);
    cursor: pointer;
    white-space: nowrap;
}

.cartboost-gift-choose:hover,
.cartboost-gift-pick:hover {
    filter: brightness(0.92);
}

.cartboost-gift-pick[disabled],
.cartboost-gift-pick.is-loading {
    opacity: 0.6;
    cursor: progress;
}

.cartboost-gift-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.cartboost-gift-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.cartboost-gift-modal-box {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    color: #222;
    border-radius: 12px;
    padding: 22px 22px 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.cartboost-gift-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    appearance: none;
    border: 0;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
}

.cartboost-gift-modal-close:hover {
    opacity: 1;
}

.cartboost-gift-modal-title {
    margin: 0 28px 4px 0;
    font-size: 1.2em;
}

.cartboost-gift-modal-sub {
    margin: 0 0 14px;
    opacity: 0.75;
}

.cartboost-gift-options {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.cartboost-gift-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    margin: 0;
}

.cartboost-gift-option img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    flex: 0 0 auto;
}

.cartboost-gift-option-name {
    flex: 1 1 auto;
    font-weight: 600;
    min-width: 0;
}

html.cartboost-modal-open {
    overflow: hidden;
}
