/*
 * The cart page's own styles. Moved out of shop.css so the cart page and the
 * product page stop sharing a stylesheet — two sessions were editing that one
 * file and a split by selector prefix is not safe: .shop-cart-add LOOKS like a
 * cart rule and is the product page's add-to-cart form, so it deliberately
 * stayed behind.
 *
 * cart.php loads shop.css too and still needs it — .shop-main, .shop-empty and
 * the shared button rules live there. This sheet holds only what no other page
 * renders.
 *
 * Registered in _probes/probe_portal_theme.php's $sheets array. That list is
 * HARDCODED and a sheet missing from it is skipped silently, so a stylesheet
 * added here without that line becomes the one place a raw hex passes review.
 *
 * NO QUANTITY STEPPER, NO INSTALLATION-TIER PANEL — this system cannot honour
 * either, so neither gets a class here. A coupon field DOES belong here now:
 * every payment path (stripe/razorpay/paypal/wallet init) applies one to a
 * cart's frozen row via wc_cart_coupon_discount() — see .shop-cart-coupon
 * below and cart.php's own comment on why it previews via a plain GET.
 */

/* ---- head: breadcrumb + heading + subtitle ---- */

.shop-cart-head { margin-bottom: 1.75rem; }
.shop-cart-subtitle { margin: 0; color: var(--text2); font-size: 1.0625rem; }

/* ---- two columns on desktop, one on mobile ---- */

.shop-cart-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22rem;
    gap: 28px;
    align-items: start;
    margin-bottom: 3rem;
}
.shop-cart-main { min-width: 0; }

@media (max-width: 60rem) {
    .shop-cart-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---- cart lines ---- */

.shop-cart-list {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
    display: grid;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--rl);
    overflow: hidden;
}
.shop-cart-line {
    display: grid;
    grid-template-columns: 64px 1fr auto auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg2);
}
.shop-cart-line__media {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: var(--r);
    overflow: hidden;
    background: var(--bg3);
    border: 1px solid var(--border2);
}
.shop-cart-line__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shop-cart-line__info { display: flex; flex-direction: column; align-items: start; gap: .3rem; min-width: 0; }
.shop-cart-line__title { display: flex; align-items: center; gap: .35rem; min-width: 0; }
.shop-cart-line__info a { color: var(--text); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.shop-cart-line__info a:hover { color: var(--amber); }
/* Which of the buyer's licences a bound add-on line attaches to — the same
   monospace the purchase key itself is set in elsewhere in the portal, so it
   reads as an id rather than as ordinary copy. */
.cart-line__target { font-size: 12.5px; color: var(--text3); font-family: 'DM Mono', monospace; }
/* A bound line the checkout-time gate refused (its licence was revoked, or
   the add-on was bought another way, since it went in the cart). */
.cart-line__warn { font-size: 12.5px; color: var(--danger-d); }
/* Same recipe as .shop-free-item-badge in shop.css — a token-built pill,
   just named for what this one badges rather than shared across files. */
.shop-cart-line__badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--bg3);
    border: 1px solid var(--border2);
    color: var(--text2);
    white-space: nowrap;
}
/* The licence switcher, on a line whose SKU is sold under more than one
   licence. It sits INSIDE .shop-cart-line__info (a flex column) in place of
   the badge above, not beside it — the selected option already names the
   licence, so rendering both would print the same word twice. */
.shop-cart-line__licence {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}
/* Sized down from .shop-review-form's controls in shop.css: same tokens, but
   this one shares a row with a price and a remove button rather than owning a
   form's full width. min-height stays at 44px — a control that changes what a
   buyer pays should keep a full touch target however narrow it gets. */
.shop-cart-line__licence-select {
    font: inherit;
    font-size: 13px;
    color: var(--text);
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: var(--r);
    padding: .35rem .5rem;
    min-height: 44px;
    max-width: 100%;
}
.shop-cart-line__licence-btn {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: .55rem .85rem;
    min-height: 44px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--bg2);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.shop-cart-line__licence-btn:hover { border-color: var(--base); color: var(--base); }

.shop-cart-line__flag { color: var(--danger); font-size: .8125rem; }
.shop-cart-line__price { font-weight: 700; color: var(--amber); white-space: nowrap; }
.shop-cart-line.is-unavailable .shop-cart-line__price { color: var(--text3); }

