/**
 * KSEC block cart/checkout skin.
 *
 * Restyles WooCommerce block components to carry the KSEC checkout styling that
 * previously lived as classic-only CSS (theme Customizer post 36), whose
 * selectors don't exist on the block checkout. Store-NEUTRAL and enqueued on any
 * cart/checkout page: the selectors only match WooCommerce block markup, so it's
 * inert on a classic checkout — which means labs can adopt the block checkout
 * later and inherit this skin with no change. Class names verified against the
 * live eu block checkout DOM 2026-07-15.
 *
 * Selectors use the block's own double-class where needed for specificity, so no
 * !important is required.
 */

/* #1 "Available on backorder" badge — classic was red text
   (.cart p.backorder_notification { color:#ec0303 }); brand the block pill red
   instead of the default grey. */
.wc-block-components-product-badge.wc-block-components-product-backorder-badge {
	color: #e8000d;
	background: rgba( 232, 0, 13, 0.08 );
	border: 1px solid rgba( 232, 0, 13, 0.22 );
}

/* Order-summary SlotFill padding: the ExperimentalOrderMeta slot (where the
   dispatch + free-shipping notices land) renders its children flush; give them
   consistent inner padding. */
.wc-block-components-totals-wrapper.slot-wrapper > * > * {
	padding: 16px 16px 0 16px;
}

/* #9 Field validation errors — classic boxed .woocommerce-error; give the block
   inline error a branded red and a touch more weight so it reads clearly. Keeps
   the block's inline layout (no forced box that would collide with field flow). */
.wc-block-components-validation-error {
	color: #d5001c;
}
.wc-block-components-validation-error > p {
	font-weight: 500;
}

/* #7 Delivery-protection bump card. The "Conditional Extra Fees" plugin's optional-
   service checkbox DOES render on the block checkout (.pisol-fees-container) — the fee
   already works — but it's a bare label + checkbox, unlike the labs-uk classic bump
   card (icon + title + description). This restyles that container into a bump card
   with a shield icon + a reassurance line, so the block matches the UK richness.
   CSS-ONLY on purpose: .pisol-fees-container is React-managed and re-renders on every
   cart update, so injected DOM nodes would be wiped — styling survives. The native
   checkbox stays the Add/Remove control. Store-neutral: .pisol-fees-container only
   exists on the BLOCK checkout (classic pi-cefw uses .pi-cefw-optional-fees), so this
   is inert on classic labs; both KSEC stores' only optional fee is Delivery Protection,
   so the reassurance copy is accurate wherever it renders. */
.pisol-fees-container {
	margin: 12px 0 0;
	padding: 12px 14px;
	border: 1px solid #d7ece2;
	border-left: 4px solid #01cc68;
	border-radius: 8px;
	background: #f6fdf9;
}
.pisol-fees-container .pisol-fees-container-label {
	display: block;
	margin: 0 0 6px;
	font-weight: 600;
	color: #14320a;
}
.pisol-fees-container .pisol-fees-container-label::before {
	content: "🛡️ ";
}
.pisol-fees-container .pisol-fees-parent label {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-size: 14px;
	line-height: 1.4;
	cursor: pointer;
}
.pisol-fees-container .pisol-fees-parent input[type="checkbox"] {
	margin-top: 2px;
	flex: 0 0 auto;
}
/* Description + "learn what's covered" link injected by eu-delivery-protection-link.js
   (a real <a>, which a CSS ::after cannot provide). Kept out of the label so the link
   is clickable and the copy is selectable / screen-reader friendly. */
.pisol-fees-container .ksec-dp-extra {
	margin-top: 6px;
}
.pisol-fees-container .ksec-dp-extra .ksec-dp-desc {
	margin: 0;
	font-size: 12px;
	line-height: 1.45;
	color: #4f6b60;
}
.pisol-fees-container .ksec-dp-extra .ksec-dp-link {
	display: inline-block;
	margin-top: 4px;
	font-size: 12px;
	font-weight: 600;
	color: #01a152;
	text-decoration: underline;
}

