/*
 * Button (cis/bw-button). Loaded with the block, front end and editor canvas.
 *
 * Moved here from the Etch style of the Button component (.bw-button), because Etch only prints a style
 * while an Etch block uses it. Plain stylesheet, not compiled by Etch, so lengths are in rem
 * (to-rem(4px) = 0.25rem, 10px = 0.625rem, 28px = 1.75rem, 8px = 0.5rem) and ACSS variables are used as is.
 *
 * The colours, sizes and shape come from ACSS (.btn--primary, .btn--white, ... and the --btn-* variables).
 * This file only adds what the Etch component added on top: the arrow, its hover turn, the small size
 * and the "link" look. The empty .unrelate class Etch also printed has no rules and is not needed here.
 * One addition: reduced-motion users get no icon turn or colour fade (the Etch style had no such rule).
 */

.bw-button {
	--btn-justify-content: space-between;
	--icon-path-color: var(--btn-text-color);
	--icon-path-color-hover: var(--btn-text-color-hover);

	&:has([data-icon]) {
		gap: 0.25rem;
	}

	/* An ACSS size class (btn--l ...) brings its own padding, so only the Etch sizes get this one. */
	&:not(.bw-button--sized):not(:has([data-icon])) {
		--btn-padding-block: 0.625rem;
		--btn-padding-inline: 1.75rem;
		--btn-justify-content: center;
	}

	&[data-button-size='small'] {
		--btn-font-size: var(--text-l);
		--btn-padding-block: 0.25rem;
	}

	&:hover {
		[data-icon] {
			transform: rotateZ(30deg);
		}

		svg {
			path {
				fill: var(--icon-path-color-hover);
			}
		}
	}

	&.btn--outline.btn--link {
		--btn-background: transparent;
		--btn-padding-block: 0;
		--btn-padding-inline: 0;
		--btn-border-radius: 0;
		--btn-border-style: unset;
		--btn-border-width: 0;
		--btn-border-color: transparent;

		&:hover {
			--btn-background-hover: transparent;
			--btn-border-color-hover: transparent;
		}
	}

	[data-icon] {
		padding-block: 0.5rem;
		padding-inline: 0.25rem;
	}

	svg {
		path {
			transition: var(--transition);
			fill: var(--icon-path-color);
		}
	}

	/* The arrow follows the text size on the ACSS sizes (xs ... xxl), instead of staying 25px wide (0.9em = 25px at the default 28px text). */
	&.bw-button--sized {
		gap: 0.5em;

		[data-icon] {
			font-size: inherit;
			inline-size: 0.9em;
			block-size: auto;
			aspect-ratio: 25 / 16;
			padding: 0;
		}
	}

	@media (prefers-reduced-motion: reduce) {
		[data-icon] {
			transition: none;
		}

		&:hover [data-icon] {
			transform: none;
		}

		svg path {
			transition: none;
		}
	}
}
