/**
 * Form element styles for the forms this site actually has.
 *
 * WHAT CHANGED, AND WHY IT WAS DEBT. This file used to be loaded by a `render_block`
 * filter that searched every block's rendered output for the substring `<form`, and it
 * styled bare tags - `form input[type="text"]`, `form select` - at `width: 100%`.
 *
 * Both halves failed for the same reason: the header search is a form, on every page.
 * So the sniffer matched it and this stylesheet loaded on ONE HUNDRED PERCENT of
 * requests, measured on staging on the homepage, which has no other form at all. And
 * because it loaded everywhere, its rules reached the header everywhere, which
 * collapsed the header's flex row - so every selector had to carry
 * `form:not(.site-search)` to hold it off. The exclusion is what stopped anyone
 * noticing that the file was being served to every visitor for nothing.
 *
 * Both are now positive statements instead of negative ones. Loading is per block, via
 * f32_get_form_block_list() and wp_enqueue_block_style(). Scoping names the form classes
 * this site styles rather than excluding the one it must not touch:
 *
 *   .edd_form          EDD's legacy forms - login, profile editor
 *   .edd-blocks-form   EDD's block forms - the checkout, the withdrawal declaration
 *   .wp-block-search   core/search, on the 404 template
 *
 * A form that is not one of those cannot be reached from here no matter what loads on
 * the page, which is what makes the exclusion unnecessary rather than merely absent.
 *
 * DELIBERATELY NOT IN THE LIST: `.edd_download_purchase_form`, the add-to-cart form on
 * every single-download page. Its buttons carry `wp-element-button` and are supposed to
 * inherit theme.json - see the submit-button note below - so styling it here would
 * repaint the one control that already had a correct answer.
 *
 * ALSO DELIBERATELY NOT IN THE LIST: Plain Forms (`plain-forms/form` and
 * `plain-forms/form-embed`), which replaced Formidable. The theme does not style Plain
 * Forms controls in CSS at all; it supplies tokens through theme.json. The plugin ships
 * a stylesheet built to inherit - `currentColor`, `color-mix()`, and the tokens
 * `--wp--custom--form--border-radius`, `--wp--style--block-gap` and the theme's palette
 * presets - and its submit button carries `wp-element-button`, so theme.json's button
 * styles already reach it. Rendered forms were checked in a browser and already match
 * the site. A rule added here would not be an improvement but a specificity fight with
 * the plugin's own sheet, over controls that are already correct.
 *
 * THE SCOPE LIST AND f32_get_form_block_list() MUST AGREE. A block added to the loader
 * whose form class is missing here loads a stylesheet that does nothing; a class added
 * here whose block is not in the loader writes rules that never arrive. Neither errors.
 *
 * `form:is(…)` rather than each form class written out keeps the scope list in ONE
 * place per rule. Specificity is unchanged from the `form:not(.site-search)` version it
 * replaces, deliberately and in every case: `form:is(.class, …)` is 0,1,1, exactly what
 * `form:not(.site-search)` was, and each control group keeps the weight it had - see the
 * note above the first rule for why `select` and `textarea` are not folded in with the
 * typed inputs. Nothing that used to win or lose a cascade fight changes side.
 *
 * @package F32
 */

/* === Inputs & Selects === */

/*
 * Split into two selectors on purpose, and it is not cosmetic. `:is()` takes the
 * specificity of its heaviest argument, so folding `select` and `textarea` in with the
 * typed inputs would raise them from 0,1,2 to 0,2,2 - a class unit they did not have
 * before, and enough to start winning cascade fights they used to lose. Each group
 * keeps exactly the weight the `form:not(.site-search)` version gave it.
 */
form:is(.edd_form, .edd-blocks-form, .wp-block-search)
	:is(
		input[type="text"],
		input[type="email"],
		input[type="password"],
		input[type="url"],
		input[type="search"],
		input[type="tel"],
		input[type="number"]
	),
form:is(.edd_form, .edd-blocks-form, .wp-block-search) select,
form:is(.edd_form, .edd-blocks-form, .wp-block-search) textarea {
	width: 100%;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--wp--preset--color--border-subtle, #e0e0e0);
	border-radius: var(--wp--custom--border-radius--sm, 4px);
	font-family: inherit;
	font-size: inherit;
	line-height: 1.5;
	background: #fff;
	color: inherit;
	box-sizing: border-box;
}

form:is(.edd_form, .edd-blocks-form, .wp-block-search)
	:is(
		input[type="text"],
		input[type="email"],
		input[type="password"],
		input[type="url"],
		input[type="search"],
		input[type="tel"],
		input[type="number"]
	):focus,