/* "Optional services" relocated to the LEFT column (block-optional-services.js).
   Hide the Conditional Extra Fees plugin's own sidebar instance ONLY once our
   left-column card is anchored (body.ksec-optsvc-relocated is added by the JS only
   when our card is mounted and there are fee options), so the fee is never hidden
   without a visible replacement. At phone width WooCommerce renders the order
   summary in a separate fill (.checkout-order-summary-block-fill) outside the
   sidebar, so that copy is hidden as well; it showed an unticked box beside the
   DP9 "Included" row. */
body.ksec-optsvc-relocated .wc-block-checkout__sidebar .pisol-fees-container,
body.ksec-optsvc-relocated .checkout-order-summary-block-fill .pisol-fees-container {
	display: none !important;
}

/* Our left-column step (DEV-685). It reads as a checkout step like "Shipping options":
   Woo's own step heading classes carry the title, and the options sit in a bordered list
   like the delivery choices. No card, no side stripe (ui-craft-checklist item 10). The
   ticked row (.is-checked, set by the JS from the fee state) and the included cover row
   take the green highlight; each row pulls 1px over the list border so its own green
   border replaces the grey one rather than sitting inside it. */
#ksec-optional-services .ksec-optional-services {
	margin: 0 0 24px;
}
#ksec-optional-services .ksec-optsvc-heading {
	margin-bottom: 12px;
}
#ksec-optional-services .ksec-optsvc-list {
	border: 1px solid #e3e6ea;
	border-radius: 8px;
	background: #ffffff;
}
#ksec-optional-services .ksec-optsvc-item {
	position: relative;
	margin: -1px;
	padding: 12px 14px;
	border: 1px solid transparent;
	cursor: pointer;
}
#ksec-optional-services .ksec-optsvc-item:first-child {
	border-radius: 8px 8px 0 0;
}
#ksec-optional-services .ksec-optsvc-item:last-child {
	border-radius: 0 0 8px 8px;
}
#ksec-optional-services .ksec-optsvc-item:only-child {
	border-radius: 8px;
}
#ksec-optional-services .ksec-optsvc-item + .ksec-optsvc-item {
	border-top-color: #e3e6ea;
}
#ksec-optional-services .ksec-optsvc-item.is-checked,
#ksec-optional-services .ksec-optsvc-item.is-included {
	z-index: 1;
	border-color: #3bb54a;
	background: #f2faf6;
}
#ksec-optional-services .ksec-optsvc-check {
	display: flex;
	align-items: flex-start;
	gap: 9px;
	font-size: 14px;
	font-weight: 600;
	color: #1d2125;
	cursor: pointer;
}
#ksec-optional-services .ksec-optsvc-title {
	flex: 1 1 auto;
}
#ksec-optional-services .ksec-optsvc-amount {
	flex: 0 0 auto;
	margin-left: auto;
	padding-left: 12px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
#ksec-optional-services .ksec-optsvc-check input[type="checkbox"] {
	margin: 2px 0 0;
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	accent-color: #3bb54a;
	cursor: pointer;
}
#ksec-optional-services .ksec-dp-extra {
	margin: 6px 0 0 25px;
}
/* DP8 end-of-year half price: the real full price struck in the muted text colour,
   and the sale line in the card's title colour above the description. */
