/* ==========================================================================
   Envision Theme - buttons (2.16)

   Every "main" button on the site uses the primary colour picked in Envision > Style
   (--envision-accent, with --envision-accent-ink as the text colour that stays readable on it):
   form submit buttons of Contact Form 7, WPForms, Gravity Forms, Forminator, Formidable and Ninja Forms,
   the comment form, the password form, the Search block, the core Button block and the WooCommerce buttons
   (single product, cart, checkout - classic pages and the Cart / Checkout blocks - and account).

   Not touched on purpose:
   - the product cards in shop grids (Envision > Product Cards has its own button colours),
   - Elementor / page-builder buttons and buttons that got a colour of their own
     (core Button block with a chosen colour, outline buttons, colours a form plugin sets with its own #id rules),
   - the theme's own forms (Envision > Forms), which already follow the same colour.

   Specificity: the selectors are a little stronger than the plugins' default styles (they repeat the plugin's root class),
   so no !important is needed and a colour set in a plugin's own settings (printed with an #id) still wins.
   ========================================================================== */

:root {
	--envision-btn-bg: var(--envision-accent, #d62828);
	--envision-btn-ink: var(--envision-accent-ink, #ffffff);
	--envision-btn-radius: 6px;
}

/* ---------- 1. Plugin buttons: only the colour (the plugin already sizes them) ---------- */
html body :is(
	.wpforms-container.wpforms-container .wpforms-form .wpforms-submit,
	.wpforms-container.wpforms-container .wpforms-form .wpforms-page-button,
	.gform_wrapper.gform_wrapper .gform_button,
	.gform_wrapper.gform_wrapper input[type="submit"],
	.gform_wrapper.gform_wrapper button[type="submit"],
	.gform_wrapper.gform_wrapper .gform_next_button,
	.forminator-ui.forminator-ui.forminator-custom-form .forminator-button-submit,
	.frm_forms.frm_forms .frm_submit button,
	.frm_forms.frm_forms .frm_submit input[type="submit"],
	.frm_forms.frm_forms .frm_button_submit,
	.nf-form-cont.nf-form-cont .submit-container input[type="button"],
	.nf-form-cont.nf-form-cont .submit-container input[type="submit"],
	.nf-form-cont.nf-form-cont .nf-field-container .nf-element[type="submit"]
) {
	background: var(--envision-btn-bg);
	background-color: var(--envision-btn-bg);
	border-color: var(--envision-btn-bg);
	color: var(--envision-btn-ink);
	border-radius: var(--envision-btn-radius);
	transition: filter .15s ease, transform .08s ease;
}
html body :is(
	.wpforms-container.wpforms-container .wpforms-form .wpforms-submit,
	.wpforms-container.wpforms-container .wpforms-form .wpforms-page-button,
	.gform_wrapper.gform_wrapper .gform_button,
	.gform_wrapper.gform_wrapper input[type="submit"],
	.gform_wrapper.gform_wrapper button[type="submit"],
	.gform_wrapper.gform_wrapper .gform_next_button,
	.forminator-ui.forminator-ui.forminator-custom-form .forminator-button-submit,
	.frm_forms.frm_forms .frm_submit button,
	.frm_forms.frm_forms .frm_submit input[type="submit"],
	.frm_forms.frm_forms .frm_button_submit,
	.nf-form-cont.nf-form-cont .submit-container input[type="button"],
	.nf-form-cont.nf-form-cont .submit-container input[type="submit"],
	.nf-form-cont.nf-form-cont .nf-field-container .nf-element[type="submit"]
):is(:hover, :focus, :active) {
	background: var(--envision-btn-bg);
	background-color: var(--envision-btn-bg);
	border-color: var(--envision-btn-bg);
	color: var(--envision-btn-ink);
	filter: brightness(.92);
}

/* ---------- 2. Buttons the theme has to draw completely (nobody else styles them) ---------- */
html body :is(
	.wpcf7 input[type="submit"],
	.wpcf7 button[type="submit"],
	.wpcf7-form .wpcf7-submit,
	.comment-form .submit,
	.post-password-form input[type="submit"],
	.wp-block-search__button,
	.wp-block-post-comments-form .wp-block-button__link
) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 46px;
	margin: 0;
	padding: 12px 30px;
	font-family: inherit;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: .02em;
	text-transform: none;
	text-decoration: none;
	color: var(--envision-btn-ink);
	background: var(--envision-btn-bg);
	border: 1px solid var(--envision-btn-bg);
	border-radius: var(--envision-btn-radius);
	box-shadow: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: filter .15s ease, transform .08s ease;
}
html body :is(
	.wpcf7 input[type="submit"],
	.wpcf7 button[type="submit"],
	.wpcf7-form .wpcf7-submit,
	.comment-form .submit,
	.post-password-form input[type="submit"],
	.wp-block-search__button,
	.wp-block-post-comments-form .wp-block-button__link
):is(:hover, :focus, :active) {
	color: var(--envision-btn-ink);
	background: var(--envision-btn-bg);
	border-color: var(--envision-btn-bg);
	filter: brightness(.92);
}
html body :is(.wpcf7 input[type="submit"], .wpcf7 button[type="submit"], .comment-form .submit):active { transform: translateY(1px); }

/* The Contact Form 7 spinner sits next to the button: give it a little room */
html body .wpcf7 .wpcf7-spinner { margin: 0 0 0 10px; }

/* ---------- 3. Core "Button" block ----------
   Only the plain (filled) look without a colour chosen in the editor; outline buttons and chosen colours stay as they are. */
html body .wp-block-button:not(.is-style-outline) > .wp-block-button__link:not(.has-background),
html body .wp-block-file .wp-block-file__button:not(.has-background) {
	background: var(--envision-btn-bg);
	color: var(--envision-btn-ink);
	transition: filter .15s ease; /* the shape (WordPress's pill or a radius chosen in the editor) is left alone */
}
html body .wp-block-button:not(.is-style-outline) > .wp-block-button__link:not(.has-background):is(:hover, :focus),
html body .wp-block-file .wp-block-file__button:not(.has-background):is(:hover, :focus) {
	background: var(--envision-btn-bg);
	color: var(--envision-btn-ink);
	filter: brightness(.92);
}
html body .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color) {
	color: var(--envision-btn-bg);
	border-color: var(--envision-btn-bg);
}

