.main-nav-wrapper{
	position: relative;
	z-index: 4;

	.main-nav-below.top-nav-below-main-nav &{
		z-index: 9;
	}

	.main-nav-above.top-nav-below &{
		z-index: 10;
	}
}

.main-nav{
	position: relative;
	border: $base-border;
	border-width: 1px 0;
}

.main-menu-wrapper{
	border: 0 solid $base-border-color;
	position: relative;
}

@include breakpoint(md){
	// Header menus arrows ---------------------------------------
	.menu-item-has-children,
	.mega-menu{
		> a:before{
			content: '';
			position: absolute;
			right: 12px;
			margin-top: 2px;
			@include center(y);
			width: 0;
			height: 0;
			border: 4px solid transparent;
			border-top: 4px solid #ffffff;
			transition: border 0.15s;
		}

		.menu-item-has-children > a:before{
			border: 4px solid transparent;
			border-left-color: #ffffff;
		}
	}

	.menu > .menu-item-has-children:not(.is-icon-only) > a,
	.menu .mega-menu:not(.is-icon-only) > a{
		padding-right: 25px;
	}

	// Main menu arrow
	.main-menu .menu > li.tie-current-menu > a:before,
	.main-menu .menu > li:hover > a:before {
	  border-top-color: $bright;
	}

	.main-nav-light{
		.main-nav .menu-item-has-children,
		.mega-menu {
			> a:before {
				border-top-color: $base-color;
			}

			.menu-item-has-children > a:before {
				border-top-color: transparent;
				border-left-color: $base-color;
			}

			li:hover > a:before{
				border-left-color: $brand-color;
			}
		}
	}

	// Top menu arrow
	.top-nav-dark{
		.top-menu .menu-item-has-children {
			> a:before{
				border-top-color: $dark-base-color;
			}

			.menu-item-has-children > a:before{
				border-left-color: $dark-base-color;
				border-top-color: transparent;
			}
		}
	}

	.theme-header .top-menu li{
		> a:before{
			border-top-color: $base-color;
		}

		&.tie-current-menu > a:before,
		&:hover > a[href]:before{
			border-top-color: $brand-color;
		}

		.menu-item-has-children > a:before{
			border-left-color: $base-color;
			border-top-color: transparent !important;
		}

		.current-menu-item > a:before,
		li:hover > a[href]:before{
			border-left-color: $brand-color;
		}
	}

	// header menus [Main menu, Top menu] ------------------------
	.header-menu{
		float: left;

		.menu {
			li {
				display: block;
				float: left;
			}

			a {
				display: block;
				position: relative;
			}

			.sub-menu a {
				padding: 10px;
			}

			a:hover,
			li:hover > a{
				background: rgba(0,0,0,0.03);
				z-index: 2;
			}

			// lower levels
			ul {
				box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);

				li {
					position: relative;
				}

				a {
					border: solid rgba(0,0,0, 0.07);
					border-width: 0 0 1px;
					transition: 0.15s;
				}

				ul{
					top: 0;
					left: 100%;
				}
			}
		}
	}

	// Main Navigation--------------------------------------------
	#main-nav{
		z-index: 9;
		line-height: 60px;

		// Remove the thick border bottom of current item.
		.top-nav-below-main-nav & .main-menu > ul > li,
		.header-layout-1.top-nav-below & .main-menu > ul > li{
			border-bottom: 0;
			margin-bottom: 0;
		}
	}

	.main-menu {
		.menu {
			a{
				transition: 0.15s;
			}

			// first level
			> li {
				> a {
					padding: 0 14px;
					font-size: 13px;
					font-weight: 600;
				}

				> .menu-sub-content{
					border-top: 2px solid $brand-color;
				}

				&.tie-current-menu{
					border-bottom: 5px solid $brand-color;
					margin-bottom: -5px;

					> a{
						&:after{
							content: "";
							width: 20px;
							height: 2px;
							position: absolute;
							margin-top: 17px;
							@include center(xy);
							background: $dark-color;
							transition: 0.3s;
						}
					}
				}

				&.is-icon-only {
					> a{
						padding: 0 20px;
						line-height: inherit;

						&:after,
						&:before{
							display: none;
						}

						.fa{
							font-size: 160%;
							transform: translateY(15%);
						}
					}
				}
			}

			ul{
				line-height: 20px;
				z-index: 1;
			}

			.sub-menu .fa,
			.mega-recent-featured-list .fa,
			.mega-link-column .fa,
			.mega-cat-more-links .fa{
				width: 20px;
			}
		}

		.menu-sub-content{
			display: none;
			padding: 0;
			width: 200px;
			position: absolute;
			box-shadow: 0 2px 2px rgba(0, 0, 0, 0.15);

			a{
				width: 200px;
			}
		}

		// display sub-meus on hover while page loading
		ul{
			li:hover > .menu-sub-content,
			li[aria-expanded="true"] > ul,
			li[aria-expanded="true"] > .mega-menu-block{
				display: block;
				z-index: 1;
			}
		}
	}

	// current item
	nav.main-nav .menu > li.tie-current-menu > a,
	nav.main-nav .menu > li:hover > a{
		background-color: $brand-color;
		color: $bright;
	}

	// Photography demo menu
	.header-layout-1 .main-menu-wrap .menu > li:only-child{
		&:not(.mega-menu){
			position: relative;
		}

		> .menu-sub-content{
			right: 0;
			left: auto;

			ul{
		    left: auto;
		    right: 100%;
			}
		}
	}

	// Mega Menu -------------------------------------------------
	.mega-menu .mega-menu-block{
		left: 0;
		width: 100%;
		padding: 20px 30px 40px;

		a{
			width: auto;
		}
	}

	// Mega Links (Columns)
	.sub-menu-columns{
		margin: 0 -15px;
	}

	.main-menu .mega-links-head{
		width: 100%;
		font-weight: 600;
		background: transparent!important;
		border-bottom: 2px solid rgba(0,0,0,0.08);
		border-top: 0;
		line-height: 40px;
		font-size: 14px;
		margin-bottom: 10px;
		padding: 8px 0;

		&:before{
			display: none;
		}

		&:after{
			display: block;
			content: "";
			width: 50px;
			height: 2px;
			background: $brand-color;
			position: absolute;
			bottom: -2px;
			left: 0;
			transition: width 0.2s;
		}
	}

	.mega-link-column{
		margin-bottom: 10px;
		padding: 0 15px;
		width: 50%;

		li{
			width: 100%;

			a{
				padding: 8px 10px;
			}
		}

		&:hover {
			.mega-links-head:after{
				width: 65px;
			}
		}

		.menu-sub-content{
			width: 100%;
			max-width: 200px;
		}
	}

	.hide-mega-headings{
		margin-top: 20px;
		margin-bottom: 0;

		> a{
			display: none !important;
		}
	}

	.mega-links-3col .mega-link-column{
		width: 33.333%;

		&:nth-child(3n + 4){
			clear: left;
		}
	}

	.mega-links-4col .mega-link-column{
		width: 25%;

		&:nth-child(4n + 5){
			clear: left;
		}
	}

	.mega-links-5col .mega-link-column{
		width: 20%;

		&:nth-child(5n + 6){
			clear: left;
		}
	}

	// Mega Categories -------------------------------------------
	.main-menu {
		.is-loading li{
			opacity: 0.5 !important;
			transition: opacity 0.3s;
		}

		.mega-cat-wrapper{
			overflow: hidden;
	    height: auto;
	    clear: both;
		}

		.mega-ajax-content{
			min-height: 190px;
			position: relative; // to center the loader overlay
		}

		.mega-cat {
			.mega-menu-content{
				clear: both;
			}

			.mega-menu-block{
				padding: 0;
			}
		}

		.mega-cat-content{
			padding: 40px 30px;
		}

		.mega-cat-sub-exists{
			width: 80%;
			float: left;
		}

		.horizontal-posts{
			padding-top: 30px;
			width: 100%;
		}

		.mega-cat-posts-container ul{
			margin-left: -10px;
			margin-right: -10px;
		}

		.mega-cat .mega-menu-post{
			width: 20%;
			opacity: 0;
			padding: 0 10px;

			&:nth-child(5n + 1){
				clear: both;
			}
		}

		// post title and thumbs
		.mega-menu{
			.post-box-title{
				line-height: 1.4;
			}

			a.mega-menu-link{
				@include font-size(15px);
				border: 0;
				display: block;

				&:hover{
					color: $brand-color;
					background: transparent!important;
				}
			}

			.post-thumb{
				margin-bottom: 10px;
			}

			.post-meta{
				margin: 5px 0 0;
				line-height: 20px;

				a:not(:hover){
					color: #777;
				}

				a{
					padding: 0;
					background-color: transparent;
				}
			}
		}

		.vertical-posts .mega-menu-post{
			width: 25%;
		}

		// if it has a sub-menu
		.menu-item-has-children{
			.mega-cat-wrapper{
				border-top: 1px solid rgba(0,0,0,0.08);
			}

			.cats-vertical,
			.cats-vertical	+ .mega-cat-content{
				padding-top: 30px;
			}

			.cats-horizontal{
				margin-top: 30px;
			}
		}

		// Mega Cat More Links
		// above the categories filters
		ul.mega-cat-more-links{
			opacity: 1 !important;
			box-shadow: none;
		}

		.mega-cat-more-links{
			padding: 20px 30px;
			margin: 0 -10px;

			> li{
				float: left;
				width: 25%;
				padding: 0 10px;

				> a{
					border-bottom-width: 0;
				}

				&:nth-child(n + 5) > a{
					border: solid rgba(0, 0, 0, 0.05);
					border-width: 1px 0 0;
				}

				ul{
					left: calc(100% - 10px);
				}

				li{
					width: 100%;
				}
			}
		}

		// Categories Filters
		ul.mega-cat-sub-categories{
			overflow: hidden;
			box-shadow: none;
		}

		// Horizontal Categories Filter
		.cats-horizontal{
			margin: 40px 30px 0;

			li{
				line-height: 20px;
				margin-right: 10px;

				a{
					border: 1px solid rgba(0,0,0,0.08);
					background-color: rgba(0,0,0,0.02);
					border-radius: $base-border-radius;
					padding: 0 10px;
					width: auto;
				}
			}
		}

		@at-root .main-nav .mega-menu.mega-cat .cats-horizontal li {
			a.is-active,
			a:hover{
				color: $bright;
				background: $brand-color;
				border-color: $brand-color;
			}
		}

		// Vertical Categories Filter
		.cats-vertical{
			width: 20%;
			float: left;
			padding: 40px 30px;
			background: rgba(0,0,0,0.03);
			padding-bottom: 1500px;
			margin-bottom: -1500px;

			li{
				width: 100%;

				&:last-child{
					margin-bottom: 50px;
				}

				a{
					display: block;
					border-top: 0;
					width: 100%;
					padding: 8px 10px;
					border-bottom: 1px solid rgba(0,0,0,0.05);
				}

			}
		}

		ul.cats-vertical li{
			a.is-active,
			a:hover{
				color: $brand-color;
				background: rgba(0,0,0,0.05);
			}
		}
	}


	//  Mega Recent - Featured Posts -----------------------------
	.main-menu{
		// Posts List
		.mega-recent-post{
			float: left;
			width: 37%;
			padding-right: 30px;

			.post-box-title a{
				@include font-size(22px);
				margin-top: 7px;
				line-height: 30px;
			}
		}

		.mega-check-also{
			float: left;
			width: 63%;

			ul{
				overflow: hidden;
				margin: 0 -15px -20px;
				box-shadow: none;
			}

			li{
				width: 50%;
				padding: 0 15px 20px;
				overflow: hidden;

				&:nth-child(2n + 1){
					clear: left;
				}
			}

			.post-thumbnail{
				margin-right: 20px;
				float: left;
			}

			.post-thumb{
				overflow: hidden;
				margin-bottom: 0;

				img{
					width: 110px;
				}
			}

			.post-details{
				padding-left: 130px;
			}
		}

		.mega-recent-featured{
			> .menu-sub-content{
				overflow: hidden;
				padding-top: 40px;
			}

			.mega-menu-content {
				float: right;
				position: relative;
				min-height: 30px;
				width: 100%;
			}

			// If it has a sub menu
			&.menu-item-has-children{
				.mega-menu-content {
					width: 77%;
				}

				.mega-recent-post {
					width: 52%;
					padding-left: 30px;
				}

				.mega-check-also {
					width: 48%;

					li {
						width: 100%;
					}
				}
			}
		}

		// If it has a sub menu
		ul.mega-recent-featured-list{
			width: 23%;
			padding-right: 30px;
			float: left;
			position: relative;
			box-shadow: none;
		}

		.mega-recent-featured-list{
			li{
				width: 100%;
				z-index: 2;
			}

			a{
				display: block;
				border-top: 0;
				padding: 8px 10px;
				border-bottom: 1px solid rgba(0,0,0,0.06);
			}

			&:after{
				content: "";
				width: 1500px;
				height: 1500px;
				background: rgba(0,0,0,0.04);
				position: absolute;
				z-index: 1;
				right: 0;
				top: -100px;
			}
		}
	}

	.ajax-no-more-posts{
		text-align: center;
		position: absolute;
		width: calc(100% - 40px);
	}


	// Main Nav Components ---------------------------------------
	nav.main-nav{
		.components{
			> li > a:not(.follow-btn){
				width: 35px;
				font-size: 14px;
			}

			> li:hover > a{
				color: $brand-color;
			}
		}
	}


	// Main Nav Dark Skin  ---------------------------------------
	.main-nav-dark{
		.main-nav{
			background: $darker-bg;
			border-width: 0;

			.search-bar {
				border-color: rgba(255,255,255,0.07);
			}

			.components > li > a {
				color: #ffffff;
			}

			.components > li.social-icons-item .social-link:not(:hover) span{
				color: #ffffff;
			}

			&.fixed-nav{
				background-color: rgba(31,32,36,0.95);
			}
		}

		.main-menu {
			.menu {
				> li a{
					color: #ffffff;
				}

				ul{
					li:hover > a,
					li.current-menu-item:not(.mega-link-column) > a{ // active link in the sub menu
						background: rgba(0,0,0,0.08);
					}
				}
			}

			.menu-sub-content {
				background: $darker-bg;
				color: #ffffff;
			}
		}

		.main-menu .menu ul a,
		.main-menu .mega-cat-wrapper,
		.mega-cat-more-links > li a{
		  border-color: rgba(255,255,255,0.04);
		}

		.mega-recent-featured-list:after {
		  background: rgba(0, 0, 0, 0.08);
		}

		&.main-nav-boxed .main-nav .main-menu-wrapper{
			background-color: #1f2024;
		}
	}


	// Main Nav Light Skin ---------------------------------------
	.main-nav-light{
		.main-nav{
			background-color: #ffffff;
			color: $base-color;

			.menu-sub-content{
				background: #ffffff;
			}

			.menu ul li:hover > a,
			.menu ul li.current-menu-item:not(.mega-link-column) > a {
			  background: rgba(0, 0, 0, 0.03);
			  color: $brand-color;
			}

			.menu a,
			.components li a{
				color: $base-color;
			}

			.components li a:hover{
				color: $brand-color;
			}

			.components li a.button:hover,
			.components li a.checkout-button{
				color: $bright;
			}

			&.fixed-nav{
				background-color: rgba(255,255,255,0.95);
			}
		}

		.mega-menu .post-meta,
		.mega-menu .post-meta a:not(:hover){
			color: rgba(0,0,0,0.5);
		}
	}


	// Sticky Menu -----------------------------------------------
	#sticky-logo{
		overflow: hidden;
		float: left;
		vertical-align: middle;

		a{
			line-height: 1;
			display: inline-block;
		}

		img{
			position: relative;
			vertical-align: middle;
			padding: 8px 10px;
			top: -1px;
			max-height: 50px;

			.just-before-sticky &,
			.header-layout-1 &{
				padding: 0;
			}
		}

		.header-layout-1:not(.has-custom-sticky-logo) &{
			display: none;
		}
	}

	.theme-header{
		#sticky-logo img{
			opacity: 0;
			visibility: hidden;
			width: 0 !important;
			transform: translateY(75%);
			transition: transform 0.3s cubic-bezier(0.55, 0, 0.1, 1), opacity 0.6s cubic-bezier(0.55, 0, 0.1, 1);
		}

		&.header-layout-1:not(.has-custom-sticky-logo) #sticky-logo img{
			transition: none;
		}
	}

	.theme-header:not(.header-layout-1) #main-nav:not(.fixed-nav) #sticky-logo img{
		margin-left: -20px;
	}

	.header-layout-1 .flex-placeholder{ // fake div to override justify-content for single element .
		flex-grow: 1;
	}
}