form:is(.edd_form, .edd-blocks-form, .wp-block-search) select:focus,
form:is(.edd_form, .edd-blocks-form, .wp-block-search) textarea:focus {
	border-color: var(--wp--preset--color--accent, #1473e6);
	outline: 2px solid color-mix(in srgb, var(--wp--preset--color--accent, #1473e6) 25%, transparent);
	outline-offset: 0;
}

/* === Labels === */

form:is(.edd_form, .edd-blocks-form, .wp-block-search) label {
	display: block;
	font-weight: 500;
	margin-bottom: 0.25rem;
}

/* === Fieldsets === */

form:is(.edd_form, .edd-blocks-form, .wp-block-search) fieldset {
	border: 0;
	margin: 0;
	padding: 0;
}

/* === Legends === */

form:is(.edd_form, .edd-blocks-form, .wp-block-search) legend {
	font-weight: 600;
	font-size: 1.1em;
	padding: 0;
}

/* === Submit Buttons === */

/*
 * This is the rule that covers Easy Digital Downloads.
 *
 * EDD's commerce controls split into two groups, and only one of them reaches
 * theme.json. `edd_purchase_link_args` (functions.php) appends
 * `wp-element-button`, so add-to-cart, its no-js twin and go-to-checkout all
 * inherit `styles.elements.button`. The other three do not:
 *
 *   <input type="submit" class="edd-submit">                  #edd_login_submit
 *   <input type="submit" class="edd_submit edd-submit">       profile editor
 *   <input type="submit" class="edd-submit  button">          checkout "Next"
 *
 * All three are `input[type="submit"]` inside one of the scoped forms, so the
 * selector below already matches every one of them - no `.edd-submit` selector
 * is needed, and adding one would be worse than useless: `.edd-submit` is a
 * single class, it would tie with core's `:root :where(.wp-element-button)`
 * and lose on order for the three buttons that carry both, while ALSO
 * repainting add-to-cart's padding on the pages where it is meant to keep
 * theme.json's. Match on shape, not on EDD's class names. (The add-to-cart form
 * is now out of scope entirely, which makes that second hazard structural
 * rather than something this selector has to keep dodging.)
 *
 * EDD's own stylesheet is off site-wide (`edd_settings.disable_styles = 1`),
 * so nothing of EDD's competes for these buttons. That setting turns off the
 * LEGACY stylesheet only - EDD's *block* stylesheet still loads, and it is what
 * paints `.edd-button-secondary` on the checkout. See below.
 *
 * The rule below used to read `form button[type="submit"]`, which never matched
 * a bare `<button>`. A `<button>` has an IDL `type` of "submit" by default but
 * NO type ATTRIBUTE, and an attribute selector can only match an attribute that
 * is written out. The reasoning above is about `input[type="submit"]`, where the
 * attribute is always present, so it never had cause to notice.
 *
 * Measured on staging's checkout: `<button class="edd-button-secondary
 * edd_discount_link">` - no type attribute, inside a form - fell through to the
 * user-agent default of 13.3333px Arial while every sibling control rendered at
 * 16px Inter. `button:not([type="button"]):not([type="reset"])` is the
 * shape-based equivalent of the old selector and matches it: same principle as
 * the paragraph above, just stated as "everything a form submits with" rather
 * than as one spelling of it.
 *
 * One control must NOT take the primary treatment this rule gives, and the exclusion
 * for it is the one EDD class name in this file. The discount toggle is a SECONDARY
 * action - production renders it as EDD's grey secondary button, not as a blue pill.
 * There is no shape that expresses "secondary": `.edd_discount_link` is a bare
 * `<button>` with no type attribute, which is submit-shaped in every way this rule can
 * see. `.edd-button-secondary` is the role, stated by the only party that knows it.
 *
 * The exclusion has to be HERE rather than as an override elsewhere, and that is a
 * correction. `checkout.css` used to carry the override, keyed on
 * `#edd_purchase_form` - and EDD has since moved the discount toggle into
 * `#edd_checkout_cart_form`, so both that rule AND EDD's own
 * `.wp-block-edd-checkout #edd_purchase_form .edd-button-secondary` stopped matching
 * it. Measured on staging: the toggle rendered as a 214x46 blue pill, padding
 * 14px 24px, radius 9999px - this rule winning uncontested, exactly what the override
 * was written to prevent. Not matching a control is a silent failure; not matching a
 * control it also has to out-specify is a silent failure that looks deliberate.
 *
 * Values are production's "Log In" button measured at 1263px: pill radius,
 * 16px/500, padding 14px 24px, 46px tall (14 + 14 + 16 x 1.125). That is 4px
 * shorter than theme.json's default button, which production measures at 50px
 * with 16px padding all round - the two really are different sizes there.
 */
form:is(.edd_form, .edd-blocks-form, .wp-block-search) input[type="submit"]:not(.edd-button-secondary),
form:is(.edd_form, .edd-blocks-form, .wp-block-search) button:not([type="button"]):not([type="reset"]):not(.edd-button-secondary) {
	display: inline-block;
	padding: 14px 24px;
	background: var(--wp--preset--color--action, #1d4ed8);
	color: #fff;
	border: 0;
	border-radius: var(--wp--custom--border-radius--full, 9999px);
	font-family: inherit;
	font-size: 16px;
	font-weight: 500;
	line-height: 1.125;
	cursor: pointer;
	transition: background 0.15s ease;
}

form:is(.edd_form, .edd-blocks-form, .wp-block-search) input[type="submit"]:not(.edd-button-secondary):hover,
form:is(.edd_form, .edd-blocks-form, .wp-block-search) button:not([type="button"]):not([type="reset"]):not(.edd-button-secondary):hover {
	background: color-mix(in srgb, var(--wp--preset--color--action, #1d4ed8) 85%, #000);
}
