/*
 * Magnetic button — three layers.
 *
 *   .wp-block-button          base: stationary, holds the size cascade and the
 *                             solid colour the panel slides off
 *   .wp-block-button__link    panel: the <a> or <button> that actually moves
 *   .wp-block-button__inner   layout: padding, gap and clipping
 *
 * Every interior length is em, so a single font-size token rescales the whole
 * control. The base sets ~30px; the panel sets 0.5em of it, and padding, gap
 * and icons resolve against the panel.
 *
 * Nothing here targets element names, so the same rules serve <a> and <button>.
 */

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) {
	--mx: 0;
	--my: 0;
	--button-text: var(--wp--preset--color--off-black);
	/* The hairline is its own colour: the dark variation wants light text on a
	 * grey frame, so border and text cannot share one variable. */
	--button-border: var(--button-text);
	--button-panel: var(--wp--preset--color--off-white);
	--button-panel-active: var(--wp--preset--color--surface);
	--button-base: var(--wp--preset--color--off-black);
	--button-panel-scale: var(--wp--custom--button--panel-scale);
	--button-padding-block: var(--wp--custom--button--padding-block);
	--button-padding-inline: var(--wp--custom--button--padding-inline);
	--button-gap: var(--wp--custom--button--gap);
	--button-letter-spacing: var(--wp--custom--button--letter-spacing);
	--button-text-transform: uppercase;
	--button-weight: 600;
	--button-white-space: normal;
	--button-icon-size: var(--wp--custom--button--icon-size);

	position: relative;
	isolation: isolate;
	display: inline-flex;
	box-sizing: border-box;
	max-width: 100%;
	min-height: var(--wp--custom--button--height);
	font-size: var(--wp--custom--button--font-size);
	background: var(--button-base);

	/*
	 * Side by side, buttons are siblings with no z-index, so they paint in DOM
	 * order and the panel — which lifts up and to the RIGHT, out of its own
	 * box — slid underneath the next button along. The active one is raised
	 * for as long as it is lifted.
	 *
	 * The drop is delayed by the panel's own transition so the button does not
	 * duck back under its neighbour halfway through the return; z-index is a
	 * discrete step, so the 0s duration just defers the switch.
	 *
	 * That delay needs a companion rule wherever these sit in a row: while it
	 * runs, the button being left is still raised and would cover the one the
	 * pointer just moved onto. See .site-menu__actions in the chrome styles.
	 */
	z-index: 0;
	transition: z-index 0s linear 0.4s;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden):is(:hover, :focus-within) {
	z-index: 1;
	transition-delay: 0s;
}

/*
 * Dark variation. The frame and the base revealed by the magnetic lift are the
 * same grey hairline the reference uses on dark ground; only the label and the
 * icons stay light.
 */
.wp-block-button.is-style-magnetic-dark {
	--button-text: var(--wp--preset--color--off-white);
	--button-border: var(--wp--custom--button--line-dark);
	--button-panel: var(--wp--preset--color--off-black);
	--button-panel-active: var(--wp--preset--color--off-black);
	--button-base: var(--wp--custom--button--line-dark);
}

/* Golden panel with an off-black label, frame and base. */
.wp-block-button.is-style-magnetic-golden {
	--button-text: var(--wp--preset--color--off-black);
	--button-border: var(--wp--preset--color--off-black);
	--button-panel: var(--wp--preset--color--golden);
	--button-panel-active: var(--wp--preset--color--golden);
	--button-base: var(--wp--preset--color--off-black);
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) > .wp-block-button__link {
	position: relative;
	z-index: 1;
	display: flex;
	flex: 1 1 auto;
	align-items: stretch;
	box-sizing: border-box;
	min-width: 0;
	/*
	 * The panel takes the base's min-height instead of relying on
	 * align-items: stretch to fill it. A flex container's cross size counts as
	 * "definite" only when height is set; with min-height alone the flex line
	 * is sized from the content, the item stretches to that line, and only
	 * then is the container clamped up to min-height — leaving the base
	 * showing as a solid bar under a panel that never grew.
	 *
	 * `inherit`, not the token: --wp--custom--button--height is 2.666em, and
	 * the panel's font-size is half the base's, so re-resolving the token here
	 * would yield 42px instead of 85px. Inheriting takes the base's already
	 * computed pixel value. A taller panel still pushes the base with it.
	 */
	min-height: inherit;
	margin: 0;
	padding: 0;
	border: 1px solid var(--button-border);
	border-radius: 0;
	background: var(--button-panel);
	color: var(--button-text);
	font-family: var(--wp--custom--button--font-family);
	font-size: var(--button-panel-scale);
	font-weight: var(--button-weight);
	line-height: 1.5;
	letter-spacing: var(--button-letter-spacing);
	text-decoration: none;
	text-transform: var(--button-text-transform);
	cursor: var(--cursor-pointer);
	appearance: none;
	transform: none;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) .wp-block-button__inner {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	justify-content: space-between;
	box-sizing: border-box;
	gap: var(--button-gap);
	min-width: 0;
	padding: var(--button-padding-block) var(--button-padding-inline);
	overflow: hidden;
}

