/*
 * Free-shipping bar (#1326): mini cart, cart page and the add-to-cart panel.
 * Colours and radii come from the theme tokens (popy-csp, asgano-csp); asgano's
 * --color-ok/--color-line are used where they exist, popy falls back to primary.
 */
popy-freeship {
    --fs-fg: var(--color-fg, #0a0a0a);
    --fs-muted: var(--color-fg-secondary, #666666);
    --fs-accent: var(--color-primary, #0a0a0a);
    --fs-on-accent: var(--color-on-primary, #ffffff);
    --fs-ok: var(--color-ok, var(--color-primary, #0a0a0a));
    --fs-line: var(--color-line, rgb(10 10 10 / 0.1));
    --fs-surface: var(--color-surface, #ffffff);
    --fs-radius: var(--radius-md, 0.5rem);
    display: block;
    color: var(--fs-fg);
}

popy-freeship[hidden] {
    display: none;
}

/* Cart page: keep the bar's height while the script loads, so the items do not jump. */
popy-freeship[data-context="cart"]:not(:defined) {
    display: block;
    min-height: 3.5rem;
}

popy-freeship[data-context="drawer"] {
    padding: 0.75rem 0 0.25rem;
}

popy-freeship[data-context="cart"] {
    margin: 0 0 1.25rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--fs-line);
    border-radius: var(--radius-lg, 0.75rem);
    background: var(--fs-surface);
}

.popy-fs__msg {
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    line-height: 1.35;
}

.popy-fs__msg strong {
    font-weight: 700;
    white-space: nowrap;
}

popy-freeship[data-state="reached"] .popy-fs__msg {
    font-weight: 600;
}

.popy-fs__track {
    position: relative;
    height: 0.5rem;
    overflow: hidden;
    border-radius: 999px;
    background: var(--fs-line);
}

.popy-fs__fill {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--fs-accent);
    transform-origin: left center;
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.2s ease;
}

[dir="rtl"] .popy-fs__fill {
    transform-origin: right center;
}

popy-freeship[data-state="reached"] .popy-fs__fill {
    background: var(--fs-ok);
}

.popy-fs__check {
    display: inline-block;
    flex: none;
    margin-right: 0.25rem;
    vertical-align: -0.15em;
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

popy-freeship[data-state="reached"] .popy-fs__msg .popy-fs__check {
    color: var(--fs-ok);
}

popy-freeship.is-celebrating .popy-fs__track {
    animation: popy-fs-pulse 0.9s ease-out 1;
}

@keyframes popy-fs-pulse {
    0% { box-shadow: 0 0 0 0 var(--fs-ok); }
    100% { box-shadow: 0 0 0 0.5rem transparent; }
}

/* Suggestions: up to three cards side by side, also on a phone. */
.popy-fs__sugs {
    margin-top: 0.875rem;
}

.popy-fs__sugs[hidden],
.popy-fs-drawer-sugs[hidden] {
    display: none;
}

.popy-fs__h {
    margin: 0 0 0.5rem;
    color: var(--fs-muted, var(--color-fg-secondary, #666666));
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.popy-fs__list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.popy-fs__card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    padding: 0.5rem;
    border: 1px solid var(--fs-line, rgb(10 10 10 / 0.1));
    border-radius: var(--fs-radius, 0.5rem);
    background: var(--fs-surface, #ffffff);
}

.popy-fs__img {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 4.5rem;
    overflow: hidden;
    border-radius: var(--radius-sm, 0.25rem);
}

.popy-fs__img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.popy-fs__name {
    display: -webkit-box;
    overflow: hidden;
    color: inherit;
    font-size: 0.875rem;
    line-height: 1.3;
    text-decoration: none;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    min-height: 2.6em;
}

.popy-fs__name:hover,
.popy-fs__name:focus-visible {
    text-decoration: underline;
}

.popy-fs__price {
    font-size: 0.875rem;
    font-weight: 700;
    white-space: nowrap;
}

.popy-fs__add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-height: 2.75rem;
    margin-top: auto;
    padding: 0 0.5rem;
    border: 0;
    border-radius: var(--radius-xl, 999px);
    background: var(--fs-accent, var(--color-primary, #0a0a0a));
    color: var(--fs-on-accent, var(--color-on-primary, #ffffff));
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    hyphens: auto;
    cursor: pointer;
}

/* Narrow cards (three side by side on a phone): label only, a little smaller, so long words fit. */
.popy-fs__card {
    container-type: inline-size;
}

@container (max-width: 8.5rem) {
    .popy-fs__add {
        padding: 0 0.25rem;
        font-size: 0.875rem;
    }

    .popy-fs__plus {
        display: none;
    }
}

.popy-fs__add:focus-visible {
    outline: 2px solid var(--fs-accent, #0a0a0a);
    outline-offset: 2px;
}

.popy-fs__add[data-state="busy"] {
    opacity: 0.6;
    cursor: progress;
}

.popy-fs__add[data-state="done"] {
    background: var(--fs-ok, var(--color-primary, #0a0a0a));
    cursor: default;
}

.popy-fs__add[data-state="error"] {
    background: transparent;
    color: var(--fs-fg, #0a0a0a);
    box-shadow: inset 0 0 0 1px currentColor;
    font-size: 0.6875rem;
}

.popy-fs__plus {
    font-size: 1rem;
    line-height: 1;
}

.popy-fs__plus:empty {
    display: none;
}

/* Mini cart: the cards are the last row of the scrolling item list. */
.popy-fs-drawer-sugs {
    list-style: none;
    padding: 0.25rem 1rem 1rem;
}

.popy-fs-drawer-sugs .popy-fs__sugs {
    margin-top: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
    .popy-fs__fill {
        transition: none;
        animation: none;
    }
}

/* Keep the original button dimensions while native cart requests settle. */
.popy-cart-feedback { position: relative; }
.popy-cart-feedback > :not(.popy-cart-feedback__label) { visibility: hidden; }
.popy-cart-feedback__label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.125rem 0.25rem;
    font-size: 0.875rem;
    line-height: 1.1;
    text-align: center;
    overflow-wrap: anywhere;
}

.popy-cart-added { padding: 0.5rem 0; }
.popy-cart-added p { margin: 0 0 0.5rem; overflow-wrap: anywhere; }
.popy-cart-added .btn { min-height: 44px; width: 100%; }
.popy-purchase-loading { min-height: 8rem; display: grid; place-items: center; }
#cart-drawer { transition-duration: 250ms; }
@media (prefers-reduced-motion: reduce) {
    #cart-drawer { transition-duration: 0ms; }
}
