
/* ==========================================================================
   Cart Progress Bar
   ========================================================================== */

/*
 * Color tokens — override these to theme the progress bar, achievement
 * cards and promo page. FreebieTierProgressListener injects the saved
 * settings values via wp_add_inline_style() using this same selector list,
 * so keep them in sync.
 *
 * Two layers: the base tokens (accent/complete, falling back to the block
 * theme palette) feed every derived token, and each derived token has its
 * own settings color picker for per-element overrides.
 */
.cart-progress,
.nuclii-freebie-achievements,
.nuclii-promo-page {
    /* Base — the legacy Accent/Complete settings write these */
    --nuclii-progress-accent:   #cb5024;
    --nuclii-progress-complete: #3d7b3c;
    --nuclii-progress-track:    #dfe3e4;
    --nuclii-progress-pending:  #999;
    --nuclii-progress-bg:       #fff;

    /* Progress bar (and the mini bars / dots on cards) */
    --nuclii-bar-fill:     var(--nuclii-progress-accent);
    --nuclii-bar-complete: var(--nuclii-progress-complete);
    --nuclii-bar-track:    var(--nuclii-progress-track);

    /* Cards — in progress */
    --nuclii-card-bg:      #f5f5f5;
    --nuclii-card-border:  #e5e5e5;
    --nuclii-card-title:   var(--nuclii-progress-accent);
    --nuclii-card-text:    #999;
    --nuclii-card-message: var(--nuclii-progress-complete);
    --nuclii-card-link:    var(--nuclii-progress-accent);

    /* Cards — complete */
    --nuclii-card-complete-bg:     var(--nuclii-card-bg);
    --nuclii-card-complete-border: var(--nuclii-progress-complete);
    --nuclii-card-complete-title:  var(--nuclii-progress-complete);
}

.cart-progress {
    position: relative;
    display: flex;
    margin-bottom: 32px;
    padding-top: 22px; /* space for the track + dots above labels */
}

.cart-progress .progress-track {
    position: absolute;
    top: 11px; /* centers on the 22px-tall dot (14px + 4px*2 border) */
    left: 0;
    width: 100%;
    height: 5px;
    background-color: var(--nuclii-bar-track);
    border-radius: 3px;
    overflow: hidden;
}

.cart-progress .progress-fill {
    height: 100%;
    background: var(--nuclii-bar-fill);
    border-radius: 3px;
    transition: width 0.8s ease-in-out;
}

.cart-progress .progress-step {
    position: relative;
    flex: 1;
    font-size: 11px;
    text-align: center;
    z-index: 1;
}

.cart-progress .progress-step img {
    width: 40px;
    margin: 0 auto;
    display: block;
    margin-top: 8px;
}

/* Dot marker */
.cart-progress .progress-step:before {
    content: "\2713";
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    margin-bottom: 6px;
    width: 14px;
    height: 14px;
    background: var(--nuclii-progress-bg);
    border: 4px solid var(--nuclii-bar-track);
    border-radius: 100%;
    color: transparent;
    font-size: 9px;
    position: relative;
    z-index: 2;
}

/* Active step — pulsing border */
.cart-progress .progress-step.is-active:before {
    border: 4px solid var(--nuclii-bar-fill);
    animation: nuclii-pulse 2s infinite;
}

/* Pending steps */
.cart-progress .progress-step.is-pending:before {
    border: 4px solid var(--nuclii-bar-track);
}

/* Complete step — filled dot with checkmark */
.cart-progress .progress-step.is-complete:before {
    font-size: 9px;
    color: var(--nuclii-progress-bg);
    background: var(--nuclii-bar-complete);
    border: 4px solid transparent;
}

@keyframes nuclii-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(0, 0, 0, 0.25); }
    70%  { box-shadow: 0 0 0 8px rgba(0, 0, 0, 0); }
    100% { box-shadow: 0 0 0 0   rgba(0, 0, 0, 0); }
}

/* ==========================================================================
   Achievement Cards
   ========================================================================== */

.nuclii-freebie-achievements {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    /* Column count is driven by this container's width (not the viewport) —
       narrow theme containers get one card per row. */
    container-type: inline-size;
    align-items: normal;
    justify-content: center;
    margin-bottom: 8px;
}

.nuclii-achievement-label-heading {
    width: 100%;
    margin: 4px 0 2px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--nuclii-card-text);
    text-align: center;
}

