/**
 * Structural rules for the CROPPED checkout fields.
 * ==========================================================================
 * Not theme styling. These rules keep the form *correct* rather than pretty,
 * which is why they ship with the plugin that registers the fields rather than
 * with whichever theme happens to be active.
 *
 * @package CroppedCore
 * @since   1.0.0
 * ========================================================================== */

/*
 * Fields the shopper is never asked but WooCommerce still needs on the order.
 *
 * `billing_last_name` is filled by splitting the Full name field on submit, and
 * the country has exactly one possible answer. Both are still posted - which is
 * why this is `display: none` on the row and not `hidden` on the input: an
 * input inside a hidden container still submits, while removing it would leave
 * WooCommerce with no value at all.
 */
.woocommerce .cropped-field-hidden,
.woocommerce-page .cropped-field-hidden {
	display: none !important;
}

/*
 * The city datalist arrow.
 *
 * Chrome and Edge render a small dropdown affordance on `input[list]` only on
 * hover, so on a phone - where there is no hover - nothing indicates the field
 * has suggestions at all. A shopper types the whole city name instead of two
 * letters, which is the entire benefit of the control lost.
 *
 * A caret drawn on the wrapper is always visible and costs no JavaScript.
 */
.woocommerce .woocommerce-input-wrapper:has(> input[list]) {
	position: relative;
	display: block;
}

.woocommerce .woocommerce-input-wrapper:has(> input[list])::after {
	content: "";
	position: absolute;
	top: 1.15em;
	inset-inline-end: 0.9em;
	width: 0.5em;
	height: 0.5em;
	border-inline-end: 2px solid currentColor;
	border-block-end: 2px solid currentColor;
	transform: rotate(45deg);
	opacity: 0.45;
	pointer-events: none;
}

.woocommerce input[list] {
	/* Room for the caret above, so a long city name never runs under it. */
	padding-inline-end: 2.25em;
}

/*
 * `:has()` is unsupported in Firefox before 121 and Safari before 15.4, where
 * the caret simply does not render. That is a graceful loss - the field still
 * works - so there is no fallback beyond leaving the padding in place.
 */
