/**
 * Dino Discounts — Mini-Cart Discount Display Styles
 *
 * Uses class-based CSS with no colour declarations so that discount lines
 * inherit the active theme's text colour (Astra, Elementor, etc.).
 * Override the CSS custom properties in your theme to restyle nudges.
 */

/*
 * PROVENANCE SENTINEL — do not remove. Marks this stylesheet as dino's from
 * inside the CSS text, so `tests/e2e/helpers/removal-affordance.js` attributes a
 * `display:none` shipped from HERE to dino and never to the merchant. Full
 * rationale: the sentinel note in `reward-removal.css`.
 */
:root {
    --dino-reward-removal-css: 1;
}

/* ── Custom properties (override in your theme) ────────────────── */

.dd-spend-more-nudge {
    --dd-nudge-padding:    10px 0;
    --dd-nudge-margin:     12px 0;
    --dd-nudge-font-size:  inherit;
}

/* ── Standalone cart-notice overlap resilience ─────────────────────────────
 * (bug-notice-overlap-block-checkout-2026-06-28)
 *
 * The merchant cart-notice is a vanilla `wc_add_notice( …, 'notice' )` that
 * WooCommerce renders as a normal STATIC banner (block: `.wc-block-components-
 * notice-banner`; classic: `.woocommerce-info` / `.woocommerce-message`), stamped
 * with the `data-dino-cart-notice` marker by MessagingCartNotice. On a clean
 * install it sits in normal flow with a positive margin and never overlaps. But
 * some themes / page-builders override the WC notice banner with a fixed height,
 * a clipped `overflow`, a negative/zero bottom margin, or absolute/positioned
 * placement — any of which makes the banner's box sit OVER the element after it
 * (the field/label below the notice gets covered: "notice over the top of text").
 *
 * These declarations pin OUR marked notice back into normal document flow so it
 * can never be pulled out of flow, clipped, or collapsed onto the next block.
 * Scoped to the dino marker so no other plugin's or theme's notices are touched;
 * `!important` is required to win over a theme rule on the same banner. This
 * cannot fix a theme that negatively-margins the FOLLOWING element instead — that
 * remains a theme-side fix (see docs/diagnostics/notice-overlap-investigation-
 * 2026-06-28.md). */
[data-dino-cart-notice] {
    position: relative !important;
    z-index: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    margin-bottom: 16px !important;
}

/* The immediate WRAPPER that holds a Dino notice. A theme can box the notice by
 * styling its container instead of the banner — e.g. a fixed height + clipped
 * `overflow` on the notices wrapper crops the banner over the next block. The
 * `:has(> …)` guard is scoped to a parent that DIRECTLY contains our marked
 * notice (never a broad ancestor), so it only relaxes a wrapper that actually
 * holds a Dino notice. We neutralise clipping/height here but deliberately do
 * NOT force the wrapper's position (that belongs to the theme's layout).
 *
 * Browser support: the banner-level rule above is universal and carries the
 * primary fix (the common negative-margin / fixed-height case acts on the banner
 * itself). This wrapper guard uses `:has()` (Chrome/Edge 105+, Safari 15.4+,
 * Firefox 121+); on a browser without `:has()` it is simply ignored and the
 * banner-level guard still applies — graceful degradation, never a regression. */
:has(> [data-dino-cart-notice]) {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

/* The Dino-owned below-title notice container (server-rendered by
 * Frontend::render_dino_notice_region on `woocommerce_before_cart` /
 * `woocommerce_before_checkout_form`). It hosts the dino cart notice in the page
 * flow below the title instead of the theme's `.woocommerce-notices-wrapper`,
 * which some themes CSS-position ABOVE the title on mobile (mobile-notice-title-
 * overlap-2026-07-01). It carries no visual style of its own — the notice inside
 * keeps its native WooCommerce banner styling — but an EMPTY container (the stable
 * anchor rendered before any notice is delivered) collapses to nothing so it never
 * adds a stray gap above the cart/checkout. */
[data-dino-cart-notice-region]:empty {
    display: none;
}

/* ── Mini-cart discount lines ──────────────────────────────────── */

.dd-mini-cart-discounts {
    padding: 8px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.2);
    margin-bottom: 8px;
    font-size: 13px;
    color: inherit;
}

.dd-discount-line {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    color: inherit;
}

.dd-discount-line span {
    color: inherit;
}

/* ── Block mini-cart drawer: native 16px content inset ──────────────────────
 * (block-minicart-discount-rows-full-bleed)
 *
 * In the WooCommerce Blocks mini-cart drawer, dino's `.dd-mini-cart-discounts`
 * container (which holds the discount lines and the net-total row) is injected
 * as a SIBLING of `.wc-block-mini-cart__footer`, directly inside the drawer's
 * content wrapper (`.wp-block-woocommerce-mini-cart-contents`, itself
 * `padding:0`). WooCommerce insets every native section 16px horizontally
 * (`.wc-block-mini-cart__items` → `padding:16px 16px 0`; `.wc-block-mini-cart__
 * footer` → `padding:24px 16px`). Without a matching inset our rows ran
 * full-bleed to the drawer edge, so their amounts sat ~16px to the right of the
 * native "Subtotal" row. Mirror WC's own 16px content inset so our rows join
 * the same content column and align with the native totals. Scoped to the block
 * drawer only — the classic / Elementor mini-cart lays these rows out in its own
 * flow and must not be touched. */
