/* stylelint-disable no-descending-specificity -- base states carry a :root prefix to beat core, and the style variants after them are meant to be overridden by their own :hover rules only */

/*
 * Button states (FD-042). Base rules carry a :root prefix so they beat core's .wp-block-button__link
 * defaults whatever the stylesheet order. Role colours come from sections.css with token fallbacks, so the same
 * rules work on every ground. Targets are at least 48px high.
 */
:root .wp-block-button__link,
:root .wp-element-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: 3rem;
	padding: var(--wp--preset--spacing--12) var(--wp--preset--spacing--20);
	border: 1px solid var(--flydoo-button-border, transparent);
	border-radius: var(--wp--custom--radius--pill);
	background-color: var(--flydoo-button-bg, var(--wp--preset--color--brand-primary));
	color: var(--flydoo-button-text, var(--wp--preset--color--text-on-brand));
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--body-emphasis);
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}

:root .wp-block-button__link:hover,
:root .wp-element-button:hover {
	background-color: var(--flydoo-button-bg-hover, var(--wp--preset--color--brand-primary-hover));
}

/* Open question (listed in docs/section-styles.md): the notes say "active inset 1 px translate none"; active equals hover until answered. */
:root .wp-block-button__link:active,
:root .wp-element-button:active {
	background-color: var(--flydoo-button-bg-hover, var(--wp--preset--color--brand-primary-hover));
}

/* Disabled stays focusable (aria-disabled) and readable, with a solid fill. */
:root .wp-block-button__link[aria-disabled="true"],
:root .wp-block-button__link[aria-busy="true"],
:root .wp-block-button__link:disabled,
:root .wp-element-button[aria-disabled="true"],
:root .wp-element-button[aria-busy="true"],
:root .wp-element-button:disabled {
	border-color: var(--wp--custom--line--input);
	background-color: var(--wp--preset--color--surface-sunken);
	color: var(--wp--preset--color--text-secondary);
	cursor: not-allowed;
}

.is-style-outline-inverse .wp-block-button__link,
.is-style-outline-inverse .wp-element-button {
	border-color: var(--flydoo-line-strong, var(--wp--preset--color--line-strong));
	background-color: transparent;
	color: var(--flydoo-text, var(--wp--preset--color--text-primary));
}

.is-style-text-inverse .wp-block-button__link,
.is-style-text-inverse .wp-element-button {
	border-color: transparent;
	background-color: transparent;
	color: var(--flydoo-link, var(--wp--preset--color--brand-primary));
}

.is-style-outline-inverse .wp-block-button__link:hover,
.is-style-outline-inverse .wp-element-button:hover {
	border-color: var(--flydoo-link, var(--wp--preset--color--brand-primary));
	background-color: transparent;
	color: var(--flydoo-link, var(--wp--preset--color--brand-primary));
}

.is-style-text-inverse .wp-block-button__link:hover,
.is-style-text-inverse .wp-block-button__link:focus-visible,
.is-style-text-inverse .wp-element-button:hover,
.is-style-text-inverse .wp-element-button:focus-visible {
	background-color: transparent;
	text-decoration: underline;
}

.is-style-outline-inverse .wp-block-button__link[aria-disabled="true"],
.is-style-outline-inverse .wp-block-button__link[aria-busy="true"],
.is-style-text-inverse .wp-block-button__link[aria-disabled="true"],
.is-style-text-inverse .wp-block-button__link[aria-busy="true"] {
	border-color: var(--wp--custom--line--input);
	background-color: var(--wp--preset--color--surface-sunken);
	color: var(--wp--preset--color--text-secondary);
}

/*
 * Core search (404, search results, empty search). WordPress gives its button only
 * wp-block-search__button, never wp-element-button, so it gets the theme button here; the input
 * matches it at 44px or more (AGENTS.md section 6 touch targets).
 */
.wp-block-search__input {
	box-sizing: border-box;
	min-height: 2.875rem;
	padding: var(--wp--preset--spacing--12) var(--wp--preset--spacing--16);
	border: 1px solid var(--wp--custom--line--input);
	border-radius: var(--wp--custom--radius--sm);
	background-color: var(--wp--preset--color--surface-raised);
	color: var(--flydoo-text, var(--wp--preset--color--text-primary));
	font: inherit;
}

.wp-block-search__button {
	box-sizing: border-box;
	min-height: 3rem;
	margin-inline-start: var(--wp--preset--spacing--8);
	padding: var(--wp--preset--spacing--12) var(--wp--preset--spacing--20);
	border: 1px solid var(--flydoo-button-border, transparent);
	border-radius: var(--wp--custom--radius--pill);
	background-color: var(--flydoo-button-bg, var(--wp--preset--color--brand-primary));
	color: var(--flydoo-button-text, var(--wp--preset--color--text-on-brand));
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--body-emphasis);
	font-weight: 600;
	cursor: pointer;
}

.wp-block-search__button:hover {
	background-color: var(--flydoo-button-bg-hover, var(--wp--preset--color--brand-primary-hover));
}

.wp-block-search__input:focus-visible,
.wp-block-search__button:focus-visible {
	outline: var(--wp--custom--focus--width, 2px) solid var(--flydoo-focus, var(--wp--custom--focus--color));
	outline-offset: var(--wp--custom--focus--offset, 2px);
}
