// Navigation

.main-navigation {

	color: #{map-deep-get($config-header, "main-nav", "color", "text")};

	// Menu wrapper
	& > div {
		display: none;
	}

	// Mobile menu toggle
	#toggle-menu {
		display: inline-block;
		margin: 0;
	}

	// Checkbox hack
	#toggle:checked ~ div:not(.woocommerce-menu-container) {
		display: block;
	}

	#toggle:focus + #toggle-menu {
		background-color: #{map-deep-get($config-header, "main-nav", "color", "link-hover")};
		outline: inherit;
		text-decoration: underline;
	}

	.dropdown-icon.close {
		display: none;
	}

	#toggle:checked + #toggle-menu {
		.open {
			display: none;
		}

		.close {
			display: inline;
		}
	}

	@include media(mobile) {

		& > div {
			display: inline-block;
		}

		#toggle-menu {
			display: none;
		}

		// Hide sub-sub-menus
		& > div > ul > li > ul {
			display: none;
		}
	}

	// Menu list wrapper
	& > div > ul {
		display: flex;
		flex-wrap: wrap;
		list-style: none;
		margin: 0;
		max-width: none;
		padding-left: 0;
		position: relative;

		ul {
			padding-left: 0;
		}

		li {
			display: block;
			position: relative;
			width: 100%;
			z-index: 1;

			&:hover,
			&:focus-within {
				cursor: pointer;
				z-index: 99999;
			}

			&:focus-within a {
			//	outline: none;
			}

			@include media(mobile) {
				display: inherit;
				width: inherit;

				/* Submenu display */
				&:hover > ul,
				&:focus-within > ul,
				& ul:hover,
				& ul:focus {
					visibility: visible;
					opacity: 1;
					display: block;
				}
			}
		}

		& > li {

			@include media(mobile) {
				& > a {
					@include crop-text(map-deep-get($config-header, "main-nav", "font", "line-height"));
				}

				&:first-of-type > a {
					padding-left: 0;
				}

				&:last-of-type > a {
					padding-right: 0;
				}
			}
		}

		/* Sub-menus Flyout */
		& > li > .sub-menu {
			margin: 0;
			position: relative;

			@include media(mobile) {
				background: map-deep-get($config-global, "color", "background", "default");
				box-shadow: map-deep-get($config-global, "elevation", "4dp");
				left: 0;
				top: 100%;
				min-width: max-content;
				opacity: 0;
				position: absolute;
				transition: all 0.5s ease;
				visibility: hidden;
			}

			.sub-menu {
				width: 100%;
			}
		}
	}

	// Menu Link
	a {
		color: #{map-deep-get($config-header, "main-nav", "color", "link")};
		display: block;
		@include font-family( map-deep-get($config-header, "main-nav", "font", "family" ) );
		font-weight: #{map-deep-get($config-header, "main-nav", "font", "weight")};
		padding: #{0.5 * map-deep-get($config-header, "main-nav", "link-padding")} 0;

		@include media(mobile) {
			padding: #{map-deep-get($config-header, "main-nav", "link-padding")};
		}

		&:link,
		&:visited {
			color: #{map-deep-get($config-header, "main-nav", "color", "link")};
		}

		&:hover {
			color: #{map-deep-get($config-header, "main-nav", "color", "link-hover")};
		}
	}

	// Sub-menu depth indicators
	.sub-menu {

		list-style: none;
		margin-left: 0;
		/* Reset the counter for each UL */
		counter-reset: nested-list;

		.menu-item a {

			padding-top: #{0.5 * map-deep-get($config-header, "main-nav", "link-padding")};
			padding-bottom: #{0.5 * map-deep-get($config-header, "main-nav", "link-padding")};

			&::before {
				/* Increment the dashes */
				counter-increment: nested-list;
				/* Insert dashes with spaces in between */
				content: "\2013\00a0" counters( nested-list, "\2013\00a0", none );
			}
		}
	}

	// Show top-level sub-menu indicators above mobile-breakpoint-only
	@include media(mobile) {
		& > div > ul > .menu-item-has-children > a {

			&::after {
				content: "\00a0\25BC";
				display: inline-block;
				font-size: map-deep-get($config-global, "font", "size", "xs");
				height: inherit;
				width: inherit;
			}
		}
	}

	.hide-visually {
		position: absolute !important;
		clip: rect(1px, 1px, 1px, 1px);
		padding:0 !important;
		border:0 !important;
		height: 1px !important;
		width: 1px !important;
		overflow: hidden;
	}
}

// Prevent overruling the user defined font size value set inside Gutenberg
// for Full Site Editing's Menu Navigation block.
body:not( .fse-enabled ) {
	.main-navigation a {
		font-size: #{map-deep-get($config-header, "main-nav", "font", "size")};
	}
}
