/*!
 * 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";

@media (forced-colors: active) {
	/* forced-color-adjust: preserve-parent-color addresses svg bug on icon hover */
	.spectrum-SideNav {
		.spectrum-Icon {
			forced-color-adjust: preserve-parent-color;
		}
	}

	.spectrum-SideNav-item {
		--highcontrast-sidenav-content-disabled-color: GrayText;

		--highcontrast-sidenav-focus-ring-color: Highlight;

		--highcontrast-sidenav-content-color-default-selected: SelectedItemText;
		--highcontrast-sidenav-item-background-default-selected: SelectedItem;

		--highcontrast-sidenav-background-key-focus-selected: Highlight;
		--highcontrast-sidenav-background-hover-selected: Highlight;
		--highcontrast-sidenav-item-background-down-selected: Highlight;

		--highcontrast-sidenav-item-background-down: Highlight;
		--highcontrast-sidenav-background-hover: Highlight;
		--highcontrast-sidenav-content-color-hover: HighlightText;
		--highcontrast-sidenav-background-key-focus: Highlight;

		--highcontrast-sidenav-top-level-font-color: ButtonText;
		--highcontrast-sidenav-content-color-default: ButtonText;
		--highcontrast-sidenav-content-color-down: HighlightText;

		forced-color-adjust: none;
	}
}