/* ---------- 4. WooCommerce (single product, cart, checkout, account, notices) ----------
   Woo's own rules start with  .woocommerce a.button / button.button.alt ...  and the default look is grey (plain) or its
   purple (primary). "html" in front wins without !important. Shop-grid buttons (ul.products) are NOT in this list. */
html .woocommerce div.product form.cart .button,
html .woocommerce :is(a.button, button.button, input.button):is(.alt, .checkout-button, .single_add_to_cart_button),
html .woocommerce-cart .woocommerce :is(a.button, button.button, input.button),
html .woocommerce-checkout .woocommerce :is(a.button, button.button, input.button),
html .woocommerce-account .woocommerce :is(a.button, button.button, input.button),
html .woocommerce :is(.woocommerce-message, .woocommerce-info) a.button,
html .woocommerce .return-to-shop a.button,
html .woocommerce #respond input#submit,
html .woocommerce #respond input#submit.alt,
html .woocommerce .woocommerce-form-login__submit,
html .woocommerce .woocommerce-form-register__submit,
html .woocommerce .woocommerce-Button,
html .woocommerce #place_order {
	background: var(--envision-btn-bg);
	background-color: var(--envision-btn-bg);
	border-color: var(--envision-btn-bg);
	color: var(--envision-btn-ink);
	border-radius: var(--envision-btn-radius);
	font-weight: 700;
	text-shadow: none;
	box-shadow: none;
	transition: filter .15s ease, transform .08s ease;
}
html .woocommerce div.product form.cart .button:is(:hover, :focus),
html .woocommerce :is(a.button, button.button, input.button):is(.alt, .checkout-button, .single_add_to_cart_button):is(:hover, :focus),
html .woocommerce-cart .woocommerce :is(a.button, button.button, input.button):is(:hover, :focus),
html .woocommerce-checkout .woocommerce :is(a.button, button.button, input.button):is(:hover, :focus),
html .woocommerce-account .woocommerce :is(a.button, button.button, input.button):is(:hover, :focus),
html .woocommerce :is(.woocommerce-message, .woocommerce-info) a.button:is(:hover, :focus),
html .woocommerce .return-to-shop a.button:is(:hover, :focus),
html .woocommerce #respond input#submit:is(:hover, :focus),
html .woocommerce #respond input#submit.alt:is(:hover, :focus),
html .woocommerce .woocommerce-form-login__submit:is(:hover, :focus),
html .woocommerce .woocommerce-form-register__submit:is(:hover, :focus),
html .woocommerce .woocommerce-Button:is(:hover, :focus),
html .woocommerce #place_order:is(:hover, :focus) {
	background: var(--envision-btn-bg);
	background-color: var(--envision-btn-bg);
	border-color: var(--envision-btn-bg);
	color: var(--envision-btn-ink);
	filter: brightness(.92);
}

