/* Basic */

$sub-menu-translate: 30px;

.main-navigation {
	display: block;
	width: 100%;
	@include media-breakpoint-up(md) {
		width: auto;
	}
	ul {
		margin: 0;
		padding-left: 0;
		list-style: none;
	}
	.menu {
		display: none;
	}
	li {
		position: relative;
		text-align: left;
	}
	a {
		position: relative;
		display: block;
		text-decoration: none;
	}
	@include media-breakpoint-down(sm) {
		ul {
			ul {
				a {
					padding-left: 2rem;
				}
				ul {
					a {
						padding-left: 3rem;
					}
					ul {
						a {
							padding-left: 4rem;
						}
						ul {
							a {
								padding-left: 5rem;
							}
							ul {
								a {
									padding-left: 6rem;
								}
							}
						}
					}
				}
			}
		}
		&.toggled {
			.menu {
				display: block;
			}
		}
	}
	&:not(.vertical-menu) {
		@include media-breakpoint-up(md) {
			.menu:not(.tm-mega-menu) {

				// level 2,3,....,n
				li {
					&:hover,
					&.menu-hover {
						& > ul {
							transform: translateY(0);
							visibility: visible;
							opacity: 1;
						}
					}
					li {
						&:hover,
						&.menu-hover {
							& > ul {
								left: calc(100% + 1px);
								&.inverse-side {
									left: auto;
									right: calc(100% + 1px);
								}
							}
						}
						& > ul {
							top: -26px;

							&.in-transition {
								left: calc(100% + 1px);
							}
							&.inverse-side.in-transition {
								left: auto;
								right: calc(100% + 1px);
							}
						}
					}
				}

				// level 1
				> li {
					&[hidden] {
						display: none;
					}
					&:hover,
					&.menu-hover {
						& > ul {
							left: -40px;
							&.inverse-side {
								left: auto;
								right: -10px;
							}
						}
					}
					& > ul {
						top: 100%;

						&.in-transition {
							left: -40px;
						}
						&.in-transition.inverse-side {
							left: auto;
							right: -10px;
						}
					}
				}

				// sub-menu
				.sub-menu {
					position: absolute;
					z-index: 999;
					left: -999em;

					opacity: 0;
					visibility: hidden;
					transform: translateY($sub-menu-translate);
					transition-duration: 200ms;
					transition-timing-function: linear;
					transition-property: transform, opacity, visibility;
				}
			}

			.menu {
				display: flex;
				flex-wrap: wrap;
				position: static;
				> li {
					display: flex;
					align-items: flex-start;
				}
			}

			.menu{
				.sub-menu {
					margin: 0;
					box-shadow: $box__shadow;
				}

				> li {
					&[hidden] {
						display: none;
					}
				}

				> li > .sub-menu {
					margin-top: 20px;
					&:before {
						content: '';
						position: absolute;
						height: 20px;
						width: 100%;
						bottom: 100%;
						left: 0;
					}
				}
				.sub-menu .sub-menu {
					li a {
						&:before {
							content: '';
							position: absolute;
							height: 100%;
							width: 2px;
							bottom: 0;
							top: 0;
							right: calc(100% - 0.5px);
						}
					}

					&.inverse-side li a {
						&:before {
							right: auto;
							left: calc(100% - 0.5px);
						}
					}
				}
			}
		}
	}
}

/* Skin */
.main-navigation {
	&.mobile-menu {
		@include media-breakpoint-down(sm) {
			position: fixed !important;
			top: 0 !important;
			left: 0;
			right: 0;
			bottom: 0;
			z-index: 997;
			transform: translateX(-100%);
			transition: transform .2s linear;
			padding-top: 60px;
			margin: 0;
			width: 100%;
			height: 100vh;

			.admin-bar & {
				padding-top: 105px;
			}

			& > .menu {
				max-height: 100%;
				overflow-x: hidden;
				overflow-y: auto;
			}

			&.animate {
				transition: transform .2s linear;
			}

			&.show {
				transform: translateX(0);
			}

			& > .menu {
				display: block;

				> li:first-child {
					margin-top: 20px;
				}
			}
		}
	}

	a {
		padding: 8px 22px;
		@include font-size(1.0625);
		text-transform: uppercase;
		letter-spacing: 0.7px;
		font-weight: 400;
		&:focus {}
	}
	.menu {
		@include media-breakpoint-up(md) {
			@include  grid-indent(18px, 'margin', '>li');
		}
		> li {
			> a {
				@include media-breakpoint-up(md) {
					@include font-size(.75);
					padding: 5px 0;
				}
			}
			&.menu-item-has-children:not(.super-guacamole__menu-with-icon) {
				a {
					@include media-breakpoint-down(sm) {
						padding-right: 65px;
					}
				}
				> a {
					@include media-breakpoint-up(md) {
						padding-right: 15px;
						&::after {
							/* Marker (level 1) */
							content: '\e93a';
							right: 0;
							top: 11px;
						}
					}
				}
			}
			&:hover,
			&.menu-hover,
			&.current_page_item,
			&.current_page_ancestor,
			&.current-menu-item,
			&.current-menu-ancestor {
				> a {
					/* Active and hover state (level 1) */
				}
			}
		}
	}
	.sub-menu {
		@include media-breakpoint-up(md) {
			padding: 26px 0;
		}
		li {
			&.menu-item-has-children {
				@include media-breakpoint-up(md) {
					> a:after {
						/* Marker (level 2, 3, ..., N) */
						content: '\e93c';
						right: 10px;
						top: 13px;
					}
				}
			}
		}
		> li > a {
			@include media-breakpoint-up(md) {
				width: 220px;
				padding: 4px 30px 4px 35px;
			}
		}
		a {
			@include media-breakpoint-up(md) {
				@include font-size(0.875);
				font-weight: 300;
				letter-spacing: normal;
				text-transform: capitalize;
			}
		}
		li:hover,
		li.menu-hover,
		li.current_page_item,
		li.current_page_ancestor,
		li.current-menu-item,
		li.current-menu-ancestor {
			> a {
				/* Active and hover state (level 2, 3, ..., N) */
			}
		}
	}
	a {
		&::after {
			/* Marker style */
			cursor: pointer;
			position: absolute;

			@include linear-icon;
			@include font-size(.625);
		}
	}
}

/* Menu items description */
.menu-item__desc {
	@include font-size(.75);
	text-transform: capitalize;
	@include media-breakpoint-up(md) {
		.menu > li > a > & {
			text-align: center;
		}
	}
}

/* Mobile style */
.mobile-menu {

	// For compatibility mobile and vertical menu
	.menu {
		transform: none !important;
	}

	.admin-bar &{
		top: 46px;
	}
	@include media-breakpoint-down(sm) {
		.sub-menu-toggle {
			display: flex;
		}

		.menu-item-has-children > .sub-menu {
			display: none;
		}

		.sub-menu-open > .sub-menu {
			display: block;
		}
	}
}

html.mobile-menu-active {
	@include media-breakpoint-down(sm) {
		&,
		body {
			overflow: hidden;
		}
	}
}

.sub-menu-toggle {
	display: none;
	position: absolute;
	top: 0;
	bottom: 0;
	right: 0;
	z-index: 995;
	border: 0;
	padding: 5px 22px;
	cursor: pointer;
	align-items: center;

	&:before {
		content: '\e93a';
		@include linear-icon;
		@include font-size(1.125);
	}
	&.active {
		&:before {
			content: '\e939';
		}
	}
}