.shop-cart-line__remove-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--bg3);
    color: var(--text2);
    cursor: pointer;
}
.shop-cart-line__remove-btn:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-08); }
.shop-cart-line__remove-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

@media (max-width: 560px) {
    /* Remove moves into the top-right corner beside the name, instead of
       taking a full row of its own under the line. On its own row it read as
       a control belonging to the whole cart rather than to one item, and the
       licence switcher — which makes .shop-cart-line__info two rows taller —
       pushed it far enough from its item to look unattached. */
    .shop-cart-line {
        grid-template-columns: 56px 1fr auto;
        grid-template-areas:
            "media info   remove"
            "media price  price";
        row-gap: .5rem;
        align-items: start;
    }
    .shop-cart-line__media { grid-area: media; width: 56px; height: 56px; }
    .shop-cart-line__info { grid-area: info; }
    .shop-cart-line__price { grid-area: price; align-self: center; }
    .shop-cart-line__remove { grid-area: remove; }
    /* The select takes the row it is on; nothing else shares it once the
       Change button is gone. min-width:0 so a long licence name shortens the
       control instead of widening the line. */
    .shop-cart-line__licence { width: 100%; }
    /* A step down from the desktop 13px: the option label carries a licence
       name AND its price, and at 13px the price was clipping mid-figure in the
       width this column has left after the remove button. min-width:0 is what
       lets it take that width at all rather than forcing the line wider. */
    .shop-cart-line__licence-select { flex: 1; min-width: 0; font-size: 12px; padding-inline: .4rem; }
}

/* Hidden only once chrome.js has wired the select to submit on change — see
   initCartLicences(). Without JS the button stays and the form still works. */
.shop-cart-line__licence.is-live .shop-cart-line__licence-btn { display: none; }

/* ---- addons block beneath the cart's lines (see cart.php's own comment on
   why this is one list rather than one repeated under every line) ---- */

.shop-cart-addons {
    margin: 0 0 1.5rem;
    padding: 1.25rem 1.25rem 1.4rem;
    border: 1px solid var(--border);
    border-radius: var(--rl);
    background: var(--bg2);
}
.shop-cart-addons h2 {
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--text3);
    font-weight: 600;
    margin: 0 0 1rem;
}
.shop-cart-addons-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .85rem; }
.shop-cart-addon {
    display: grid;
    grid-template-columns: 48px 1fr auto auto;
    align-items: center;
    gap: .85rem;
}
.shop-cart-addon__media {
    width: 48px;
    height: 48px;
    border-radius: var(--r);
    overflow: hidden;
    background: var(--bg3);
    border: 1px solid var(--border2);
}
.shop-cart-addon__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shop-cart-addon__name { font-weight: 600; font-size: .9375rem; overflow-wrap: anywhere; min-width: 0; }
.shop-cart-addon__price { font-weight: 700; color: var(--amber); font-size: .9375rem; white-space: nowrap; }
.shop-cart-addon__add {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--bg2);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.shop-cart-addon__add:hover { border-color: var(--base); color: var(--base); }

@media (max-width: 480px) {
    .shop-cart-addon {
        grid-template-columns: 40px 1fr;
        grid-template-areas:
            "media name"
            "media price-add";
        row-gap: .4rem;
    }
    .shop-cart-addon__media { grid-area: media; width: 40px; height: 40px; }
    .shop-cart-addon__name { grid-area: name; }
    .shop-cart-addon__price { grid-area: price-add; justify-self: start; }
    /* The price and the form both claim the same area on this narrow layout
       — they sit side by side inside it via the form's own inline-flex,
       rather than a third grid area for a one-element row. */
    .shop-cart-addon form { grid-area: price-add; justify-self: end; }
}

/* ---- order summary card (sticky on desktop) ---- */

.shop-order-summary {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--rl);
    padding: 1.5rem;
    position: sticky;
    top: 20px;
}
@media (max-width: 60rem) { .shop-order-summary { position: static; } }