/*
 * The block editor renders core/button from its saved content, which has no
 * inner layer — that one is added by the render filter on the frontend. Give
 * the bare link the same padding so the editor shows the real proportions.
 * It is also the fallback if the filter ever meets markup it cannot rebuild.
 */
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) > .wp-block-button__link:not(:has(> .wp-block-button__inner)) {
	align-items: center;
	justify-content: space-between;
	gap: var(--button-gap);
	padding: var(--button-padding-block) var(--button-padding-inline);
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) .wp-block-button__text {
	flex: 1 1 auto;
	text-align: start;
	white-space: var(--button-white-space);
	overflow-wrap: anywhere;
	font-size: var(--step--1);
}

/* Icons are decorative: the accessible name comes from the label alone. */
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) .wp-block-button__icon {
	display: block;
	flex: none;
	width: var(--button-icon-size);
	aspect-ratio: 1 / 1;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) .wp-block-button__icon > svg {
	display: block;
	width: 100%;
	height: 100%;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).is-icon-first .wp-block-button__inner {
	flex-direction: row-reverse;
}

/*
 * Badge: a short counter riding along with the panel.
 *
 * Anchored to the inner layer, so it lifts with the panel on hover instead of
 * staying behind on the stationary base. The inner layer clips, which is why
 * the badge sits fully inside it rather than straddling a corner. It is
 * aria-hidden — the number belongs in the control's label, where a screen
 * reader reads it as part of the accessible name.
 */
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).has-badge .wp-block-button__inner {
	position: relative;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) .wp-block-button__badge {
	position: absolute;
	top: 0.4em;
	right: 0.4em;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 1.5em;
	height: 1.5em;
	padding-inline: 0.35em;
	border-radius: 1em;
	background: var(--button-text);
	color: var(--button-panel);
	/* About 11.5–13.5px on the header cart button; 0.7em (9.5–11px) was
	 * hard to read. Text buttons (the blog's category counts) keep it in their
	 * end padding, clear of the label. */
	font-size: 0.85em;
	font-weight: 700;
	letter-spacing: 0;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

/* An empty badge is no badge. The element still has to exist for a script to
 * write into, so it is emptied rather than removed. */
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) .wp-block-button__badge:empty {
	display: none;
}

/*
 * Width. Default is content width plus padding. Full width comes from the
 * Button block's own Width control, which writes wp-block-button__width-100.
 * Core's stylesheet is not loaded for buttons this theme renders in PHP, so
 * the 100% case is restated here; 25/50/75 stay with core inside a Buttons row.
 */
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).wp-block-button__width-100 {
	display: flex;
	width: 100%;
}

/* Icon only: height is the module, width follows from the ratio. */
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).is-icon-only {
	--button-icon-size: var(--wp--custom--button--icon-solo-size);
	--button-padding-inline: var(--wp--custom--button--icon-solo-padding-inline);

	flex: none;
	width: auto;
	height: var(--wp--custom--button--height);
	aspect-ratio: 1 / 1;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).is-icon-only .wp-block-button__inner {
	justify-content: center;
	padding-block: 0;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).is-size-sm {
	--button-panel-scale: 0.45em;
	--button-padding-block: 1.3em;
	--button-gap: 0.5em;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).is-size-lg {
	--button-panel-scale: 0.66em;
	--button-padding-block: 1em;
	--button-letter-spacing: normal;
	--button-text-transform: none;
	--button-weight: 600;
	--button-white-space: nowrap;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).is-size-lg .wp-block-button__text {
	font-size: var(--step-0);
}