#ksec-optional-services .ksec-optsvc-was {
	font-weight: 400;
	color: #5b6670;
}
#ksec-optional-services .ksec-optsvc-save {
	display: block;
	text-align: right;
	font-size: 12px;
	font-weight: 600;
	color: #0f5132;
}
#ksec-optional-services .ksec-dp-extra .ksec-dp-sale,
.pisol-fees-container .ksec-dp-extra .ksec-dp-sale {
	margin: 0 0 2px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.45;
	color: #173404;
}
/* DP9 included cover: a fixed row, so no pointer on the row or the disabled control. */
#ksec-optional-services .ksec-optsvc-item.is-included,
#ksec-optional-services .ksec-optsvc-item.is-included .ksec-optsvc-check,
#ksec-optional-services .ksec-optsvc-item.is-included .ksec-optsvc-check input[type="checkbox"] {
	cursor: default;
}
#ksec-optional-services .ksec-optsvc-included {
	font-weight: 600;
	color: #0f5132;
}
#ksec-optional-services .ksec-optsvc-pill {
	display: inline-block;
	padding: 2px 9px;
	border-radius: 999px;
	background: rgba(59, 181, 74, 0.14);
	font-size: 12px;
	color: #0e5a1e;
}
#ksec-optional-services .ksec-dp-extra .ksec-dp-desc {
	margin: 0;
	font-size: 12px;
	line-height: 1.45;
	color: #5b6670;
}
#ksec-optional-services .ksec-dp-extra .ksec-dp-link {
	display: inline-block;
	margin-top: 4px;
	font-size: 12px;
	font-weight: 600;
	color: #01a152;
	text-decoration: underline;
}

/* Sale badge + discounted prices in the block ORDER SUMMARY. The block defaults are a
   plain grey "Save £X" box and a mid-grey discounted price; re-skin to the KSEC green
   accent used by the checkout cards (the "Save" pill matches the savings-badge -Y% pill),
   with the old price clearly struck/secondary and the new price emphasised. Scoped to the
   order summary so it does not touch product-archive/cart sale badges. */
.wc-block-components-order-summary-item .wc-block-components-sale-badge {
	display: inline-block;
	margin-top: 2px;
	padding: 2px 9px;
	border-radius: 999px;
	background: rgba(59, 181, 74, 0.14);
	color: #0e5a1e;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.01em;
}
.wc-block-components-order-summary-item .wc-block-components-sale-badge .wc-block-formatted-money-amount {
	font-weight: 700;
}
/* Was: regular price, struck through — make it clearly the secondary figure. */
.wc-block-components-order-summary-item__regular-individual-price {
	color: #8a9199;
	font-size: 12px;
	font-weight: 400;
}
/* Now: discounted price — emphasised (bold, light KSEC green), no default <ins> underline. */
.wc-block-components-order-summary-item__individual-price.is-discounted {
	color: #01a152;
	font-weight: 700;
	text-decoration: none;
}

/* Order of the cards below the total (the ExperimentalOrderMeta slot). Default DOM order
   is [pisol fees] -> order bump ("Don't forget to buy...") -> savings ("Your discount").
   Put "Your discount" ABOVE the order bump (both stay below the total) by flex-ordering the
   slot's direct children. The hidden pisol container keeps its default order:0 but is
   display:none so it takes no space. */
.wc-block-checkout__sidebar .wc-block-components-order-meta {
	display: flex;
	flex-direction: column;
}
.wc-block-checkout__sidebar .wc-block-components-order-meta > * {
	order: 3;
}
.wc-block-checkout__sidebar .wc-block-components-order-meta > .ksec-eu-savings-badge {
	order: 1;
}
.wc-block-checkout__sidebar .wc-block-components-order-meta > .ksec-block-order-bump {
	order: 2;
}

/* Hide the product SHORT DESCRIPTION in the block order summary robustly, regardless of
   whether the Store API payload still carries it (the server-side strip only fires on some
   routes/loads). The summary shows name + price + quantity only. Scoped to the order
   summary item so PDP/cart descriptions elsewhere are unaffected. */
.wc-block-components-order-summary-item .wc-block-components-product-metadata__description {
	display: none !important;
}

/* Item data rows go the same way, EXCEPT a row carrying .ksec-bo-keep-in-summary
   (ksec-backorder-manager SUMMARY_KEEP_CLASS: change it in both places or neither).
   That is the Back-ordered restock date (Batch BK1, 2026-10-10), which has to be
   read here, before paying. The container hides when it holds no kept row; when it
   does, only the other rows hide. Each row's " / " separator sits inside its own
   span, so it hides with it. Three rules rather than one selector list: a browser
   without :has() drops only the container rule, and the row rule still hides the
   rest. */