//Desktip Sitcky Main Menu ----------------------------------------------
.theme-header{
	.fixed-nav{
		position: fixed;
		width: 100%;
		top: 0;
		bottom: auto !important;
		z-index: 100;
  	will-change: transform;
  	transform: translateY(-100%);
		transition: transform 0.3s;
		box-shadow: 0 4px 2px -2px rgba(0, 0, 0, 0.1);
		border-width: 0;
		background-color: rgba(255,255,255,0.95);

		// @include breakpoint(max_min_md){ // Fix Mobile issue
		// 	transform: translateZ(0) !important;
		// }

		&:not(.just-before-sticky){
			line-height: 60px !important;

			@include breakpoint(md){
				.header-layout-1-logo{
					display: none;
				}
			}

			#sticky-logo img{
				opacity: 1;
				visibility: visible;
				width: auto !important;
				transform: translateY(0);
			}
		}

		@include breakpoint(md){
			@at-root .header-layout-1:not(.just-before-sticky):not(.has-custom-sticky-logo) .fixed-nav #sticky-logo{
				display: block;
			}
		}

		.admin-bar &{
			top: 32px;

			@include breakpoint_max(782px){
			  top: 46px;
			}

			@include breakpoint_max(600px){
				top: 0;
			}
		}

		@include breakpoint(md){
			.border-layout &{
				top: 25px;
			}

			.border-layout.admin-bar &{
				top: 57px;
			}
		}

		.container{
			opacity: 0.95;
		}

		.main-menu-wrapper,
		.main-menu{
			border-top: 0;
		}

		&.fixed-unpinned:not(.default-behavior-mode) {
			.main-menu .menu > li.tie-current-menu{
				border-bottom-width: 0;
				margin-bottom: 0;
			}
		}
	}

	.fixed-nav.unpinned-no-transition {
		transition: none;
	}

	.fixed-pinned,
	.default-behavior-mode.fixed-unpinned {
	  transform: translate3d(0,0,0);
	}
}