@media (min-width: 1280px) {
	.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) {
		--button-padding-inline: var(--wp--custom--button--padding-inline-wide);
		--button-letter-spacing: var(--wp--custom--button--letter-spacing-wide);
	}

	.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).is-size-lg {
		--button-padding-inline: 1.8em;
		--button-letter-spacing: normal;
	}
}

/*
 * Grid border: top and left are real borders, right and bottom are pseudo
 * elements offset by 1px so neighbouring cells share one line instead of
 * doubling it. Opt in where a button sits on the background grid.
 *
 * The -1px on `top` and `left` is not symmetry for its own sake. An absolutely
 * positioned pseudo element is offset from the padding box, which the 1px top
 * and left borders push inwards, so `top: 0` would start the right line 1px
 * below the box and leave the top-right corner open (same for bottom-left).
 * `.ui-framed` in main.css compensates the same way.
 */
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).has-grid-border > .wp-block-button__link {
	border-width: 1px 0 0 1px;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).has-grid-border > .wp-block-button__link::before,
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).has-grid-border > .wp-block-button__link::after {
	content: "";
	position: absolute;
	background: var(--button-border);
	pointer-events: none;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).has-grid-border > .wp-block-button__link::before {
	top: -1px;
	right: -1px;
	bottom: -1px;
	width: 1px;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).has-grid-border > .wp-block-button__link::after {
	right: -1px;
	bottom: -1px;
	left: -1px;
	height: 1px;
}

/*
 * The base needs the same 1px overhang. The two lines above belong to the
 * panel, so they leave with it on hover, and the base it uncovers was 1px
 * short on the right and bottom of everything beside it — a .ui-framed logo
 * tile paints to the same overhang. Behind the panel at rest (z-index -1
 * inside the base's isolated stacking context), so only the lift reveals it.
 */
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden).has-grid-border::after {
	content: "";
	position: absolute;
	inset: 0 -1px -1px 0;
	z-index: -1;
	background: var(--button-base);
	pointer-events: none;
}

/* Keyboard focus stays visible on touch devices and with motion disabled. */
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) > .wp-block-button__link:focus-visible {
	outline: 2px solid var(--button-text);
	outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
	.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) > .wp-block-button__link {
		transition:
			transform 0.4s var(--wp--custom--motion--out),
			background-color 0.4s var(--wp--custom--motion--out),
			color 0.4s var(--wp--custom--motion--out);
	}

	/*
	 * The panel slides up and to the right, then leans away from the pointer.
	 * --mx / --my come from assets/js/blocks/button.js and stay 0 without it.
	 */
	.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden):hover > .wp-block-button__link,
	.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) > .wp-block-button__link:focus-visible {
		transform: translate3d(
			calc(var(--wp--custom--button--lift) + var(--mx) * var(--wp--custom--button--pull)),
			calc(var(--wp--custom--button--lift) * -1 + var(--my) * var(--wp--custom--button--pull)),
			0
		);
	}
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) > .wp-block-button__link:active {
	background: var(--button-panel-active);
	transform: none;
	transition-duration: 0.12s;
}

/*
 * Pressed state for on/off toggles: the panel inverts and stops moving.
 *
 * Deliberately NOT keyed on aria-expanded. That attribute marks a disclosure
 * control — a button that reveals something else — and its open state belongs
 * in the colour variation the revealed surface calls for, not in a "pressed"
 * look. Keying on it also froze the magnetic transform for as long as the
 * disclosure stayed open, and inverted a palette the caller had already
 * swapped, landing on the opposite colour from the one intended.
 */
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) > .wp-block-button__link:is([aria-pressed="true"], [data-active="true"]) {
	background: var(--button-text);
	color: var(--button-panel);
	transform: none;
}

/* Disabled: no lift and no :active colour. `.disabled` is how WooCommerce disables its links. */
.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) > .wp-block-button__link:is(:disabled, [aria-disabled="true"], .disabled) {
	background: var(--button-panel);
	color: var(--button-text);
	cursor: var(--cursor-not-allowed);
	transform: none;
	transition: none;
}