.wc-block-components-order-summary-item .wc-block-components-product-metadata > .wc-block-components-product-details:not(:has(> .ksec-bo-keep-in-summary)) {
	display: none !important;
}
.wc-block-components-order-summary-item .wc-block-components-product-metadata > .wc-block-components-product-details > :not(.ksec-bo-keep-in-summary) {
	display: none !important;
}
/* The kept row is the only visible one, so its own separator never separates
   anything. It renders when a hidden row follows it, as a "Discount: Free" row
   (WPLoyalty, Discount Rules, priority 100) does on a free-product line. */
.wc-block-components-order-summary-item .wc-block-components-product-metadata > .wc-block-components-product-details > .ksec-bo-keep-in-summary > [aria-hidden="true"] {
	display: none !important;
}

/* VAT country confirmation ("sometimesask" conflict resolution on eu).
   The EU VAT Compliance plugin appends its country-confirmation radios in a fieldset of
   their own as the LAST child of the checkout form, which puts them BELOW the Place Order
   button, after the terms line, where no customer sees them before paying. The answer
   decides which member state the VAT number is validated against, so it has to sit with
   the VAT number field it governs, up in the address step.

   CSS-ONLY on purpose, same reasoning as the .pisol-fees-container card above: the radios
   are a React RadioControl owned by the plugin's Checkout Block integration, so anything
   that depends on where the node sits in the DOM is at the mercy of the next re-render.
   Flex ordering moves it visually with no DOM mutation and no JS to keep in sync, the same
   technique already used for the order-meta slot below.

   Two buckets are enough because flexbox preserves source order within a bucket. Bucket 0
   (the default) is everything up to and including #shipping-fields plus the plugin's
   trailing fieldset, which is the only source-order outlier. Bucket 1 is everything that
   has to stay below it. Anything WooCommerce adds later defaults to bucket 0, so the
   trailing group is the one listed explicitly. */
.wc-block-checkout__form {
	display: flex;
	flex-direction: column;
}
.wc-block-checkout__form > #billing-fields,
.wc-block-checkout__form > #shipping-option,
.wc-block-checkout__form > #ksec-optional-services,
.wc-block-checkout__form > #payment-method,
.wc-block-checkout__form > .wc-block-checkout__terms,
.wc-block-checkout__form > .wc-block-checkout__actions {
	order: 1;
}

/* The plugin emits its fieldset on every checkout load and only fills it when there is a
   conflict to resolve, so collapse the empty case rather than leaving a gap between the
   shipping and billing steps. Matched on wp-block-billing-fields WITHOUT an id: the real
   billing step is #billing-fields and carries wp-block-woocommerce-checkout-billing-address-block. */
.wc-block-checkout__form > fieldset.wp-block-billing-fields:not([id]) {
	margin: 0;
	padding: 0;
	border: 0;
}
.wc-block-checkout__form > fieldset.wp-block-billing-fields:not([id]):not(:has(#woocommerce_eu_vat_compliance_self_certify)) {
	display: none;
}

/* Card, styled to sit with the other checkout cards. Neutral slate rather than the green
   used by Optional services: this is a required tax question, not an upsell, and it must
   not read as an error either. */
.wc-block-checkout__form #woocommerce_eu_vat_compliance {
	margin: 4px 0 24px;
	padding: 14px 16px;
	border: 1px solid #dde1e6;
	border-left: 4px solid #55606b;
	border-radius: 8px;
	background: #f7f8fa;
}

/* Empty heading + description the plugin renders above the radios. The VAT number input
   itself lives in the address form, not here, so this wrapper is blank in practice. The
   :has() guard leaves it alone if a future release does render the field inside it. */