// Mobile Sticky Nav -----------------------------------------------------
@include breakpoint(max_min_md){
	.fixed-nav{
		.theme-header &{
			transition: none;
		}

		&.logo-container.sticky-up,
		&.logo-container.sticky-nav-slide.sticky-down,
		&#main-nav.sticky-up,
		&#main-nav.sticky-nav-slide.sticky-down {
			transition: transform 0.4s ease;
		}

		.sticky-type-slide &.logo-container.sticky-nav-slide-visible,
		.sticky-type-slide &#main-nav.sticky-nav-slide-visible {
			transform: translateY(0);
		}

		&.default-behavior-mode{
			transform: none !important;
		}
	}
}


//Boxed Main Menu ----------------------------------------------
@include breakpoint(md){
	.main-nav-boxed{
		.main-nav{
			border-width: 0;
		}

		.main-menu-wrapper{
			float: left;
			width: 100%;

			.search-bar{
				border-right-width: 0;
			}
		}

		&.main-nav-light{
			.main-menu-wrapper{
				border-width: 1px;
				background-color: #ffffff;

				.dark-skin &{
					border-width: 0;
				}
			}

			.fixed-nav .main-menu-wrapper{
				border-color: transparent;
			}
		}
	}

	// borders between topNav and MainNav
	.main-nav-above.top-nav-above #main-nav:not(.fixed-nav){
		top: -1px;
	}

	.main-nav-below.top-nav-below #main-nav:not(.fixed-nav){
		bottom: -1px;
	}

	.dark-skin .main-nav-below.top-nav-above #main-nav{
		border-width: 0;
	}

	.dark-skin .main-nav-below.top-nav-below-main-nav #main-nav{
		border-top-width: 0;
	}
}

