// ============================================================================
// :: Header
// ============================================================================
.o-header {
	position: relative;

	width: 100%;

	background-color: $background-color-white;

	@include respond-to($screen-medium-base) {
		padding-top: 1rem;
	}

	@include respond-at($screen-medium-base) {
		position: fixed;
		top: 0;
		left: 0;
		z-index: $z-index-highest;

		width: 100%;

		transform: translateY(0);

		transition: transform 0.3s ease-in-out;
	}
}

// ============================================================================
// :: Elements
// ============================================================================
.o-header__container {
	position: relative;

	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;

	@include respond-at($screen-medium-base) {
		flex-wrap: nowrap;
	}
}

.o-header__content {
	display: flex;
	justify-content: flex-start;
	align-items: center;
}

.o-header__content-item {

	&:not(:last-child) {

		@include respond-at($screen-medium-base) {
			margin-right: 2.5rem;
		}
	}
}

.o-header__overlay {
	position: fixed;
	top: 0;
	left: 0;
	z-index: $z-index-lowest;

	width: 100vw;
	height: 100vh;

	pointer-events: none;
}

.o-header__background {

	&::before {
		content: "";

		position: absolute;
		top: 0;
		left: 0;

		display: block;

		width: 100%;
		height: 100%;
		max-height: 18.8rem;

		background: $gradient-primary;

		transform: scaleY(0);
		transform-origin: center top;

		transition: transform 0.3s ease-in-out 0.5s;
	}
}

.o-header__search {
	width: 100%;
	height: 0;
	overflow: hidden;
	margin-top: 1rem;

	transition: height 0.3s ease-in-out 0.5s;

	pointer-events: none;

	@include respond-at($screen-medium-base) {
		position: absolute;

		margin-top: 1.2rem;

		transform: translateY(100%);
	}
}

.o-header__search-input {
	opacity: 0;

	transform-origin: left center;
	transform: scaleX(0);

	transition: transform 0.5s ease-in-out 0.2s, opacity 0.5s ease-in-out 0.2s;

	.a-input__label,
	.a-input__button {
		opacity: 0;

		transition: opacity 0.2s ease-in-out 0.2s;
	}
}

.o-header__search-link {

	margin-top: 1.5rem;

	opacity: 0;

	transform: translateY(-1rem);

	transition: transform 0.3s ease-in-out 0.4s, opacity 0.3s ease-in-out 0.4s;

	.a-button__icon {
		//important because it otherwise gets overwritten by
		//the default a-link
		@include respond-to($screen-medium-base) {
			color: $text-color-white-2x-light;
		}
	}

	&:hover {
		color: $text-color-white;
	}
}

.o-header__mobile-nav {
	width: 100%;

	height: 0;

	overflow-y: auto;
	padding: 0 2rem;

	opacity: 0;

	pointer-events: none;

	.m-mobile-nav__languages {
		opacity: 0;

		transform: translateX(5rem);

		transition: opacity 0.3s ease-in-out 0.3s, transform 0.3s ease-in-out 0.3s;
	}
}

.o-header__breadcrumb {
	position: absolute;
	bottom: -4rem;

	transform: translateY(0);

	transition:
		opacity 0.3s ease-in-out,
		transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

// ============================================================================
// :: Modifiers
// ============================================================================
.o-header--sticky {
	@include respond-at($screen-medium-base) {
		position: sticky;
	}
}

// ============================================================================
// :: States
// ============================================================================
.o-header {
	box-shadow: $box-shadow-header;

	&.has-search-open,
	&.has-menu-open {
		z-index: $z-index-highest;

		&.is-hidden {
			transform: translateY(0);
		}

		.a-logo__image {

			@include respond-to($screen-medium-base) {
				opacity: 0;

				transition: opacity 0.3s ease-in-out 0.3s;
			}
		}

		.o-header__overlay {
			@include respond-at($screen-medium-base) {
				pointer-events: auto;
			}
		}

		.a-logo__image--inverted {

			@include respond-to($screen-medium-base) {
				opacity: 1;

				transition: opacity 0.3s ease-in-out 0.3s;
			}
		}

		.o-header__breadcrumb {
			opacity: 0;
		}
	}

	&.has-search-open {
		z-index: $z-index-highest + 2;

		.o-header__breadcrumb {
			opacity: 0;
		}

		.o-header__search {
			height: 10rem;

			transition: height 0.3s ease-in-out;

			pointer-events: auto;
		}

		.o-header__search-input {
			opacity: 1;

			transform: scaleX(1);

			transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out;

			.a-input__field,
			.a-input__field input {
				height: auto;
			}

			.a-input__label,
			.a-input__button {
				opacity: 1;

				transition: opacity 0.2s ease-in-out 0.6s, color 0.2s ease-in-out;
			}
		}

		.o-header__search-link {
			opacity: 1;

			transform: translateY(0);
		}

		&:not(.has-menu-open) {

			.o-header__background::before {
				max-height: 18rem;

				transform: scaleY(1.1);

				transition: transform 0.2s ease-in-out;
			}

			.o-header__mobile-nav {
				display: none;
			}
		}
	}

	&.has-menu-open {
		position: fixed;

		height: 100vh;

		background: transparent;

		.o-header__mobile-nav {
			height: calc(100% - 14rem);

			opacity: 1;

			pointer-events: auto;

			.m-mobile-nav__languages {
				opacity: 1;

				transform: translateX(0);
			}
		}

		.m-search__button--open {
			background: $background-color-white;

			&::before {
				display: none;
			}

			.a-button__text,
			.a-button__icon {
				color: $text-color;
			}
		}

		.o-header__mobile-nav {

			.m-mobile-nav__collapse {

				@include respond-to($screen-medium-base) {
					opacity: 1;

					transition: opacity 0s;

					//this will show each list item with a delay of 0.15s
					@for $i from 1 through 10 {

						&:nth-child(#{$i}) {
							transition: opacity 0.3s ease-in-out (0.2s + (0.15s * $i));
						}
					}
				}
			}
		}
	}

	&.is-hidden {

		transform: translateY(-100%);


		.o-header__breadcrumb {
			transform: translateY(-4rem);
		}
	}
}