.spectrum-SideNav {
	/* focus indicator */
	--spectrum-sidenav-focus-ring-size: var(--spectrum-focus-indicator-thickness);
	--spectrum-sidenav-focus-ring-gap: var(--spectrum-focus-indicator-gap);
	--spectrum-sidenav-focus-ring-color: var(--spectrum-focus-indicator-color);

	/* layout */
	--spectrum-sidenav-min-height: var(--spectrum-component-height-100);
	--spectrum-sidenav-width: 100%;
	--spectrum-sidenav-min-width: var(--spectrum-side-navigation-minimum-width);
	--spectrum-sidenav-max-width: var(--spectrum-side-navigation-maximum-width);
	--spectrum-sidenav-border-radius: var(--spectrum-corner-radius-100);
	--spectrum-sidenav-icon-size: var(--spectrum-workflow-icon-size-100);
	--spectrum-sidenav-icon-spacing: var(--spectrum-text-to-visual-100);
	--spectrum-sidenav-inline-padding: var(--spectrum-component-edge-to-text-100);
	--spectrum-sidenav-gap: var(--spectrum-side-navigation-item-to-item);
	--spectrum-sidenav-top-to-icon: var(--spectrum-component-top-to-workflow-icon-100);
	--spectrum-sidenav-top-to-label: var(--spectrum-component-top-to-text-100);
	--spectrum-sidenav-bottom-to-label: var(--spectrum-side-navigation-bottom-to-text);

	--spectrum-sidenav-start-to-content-second-level: var(--spectrum-side-navigation-second-level-edge-to-text);
	--spectrum-sidenav-start-to-content-third-level: var(--spectrum-side-navigation-third-level-edge-to-text);

	--spectrum-sidenav-start-to-content-with-icon-second-level: var(--spectrum-side-navigation-with-icon-second-level-edge-to-text);
	--spectrum-sidenav-start-to-content-with-icon-third-level: var(--spectrum-side-navigation-with-icon-third-level-edge-to-text);

	--spectrum-sidenav-heading-top-margin: var(--spectrum-side-navigation-item-to-header);
	--spectrum-sidenav-heading-bottom-margin: var(--spectrum-side-navigation-header-to-item);

	/* color - background */
	--spectrum-sidenav-background-disabled: transparent;
	--spectrum-sidenav-background-default: transparent;

	/* color font */
	--spectrum-sidenav-header-color: var(--spectrum-gray-600);

	--spectrum-sidenav-content-disabled-color: var(--spectrum-disabled-content-color);

	--spectrum-sidenav-content-color-default: var(--spectrum-neutral-content-color-default);
	--spectrum-sidenav-content-color-hover: var(--spectrum-neutral-content-color-hover);
	--spectrum-sidenav-content-color-down: var(--spectrum-neutral-content-color-down);
	--spectrum-sidenav-content-color-key-focus: var(--spectrum-neutral-content-color-key-focus);

	--spectrum-sidenav-content-color-default-selected: var(--spectrum-neutral-content-color-default);
	--spectrum-sidenav-content-color-hover-selected: var(--spectrum-neutral-content-color-hover);
	--spectrum-sidenav-content-color-down-selected: var(--spectrum-neutral-content-color-down);
	--spectrum-sidenav-content-color-key-focus-selected: var(--spectrum-neutral-content-color-key-focus);

	/* typography */
	--spectrum-sidenav-text-font-family: var(--spectrum-sans-font-family-stack);
	--spectrum-sidenav-text-font-weight: var(--spectrum-regular-font-weight);
	--spectrum-sidenav-text-font-style: var(--spectrum-default-font-style);
	--spectrum-sidenav-text-font-size: var(--spectrum-font-size-100);
	--spectrum-sidenav-text-line-height: var(--spectrum-line-height-100);

	--spectrum-sidenav-top-level-font-family: var(--spectrum-sans-font-family-stack);
	--spectrum-sidenav-top-level-font-weight: var(--spectrum-bold-font-weight);
	--spectrum-sidenav-top-level-font-style: var(--spectrum-default-font-style);
	--spectrum-sidenav-top-level-font-size: var(--spectrum-font-size-100);
	--spectrum-sidenav-top-level-line-height: var(--spectrum-line-height-100);

	--spectrum-sidenav-header-font-family: var(--spectrum-sans-font-family-stack);
	--spectrum-sidenav-header-font-weight: var(--spectrum-medium-font-weight);
	--spectrum-sidenav-header-font-style: var(--spectrum-default-font-style);
	--spectrum-sidenav-header-font-size: var(--spectrum-font-size-75);
	--spectrum-sidenav-header-line-height: var(--spectrum-line-height-100);

	display: flex;
	flex-direction: column;

	list-style-type: none;
	margin: 0;
	padding: 0;

	&:lang(ja),
	&:lang(zh),
	&:lang(ko) {
		--spectrum-sidenav-text-line-height: var(--spectrum-cjk-line-height-100);
		--spectrum-sidenav-top-level-line-height: var(--spectrum-cjk-line-height-100);
		--spectrum-sidenav-header-line-height: var(--spectrum-cjk-line-height-100);
	}
}

.spectrum-SideNav-item {
	list-style-type: none;
	margin-inline: 0;

	&.is-disabled {
		/* Disable all children */
		.spectrum-SideNav-itemLink {
			background-color: var(--mod-sidenav-background-disabled, var(--spectrum-sidenav-background-disabled));
			color: var(--highcontrast-sidenav-content-disabled-color, var(--mod-sidenav-content-disabled-color, var(--spectrum-sidenav-content-disabled-color)));

			cursor: default;
			pointer-events: none;
		}
	}

	&.is-selected {
		.spectrum-SideNav-itemLink {
			background-color: var(--highcontrast-sidenav-item-background-default-selected, var(--mod-sidenav-item-background-default-selected, var(--spectrum-sidenav-item-background-default-selected)));
			color: var(--highcontrast-sidenav-content-color-default-selected, var(--mod-sidenav-content-color-default-selected, var(--spectrum-sidenav-content-color-default-selected)));

			&:hover {
				background-color: var(--highcontrast-sidenav-background-hover-selected, var(--mod-sidenav-background-hover-selected, var(--spectrum-sidenav-background-hover-selected)));
				color: var(--mod-sidenav-content-color-hover-selected, var(--spectrum-sidenav-content-color-hover-selected));
			}

			&:active {
				background-color: var(--highcontrast-sidenav-item-background-down-selected, var(--mod-sidenav-item-background-down-selected, var(--spectrum-sidenav-item-background-down-selected)));
				color: var(--mod-sidenav-content-color-down-selected, var(--spectrum-sidenav-content-color-down-selected));
			}

			&.is-keyboardFocused,
			&:focus-visible {
				background-color: var(--highcontrast-sidenav-background-key-focus-selected, var(--mod-sidenav-background-key-focus-selected, var(--spectrum-sidenav-background-key-focus-selected)));
				color: var(--mod-sidenav-content-color-key-focus-selected, var(--spectrum-sidenav-content-color-key-focus-selected));
			}
		}
	}
}

