/*
 * Block: core/button. Loads only on pages that render a Button block
 * (wp_enqueue_block_style in inc/block-styles.php; core inlines it in <head>).
 * Colours, radius and padding come from theme.json elements.button and the
 * button-* partials in styles/blocks. This file holds what JSON cannot say:
 * layout, hover motion, the outline and text looks, the small legacy size.
 */

/* ---------- every button ---------- */

.wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	box-sizing: border-box;
	min-height: 48px;
	transition:
		transform var(--wp--custom--transition--fast, 0.15s ease),
		box-shadow var(--wp--custom--transition--fast, 0.15s ease),
		background-color var(--wp--custom--transition--fast, 0.15s ease),
		border-color var(--wp--custom--transition--fast, 0.15s ease),
		color var(--wp--custom--transition--fast, 0.15s ease);
}

.wp-block-button__link:hover {
	transform: translateY(-2px);
}

.wp-block-button__link:active {
	transform: translateY(0);
}

/* Ring colour comes from base.css (secondary; accent on dark and brand surfaces). */
.wp-block-button__link:focus-visible {
	outline-width: 2px;
	outline-style: solid;
	outline-offset: 3px;
}

/* A button with its own background keeps it on hover; quiet overlay instead. */
.wp-block-button__link.has-background:hover,
.wp-block-button__link.has-background:focus-visible {
	box-shadow: inset 0 0 0 999px color-mix(in srgb, var(--wp--preset--color--contrast) 8%, transparent);
}

/* ---------- Outline (core's style name) ---------- */

.wp-block-button.is-style-outline > .wp-block-button__link,
.wp-block-button .wp-block-button__link.is-style-outline {
	background: transparent;
	border: var(--wp--custom--border--button, 1.5px) solid currentColor;
	box-shadow: none;
	/* theme.json button padding (0.9rem 1.5rem) minus the border, so outline
	   and filled buttons are the same height. */
	padding: calc(0.9rem - var(--wp--custom--border--button, 1.5px)) calc(1.5rem - var(--wp--custom--border--button, 1.5px));
}

.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color),
.wp-block-button .wp-block-button__link.is-style-outline:not(.has-text-color) {
	color: currentColor;
}

.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background):hover,
.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background):focus-visible,
.wp-block-button .wp-block-button__link.is-style-outline:not(.has-background):hover,
.wp-block-button .wp-block-button__link.is-style-outline:not(.has-background):focus-visible {
	background: var(--wp--preset--color--contrast);
	border-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base-2);
}

/* On brand and dark sections the ghost border is the section's translucent
   on-colour: primary-contrast on brand, base-2 on dark (primary-contrast can be
   dark in the dark palette; base-2 stays light inside a dark section). */
.is-style-section-brand .wp-block-button.is-style-outline > .wp-block-button__link {
	border-color: color-mix(in srgb, var(--wp--preset--color--primary-contrast) 70%, transparent);
}

.is-style-section-dark .wp-block-button.is-style-outline > .wp-block-button__link {
	border-color: color-mix(in srgb, var(--wp--preset--color--base-2) 70%, transparent);
}

/* On a dark section the inverted hover would vanish; flip to the surface colour. */
.is-style-section-dark .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background):hover,
.is-style-section-dark .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background):focus-visible {
	background: var(--wp--preset--color--base-2);
	border-color: var(--wp--preset--color--base-2);
	color: var(--wp--preset--color--contrast);
}

/* ---------- Small (legacy name; header action) ---------- */

.wp-block-button.is-style-revsults-small .wp-block-button__link {
	min-height: 40px;
	padding: 0.6rem 1.1rem;
	font-size: var(--wp--preset--font-size--small);
}

/* ---------- Text link with arrow ---------- */

.wp-block-button.is-style-text > .wp-block-button__link::after {
	content: "";
	flex: none;
	width: 1em;
	height: 1em;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><line x1='4' y1='12' x2='20' y2='12'/><polyline points='13 5 20 12 13 19'/></svg>") center / contain no-repeat;
	mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><line x1='4' y1='12' x2='20' y2='12'/><polyline points='13 5 20 12 13 19'/></svg>") center / contain no-repeat;
	transition: transform var(--wp--custom--transition--fast, 0.15s ease);
}

.wp-block-button.is-style-text > .wp-block-button__link:hover {
	transform: none;
}

.wp-block-button.is-style-text > .wp-block-button__link:hover::after {
	transform: translateX(0.25em);
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.wp-block-button__link,
	.wp-block-button.is-style-text > .wp-block-button__link::after {
		transition: none;
	}

	.wp-block-button__link:hover,
	.wp-block-button.is-style-text > .wp-block-button__link:hover::after {
		transform: none;
	}
}
