/*!
 * 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 "./themes/spectrum-two.css";

.spectrum-Toast {
	/* Hardcoded variables */
	--spectrum-toast-font-weight: var(--spectrum-regular-font-weight);

	/* Size */

	--spectrum-toast-font-size: var(--spectrum-font-size-100);
	--spectrum-toast-corner-radius: var(--spectrum-corner-radius-100);
	--spectrum-toast-block-size: var(--spectrum-toast-height);
	--spectrum-toast-max-inline-size: var(--spectrum-toast-maximum-width);
	--spectrum-toast-border-width: var(--spectrum-border-width-100);

	--spectrum-toast-line-height: var(--spectrum-line-height-100);
	--spectrum-toast-line-height-cjk: var(--spectrum-cjk-line-height-100);

	/* Space */

	--spectrum-toast-spacing-icon-to-text: var(--spectrum-text-to-visual-100);

	--spectrum-toast-spacing-start-edge-to-text-and-icon: var(--spectrum-spacing-300);
	--spectrum-toast-spacing-text-and-action-button-to-divider: var(--spectrum-spacing-300);

	--spectrum-toast-spacing-top-edge-to-divider: var(--spectrum-spacing-100);
	--spectrum-toast-spacing-bottom-edge-to-divider: var(--spectrum-spacing-100);

	--spectrum-toast-spacing-top-edge-to-icon: var(--spectrum-toast-top-to-workflow-icon);

	--spectrum-toast-spacing-text-to-action-button-horizontal: var(--spectrum-spacing-300);
	--spectrum-toast-spacing-close-button: var(--spectrum-spacing-100);

	--spectrum-toast-spacing-block-start: var(--spectrum-spacing-100);
	--spectrum-toast-spacing-block-end: var(--spectrum-spacing-100);

	--spectrum-toast-spacing-top-edge-to-text: var(--spectrum-toast-top-to-text);
	--spectrum-toast-spacing-bottom-edge-to-text: var(--spectrum-toast-bottom-to-text);

	/* Color */
	--spectrum-toast-negative-background-color-default: var(--spectrum-negative-background-color-default);
	--spectrum-toast-positive-background-color-default: var(--spectrum-positive-background-color-default);
	--spectrum-toast-informative-background-color-default: var(--spectrum-informative-background-color-default);

	--spectrum-toast-text-and-icon-color: var(--spectrum-white);
}

@media (forced-colors: active) {
	.spectrum-Toast {
		/* Border is visible in high contrast mode */
		--highcontrast-toast-border-color: ButtonText;

		border: var(--mod-toast-border-width, var(--spectrum-toast-border-width)) solid var(--highcontrast-toast-border-color, transparent);
	}
}

.spectrum-Toast {
	box-sizing: border-box;
	display: inline-flex;
	flex-direction: row;
	align-items: stretch;
	min-block-size: var(--mod-toast-block-size, var(--spectrum-toast-block-size));
	max-inline-size: var(--mod-toast-max-inline-size, var(--spectrum-toast-max-inline-size));

	border-radius: var(--mod-toast-corner-radius, var(--spectrum-toast-corner-radius));

	padding-inline-start: var(--mod-toast-spacing-start-edge-to-text-and-icon, var(--spectrum-toast-spacing-start-edge-to-text-and-icon));

	font-size: var(--mod-toast-font-size, var(--spectrum-toast-font-size));
	font-weight: var(--mod-toast-font-weight, var(--spectrum-toast-font-weight));

	-webkit-font-smoothing: antialiased;

	background-color: var(--mod-toast-background-color-default, var(--spectrum-toast-background-color-default));
	color: var(--mod-toast-background-color-default, var(--spectrum-toast-background-color-default));
	overflow-wrap: anywhere;
}

.spectrum-Toast--negative {
	background-color: var(--mod-toast-negative-background-color-default, var(--spectrum-toast-negative-background-color-default));
	color: var(--mod-toast-negative-background-color-default, var(--spectrum-toast-negative-background-color-default));

	.spectrum-Toast-closeButton:focus-visible:not(:active) {
		color: var(--mod-toast-negative-background-color-default, var(--spectrum-toast-negative-background-color-default));
	}
}