.wc-block-mini-cart__drawer .dd-mini-cart-discounts {
    padding-left: 16px;
    padding-right: 16px;
}

/* Net-discounted total — the block mini-cart's running total after dino's
   discount lines, so the listed discounts visibly net down instead of
   leaving only WC's pre-discount "Subtotal"
   (block-minicart-discount-net-total-display). */
.dd-mini-cart-net-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0 3px;
    margin-top: 4px;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    font-weight: 600;
    color: inherit;
}

.dd-mini-cart-net-total span {
    color: inherit;
}

/* ── Spend-More Nudge (FF-SPENDMORE) ────────────────────────────── */
.dd-spend-more-nudge {
    display: block;
    padding: var(--dd-nudge-padding);
    margin: var(--dd-nudge-margin);
    font-size: var(--dd-nudge-font-size);
    line-height: 1.5;
    color: inherit;
}

.dd-spend-more-nudge--empty {
    display: none;
}

.dd-spend-more-nudge--mini-cart {
    --dd-nudge-font-size: 0.9em;
    --dd-nudge-padding:   6px 0;
    --dd-nudge-margin:    8px 0;
}

/* ── Per-item attribution (FEAT-PER-ITEM-ATTRIBUTION-ALL-SURFACES) ── */

.dd-mini-cart-per-item {
    font-size: 0.85em;
    padding: 2px 0 0;
    color: inherit;
    opacity: 0.85;
}

.dd-free-gift-price {
    font-weight: 600;
}

/*
 * ── Block / Store-API free-gift "Free" label ──────────────────────────────
 * (free-gift-price-free-label-2026-06-22)
 *
 * The WooCommerce Blocks cart / checkout-summary / mini-cart render their money
 * columns from the Store API and never run the PHP "Free" filters, so a £0 gift
 * line would show a struck original price + a bare "£0.00". The companion
 * `assets/js/cart-block-free-gift.js` tags those rows with `.dd-block-free-gift`
 * via the `cartItemClass` checkout filter (`cart-ui-drawer-extras.js` tags them
 * in the Mini-Cart drawer), and these rules render "Free" in
 * the per-unit price AND line-total cells instead. The struck original price and
 * the "Save £x" sale badge are hidden (they read as confusing on a free line).
 *
 * Accessibility: the accurate £0.00 value is kept in the accessibility tree
 * (visually hidden, not removed), so assistive tech still announces the real
 * price; only the SIGHTED rendering swaps to "Free". The label text comes from
 * the `--dd-free-gift-label` custom property `Frontend::enqueue_frontend_styles`
 * sets from the localized "Free" string, with a literal fallback.
 */
.dd-block-free-gift .wc-block-components-product-price__regular,
.dd-block-free-gift .wc-block-components-sale-badge {
    display: none !important;
}

.dd-block-free-gift .wc-block-components-product-price__value {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.dd-block-free-gift .wc-block-components-product-price::after {
    content: var(--dd-free-gift-label, "Free");
    font-weight: 600;
}

/*
 * The "Free gift:" prefix on a gift line's name in the block Mini-Cart drawer.
 * `cart-ui-drawer-extras.js` tags the row `.dd-gift-prefix` unless the merchant
 * hid the label on the mini-cart surface; the localized text arrives on
 * `--dd-free-gift-prefix`. The block cart and checkout prefix the name through
 * the `itemName` checkout filter instead.
 */
.dd-gift-prefix .wc-block-components-product-name::before {
    content: var(--dd-free-gift-prefix, "Free gift: ");
}

/*
 * ── Block / Store-API free-gift line: no quantity control at all ──────────
 *
 * The engine grants exactly one unit of the gift and pins it server-side
 * (`GiftLinePlumbing::clamp_gift_cart_item_quantities`), and the Store API
 * reports the line as non-editable so `cart/update-item` refuses a change for
 * it. WooCommerce Blocks still draws the quantity-selector widget for the row —
 * and draws its -/+ buttons wherever that non-editable flag does not reach the
 * rendered control — offering a shopper a way to ask for more free units that
 * can only ever fail.
 *
 * A fixed free gift has no quantity to pick, so the widget is removed outright
 * rather than shown inert: nothing on the row invites an edit, and there is no
 * dead control to explain. This is presentation only — the clamp above is the
 * authority. The "Remove item" button is a SIBLING of the selector inside
 * `.wc-block-cart-item__quantity`, not a child, so declining the gift is
 * untouched.
 *
 * Accessibility: unlike the "Free" price rule above — which keeps the real
 * £0.00 visually-hidden so assistive tech still announces the true value — this
 * one REMOVES the quantity from the accessibility tree, deliberately. There is
 * no value being withheld: the quantity is always 1 and cannot be changed, so
 * dropping it keeps the AT and sighted renderings in parity instead of
 * announcing a control no shopper can reach.
 *
 * Surfaces: `.dd-block-free-gift` is stamped in the block cart and the
 * mini-cart drawer, so this reaches both — wanted, for the same reason. The
 * block checkout order summary renders its count as `…order-summary-item__quantity`, not this widget, and is
 * unaffected.
 */
.dd-block-free-gift .wc-block-components-quantity-selector {
    display: none !important;
}
