/*!
 * 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-Tray-wrapper {
	inset-inline-start: 0;

	/* Positioned at the bottom of the window */
	position: fixed;
	inset-block-end: 0;
	display: flex;
	justify-content: center;
	inline-size: 100%;
}

.spectrum-Tray {
	/* Maximum width for landscape */
	--spectrum-tray-max-inline-size: var(--mod-tray-max-inline-size, 375px);

	/* https://spectrum.adobe.com/page/tray/#Maximum-height */
	--spectrum-tray-spacing-edge-to-tray-safe-zone: var(--mod-tray-spacing-edge-to-tray-safe-zone, 64px);

	--spectrum-tray-entry-animation-delay: var(--mod-tray-entry-animation-delay, 160ms);
	--spectrum-tray-entry-animation-duration: var(--mod-tray-entry-animation-duration, var(--spectrum-animation-duration-500));
	--spectrum-tray-exit-animation-delay: var(--mod-tray-exit-animation-delay, 0ms);
	--spectrum-tray-exit-animation-duration: var(--mod-tray-exit-animation-duration, var(--spectrum-animation-duration-100));

	--spectrum-tray-corner-radius: var(--mod-tray-corner-radius, var(--spectrum-corner-radius-100));
	--spectrum-tray-background-color: var(--highcontrast-tray-background-color, var(--mod-tray-background-color, var(--spectrum-background-layer-2-color)));

	--mod-modal-max-width: 100%;

	/* Default to full width when the viewport is in portrait orientation */
	inline-size: 100%;
	max-inline-size: 100%;

	max-block-size: calc(100vh - var(--spectrum-tray-spacing-edge-to-tray-safe-zone));
	margin-block-start: var(--spectrum-tray-spacing-edge-to-tray-safe-zone);
	padding-block-start: var(--mod-tray-top-to-content-area, var(--spectrum-tray-top-to-content-area));
	padding-block-end: var(--mod-tray-bottom-to-content-area, var(--spectrum-tray-top-to-content-area));
	box-sizing: border-box;
	overflow: auto;
	outline: none;
	border-radius: var(--mod-tray-corner-radius-portrait, 0) var(--mod-tray-corner-radius-portrait, 0) 0 0;

	/* Start offset by the animation distance */
	transform: translateY(100%);

	/* Exit animations */
	transition:
		opacity var(--spectrum-tray-exit-animation-duration) cubic-bezier(0.5, 0, 1, 1) var(--spectrum-tray-exit-animation-delay),
		visibility var(--spectrum-tray-exit-animation-duration) linear calc(var(--spectrum-tray-exit-animation-delay) + var(--spectrum-tray-exit-animation-duration)),
		transform var(--spectrum-tray-exit-animation-duration) cubic-bezier(0.5, 0, 1, 1) var(--spectrum-tray-exit-animation-delay);

	background-color: var(--spectrum-tray-background-color);

	&.is-open {
		transform: translateY(0);

		/* Entry animations */
		transition:
			transform var(--spectrum-tray-entry-animation-duration) cubic-bezier(0, 0, 0.4, 1) var(--spectrum-tray-entry-animation-delay),
			opacity var(--spectrum-tray-entry-animation-duration) cubic-bezier(0, 0, 0.4, 1) var(--spectrum-tray-entry-animation-delay);
	}
}

@media screen and (orientation: landscape) {
	.spectrum-Tray {
		border-start-start-radius: var(--spectrum-tray-corner-radius);
		border-start-end-radius: var(--spectrum-tray-corner-radius);
		max-inline-size: var(--spectrum-tray-max-inline-size);
	}
}

@media (forced-colors: active) {
	.spectrum-Tray {
		--highcontrast-tray-background-color: Canvas;

		border: solid;

		& .spectrum-Dialog {
			border: none;
		}
	}
}