.spectrum-Toast--info {
	background-color: var(--mod-toast-informative-background-color-default, var(--spectrum-toast-informative-background-color-default));
	color: var(--mod-toast-informative-background-color-default, var(--spectrum-toast-informative-background-color-default));

	.spectrum-Toast-closeButton:focus-visible:not(:active) {
		color: var(--mod-toast-informative-background-color-default, var(--spectrum-toast-informative-background-color-default));
	}
}

.spectrum-Toast--positive {
	background-color: var(--mod-toast-positive-background-color-default, var(--spectrum-toast-positive-background-color-default));
	color: var(--mod-toast-positive-background-color-default, var(--spectrum-toast-positive-background-color-default));

	.spectrum-Toast-closeButton:focus-visible:not(:active) {
		color: var(--mod-toast-positive-background-color-default, var(--spectrum-toast-positive-background-color-default));
	}
}

.spectrum-Toast-typeIcon {
	flex-shrink: 0;
	flex-grow: 0;

	margin-block-start: var(--mod-toast-spacing-top-edge-to-icon, var(--spectrum-toast-spacing-top-edge-to-icon));
	margin-inline-end: var(--mod-toast-spacing-icon-to-text, var(--spectrum-toast-spacing-icon-to-text));
	margin-inline-start: 0;

	color: var(--mod-toast-text-and-icon-color, var(--spectrum-toast-text-and-icon-color));
}

.spectrum-Toast-content {
	flex: 1 1 auto;
	display: inline-block;
	box-sizing: border-box;

	padding-block-start: calc(var(--mod-toast-spacing-top-edge-to-text, var(--spectrum-toast-spacing-top-edge-to-text)) - var(--mod-toast-spacing-block-start, var(--spectrum-toast-spacing-block-start)));
	padding-block-end: calc(var(--mod-toast-spacing-bottom-edge-to-text, var(--spectrum-toast-spacing-bottom-edge-to-text)) - var(--mod-toast-spacing-block-end, var(--spectrum-toast-spacing-block-end)));

	padding-inline-end: var(--mod-toast-spacing-text-to-action-button-horizontal, var(--spectrum-toast-spacing-text-to-action-button-horizontal));
	padding-inline-start: 0;

	line-height: var(--mod-toast-line-height, var(--spectrum-toast-line-height));

	text-align: start;

	color: var(--mod-toast-text-and-icon-color, var(--spectrum-toast-text-and-icon-color));

	&:lang(ja),
	&:lang(zh),
	&:lang(ko) {
		line-height: var(--mod-toast-line-height-cjk, var(--spectrum-toast-line-height-cjk));
	}
}

.spectrum-Toast-buttons {
	display: flex;
	flex: 0 0 auto;
	align-items: flex-start;

	margin-block-start: var(--mod-toast-spacing-top-edge-to-divider, var(--spectrum-toast-spacing-top-edge-to-divider));
	margin-block-end: var(--mod-toast-spacing-bottom-edge-to-divider, var(--spectrum-toast-spacing-bottom-edge-to-divider));

	/* Divider color for Text | Action Button */
	border-inline-start-color: var(--mod-toast-divider-color, var(--spectrum-toast-divider-color));
	padding-inline-end: var(--mod-toast-spacing-close-button, var(--spectrum-toast-spacing-close-button));

	.spectrum-CloseButton {
		align-self: flex-start;
	}
}

.spectrum-Toast-body {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	flex: 1 1 auto;
	align-self: center;

	padding-block-start: var(--mod-toast-spacing-block-start, var(--spectrum-toast-spacing-block-start));
	padding-block-end: var(--mod-toast-spacing-block-end, var(--spectrum-toast-spacing-block-end));

	.spectrum-Button {
		margin-inline-start: auto;
		margin-inline-end: var(--mod-toast-spacing-text-and-action-button-to-divider, var(--spectrum-toast-spacing-text-and-action-button-to-divider));

		&:dir(rtl) {
			margin-inline-end: auto;
			margin-inline-end: var(--mod-toast-spacing-text-and-action-button-to-divider, var(--spectrum-toast-spacing-text-and-action-button-to-divider));
		}
	}

	& + .spectrum-Toast-buttons {
		padding-inline-start: var(--mod-toast-spacing-close-button, var(--spectrum-toast-spacing-close-button));

		border-inline-start-width: 1px;
		border-inline-start-style: solid;
	}
}