.shop-order-summary h2 {
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.25rem;
    margin: 0 0 1.1rem;
    color: var(--text);
}
.shop-order-summary__lines { list-style: none; margin: 0 0 .25rem; padding: 0; display: grid; gap: .6rem; }
.shop-order-summary__line {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    font-size: .9375rem;
    color: var(--text2);
}
.shop-order-summary__line span:first-child { overflow-wrap: anywhere; min-width: 0; }
.shop-order-summary__line span:last-child { white-space: nowrap; }

.shop-order-summary__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-block: .65rem;
    border-block-start: 1px solid var(--border2);
    font-size: .9375rem;
    color: var(--text2);
}
.shop-order-summary__row.is-total { color: var(--text); font-size: 1.0625rem; font-weight: 600; }
.shop-order-summary__row.is-total strong { font-size: 1.375rem; font-weight: 700; color: var(--amber); }
.shop-order-summary__row.is-discount { color: var(--teal-d, var(--teal)); }

.shop-order-summary .shop-cart-checkout { margin-block-start: 1.1rem; }
.shop-order-summary__note { margin: .85rem 0 0; font-size: .8125rem; color: var(--text3); text-align: center; }

/* ---- member-discount banner: offered above the coupon box, gold-accented
   to read as a membership perk rather than a generic promo code. One row
   (icon, copy, CTA as three flex siblings) — see portal/checkout.css's own
   identical comment for why the copy block gets its own flex item (so long
   body text wraps inside it, not into the button) and why the CTA text uses
   --on-amber rather than a hardcoded color or --amber itself. ---- */
.shop-member-discount-banner {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .55rem .7rem;
    padding: .85rem 1.05rem;
    margin-block-end: .75rem;
    border: 1px solid var(--amber-l);
    border-radius: .85rem;
    background: linear-gradient(160deg, color-mix(in srgb, var(--amber) 16%, var(--bg2)), var(--bg2) 65%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
    font-size: .8125rem;
}
.shop-member-discount-banner__icon {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    background: var(--amber);
    color: var(--on-amber);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 18%, transparent);
}
.shop-member-discount-banner__copy { flex: 1 1 12rem; min-width: 0; }
.shop-member-discount-banner__headline { display: block; font-size: .9375rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.shop-member-discount-banner__text { margin: .15rem 0 0; font-weight: 500; line-height: 1.45; color: var(--text2); }
.shop-member-discount-banner__cta {
    flex: none;
    margin-inline-start: auto;
    padding: .5rem 1.2rem;
    border-radius: 999px;
    background: var(--amber);
    color: var(--on-amber);
    font-weight: 700;
    font-size: .78125rem;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: 0 2px 6px color-mix(in srgb, var(--amber) 45%, transparent);
    transition: transform .12s ease, box-shadow .12s ease;
}
.shop-member-discount-banner__cta:hover { background: var(--amber-d, var(--amber)); transform: translateY(-1px); box-shadow: 0 4px 10px color-mix(in srgb, var(--amber) 55%, transparent); }
.shop-member-discount-banner.is-applied .shop-member-discount-banner__icon { background: var(--teal-d, var(--teal)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 18%, transparent); }
.shop-member-discount-banner.is-applied .shop-member-discount-banner__headline { color: var(--teal-d, var(--teal)); }
.shop-member-discount-banner.is-applied .shop-member-discount-banner__cta {
    box-shadow: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text2);
}

.shop-cart-coupon { margin-block-end: .25rem; }
.shop-cart-coupon__form { display: flex; gap: .5rem; }
.shop-cart-coupon__form input {
    flex: 1;
    min-width: 0;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--bg);
    color: var(--text);
    font-size: .875rem;
}
.shop-cart-coupon__form button {
    padding: .55rem .9rem;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--bg3);
    color: var(--text);
    font-size: .875rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.shop-cart-coupon__form button:hover { border-color: var(--amber-l); }
.shop-cart-coupon__applied {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .75rem;
    padding: .55rem .7rem;
    border: 1px solid var(--teal-d, var(--teal));
    border-radius: var(--r);
    background: var(--teal-bg);
    color: var(--teal-d, var(--teal));
    font-size: .875rem;
    font-weight: 600;
}
.shop-cart-coupon__applied a { color: inherit; text-decoration: underline; font-weight: 500; white-space: nowrap; }
.shop-cart-coupon__msg { margin: .5rem 0 0; font-size: .8125rem; }
.shop-cart-coupon__msg.is-success { color: var(--teal-d, var(--teal)); }
.shop-cart-coupon__msg.is-error { color: var(--danger-d, var(--danger)); }

