/**
 * Button Styles — hover consistency system
 *
 * WordPress emits author-picked button colors as !important preset classes
 * (or inline styles) with no hover variants, while theme hovers live in
 * low-specificity theme.json rules — so any explicitly colored button
 * "freezes" through hover. This file + assets/js/button-hover.js make
 * hovers work for every color combination:
 *
 * 1. Outline buttons: border follows an explicitly-set text color unless a
 *    border color is also set.
 * 2. Outline hover fills with the button's BORDER color. CSS cannot
 *    reference "the border color" as a background, so button-hover.js reads
 *    the rendered border color into --lp-btn-hover-bg and picks
 *    --lp-btn-hover-text by luminance (white on dark fills, contrast on
 *    light fills). Fallbacks match the theme.json outline variation
 *    (primary / surface), which remains the no-JS behavior.
 *    The hover color/border are !important on purpose: it is the only way
 *    to out-rank the !important preset text classes ("red text stays red
 *    on a red fill" otherwise).
 * 3. Solid buttons with author-set backgrounds darken via filter — a filter
 *    needs no specificity war with the !important background.
 */

/* 1. Border follows explicitly-set text color (unless border color set) */
.is-style-outline .wp-block-button__link.has-text-color:not(.has-border-color) {
	border-color: currentColor;
}

/* 2. Outline hover: fill with the border color, luminance-picked text */
.is-style-outline .wp-block-button__link:hover,
.is-style-outline .wp-block-button__link:focus-visible {
	background-color: var(--lp-btn-hover-bg, var(--wp--preset--color--primary));
	border-color: var(--lp-btn-hover-bg, var(--wp--preset--color--primary)) !important;
	color: var(--lp-btn-hover-text, var(--wp--preset--color--surface)) !important;
}

/* 3. Solid buttons with author-set backgrounds: generic darken.
   (Outline buttons given an explicit background keep it on hover — the
   preset !important wins over rule 2's background — and darken here too.) */
.wp-block-button__link.has-background:hover,
.wp-block-button__link.has-background:focus-visible {
	filter: brightness(0.9);
}

/**
 * Named button variations — Light, Brand, Secondary
 *
 * Used by ~a dozen patterns since the theme's first release but never
 * registered or styled (they silently rendered as default buttons).
 * Registration lives in inc/block-styles.php; everything below is preset
 * tokens, so child themes restyle them via theme.json for free.
 *
 * User-set colors win over these resting rules the same way they win over
 * theme.json button styles: preset classes carry !important and custom
 * colors are inline — both beat these plain selectors.
 */

/* Light — for buttons sitting on dark banners/heroes. */
.is-style-button-light .wp-block-button__link {
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

.is-style-button-light .wp-block-button__link:hover,
.is-style-button-light .wp-block-button__link:focus-visible {
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
}

/* Brand — the primary brand color, for contexts where the default
   button has been recolored by a section style. */
.is-style-button-brand .wp-block-button__link {
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
}

.is-style-button-brand .wp-block-button__link:hover,
.is-style-button-brand .wp-block-button__link:focus-visible {
	background-color: var(--wp--preset--color--primary-dark);
	color: var(--wp--preset--color--base);
}

/* Secondary — the secondary palette color. Hover darkens without a
   dedicated token via brightness, so it stays brand-correct per child. */
.is-style-secondary-button .wp-block-button__link {
	background-color: var(--wp--preset--color--secondary);
	color: var(--wp--preset--color--base);
}

.is-style-secondary-button .wp-block-button__link:hover,
.is-style-secondary-button .wp-block-button__link:focus-visible {
	background-color: var(--wp--preset--color--secondary);
	color: var(--wp--preset--color--base);
	filter: brightness(0.88);
}