// transparent background in stikcy mode
.main-nav-boxed .main-nav:not(.fixed-nav),
.main-nav-boxed .fixed-nav .main-menu-wrapper,
.theme-header:not(.main-nav-boxed) .fixed-nav .main-menu-wrapper{
  background-color: transparent !important;
}

// hide stikcy logo in responsive
@include breakpoint(max_min_md){
	#sticky-logo{
		display: none;
	}
}

// Header Layout #1
@include breakpoint(md){
	.header-layout-1.main-nav-below.top-nav-above{
		.main-nav{
			margin-top: -1px;
		}

		.top-nav{
			border-top-width: 0;
		}

		.breaking-title{
			top: 0;
			margin-bottom: -1px;
		}
	}
}

.header-layout-1.main-nav-below.top-nav-below-main-nav {
	.main-nav-wrapper{
		z-index: 9;
	}

	.main-nav{
		margin-bottom: -1px;
		bottom: 0;
		border-top-width: 0;
	}

	@include breakpoint(md){
		.top-nav{
			margin-top: -1px;
		}
	}
}

.header-layout-1.has-shadow:not(.top-nav-below) .main-nav{
	border-bottom: 0 !important;
}

#theme-header.header-layout-1 > div:only-child nav{
	border-width: 0 !important;
}