/* ---- mobile sticky bottom bar: the primary action, always reachable ---- */

.shop-cart-stickybar { display: none; }

@media (max-width: 60rem) {
    /* Reserves the bar's own footprint so it never covers the last line of
       the summary card or the footer beneath it — same technique shop.css
       uses to reserve space for .shop-bottomnav, scoped to this page's own
       class because cart.php does not render that bar (see _footer.php's
       comment: the cart has no bottom-nav tab of its own). */
    .shop-cart { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }

    .shop-cart-stickybar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 210;
        background: var(--bg2);
        border-block-start: 1px solid var(--border);
        box-shadow: var(--shadow-nav-stuck);
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    }
    .shop-cart-stickybar__total { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
    .shop-cart-stickybar__total span { font-size: .75rem; color: var(--text3); }
    .shop-cart-stickybar__total strong { font-size: 1.125rem; color: var(--amber); }
    .shop-cart-stickybar .shop-cta { flex: 0 0 auto; padding-inline: 1.5rem; }
}

/* ---- the per-line info control, and the one dialog it fills ---- */

.shop-cart-line__details {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 999px;
    color: var(--text3);
    transition: color .15s, background .15s;
}
.shop-cart-line__details:hover { color: var(--base); background: var(--base-bg); }
.shop-cart-line__details:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

.shop-cart-detail-dialog {
    /* min() so the panel is a comfortable column on a desktop and a full-width
       sheet on a phone, without a second breakpoint saying so. */
    width: min(30rem, calc(100vw - 2rem));
    max-height: min(80vh, 44rem);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--rl);
    background: var(--bg2);
    color: var(--text);
    box-shadow: var(--shadow-menu);
    overflow: hidden;
}
.shop-cart-detail-dialog::backdrop { background: var(--scrim); }
.shop-cart-detail-dialog__head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem .8rem;
    border-bottom: 1px solid var(--border);
}
.shop-cart-detail-dialog__head h2 { margin: 0; font-size: 1.125rem; font-family: var(--display); font-weight: 600; }
.shop-cart-detail-dialog__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--bg3);
    color: var(--text2);
    cursor: pointer;
}
.shop-cart-detail-dialog__close:hover { color: var(--text); background: var(--bg4); }
/* The body scrolls, not the dialog: the head with its close button stays put
   however long a description runs. */
.shop-cart-detail-dialog__body {
    padding: 1rem 1.25rem 1.25rem;
    overflow-y: auto;
    max-height: calc(min(80vh, 44rem) - 4.5rem);
}

.shop-cart-detail__licence { margin: 0; font-weight: 600; color: var(--amber); }
.shop-cart-detail__tagline { margin: .35rem 0 0; color: var(--text2); font-size: .9375rem; }
.shop-cart-detail h3 {
    margin: 1.25rem 0 .5rem;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text3);
}
/* shop_blocks() output: headings, bullets, code and images, already styled by
   shop.css which this page also loads. Only containment is added here — a code
   block or a wide image in a 30rem dialog must scroll or scale inside it
   rather than widen the panel past the viewport. */
.shop-cart-detail__about { color: var(--text2); font-size: .9375rem; line-height: 1.6; }
.shop-cart-detail__about > :first-child { margin-top: 0; }
.shop-cart-detail__about > :last-child { margin-bottom: 0; }
.shop-cart-detail__about pre { overflow-x: auto; max-width: 100%; }
.shop-cart-detail__about img { max-width: 100%; height: auto; }
.shop-cart-detail__terms,
.shop-cart-detail__includes { margin: 0; padding-inline-start: 1.1rem; color: var(--text2); font-size: .9375rem; }
.shop-cart-detail__terms li,
.shop-cart-detail__includes li { margin: .2rem 0; }
.shop-cart-detail__link {
    display: inline-block;
    margin-top: 1.25rem;
    font-size: .9375rem;
    font-weight: 600;
    color: var(--base);
}
.shop-cart-detail__link:hover { text-decoration: underline; }
