/*
 * Site chrome: header (announcement bar, social row, navigation, mega menu,
 * mobile overlay) and footer.
 */

/* ------------------------------------------------------------ header */
.site-header {
	position: fixed;
	inset: 0 0 auto;
	z-index: 100;
	color: var(--c-white);
	transition: background-color var(--ease), box-shadow var(--ease);

	&.is-scrolled {
		background: var(--c-dark);
	}

	.header-solid & {
		color: #000;

		&.is-scrolled {
			background: var(--c-white);
			box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
		}
	}

	.admin-bar & {
		top: 46px;

		@media (min-width: 783px) {
			top: 32px;
		}
	}
}

/* Announcement marquee */
.announcement {
	display: block;
	overflow: hidden;
	padding-block: 12px;
	background: var(--c-purple);
	color: var(--c-white);
	font-family: var(--f-head);
	font-size: 16px;
	font-weight: 500;
	line-height: 1;
	letter-spacing: 1.5px;
	transition: background-color var(--ease);

	&:hover {
		background: var(--c-dark);
	}

	& .announcement__track {
		display: flex;
		gap: 2rem;
		width: max-content;
		animation: ice-marquee 90s linear infinite;
	}

	&:hover .announcement__track,
	&:focus-visible .announcement__track {
		animation-play-state: paused;
	}

	& .announcement__item {
		flex-shrink: 0;
		white-space: nowrap;
	}

	& .announcement__tick {
		opacity: 0.5;
	}

	@media (prefers-reduced-motion: reduce) {
		& .announcement__track {
			animation: none;
			width: auto;
			justify-content: center;
		}

		& [aria-hidden="true"] {
			display: none;
		}
	}
}

@keyframes ice-marquee {
	from {
		transform: translateX(0);
	}

	to {
		transform: translateX(-50%);
	}
}

/* Social row (hidden on small phones) */
.header-social {
	display: none;

	@media (min-width: 479px) {
		display: flex;
		justify-content: flex-end;
		padding-block: 24px;
	}

	& ul {
		display: flex;
		gap: 24px;
	}

	& a {
		display: block;
		width: 16px;
		height: 16px;
		transition: opacity var(--ease);

		&:hover {
			opacity: 0.7;
		}
	}

	& svg {
		width: 16px;
		height: 16px;
	}
}

/* Logo + navigation row */
.header-main {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-top: 24px;
	padding-bottom: 24px;

	@media (min-width: 479px) {
		padding-top: 0;
	}
}

.site-logo {
	display: block;
	width: 120px;
	height: 60px;

	& img {
		width: 100%;
		height: 100%;
		object-fit: contain;
	}

	& .site-logo__dark {
		display: none;
	}

	.header-solid & {
		& .site-logo__light {
			display: none;
		}

		& .site-logo__dark {
			display: block;
		}
	}
}

/* Navigation (mobile first: overlay) */
.nav-toggle {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	color: inherit;

	& svg {
		width: 36px;
		height: 36px;
	}

	@media (min-width: 768px) {
		display: none;
	}
}

.site-nav {
	position: fixed;
	inset: 0;
	z-index: 101;
	display: flex;
	flex-direction: column;
	padding: 120px 0;
	overflow-y: auto;
	background: var(--c-dark);
	color: var(--c-white);
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--ease), visibility var(--ease);

	&.is-open {
		opacity: 1;
		visibility: visible;
	}

	& .nav-close {
		position: absolute;
		top: 35px;
		right: 16px;
		color: var(--c-white);

		& svg {
			width: 40px;
			height: 40px;
		}
	}

	@media (min-width: 768px) {
		position: static;
		z-index: auto;
		flex-direction: row;
		padding: 0;
		overflow: visible;
		background: none;
		color: inherit;
		opacity: 1;
		visibility: visible;

		& .nav-close {
			display: none;
		}
	}
}

.nav__list {
	display: block;
	margin: 0;
	padding: 0;
	list-style: none;

	@media (min-width: 768px) {
		display: flex;
		align-items: center;
		gap: 30px;
	}

	@media (min-width: 992px) {
		gap: 40px;
	}
}

.nav__link,
.nav__toggle,
.mega__heading {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 24px 30px;
	font-family: var(--f-head);
	font-size: 32px;
	font-weight: 500;
	line-height: 1;
	letter-spacing: 1px;
	color: inherit;
	text-align: left;

	&:hover span,
	&:hover {
		text-decoration: underline;
	}

	@media (min-width: 768px) {
		padding: 0;
		font-size: 16px;
	}
}

.nav__link[aria-current="page"] {
	text-decoration: underline;
}

.nav__item--button {
	padding: 0 16px;

	& .nav__button {
		width: 100%;
		font-size: 32px;

		@media (min-width: 768px) {
			width: auto;
			font-size: 16px;
		}
	}

	@media (min-width: 768px) {
		padding: 0;
	}
}

/* Mega menu: on mobile the wrapper label is hidden and each column becomes its own item */
.nav__item--mega {
	& > .nav__toggle {
		display: none;

		@media (min-width: 768px) {
			display: flex;
		}

		& .icon {
			transition: transform var(--ease);
		}

		&[aria-expanded="true"] .icon {
			transform: rotate(180deg);
		}
	}
}

.mega {
	@media (min-width: 768px) {
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		display: none;
		padding-inline: var(--gutter);

		&.is-open {
			display: block;
		}
	}
}