.wp-block-button:is(.is-style-magnetic, .is-style-magnetic-dark, .is-style-magnetic-golden) > .wp-block-button__link:is(:disabled, [aria-disabled="true"], .disabled) .wp-block-button__inner {
	opacity: 0.66;
}

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

/*
 * Straight button — a motion-free family for core/button and native controls.
 *
 * WordPress lets a Button block select one style variation at a time, so each
 * editor-visible style combines one of three palettes with one of five sizes.
 * Native controls opt in with .drapakowo-square-button and the same variation
 * class, which keeps third-party form actions on the shared component.
 */
:is(.wp-block-button, .drapakowo-square-button)[class*="is-style-square-"] {
	--square-button-background: var(--wp--preset--color--off-black);
	--square-button-background-hover: var(--wp--preset--color--golden);
	--square-button-border: var(--wp--preset--color--off-black);
	--square-button-border-hover: var(--wp--preset--color--golden);
	--square-button-text: var(--wp--preset--color--golden);
	--square-button-text-hover: var(--wp--preset--color--off-black);
	--square-button-height: 2.5rem;
	--square-button-padding-block: 0.625rem;
	--square-button-padding-inline: 1rem;
	--square-button-font-size: 0.875rem;

	display: inline-flex;
	box-sizing: border-box;
	max-width: 100%;
}

:is(
	.wp-block-button[class*="is-style-square-"] > .wp-block-button__link,
	.drapakowo-square-button[class*="is-style-square-"]
) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: var(--square-button-height);
	margin: 0;
	padding: var(--square-button-padding-block) var(--square-button-padding-inline);
	border: 1px solid var(--square-button-border);
	border-radius: 0;
	background: var(--square-button-background);
	box-shadow: none;
	color: var(--square-button-text);
	font-family: var(--wp--custom--button--font-family);
	font-size: var(--square-button-font-size);
	font-weight: 600;
	line-height: 1;
	text-align: center;
	text-decoration: none;
	transform: none;
	transition:
		background-color 0.18s ease,
		border-color 0.18s ease,
		color 0.18s ease;
}

:is(.wp-block-button, .drapakowo-square-button)[class*="is-style-square-"] .wp-block-button__inner {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-width: 0;
	gap: 0.625em;
}

:is(.wp-block-button, .drapakowo-square-button)[class*="is-style-square-"].is-icon-first .wp-block-button__inner {
	flex-direction: row-reverse;
}

:is(.wp-block-button, .drapakowo-square-button)[class*="is-style-square-"] .wp-block-button__icon {
	display: inline-flex;
	flex: none;
	width: 1.25em;
	height: 1.25em;
	/*
	 * The icon is 0.25em taller than the 1em line. Without this it grows the
	 * content box past height − padding, so a one-line button ends up taller
	 * than its size token (XL measured 57.3px instead of 56px).
	 */
	margin-block: -0.125em;
}

:is(.wp-block-button, .drapakowo-square-button)[class*="is-style-square-"] .wp-block-button__icon > svg {
	display: block;
	width: 100%;
	height: 100%;
}

/*
 * Icon only: a square one size step tall. The label stays in the markup as
 * screen-reader text, so the control keeps its accessible name.
 */
.wp-block-button[class*="is-style-square-"].is-icon-only > .wp-block-button__link {
	width: var(--square-button-height);
	height: var(--square-button-height);
	min-height: 0;
	padding: 0;
	aspect-ratio: 1 / 1;
}

.wp-block-button[class*="is-style-square-"].is-icon-only .wp-block-button__icon {
	width: calc(var(--square-button-height) * 0.5);
	height: calc(var(--square-button-height) * 0.5);
}

/* Native WooCommerce controls carry a high-specificity display override. */
.drapakowo-square-button[class*="is-style-square-"] {
	display: inline-flex !important;
}

.drapakowo-square-button[class*="is-style-square-"].has-icon-shopping-bag-add {
	gap: 0.625em;
}

.drapakowo-square-button[class*="is-style-square-"].has-icon-shopping-bag-add::before {
	width: 1.25em;
	height: 1.25em;
	flex: none;
	margin-block: -0.125em; /* see .wp-block-button__icon */
	background: currentColor;
	content: "";
	-webkit-mask: url("../../icons/shopping-bag-add.svg") center / contain no-repeat;
	mask: url("../../icons/shopping-bag-add.svg") center / contain no-repeat;
}