/* ---------- 4b. WooCommerce Cart / Checkout BLOCKS (the default pages of new shops) ----------
   Filled buttons ("Proceed to checkout", "Place order", "Apply") are black by default; outlined ones stay outlined. */
html body .wc-block-components-button:not(.is-link):not(.outlined):not(.is-style-outline),
html body .wc-block-cart__submit-button,
html body .wc-block-components-checkout-place-order-button {
	background: var(--envision-btn-bg);
	background-color: var(--envision-btn-bg);
	border-color: var(--envision-btn-bg);
	color: var(--envision-btn-ink);
	border-radius: var(--envision-btn-radius);
	transition: filter .15s ease;
}
html body .wc-block-components-button:not(.is-link):not(.outlined):not(.is-style-outline):is(:hover, :focus),
html body .wc-block-cart__submit-button:is(:hover, :focus),
html body .wc-block-components-checkout-place-order-button:is(:hover, :focus) {
	background: var(--envision-btn-bg);
	background-color: var(--envision-btn-bg);
	border-color: var(--envision-btn-bg);
	color: var(--envision-btn-ink);
	filter: brightness(.92);
}

/* ---------- 5. Disabled + keyboard focus (all of the above) ---------- */
html body :is(
	.wpcf7 input[type="submit"],
	.wpcf7 button[type="submit"],
	.comment-form .submit,
	.gform_wrapper.gform_wrapper .gform_button,
	.wpforms-container.wpforms-container .wpforms-form .wpforms-submit,
	.forminator-ui.forminator-ui.forminator-custom-form .forminator-button-submit,
	.wp-block-search__button
):is(:disabled, [aria-disabled="true"]),
html .woocommerce :is(a.button, button.button, input.button):is(:disabled, .disabled, [aria-disabled="true"]) {
	opacity: .55;
	cursor: not-allowed;
	filter: none;
	transform: none;
}
html body :is(
	.wpcf7 input[type="submit"],
	.wpcf7 button[type="submit"],
	.comment-form .submit,
	.gform_wrapper.gform_wrapper .gform_button,
	.wpforms-container.wpforms-container .wpforms-form .wpforms-submit,
	.forminator-ui.forminator-ui.forminator-custom-form .forminator-button-submit,
	.wp-block-search__button
):focus-visible,
html .woocommerce :is(a.button, button.button, input.button):focus-visible {
	outline: 2px solid var(--envision-accent, #d62828);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	html body :is(.wpcf7 input[type="submit"], .comment-form .submit),
	html .woocommerce :is(a.button, button.button, input.button) { transition: none; }
}