.spectrum-SideNav-itemLink {
	padding-inline: var(--mod-sidenav-inline-padding, var(--spectrum-sidenav-inline-padding));
	margin-block-end: var(--mod-sidenav-gap, var(--spectrum-sidenav-gap));
	position: relative;
	display: inline-flex;
	justify-content: start;
	box-sizing: border-box;
	overflow-wrap: break-word;
	hyphens: auto;
	cursor: pointer;
	transition:
		background-color var(--spectrum-animation-duration-100) ease-out,
		color var(--spectrum-animation-duration-100) ease-out;

	border-radius: var(--mod-sidenav-border-radius, var(--spectrum-sidenav-border-radius));

	background-color: var(--mod-sidenav-background-default, var(--spectrum-sidenav-background-default));
	color: var(--highcontrast-sidenav-content-color-default, var(--mod-sidenav-content-color-default, var(--spectrum-sidenav-content-color-default)));

	inline-size: var(--mod-sidenav-width, var(--spectrum-sidenav-width));
	min-inline-size: var(--mod-sidenav-min-width, var(--spectrum-sidenav-min-width));
	max-inline-size: var(--mod-sidenav-max-width, var(--spectrum-sidenav-max-width));
	min-block-size: var(--mod-sidenav-min-height, var(--spectrum-sidenav-min-height));

	font-family: var(--mod-sidenav-text-font-family, var(--spectrum-sidenav-text-font-family));
	font-size: var(--mod-sidenav-text-font-size, var(--spectrum-sidenav-text-font-size));
	font-weight: var(--mod-sidenav-text-font-weight, var(--spectrum-sidenav-text-font-weight));
	font-style: var(--mod-sidenav-text-font-style, var(--spectrum-sidenav-text-font-style));
	text-decoration: none;
	line-height: var(--mod-sidenav-text-line-height, var(--spectrum-sidenav-text-line-height));

	.spectrum-SideNav-link-text {
		margin-block-start: var(--mod-sidenav-top-to-label, var(--spectrum-sidenav-top-to-label));
		margin-block-end: var(--mod-sidenav-bottom-to-label, var(--spectrum-sidenav-bottom-to-label));
	}

	.spectrum-Icon {
		inline-size: var(--mod-sidenav-icon-size, var(--spectrum-sidenav-icon-size));
		block-size: var(--mod-sidenav-icon-size, var(--spectrum-sidenav-icon-size));
		margin-inline-end: var(--mod-sidenav-icon-spacing, var(--spectrum-sidenav-icon-spacing));
		margin-block-start: var(--mod-sidenav-top-to-icon, var(--spectrum-sidenav-top-to-icon));
		flex-shrink: 0;
	}

	&:hover {
		background-color: var(--highcontrast-sidenav-background-hover, var(--mod-sidenav-background-hover, var(--spectrum-sidenav-background-hover)));
		color: var(--highcontrast-sidenav-content-color-hover, var(--mod-sidenav-content-color-hover, var(--spectrum-sidenav-content-color-hover)));
	}

	&:active {
		background-color: var(--highcontrast-sidenav-item-background-down, var(--mod-sidenav-item-background-down, var(--spectrum-sidenav-item-background-down)));
		color: var(--highcontrast-sidenav-content-color-down, var(--mod-sidenav-content-color-down, var(--spectrum-sidenav-content-color-down)));
	}

	&.is-keyboardFocused,
	&:focus-visible {
		outline: var(--highcontrast-sidenav-focus-ring-color, var(--mod-sidenav-focus-ring-color, var(--spectrum-sidenav-focus-ring-color))) solid var(--mod-sidenav-focus-ring-size, var(--spectrum-sidenav-focus-ring-size));
		outline-offset: var(--mod-sidenav-focus-ring-gap, var(--spectrum-sidenav-focus-ring-gap));
		background-color: var(--highcontrast-sidenav-background-key-focus, var(--mod-sidenav-background-key-focus, var(--spectrum-sidenav-background-key-focus)));
		color: var(--mod-sidenav-content-color-key-focus, var(--spectrum-sidenav-content-color-key-focus));
	}
}