:is(.wp-block-button, .drapakowo-square-button):is(.is-style-square-dark-xs, .is-style-square-dark-sm, .is-style-square-dark-md, .is-style-square-dark-lg, .is-style-square-dark-xl) {
	--square-button-background: var(--wp--preset--color--off-black);
	--square-button-background-hover: var(--wp--preset--color--golden);
	--square-button-border: var(--wp--preset--color--off-black);
	--square-button-border-hover: var(--wp--preset--color--golden);
	--square-button-text: var(--wp--preset--color--golden);
	--square-button-text-hover: var(--wp--preset--color--off-black);
}

:is(.wp-block-button, .drapakowo-square-button):is(.is-style-square-golden-xs, .is-style-square-golden-sm, .is-style-square-golden-md, .is-style-square-golden-lg, .is-style-square-golden-xl) {
	--square-button-background: var(--wp--preset--color--golden);
	--square-button-background-hover: var(--wp--preset--color--off-black);
	--square-button-border: var(--wp--preset--color--golden);
	--square-button-border-hover: var(--wp--preset--color--off-black);
	--square-button-text: var(--wp--preset--color--off-black);
	--square-button-text-hover: var(--wp--preset--color--golden);
}

:is(.wp-block-button, .drapakowo-square-button):is(.is-style-square-light-xs, .is-style-square-light-sm, .is-style-square-light-md, .is-style-square-light-lg, .is-style-square-light-xl) {
	--square-button-background: var(--wp--preset--color--off-white);
	--square-button-background-hover: var(--wp--preset--color--off-black);
	--square-button-border: var(--wp--preset--color--off-black);
	--square-button-border-hover: var(--wp--preset--color--off-black);
	--square-button-text: var(--wp--preset--color--off-black);
	--square-button-text-hover: var(--wp--preset--color--off-white);
}

:is(.wp-block-button, .drapakowo-square-button):is(.is-style-square-mono-xs, .is-style-square-mono-sm, .is-style-square-mono-md, .is-style-square-mono-lg, .is-style-square-mono-xl) {
	--square-button-background: var(--wp--preset--color--off-black);
	--square-button-background-hover: var(--wp--preset--color--off-white);
	--square-button-border: var(--wp--preset--color--off-black);
	--square-button-border-hover: var(--wp--preset--color--off-black);
	--square-button-text: var(--wp--preset--color--off-white);
	--square-button-text-hover: var(--wp--preset--color--off-black);
}

:is(.wp-block-button, .drapakowo-square-button):is(.is-style-square-dark-xs, .is-style-square-golden-xs, .is-style-square-light-xs, .is-style-square-mono-xs) {
	--square-button-height: 1.75rem;
	--square-button-padding-block: 0.3125rem;
	--square-button-padding-inline: 0.75rem;
	--square-button-font-size: var(--step--2);
}

:is(.wp-block-button, .drapakowo-square-button):is(.is-style-square-dark-sm, .is-style-square-golden-sm, .is-style-square-light-sm, .is-style-square-mono-sm) {
	--square-button-height: 2rem;
	--square-button-padding-block: 0.375rem;
	--square-button-padding-inline: 0.875rem;
	--square-button-font-size: var(--step--1);
}

:is(.wp-block-button, .drapakowo-square-button):is(.is-style-square-dark-md, .is-style-square-golden-md, .is-style-square-light-md, .is-style-square-mono-md) {
	--square-button-height: 2.5rem;
	--square-button-padding-block: 0.625rem;
	--square-button-padding-inline: 1rem;
	--square-button-font-size: var(--step--1);
}

:is(.wp-block-button, .drapakowo-square-button):is(.is-style-square-dark-lg, .is-style-square-golden-lg, .is-style-square-light-lg, .is-style-square-mono-lg) {
	--square-button-height: 3rem;
	--square-button-padding-block: 0.75rem;
	--square-button-padding-inline: 1.25rem;
	--square-button-font-size: var(--step--1);
}

:is(.wp-block-button, .drapakowo-square-button):is(.is-style-square-dark-xl, .is-style-square-golden-xl, .is-style-square-light-xl, .is-style-square-mono-xl) {
	--square-button-height: 3.5rem;
	--square-button-padding-block: 0.875rem;
	--square-button-padding-inline: 1.5rem;
	--square-button-font-size: var(--step-0);
}

