/*!
 * 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.
 */

@import "@spectrum-css/commons/basebutton.css";
@import "./themes/spectrum-two.css";

.spectrum-LogicButton {
	--spectrum-logic-button-border-radius: var(--spectrum-corner-radius-100);

	--spectrum-logic-button-and-text-color: var(--spectrum-white);
	--spectrum-logic-button-and-background-color-hover: var(--spectrum-blue-1100);
	--spectrum-logic-button-and-border-color-hover: var(--spectrum-blue-1100);

	--spectrum-logic-button-or-text-color: var(--spectrum-white);
	--spectrum-logic-button-text-color-disabled: var(--spectrum-gray-500);

	@extend %spectrum-BaseButton;
	@extend %spectrum-ButtonWithFocusRing;

	block-size: var(--mod-logic-button-height, 24px);
	padding: var(--mod-logic-button-padding, var(--spectrum-component-edge-to-text-50));

	border-width: var(--mod-logic-button-border-width, var(--spectrum-border-width-200));
	border-radius: var(--mod-logic-button-border-radius, var(--spectrum-logic-button-border-radius));

	font-size: var(--mod-logic-button-font-size, var(--spectrum-font-size-100));
	font-weight: var(--mod-logic-button-font-weight, var(--spectrum-bold-font-weight));
	line-height: 0;

	&::after {
		/* Override border-radius set in %spectrum-ButtonWithFocusRing since this is not a pill button */
		border-radius: calc(var(--mod-logic-button-border-radius, var(--spectrum-logic-button-border-radius)) + var(--mod-logic-button-focus-indicator-gap, var(--spectrum-focus-indicator-gap)));
	}

	&:focus-visible {
		outline: none;

		&::after {
			box-shadow: 0 0 0 var(--mod-logic-button-focus-indicator-width, var(--spectrum-focus-indicator-thickness)) var(--highcontrast-logic-button-focus-indicator-color, var(--mod-logic-button-focus-indicator-color, var(--spectrum-focus-indicator-color)));
		}
	}

	&:disabled,
	&.is-disabled {
		--mod-logic-button-and-background-color: var(--mod-logic-button-and-background-color-disabled, var(--spectrum-logic-button-and-background-color-disabled));
		--mod-logic-button-and-border-color: var(--mod-logic-button-and-border-color-disabled, var(--spectrum-logic-button-and-border-color-disabled));
		--mod-logic-button-and-text-color: var(--mod-logic-button-and-text-color-disabled, var(--spectrum-logic-button-text-color-disabled));
		--mod-logic-button-and-background-color-hover: var(--mod-logic-button-and-background-color-hover-disabled, var(--spectrum-logic-button-and-background-color-hover-disabled));
		--mod-logic-button-and-border-color-hover: var(--mod-logic-button-and-border-color-hover-disabled, var(--spectrum-logic-button-and-border-color-hover-disabled));

		--mod-logic-button-or-background-color: var(--mod-logic-button-or-background-color-disabled, var(--spectrum-logic-button-or-background-color-disabled));
		--mod-logic-button-or-border-color: var(--mod-logic-button-or-border-color-disabled, var(--spectrum-logic-button-or-border-color-disabled));
		--mod-logic-button-or-text-color: var(--mod-logic-button-or-text-color-disabled, var(--spectrum-logic-button-text-color-disabled));
		--mod-logic-button-or-background-color-hover: var(--mod-logic-button-or-background-color-hover-disabled, var(--spectrum-logic-button-or-background-color-hover-disabled));
		--mod-logic-button-or-border-color-hover: var(--mod-logic-button-or-border-color-hover-disabled, var(--spectrum-logic-button-or-border-color-hover-disabled));
	}
}

.spectrum-LogicButton--and {
	background-color: var(--highcontrast-logic-button-and-background-color, var(--mod-logic-button-and-background-color, var(--spectrum-logic-button-and-background-color)));
	border-color: var(--highcontrast-logic-button-and-border-color, var(--mod-logic-button-and-border-color, var(--spectrum-logic-button-and-border-color)));
	color: var(--highcontrast-logic-button-and-text-color, var(--mod-logic-button-and-text-color, var(--spectrum-logic-button-and-text-color)));

	&:hover:not([disabled]) {
		background-color: var(--highcontrast-logic-button-and-background-color-hover, var(--mod-logic-button-and-background-color-hover, var(--spectrum-logic-button-and-background-color-hover)));
		border-color: var(--highcontrast-logic-button-and-border-color-hover, var(--mod-logic-button-and-border-color-hover, var(--spectrum-logic-button-and-border-color-hover)));
	}
}

.spectrum-LogicButton--or {
	background-color: var(--highcontrast-logic-button-or-background-color, var(--mod-logic-button-or-background-color, var(--spectrum-logic-button-or-background-color)));
	border-color: var(--highcontrast-logic-button-or-border-color, var(--mod-logic-button-or-border-color, var(--spectrum-logic-button-or-border-color)));
	color: var(--highcontrast-logic-button-or-text-color, var(--mod-logic-button-or-text-color, var(--spectrum-logic-button-or-text-color)));

	&:hover:not([disabled]) {
		background-color: var(--highcontrast-logic-button-or-background-color-hover, var(--mod-logic-button-or-background-color-hover, var(--spectrum-logic-button-or-background-color-hover)));
		border-color: var(--highcontrast-logic-button-or-border-color-hover, var(--mod-logic-button-or-border-color-hover, var(--spectrum-logic-button-or-border-color-hover)));
	}
}

@media (forced-colors: active) {
	.spectrum-LogicButton::after {
		--highcontrast-logic-button-focus-indicator-color: Highlight;

		forced-color-adjust: none;
	}

	.spectrum-LogicButton {
		--highcontrast-logic-button-and-background-color: ButtonFace;
		--highcontrast-logic-button-and-background-color-hover: ButtonFace;
		--highcontrast-logic-button-and-border-color: ButtonText;
		--highcontrast-logic-button-and-border-color-hover: Highlight;
		--highcontrast-logic-button-and-text-color: ButtonText;
		--highcontrast-logic-button-or-background-color: ButtonFace;
		--highcontrast-logic-button-or-background-color-hover: ButtonFace;
		--highcontrast-logic-button-or-border-color: ButtonText;
		--highcontrast-logic-button-or-border-color-hover: Highlight;
		--highcontrast-logic-button-or-text-color: ButtonText;

		forced-color-adjust: none;

		&:disabled,
		&.is-disabled {
			--highcontrast-logic-button-and-background-color: ButtonFace;
			--highcontrast-logic-button-and-border-color: GrayText;
			--highcontrast-logic-button-and-text-color: GrayText;
			--highcontrast-logic-button-or-background-color: ButtonFace;
			--highcontrast-logic-button-or-border-color: GrayText;
			--highcontrast-logic-button-or-text-color: GrayText;
		}
	}
}
