/*!
 * Copyright 2024 Adobe. All rights reserved.
 *
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at <http://www.apache.org/licenses/LICENSE-2.0>
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

%spectrum-BaseButton {
	cursor: pointer;
	user-select: none;

	/* Contain halo */
	position: relative;

	/* Show the button overflow in Edge. */
	overflow: visible;
	display: inline-flex;
	align-items: center;
	justify-content: center;

	box-sizing: border-box;

	/* Remove button the margin in Firefox and Safari. */
	margin: 0;

	/* @deprecation --mod-sans-font-family-stack has been renamed and will be removed in a future version. */
	font-family: var(--mod-button-font-family, var(--mod-sans-font-family-stack, var(--spectrum-sans-font-family-stack)));

	-webkit-font-smoothing: antialiased;

	/* Font smoothing for Firefox */
	-moz-osx-font-smoothing: grayscale;

	/* @deprecation --mod-line-height-100 has been renamed and will be removed in a future version. */
	line-height: var(--mod-button-line-height, var(--mod-line-height-100, var(--spectrum-line-height-100)));
	text-decoration: none;

	/* Remove the inheritance of text transform on button in Edge, Firefox, and IE. */
	text-transform: none;

	/* Adjacent buttons should be aligned correctly */
	vertical-align: top;

	/* stylelint-disable-next-line property-no-vendor-prefix -- Correct the inability to style clickable types in iOS and Safari (normalize). */
	-webkit-appearance: button;

	border-style: solid;

	transition:
		background var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out,
		border-color var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out,
		color var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out,
		box-shadow var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out;

	/* Fix Firefox */
	&::-moz-focus-inner {
		border-style: none;
		padding: 0;
	}

	&:focus {
		outline: none;
	}

	&:disabled,
	&.is-disabled {
		cursor: default;
	}
}

%spectrum-ButtonIcon {
	flex-shrink: 0;
	max-block-size: 100%;
}

%spectrum-ButtonWithFocusRing {
	&::after {
		content: "";

		position: absolute;
		inset-block-start: 0;
		inset-block-end: 0;
		inset-inline-start: 0;
		inset-inline-end: 0;

		display: block;

		margin: calc(-1 * var(--mod-button-focus-indicator-gap, var(--spectrum-focus-indicator-gap)));

		transition:
			opacity var(--mod-button-animation-duration, var(--mod-button-animation-duration, var(--spectrum-animation-duration-100))) ease-out,
			margin var(--mod-button-animation-duration, var(--mod-button-animation-duration, var(--spectrum-animation-duration-100))) ease-out;
	}

	&:focus-visible::after {
		margin: calc(-2 * var(--mod-focus-indicator-gap, var(--spectrum-focus-indicator-gap)));
	}
}

%spectrum-AnchorButton {
	/* Make link text not selectable  */
	user-select: none;

	/* stylelint-disable-next-line property-no-vendor-prefix -- Remove appearance for clickable types in iOS and Safari. */
	-webkit-appearance: none;
}

%spectrum-ButtonLabel {
	align-self: center;
	justify-self: center;

	/* Fixes horizontal alignment of text in anchor buttons */
	text-align: center;

	&:empty {
		display: none;
	}
}
