/**
 * Builder sets in the cart (TASK-60.4, option A).
 *
 * A set is one native line per fragrance. These rules draw the lines of one set
 * as one labelled box (owner decision 2026-10-02): block cart rows, checkout
 * order-summary rows and the Shoptimizer side cart. Classes come from
 * set-builder-cart-blocks.js (cartItemClass) and, in the side cart and classic
 * cart, from Fragnatium_Set_Builder_Cart::row_class().
 *
 * Square corners, ink rule, saffron wash — the brand tokens from style.css.
 */

/* --- Block cart rows ---------------------------------------------------------- */

/* The wash goes on the row: WooCommerce clears every cell's background
   (!important), and a table row paints its own behind its cells. */
.wc-block-cart-items__row.fn-set {
	background: var(--sg-accent-light-bg, rgba(255, 211, 105, 0.15));
}

.wc-block-cart-items__row.fn-set > td {
	border-top: 0 !important;
	border-bottom: 0 !important;
}

.wc-block-cart-items__row.fn-set > td:first-child {
	box-shadow: inset 3px 0 0 var(--sg-ink, #222831);
}

.wc-block-cart-items__row.fn-set > td:last-child {
	box-shadow: inset -1px 0 0 var(--sg-border, rgba(34, 40, 49, 0.14));
}

.wc-block-cart-items__row.fn-set--first > td {
	border-top: 1px solid var(--sg-ink, #222831) !important;
	padding-top: var(--sg-space-4, 1rem);
}

.wc-block-cart-items__row.fn-set--last > td {
	border-bottom: 1px solid var(--sg-ink, #222831) !important;
	padding-bottom: var(--sg-space-4, 1rem);
}

/* The total cell is a flex box in the block cart, so it stops at its content
   height and the set's box would break around it; keep it a full-height cell. */
.wc-block-cart-items__row.fn-set > td.wc-block-cart-item__total {
	display: table-cell;
	vertical-align: top;
	text-align: right;
}

/* Narrow carts (WooCommerce's own container query): each row becomes a grid
   with 16px column gaps, so rules and borders drawn on the cells came out in
   pieces. Draw the box on the row instead. */
@container (max-width: 919px) {
	.wc-block-cart table.wc-block-cart-items .wc-block-cart-items__row.fn-set {
		box-shadow:
			inset 3px 0 0 var(--sg-ink, #222831),
			inset -1px 0 0 var(--sg-border, rgba(34, 40, 49, 0.14));
		border-bottom: 0 !important;
	}

	.wc-block-cart table.wc-block-cart-items .wc-block-cart-items__row.fn-set > td {
		box-shadow: none;
		border-top: 0 !important;
		border-bottom: 0 !important;
	}

	.wc-block-cart table.wc-block-cart-items .wc-block-cart-items__row.fn-set--first {
		border-top: 1px solid var(--sg-ink, #222831) !important;
	}

	.wc-block-cart table.wc-block-cart-items .wc-block-cart-items__row.fn-set--last {
		border-bottom: 1px solid var(--sg-ink, #222831) !important;
	}
}

/* One quantity per set: the other rows show WooCommerce's read-only box. */
.wc-block-cart-items__row.fn-set:not(.fn-set--first) .wc-block-components-quantity-selector,
.wc-block-cart-items__row.fn-set:not(.fn-set--first) .wc-block-cart-item__quantity {
	display: none;
}

/* Breathing room between two sets, or a set and an ordinary line. */
.wc-block-cart-items__row.fn-set--last + .wc-block-cart-items__row > td {
	border-top-width: 0;
}

.wc-block-cart-items__row.fn-set--first + .wc-block-cart-items__row:not(.fn-set) > td,
.wc-block-cart-items__row.fn-set--last + .wc-block-cart-items__row > td {
	padding-top: var(--sg-space-6, 1.5rem);
}

/* "Set 1 · built by you" — the text is a rule written by the script, per set number. */
.wc-block-cart-items__row.fn-set--first td.wc-block-cart-item__product::before,
.wc-block-components-order-summary-item.fn-set--first .wc-block-components-order-summary-item__description::before {
	display: block;
	margin: 0 0 var(--sg-space-2, 0.5rem);
	font: var(--sg-eyebrow, 600 0.7rem/1 'Inter', sans-serif);
	/* The eyebrow's line-height of 1 stacks the lines when a narrow column wraps it. */
	line-height: 1.35;
	letter-spacing: var(--sg-track-caps, 0.14em);
	text-transform: uppercase;
	color: var(--sg-ink, #222831);
}

/*
 * Savings are shown once per set, in the totals sidebar — not as a struck-through
 * "regular" price and a "Save" badge per member (owner decision 3, Omnibus).
 */
.fn-set .wc-block-components-product-price__regular,
.fn-set .wc-block-components-sale-badge,
.fn-set .wc-block-components-product-badge.wc-block-components-sale-badge {
	display: none !important;
}

.fn-set .wc-block-components-product-price__value.is-discounted {
	margin-left: 0;
	color: inherit;
	font-weight: inherit;
	background: none;
}

/* A member that blocks checkout. The text comes from the script's rule. */
.fn-set-member--flagged .wc-block-components-product-name::after,
.fn-set-member--stock .wc-block-components-product-name::after {
	display: block;
	margin-top: var(--sg-space-1, 0.25rem);
	padding: 0.15rem 0.4rem;
	width: fit-content;
	font: var(--sg-caption, 500 0.75rem/1.5 'Inter', sans-serif);
	color: var(--sg-ink, #222831);
	background: var(--sg-accent, #ffd369);
}

.fn-set-member--flagged .wc-block-components-product-name::before,
.fn-set-member--stock .wc-block-components-product-name::before {
	content: '⚠ ';
}

/* --- Checkout order summary --------------------------------------------------- */

.wc-block-components-order-summary-item.fn-set {
	background: var(--sg-accent-light-bg, rgba(255, 211, 105, 0.15));
	box-shadow: inset 3px 0 0 var(--sg-ink, #222831);
	padding-left: var(--sg-space-3, 0.75rem);
	padding-right: var(--sg-space-2, 0.5rem);
	margin: 0;
}

.wc-block-components-order-summary-item.fn-set--first {
	border-top: 1px solid var(--sg-ink, #222831);
	padding-top: var(--sg-space-3, 0.75rem);
	margin-top: var(--sg-space-2, 0.5rem);
}

.wc-block-components-order-summary-item.fn-set--last {
	border-bottom: 1px solid var(--sg-ink, #222831);
	padding-bottom: var(--sg-space-3, 0.75rem);
	margin-bottom: var(--sg-space-2, 0.5rem);
}

/* --- Totals sidebar: one summary per set --------------------------------------- */

.fn-set-summary {
	display: grid;
	gap: var(--sg-space-3, 0.75rem);
	padding-top: var(--sg-space-4, 1rem) !important;
	padding-bottom: var(--sg-space-4, 1rem) !important;
}

.fn-set-summary__set {
	padding: var(--sg-space-3, 0.75rem) var(--sg-space-4, 1rem);
	background: var(--sg-accent-light-bg, rgba(255, 211, 105, 0.15));
	box-shadow: inset 3px 0 0 var(--sg-ink, #222831);
}

.fn-set-summary__set.is-flagged {
	box-shadow: inset 6px 0 0 var(--sg-ink, #222831);
	outline: 2px solid var(--sg-ink, #222831);
	outline-offset: -2px;
}

/* Specific enough to beat the checkout's heading styles. */
.wc-block-components-totals-wrapper.fn-set-summary .fn-set-summary__title {
	margin: 0 0 var(--sg-space-1, 0.25rem);
	padding: 0;
	font: var(--sg-eyebrow, 600 0.7rem/1 'Inter', sans-serif);
	letter-spacing: var(--sg-track-caps, 0.14em);
	text-transform: uppercase;
	color: var(--sg-ink, #222831);
}

.fn-set-summary__meta {
	margin: 0 0 var(--sg-space-2, 0.5rem);
	font: var(--sg-body-sm, 400 0.85rem/1.6 'Inter', sans-serif);
	color: var(--sg-muted, #393e46);
	white-space: normal;
}

.fn-set-summary__prices {
	margin: 0;
	display: grid;
	gap: 0.15rem;
}

.fn-set-summary__row {
	display: flex;
	justify-content: space-between;
	gap: var(--sg-space-3, 0.75rem);
	font: var(--sg-body-sm, 400 0.85rem/1.6 'Inter', sans-serif);
}

.fn-set-summary__row dt,
.fn-set-summary__row dd {
	margin: 0;
	font-weight: inherit;
}

.fn-set-summary__row dd {
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.fn-set-summary__row.is-total {
	margin-top: 0.2rem;
	padding-top: 0.3rem;
	border-top: 1px solid var(--sg-border, rgba(34, 40, 49, 0.14));
	font-weight: 600;
	color: var(--sg-ink, #222831);
}

.fn-set-summary__save {
	display: inline-block;
	margin: var(--sg-space-2, 0.5rem) 0 0;
	padding: 0.1rem 0.5rem;
	font: var(--sg-caption, 500 0.75rem/1.5 'Inter', sans-serif);
	color: var(--sg-ink, #222831);
	background: var(--sg-accent, #ffd369);
}

.fn-set-summary__alert {
	margin: var(--sg-space-2, 0.5rem) 0 0;
	padding: var(--sg-space-2, 0.5rem) var(--sg-space-3, 0.75rem);
	border: 2px solid var(--sg-ink, #222831);
	background: #fff;
	font: var(--sg-body-sm, 400 0.85rem/1.6 'Inter', sans-serif);
	color: var(--sg-ink, #222831);
}

.fn-set-summary__alert p {
	margin: 0;
}

.fn-set-summary__edit {
	display: table;
	margin-top: var(--sg-space-2, 0.5rem);
	font: 600 0.85rem/1.4 var(--sg-body, 'Inter', sans-serif);
	color: var(--sg-ink, #222831);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.fn-set-summary__edit:hover,
.fn-set-summary__edit:focus-visible {
	text-decoration-thickness: 2px;
}

/* --- Shoptimizer side cart and classic cart ------------------------------------- */

li.woocommerce-mini-cart-item.fn-set,
.woocommerce-cart-form__cart-item.fn-set > td {
	background: var(--sg-accent-light-bg, rgba(255, 211, 105, 0.15));
}

/* No padding-left here: the parent's 35px left padding is the gutter the bin
   (a.remove, absolutely placed) sits in; narrowing it put the bin on the text. */
li.woocommerce-mini-cart-item.fn-set {
	box-shadow: inset 3px 0 0 var(--sg-ink, #222831);
	border-bottom: 0 !important;
	margin-bottom: 0 !important;
}

li.woocommerce-mini-cart-item.fn-set--first {
	border-top: 1px solid var(--sg-ink, #222831) !important;
	margin-top: var(--sg-space-2, 0.5rem);
}

li.woocommerce-mini-cart-item.fn-set--last {
	border-bottom: 1px solid var(--sg-ink, #222831) !important;
	margin-bottom: var(--sg-space-2, 0.5rem) !important;
}

.fn-set-label {
	display: block;
	margin-bottom: var(--sg-space-1, 0.25rem);
	font: var(--sg-eyebrow, 600 0.7rem/1 'Inter', sans-serif);
	letter-spacing: var(--sg-track-caps, 0.14em);
	text-transform: uppercase;
	color: var(--sg-ink, #222831);
}

.fn-set-total {
	display: block;
	margin-top: var(--sg-space-1, 0.25rem);
	font: 600 0.8rem/1.4 var(--sg-body, 'Inter', sans-serif);
	color: var(--sg-ink, #222831);
}

.fn-set--flagged .fn-set-label::after {
	content: ' ⚠';
}

@media (prefers-reduced-motion: no-preference) {
	.fn-set-summary__set {
		transition: box-shadow var(--sg-dur-fast, 0.2s) var(--sg-lux-ease, ease);
	}
}