.wp-block-button[class*="is-style-square-"].wp-block-button__width-100 {
	display: flex;
	width: 100%;
}

.wp-block-button[class*="is-style-square-"].wp-block-button__width-100 > .wp-block-button__link {
	width: 100%;
}

.drapakowo-square-button[class*="is-style-square-"].is-square-button-full-width {
	width: 100%;
}

@media (hover: hover) and (pointer: fine) {
	:is(
		.wp-block-button[class*="is-style-square-"]:hover > .wp-block-button__link,
		.drapakowo-square-button[class*="is-style-square-"]:hover
	) {
		background: var(--square-button-background-hover);
		border-color: var(--square-button-border-hover);
		color: var(--square-button-text-hover);
		transform: none;
	}
}

:is(
	.wp-block-button[class*="is-style-square-"] > .wp-block-button__link,
	.drapakowo-square-button[class*="is-style-square-"]
):focus-visible {
	outline: 2px solid var(--square-button-text);
	outline-offset: 3px;
}

:is(
	.wp-block-button[class*="is-style-square-"] > .wp-block-button__link,
	.drapakowo-square-button[class*="is-style-square-"]
):active {
	background: var(--square-button-background-hover);
	border-color: var(--square-button-border-hover);
	color: var(--square-button-text-hover);
	transform: none;
}

:is(
	.wp-block-button[class*="is-style-square-"] > .wp-block-button__link,
	.drapakowo-square-button[class*="is-style-square-"]
):is(:disabled, [aria-disabled="true"], .disabled) {
	/*
	 * Resting colours over the hover / :active ones: those rules come earlier
	 * with equal or lower specificity. `.disabled` is WooCommerce's class on
	 * Add to Cart until a variation is chosen. 0.5 = WooCommerce's own
	 * `.button.disabled:hover`, which outranks this rule; equal, nothing jumps.
	 */
	border-color: var(--square-button-border);
	background: var(--square-button-background);
	color: var(--square-button-text);
	opacity: 0.5;
	cursor: var(--cursor-not-allowed);
	transform: none;
}

/*
 * Busy: aria-busy="true" while the button's request runs (cart adds in
 * assets/js/components/cart-toggle.js). Label and icon give way to a spinner
 * in the middle; the box, its colours and its hover state stay, so nothing
 * moves. The content is only made transparent — an icon-only button keeps
 * its screen-reader label — and the spinner draws in currentColor.
 */
:is(
	.wp-block-button[class*="is-style-square-"] > .wp-block-button__link,
	.drapakowo-square-button[class*="is-style-square-"]
)[aria-busy="true"] {
	position: relative;
	-webkit-text-fill-color: transparent;
}

.wp-block-button[class*="is-style-square-"] > .wp-block-button__link[aria-busy="true"] .wp-block-button__inner,
.drapakowo-square-button[class*="is-style-square-"][aria-busy="true"]::before {
	opacity: 0;
}

:is(
	.wp-block-button[class*="is-style-square-"] > .wp-block-button__link,
	.drapakowo-square-button[class*="is-style-square-"]
)[aria-busy="true"]::after {
	position: absolute;
	inset: 0;
	box-sizing: border-box;
	width: 1.25em;
	height: 1.25em;
	margin: auto;
	border: max(2px, 0.1em) solid currentColor;
	border-inline-end-color: transparent;
	border-radius: 50%;
	content: "";
	animation: square-button-spin 0.7s linear infinite;
}

@keyframes square-button-spin {
	to {
		transform: rotate(1turn);
	}
}

/* No spinning under reduced motion: a full ring that slowly fades instead. */
@keyframes square-button-busy {
	to {
		opacity: 0.3;
	}
}

@media (prefers-reduced-motion: reduce) {
	:is(
		.wp-block-button[class*="is-style-square-"] > .wp-block-button__link,
		.drapakowo-square-button[class*="is-style-square-"]
	) {
		transition: none;
	}

	:is(
		.wp-block-button[class*="is-style-square-"] > .wp-block-button__link,
		.drapakowo-square-button[class*="is-style-square-"]
	)[aria-busy="true"]::after {
		border-inline-end-color: currentColor;
		animation: square-button-busy 0.9s ease-in-out infinite alternate;
	}
}