// Padding of the First level itmes in responsive from 992px to 1100px.
@include breakpoint_min_max($screen-md,1100px){
	.main-nav .menu > li{
		&:not(.is-icon-only) > a{
			padding-left: 7px;
			padding-right: 7px;

			&:before{
				display: none;
			}
		}

		&.is-icon-only > a{
			padding-left: 15px;
			padding-right: 15px;
		}
	}
}

// Demo purpose :: submenu in two columns.
@include breakpoint(md){
	.two-columns-submenu{
		> ul{
			width: 300px !important;

			> li{
				width: 50% !important;
				float: left;

				a{
					width: 100% !important
				}
			}
		}

		&.odd{
			> ul > li:last-child{
				width: 100% !important;
			}
		}
	}
}


// Tiny Label
.menu-tiny-label{
  font-size: 70%;
  font-weight: 100;
  padding: 1px 3px;
  border-radius: 2px;
  vertical-align: super;
  line-height: 0;

  &.menu-tiny-circle{
   	border-radius: 100%;
    padding: 2px 5px;
  }
}

// -fix the resize issue when resize to > 991
// -when reload the page on window < 992 and then resize to large the stikcy classes still existing.
// -this snippet will be removed when the tiesticky plugin stop firing when resizing to large.
@include breakpoint(md){
	.theme-header .logo-row > div{
		height: auto !important;
	}

	.logo-container.fixed-nav.fixed-nav{
		position: static !important;
		line-height: initial !important;
		box-shadow: none !important;
		background-color: transparent !important;
	}

	.header-layout-3 .logo-container.fixed-nav.fixed-nav{
		width: auto;
	}

	.header-layout-3 .stream-item-top-wrapper{
		float: right;
	}
}