.mega__inner {
	@media (min-width: 768px) {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 16px;
		max-width: var(--container);
		margin-inline: auto;
		padding: 30px 16px;
		background: var(--c-white);
		border-radius: 0 0 var(--radius) var(--radius);
		box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
		color: var(--c-heading);
	}

	@media (min-width: 992px) {
		padding: 60px;
	}
}

.mega__heading {
	width: 100%;
	justify-content: space-between;

	& .icon {
		width: 24px;
		height: 24px;
		transform: rotate(-90deg);
	}

	@media (min-width: 768px) {
		display: none;
	}
}

.mega__title {
	display: none;

	@media (min-width: 768px) {
		display: block;
		font-family: var(--f-head);
		font-size: 24px;
		font-weight: 500;
		line-height: 1;
		color: var(--c-heading);
	}
}

/* Mobile: column links open as a white card over the menu, with a back arrow */
.mega__panel {
	display: none;

	&.is-open {
		position: absolute;
		inset: 0;
		z-index: 2;
		display: block;
		padding: 30px 16px 16px;
		background: var(--c-dark);
	}

	& .mega__back {
		position: absolute;
		top: 46px;
		left: 32px;
		width: 32px;
		height: 32px;
		color: var(--c-heading);

		& svg {
			width: 32px;
			height: 32px;
		}
	}

	& .mega__panel-title {
		font-family: var(--f-head);
		font-size: 32px;
		line-height: 1;
		text-align: center;
		color: var(--c-heading);
	}

	&.is-open > * {
		position: relative;
	}

	&.is-open::before {
		content: "";
		position: absolute;
		inset: 30px 16px auto;
		height: calc(100% - 60px);
		max-height: 520px;
		background: var(--c-white);
		border-radius: var(--radius);
	}

	&.is-open .mega__panel-title {
		padding: 72px 32px 0;
	}

	@media (min-width: 768px) {
		display: block;
		position: static;

		& .mega__back,
		& .mega__panel-title {
			display: none;
		}
	}
}

.mega__links {
	display: grid;
	grid-template-columns: 1fr;
	gap: 16px;
	max-width: 400px;
	margin: 0 auto;
	padding: 32px 16px 0;
	list-style: none;

	& a {
		display: block;
		font-family: var(--f-body);
		font-size: 20px;
		font-weight: 500;
		line-height: 1.2;
		text-align: center;
		color: var(--c-heading);

		&:hover span {
			text-decoration: underline;
		}

		& .icon {
			display: none;
		}
	}

	@media (min-width: 768px) {
		grid-template-columns: 1fr 1fr;
		max-width: none;
		padding: 24px 0 0;

		& a {
			display: flex;
			align-items: center;
			gap: 8px;
			font-size: 16px;
			text-align: left;

			& .icon {
				display: block;
				width: 14px;
			}
		}
	}
}

/* Keep page from scrolling behind the open mobile menu */
.nav-open {
	overflow: hidden;
}

/* ------------------------------------------------------------ main */
.site-main {
	display: block;
}

/* Pages that do not start with a hero need room for the fixed header */
.site-main > :first-child:not(.hero, .single-post) {
	margin-top: var(--header-h);
}

/* ------------------------------------------------------------ search results */
.search-form--center {
	margin-inline: auto;
}

.search-results {
	padding-top: 0;

	& .search-results__empty {
		text-align: center;
	}
}

/* ------------------------------------------------------------ footer */
.site-footer {
	background: var(--c-dark);
	color: var(--c-white);

	& .container {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		padding-top: 60px;
		padding-bottom: 80px;
	}
}

.footer__brand {
	width: 100%;
	padding-bottom: 56px;

	@media (min-width: 768px) {
		width: auto;
		padding-bottom: 0;
	}
}

.footer__logo {
	display: block;
	width: 175px;
	padding-bottom: 40px;

	& img {
		width: 100%;
	}
}

.footer__copyright {
	font-size: 12px;
	line-height: 1;
}

.footer__links {
	width: 100%;

	@media (min-width: 768px) {
		width: auto;
	}
}

.footer__menu {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	margin: 0;
	padding: 0 0 16px;
	list-style: none;

	@media (min-width: 479px) {
		grid-template-columns: repeat(3, auto);
		column-gap: 32px;
	}

	& a {
		font-family: var(--f-head);
		font-size: 16px;
		font-weight: 500;
		line-height: 1;
		letter-spacing: 1px;

		&:hover {
			text-decoration: underline;
		}
	}
}

.footer__nav + .footer__nav .footer__menu {
	padding-bottom: 56px;
}

.footer__badges {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 32px;
	list-style: none;
	margin: 0;
	padding: 0;

	& img {
		max-width: 150px;
		height: auto;
	}
}

.footer__newsletter {
	padding-bottom: 32px;

	& h2 {
		font-size: 18px;
		font-weight: 400;
		padding-bottom: 16px;
	}

	& form {
		display: flex;
		gap: 8px;
	}

	& input[type="email"] {
		flex: 1;
		min-width: 0;
		padding: 8px 12px;
		background: #281547;
		border: 1px solid var(--c-dark);
		border-radius: 8px;
		color: var(--c-white);
	}

	& button {
		width: 45px;
		height: 40px;
		background: var(--c-purple);
		border-radius: 8px;
		color: var(--c-white);
		transition: background-color var(--ease), color var(--ease);

		&:hover {
			background: var(--c-white);
			color: var(--c-purple);
		}
	}
}