.wc-block-checkout__form #woocommerce_eu_vat_compliance_vat_number:not(:has(input)) {
	display: none;
}

/* The question. This is the plugin's own translatable string (filtered in
   everywhere/vat-country-prompt-copy.php), not CSS content, so TranslatePress can reach it. */
.wc-block-checkout__form #woocommerce_eu_vat_compliance .vat_self_certify_lbl {
	margin: 0 0 12px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.45;
	color: #1e2429;
}

.wc-block-checkout__form #woocommerce_eu_vat_compliance .components-radio-control {
	margin: 0;
	padding: 0;
	border: 0;
}
.wc-block-checkout__form #woocommerce_eu_vat_compliance .components-radio-control__group-wrapper {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

/* Selectable rows, matching the shipping-options rows rather than the browser default
   radio-plus-loose-text, which read as two stray lines of body copy. */
.wc-block-checkout__form #woocommerce_eu_vat_compliance .components-radio-control__option {
	position: relative;
	margin: 0;
	border: 1px solid #dde1e6;
	border-radius: 6px;
	background: #fff;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}
.wc-block-checkout__form #woocommerce_eu_vat_compliance .components-radio-control__option:hover {
	border-color: #b9c1c9;
}
.wc-block-checkout__form #woocommerce_eu_vat_compliance .components-radio-control__option:has(input:checked) {
	border-color: #55606b;
	background: #fff;
	box-shadow: inset 0 0 0 1px #55606b;
}
.wc-block-checkout__form #woocommerce_eu_vat_compliance .components-radio-control__option:has(input:focus-visible) {
	outline: 2px solid #1e2429;
	outline-offset: 2px;
}

.wc-block-checkout__form #woocommerce_eu_vat_compliance .components-radio-control__input {
	position: absolute;
	margin: 0;
	width: 16px;
	height: 16px;
	accent-color: #55606b;
	inset: 13px auto auto 14px;
	cursor: pointer;
}
.wc-block-checkout__form #woocommerce_eu_vat_compliance .components-radio-control__option label {
	display: block;
	margin: 0;
	padding: 11px 14px 11px 40px;
	font-size: 14px;
	line-height: 1.4;
	color: #1e2429;
	cursor: pointer;
}
.wc-block-checkout__form #woocommerce_eu_vat_compliance .components-radio-control__option:has(input:checked) label {
	font-weight: 600;
}

/* Side-cart Delivery Protection: hidden on checkout only.
   The PHP render guard cannot do this, because the drawer is rebuilt by
   wc-ajax=get_refreshed_fragments, which is its own request where is_checkout()
   is false and the page context is invisible. Its toggle script is not loaded on
   checkout either, so a control shown there would be inert as well as duplicate:
   the full Optional services card already offers the same fee on that screen. */
body.woocommerce-checkout .ksec-sc-dp {
	display: none;
}

/* UX L4.1 (labs and eu): after an empty Place order the first invalid field
   (email) was focused 0 to 50px from the top, under the sticky header
   (.col-full-nav.is_stuck on desktop, .site-header on phones). Scroll padding
   on the viewport keeps focus and scrollIntoView clear of it. Checkout only:
   this file also loads on the basket, which is left as it was. Works on the
   classic and the block checkout alike, since it targets html, not block markup. */
html:has(> body.woocommerce-checkout) {
	scroll-padding-top: 72px;
}

/* DP9 included Delivery Protection row in the block totals (drawn by
   assets/js/dp-included-totals-row.js). The label is long for the sidebar, so it
   shrinks and wraps on its own line while 0.00 stays on the right. */
.ksec-dp-included-total .wc-block-components-totals-item {
	flex-wrap: nowrap;
	align-items: flex-start;
}
.ksec-dp-included-total .wc-block-components-totals-item__label {
	flex: 1 1 auto;
	min-width: 0;
}
.ksec-dp-included-total .wc-block-components-totals-item__value {
	flex: 0 0 auto;
	margin-left: 12px;
	white-space: nowrap;
}