.nuclii-achievement-card {
    display: flex;
    flex-wrap: wrap; /* lets the link drop to its own row */
    align-items: center;
    gap: 10px;
    flex: 1 1 100%;
    min-width: 0;
    background: var(--nuclii-card-bg);
    border: 1px solid var(--nuclii-card-border);
    border-radius: 8px;
    padding: 10px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Two equal-width cards per row once the container allows it. The px-based
   calc matches the 8px flex gap (an em-based offset breaks on themes with
   large base font sizes). */
@container (min-width: 560px) {
    .nuclii-achievement-card {
        /* grow 0 keeps an odd last card at half width too */
        flex: 0 1 calc(50% - 40px);
    }
}

.nuclii-achievement-card.is-achieved {
    background: var(--nuclii-card-complete-bg);
    border-color: var(--nuclii-card-complete-border);
}

/* Progress-bar style dot — matches .progress-step:before exactly */
.nuclii-achievement-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    background: var(--nuclii-progress-bg, #fff);
    border: 4px solid var(--nuclii-bar-track);
    border-radius: 50%;
    color: transparent;
    font-size: 9px;
    font-weight: 700;

    /* Pending: pulse like is-active progress step */
    animation: nuclii-pulse 2s infinite;
    border-color: var(--nuclii-bar-fill);
}

/* Achieved: same as is-complete progress step */
.nuclii-achievement-card.is-achieved .nuclii-achievement-dot {
    animation: none;
    background: var(--nuclii-bar-complete);
    border-color: transparent;
    color: var(--nuclii-progress-bg, #fff);
}

/* Image wrapper */
.nuclii-achievement-img-wrap {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: #f0f0f0;
}

.nuclii-achievement-img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}


/* Text block */
.nuclii-achievement-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nuclii-achievement-badge {
    font-size: 13px;
    font-weight: 700;
    color: var(--nuclii-card-title);
    line-height: 1.2;
}

.nuclii-achievement-card.is-achieved .nuclii-achievement-badge {
    color: var(--nuclii-card-complete-title);
}

.nuclii-achievement-label {
    font-size: 11px;
    color: var(--nuclii-card-text);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nuclii-achievement-savings {
    font-size: 11px;
    font-weight: 600;
    color: var(--nuclii-card-message);
    line-height: 1.3;
}

.nuclii-achievement-fine-print {
    font-size: 10px;
    color: var(--nuclii-card-text);
    line-height: 1.3;
}

/* Mini progress bar within achievement cards */
.nuclii-achievement-mini-progress {
    position: relative;
    margin-top: 4px;
    margin-bottom: 4px;
    width: 100%;
}

.nuclii-achievement-mini-progress-track {
    width: 100%;
    height: 6px;
    background-color: var(--nuclii-bar-track);
    border-radius: 3px;
    overflow: hidden;
}

.nuclii-achievement-mini-progress-fill {
    height: 100%;
    background: var(--nuclii-bar-fill);
    border-radius: 3px;
    transition: width 0.5s ease-in-out;
}

.nuclii-achievement-card.is-achieved .nuclii-achievement-mini-progress-fill {
    background: var(--nuclii-bar-complete);
}

.nuclii-achievement-mini-progress-label {
    display: block;
    font-size: 10px;
    color: var(--nuclii-card-text);
    margin-top: 2px;
    text-align: left;
}

/* A met requirement collapses to a checked text line (no bar); a cart over
   the quantity limit gets a warning line instead — a bar would invite
   adding more when the cart has to shrink. */
.nuclii-achievement-requirement-done,
.nuclii-achievement-requirement-over {
    font-size: 10px;
    color: var(--nuclii-card-text);
    margin-top: 4px;
    margin-bottom: 4px;
    text-align: left;
}

.nuclii-achievement-requirement-check {
    color: var(--nuclii-bar-complete);
    font-weight: 700;
    margin-right: 4px;
}

.nuclii-achievement-requirement-alert {
    color: var(--nuclii-bar-fill);
    font-weight: 700;
    margin-right: 4px;
}

/* Card footer — feedback text on the left, CTA text link pushed right.
   Owns the full-width row so cards with and without it keep identical
   top-row layouts; the anchor shrinks to its text so only the words are
   clickable. */
.nuclii-achievement-footer {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.nuclii-achievement-footer .nuclii-achievement-link {
    margin-left: auto; /* right-aligned even when there is no feedback text */
}

.nuclii-achievement-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--nuclii-card-link);
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
}

.nuclii-achievement-link:hover {
    text-decoration: none;
}

.nuclii-achievement-card.is-achieved .nuclii-achievement-link {
    color: var(--nuclii-card-complete-title);
}

/* Hide the progress bar but keep it for AJAX tier computation */
.nuclii-progress-bar-hidden {
    display: none;
}

/* ==========================================================================
   Promo Landing Page  (self-contained — works on any theme)
   ========================================================================== */

.nuclii-promo-page {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    font-family: inherit;
    box-sizing: border-box;
}

.nuclii-promo-banner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--nuclii-progress-accent, #cb5024);
    color: #fff;
    border-radius: 10px;
    padding: 1.75rem 2rem;
    margin-bottom: 2rem;
}

.nuclii-promo-badge-large {
    font-size: 2.2rem;
    font-weight: 800;
    white-space: nowrap;
    background: rgba(255,255,255,.15);
    border-radius: 8px;
    padding: .3rem .8rem;
    line-height: 1.2;
}

.nuclii-promo-banner-text h1 {
    margin: 0 0 .35rem;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1.3;
}

.nuclii-promo-banner-text p {
    margin: 0;
    opacity: .85;
    font-size: .95rem;
}

.nuclii-promo-products-heading {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: inherit;
}

.nuclii-promo-fine-print {
    margin: -0.75rem 0 2rem;
    font-size: .85rem;
    color: #666;
}

.nuclii-promo-fine-print ul {
    margin: 0;
    padding-left: 1.2rem;
}

.nuclii-promo-fine-print li {
    margin-bottom: .15rem;
}

/* Mini Cart context — hide achievements to keep it compact */
.nuclii-freebie-mini-cart-bar .nuclii-freebie-achievements {
    display: none;
}

/* ==========================================================================
   Mini Cart context overrides
   ========================================================================== */

.nuclii-freebie-mini-cart-bar {
    border-top: 1px solid #e0e0e0;
    background: #fff;
}

.nuclii-freebie-mini-cart-bar .cart-progress {
    margin-bottom: 16px;
    padding: 16px 16px 0;
    font-size: 10px;
}

.nuclii-freebie-mini-cart-bar .cart-progress .progress-step img {
    width: 28px;
    margin-top: 6px;
}

.nuclii-freebie-mini-cart-bar .cart-progress .tier-text {
    font-size: 10px;
    line-height: 1.3;
}