// Mobile main nav --------------------------------------
@include breakpoint(max_min_md){
	#tie-wrapper header#theme-header{
		box-shadow: none;
		background: transparent;
	}

	.logo-container,
	.header-layout-1 .main-nav{
		border-width: 0;
		box-shadow: 0 4px 2px -2px rgba(0,0,0,0.1);
	}

	.header-layout-1.top-nav-below .main-nav:not(.fixed-nav){
		box-shadow: none;
	}

	// fix the separator issue
	.is-header-layout-1.has-header-ad .top-nav-below .main-nav{
		border-bottom-width: 1px;
	}

	.logo-container,
	.header-layout-1 .main-nav{
		background-color: #ffffff;
	}

	.dark-skin .logo-container,
	.main-nav-dark.header-layout-1 .main-nav{
		background-color: $darker-bg;
	}

	.dark-skin #theme-header .logo-container.fixed-nav{
		background-color: rgba(31,32,36,0.95);
	}

	.header-layout-1.main-nav-below.top-nav-below-main-nav .main-nav{
		margin-bottom: 0;
	}

	#sticky-nav-mask,
	.header-layout-1 #menu-components-wrap,
	.header-layout-3 .main-nav-wrapper,
	.header-layout-2 .main-nav-wrapper{
		display: none;
	}

	.main-menu-wrapper .tie-alignleft{
		width: 100%;
	}
}
