/**
 * WC Fiscal Fields — checkout styles
 *
 * Conditional field visibility is managed on two layers:
 *
 * 1. CSS :has() rules below — hide wrappers before JS runs, preventing a
 *    flash of visible content on initial page load. Requires the
 *    data-wcff-conditional attribute set by PHP on each conditional <input>.
 *    Supported in Chrome 105+, Firefox 121+, Safari 15.4+.
 *
 * 2. JavaScript (checkout.js) — adds/removes the .wcff-invoice-active class
 *    on <body> and sets wrapper.style.display as a fallback for older browsers
 *    and for any wrapper that does not match the selectors below exactly.
 *
 * The :has() selectors target 1–3 nesting levels between the list container
 * and the <input> to accommodate variations in WooCommerce Block Checkout's
 * generated markup across versions.
 */

/* --- Conditional field wrappers: hidden by default, shown when invoice active --- */
body:not( .wcff-invoice-active ) [class*="additional-fields-list"] > *:has( > input[data-wcff-conditional] ),
body:not( .wcff-invoice-active ) [class*="additional-fields-list"] > *:has( > * > input[data-wcff-conditional] ),
body:not( .wcff-invoice-active ) [class*="additional-fields-list"] > *:has( > * > * > input[data-wcff-conditional] ) {
	display: none;
}

/*
 * VAT field: hide the "(optional)" / "(facoltativo)" indicator in the label.
 * The field is required whenever it is visible (invoice requested), so the
 * optional label is always misleading. data-wcff-field="vat" is set via PHP
 * and targets only the VAT input, leaving PEC and SDI labels unchanged.
 */
[class*="additional-fields-list"] > *:has( > input[data-wcff-field="vat"] ) label span,
[class*="additional-fields-list"] > *:has( > * > input[data-wcff-field="vat"] ) label span,
[class*="additional-fields-list"] > *:has( > * > * > input[data-wcff-field="vat"] ) label span {
	display: none;
}