.spectrum-SideNav-heading {
	margin-block-start: calc(var(--mod-sidenav-heading-top-margin, var(--spectrum-sidenav-heading-top-margin)) - var(--mod-sidenav-gap, var(--spectrum-sidenav-gap)));
	margin-block-end: var(--mod-sidenav-heading-bottom-margin, var(--spectrum-sidenav-heading-bottom-margin));
	padding-inline: var(--mod-sidenav-inline-padding, var(--spectrum-sidenav-inline-padding));
	color: var(--mod-sidenav-header-color, var(--spectrum-sidenav-header-color));
	font-family: var(--spectrum-sidenav-header-font-family);
	font-size: var(--mod-sidenav-header-font-size, var(--spectrum-sidenav-header-font-size));
	font-weight: var(--mod-sidenav-header-font-weight, var(--spectrum-sidenav-header-font-weight));
	font-style: var(--mod-sidenav-header-font-style, var(--spectrum-sidenav-header-font-style));
	line-height: var(--mod-sidenav-header-line-height, var(--spectrum-sidenav-header-line-height));
}

.spectrum-SideNav--multiLevel {
	.spectrum-SideNav-itemLink {
		color: var(--highcontrast-sidenav-top-level-font-color);
		font-family: var(--mod-sidenav-top-level-font-family, var(--spectrum-sidenav-top-level-font-family));
		font-weight: var(--mod-sidenav-top-level-font-weight, var(--spectrum-sidenav-top-level-font-weight));
		font-style: var(--mod-sidenav-top-level-font-style, var(--spectrum-sidenav-top-level-font-style));
		font-size: var(--mod-sidenav-top-level-font-size, var(--spectrum-sidenav-top-level-font-size));
		line-height: var(--mod-sidenav-top-level-line-height, var(--spectrum-sidenav-top-level-line-height));
	}

	.spectrum-SideNav {
		.spectrum-SideNav-itemLink {
			font-weight: var(--mod-sidenav-text-font-weight, var(--spectrum-sidenav-text-font-weight));
			padding-inline-start: var(--mod-sidenav-start-to-content-second-level, var(--spectrum-sidenav-start-to-content-second-level));
		}

		.spectrum-SideNav .spectrum-SideNav-itemLink {
			padding-inline-start: var(--mod-sidenav-start-to-content-third-level, var(--spectrum-sidenav-start-to-content-third-level));
		}
	}
}

.spectrum-SideNav--hasIcon.spectrum-SideNav--multiLevel {
	.spectrum-SideNav {
		.spectrum-SideNav-itemLink {
			padding-inline-start: var(--mod-sidenav-start-to-content-with-icon-second-level, var(--spectrum-sidenav-start-to-content-with-icon-second-level));
		}

		.spectrum-SideNav .spectrum-SideNav-itemLink {
			padding-inline-start: var(--mod-sidenav-start-to-content-with-icon-third-level, var(--spectrum-sidenav-start-to-content-with-icon-third-level));
		}
	}
}
