/*
 * Holiday package controls inside FluentCart's native cart (page + drawer).
 *
 * Package lines are managed as a package: the per-line steppers and delete
 * button FluentCart renders would only be refused (PackageLineEditGuard), so
 * they are hidden for any line carrying the marker PackageLineMetaRenderer
 * prints — and only for a *managed* line (registry + stamps + a live package
 * variation, exactly where the guard refuses). An orphaned or retired line gets
 * no marker, so FluentCart's own remove control stays visible: it is that
 * line's exit. The :has() selector needs Chrome 105+, Firefox 121+ or Safari
 * 15.4+; an older browser keeps the native controls, which the guard refuses
 * with a toast.
 *
 * Colours and type inherit from the surrounding cart; override the
 * --pif-package-* variables to restyle without touching selectors.
 */
.fct-cart-item:has([data-pif-package-line]) .fct-cart-item-quantity,
.fct-cart-item:has([data-pif-package-line]) .fct-cart-item-remove {
    display: none;
}

/*
 * The checkout page draws the order summary through the same line hook, but
 * there is no drawer to refresh there (FluentCart hides it), so the Remove
 * list would act without the page showing it. The note stays; changing the
 * bag happens on the cart page, the drawer or the package page.
 */
[data-fluent-cart-checkout-page] [data-pif-package-list] {
    display: none;
}

/* The checkout summary prints "4 x" on every line itself. */
[data-fluent-cart-checkout-page] [data-pif-package-line-qty] {
    display: none;
}

.pif-package-line-qty {
    margin: 4px 0 0;
    font-size: 0.9em;
    font-weight: 600;
}

.pif-package-note {
    margin: 4px 0 0;
    font-size: 0.85em;
    color: var(--pif-package-muted, var(--fct-secondary-text-color, #6b7280));
}

.pif-package-note--orphan {
    color: var(--pif-package-warning, #b45309);
}

.pif-package-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
}

.pif-package-entry {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    font-size: 0.9em;
}

.pif-package-name {
    font-weight: 600;
}

.pif-package-remove {
    margin-left: auto;
    padding: 2px 10px;
    font: inherit;
    color: var(--pif-package-remove, var(--fct-danger-color, #b91c1c));
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 4px;
    cursor: pointer;
}

.pif-package-remove:hover,
.pif-package-remove:focus-visible {
    color: #fff;
    background: var(--pif-package-remove, var(--fct-danger-color, #b91c1c));
}

.pif-package-remove[disabled] {
    opacity: 0.5;
    cursor: wait;
}

/*
 * State hooks on a storefront package card (data-pif-package). The script
 * only sets attributes; layout and look belong to the page design.
 */
[data-pif-package][data-pif-package-state="busy"] {
    cursor: progress;
}

[data-pif-package][data-pif-package-state="busy"] [data-pif-package-quantity],
[data-pif-package][data-pif-package-state="busy"] [data-pif-package-increment],
[data-pif-package][data-pif-package-state="busy"] [data-pif-package-decrement] {
    opacity: 0.6;
}

[data-pif-package][data-pif-package-state="unavailable"] {
    opacity: 0.6;
}

[data-pif-package-message]:empty {
    display: none;
}

[data-pif-package-summary][hidden] {
    display: none;
}
