.#{$namespace}megamenu {
	--megamenu-gap: #{map-deep-get($token-spacer-unit-map, "32")};
	z-index: z("dropdown");
	//max-width: 460px;

	&.collapsing,
	&__level.collapsing {
		height: auto !important;
		overflow: visible;
		transition: none;
	}

	&:not(.-standalone) {


		top: 100%;
		left: 0;
		width: 100%;

		@include media-breakpoint-up(sm) {

			top: calc(100% + #{map-deep-get($token-spacer-unit-map, "8")});
			left: map-deep-get($token-spacer-unit-map, "16");
			width: calc(100% - #{map-deep-get($token-spacer-unit-map, "32")});

		}

	}

	&__surface {
		//@include custom-prop-fallback("color", "sys-color-text-primary-vivid");
		height: calc(100vh - var(--comp-header-nav-top-height));
		height: calc(100dvh - var(--comp-header-nav-top-height));
		overscroll-behavior: contain;

		@include media-breakpoint-up(sm) {

			height: calc(100vh - var(--comp-header-nav-top-height) - 16px);
			height: calc(100dvh - var(--comp-header-nav-top-height) - 16px);

		}

		@include media-breakpoint-up(lg) {

			height: var(--megamenu-height, auto);
			max-height: calc(100vh - var(--comp-header-nav-top-height) - 16px);
			max-height: calc(100dvh - var(--comp-header-nav-top-height) - 16px);
			@include transition($transition-collapse);

		}


	}

	&__body {
		//min-height: 440px;
	}

	&__item {
		// Keep the source aliases as fallbacks until these component tokens are generated.
		padding-inline: var(--comp-navbar-mega-menu-item-inset-h);
		padding-block: var(--comp-navbar-mega-menu-item-inset-v);
		gap: var(--comp-navbar-mega-menu-item-inline);
		border-radius: var(--comp-navbar-mega-menu-item-border-radius);
		min-width: var(--comp-navbar-mega-menu-item-min-width, var(--sys-size-width-17500, 280px));
		background-color: var(--comp-navbar-mega-menu-item-enabled-background-color);
		color: var(--comp-navbar-mega-menu-item-enabled-text-color);

		> .h5,
		> .#{$namespace}iconBlock:not(.#{$namespace}megamenu__arrow) {
			color: inherit;
		}

		&.-selected,
		&.-current {
			background-color: var(--comp-navbar-mega-menu-item-active-background-color);
			color: var(--comp-navbar-mega-menu-item-active-text-color);
		}

		@include hover {
			background-color: var(--comp-navbar-mega-menu-item-hovered-background-color);
			color: var(--comp-navbar-mega-menu-item-hovered-text-color);
		}

		&:active,
		&:focus-visible {
			background-color: var(--comp-navbar-mega-menu-item-pressed-background-color);
			color: var(--comp-navbar-mega-menu-item-pressed-text-color);
		}

		&:hover,
		&.-selected,
		&.-current,
		&:active,
		&:focus-visible {
			> .#{$namespace}iconBlock {
				@include custom-prop-fallback("background-color", "comp-navbar-icon-block-active-background-color");
			}
		}
	}

	&__footer {

		position: sticky;
		bottom: 0;

	}

	@include media-breakpoint-up(lg) {
		max-width: 1020px;
		// Override the retained standalone w-100 utility as well as the mobile width.
		width: auto !important;
		&.-standalone.show { display: inline-block; }
		--megamenu-column-width: calc((min(1020px, calc(100vw - #{map-deep-get($token-spacer-unit-map, "32")})) - #{map-deep-get($token-spacer-unit-map, "24") * 2} - 2 * var(--megamenu-gap)) / 3);
		&__surface {
			padding: map-deep-get($token-spacer-unit-map, "24");
			width: calc(var(--megamenu-visible-columns, 1) * var(--megamenu-column-width) + (var(--megamenu-visible-columns, 1) - 1) * var(--megamenu-gap) + #{map-deep-get($token-spacer-unit-map, "24") * 2});
		}
		&__body { min-height: var(--megamenu-content-height, 0px); }
		&__body > [data-megamenu-list],
		&__footer {
			width: var(--megamenu-column-width);
		}
		&__level {
			position: absolute;
			top: 0;
			left: calc(100% + var(--megamenu-gap));
			width: 100%;
			min-height: var(--megamenu-content-height, 0px);
			&::before {
				content: "";
				position: absolute;
				top: 0;
				bottom: 0;
				left: calc(var(--megamenu-gap) / -2);
				border-left: 1px solid currentColor;
				opacity: .3;
			}
		}

	}
}

.#{$namespace}header.-megamenuOpen { transform: none; }
