/* ==========================================================================
   Site header & main navigation
   Markup: header.php  ·  Behaviour: js/header.js
   Desktop nav from 1200px; below that the hamburger + slide-down panel.
   Uses its own tpc-header* / tpc-nav* classes so legacy .header / #main-nav
   rules (layout.css, Customizer CSS) cannot interfere.
   ========================================================================== */

.tpc-header {
	--tpc-blue: #122664;
	--tpc-blue-dark: #0c1b4a;
	--tpc-accent: #5a7cb0;
	--tpc-text: #ffffff;
	--tpc-gutter: 20px;
	--tpc-bar-height: 68px;
	--tpc-logo-width: 190px;
	--tpc-font: "source_sans_prolight", "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;

	position: relative;
	z-index: 200;
	width: 100%;
	background-color: var(--tpc-blue);
	color: var(--tpc-text);
	font-family: var(--tpc-font);
}

@media (min-width: 768px) {
	.tpc-header {
		--tpc-bar-height: 80px;
		--tpc-logo-width: 240px;
	}
}

@media (min-width: 1200px) {
	.tpc-header {
		--tpc-bar-height: 96px;
		--tpc-logo-width: 250px;
	}

	/* Home page: header sits over the hero image. */
	.tpc-header--overlay {
		position: absolute;
		left: 0;
		right: 0;
		background-color: rgba(18, 38, 100, 0.9);
	}
}

@media (min-width: 1400px) {
	.tpc-header {
		--tpc-logo-width: 300px;
	}
}

.tpc-header *,
.tpc-header *::before,
.tpc-header *::after {
	box-sizing: border-box;
}

/* Same content width as .centering used across the site. */
.tpc-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	max-width: 1590px;
	min-height: var(--tpc-bar-height);
	margin: 0 auto;
	padding: 0 var(--tpc-gutter);
}

/* --- Logo ---------------------------------------------------------------- */

.tpc-header__logo {
	display: block;
	flex: 0 0 auto;
	width: var(--tpc-logo-width);
	max-width: calc(100% - 64px); /* always leave room for the menu button */
	line-height: 0;
}

.tpc-header__logo img {
	display: block;
	width: 100%;
	height: auto;
}

/* --- Links (shared) ------------------------------------------------------ */

.tpc-header a {
	color: var(--tpc-text);
	text-decoration: none;
	transition: color 150ms ease;
}

.tpc-header a:hover,
.tpc-header .current-menu-item > a,
.tpc-header .current-menu-ancestor > a,
.tpc-header .current_page_item > a {
	color: #c9d6ee;
}

.tpc-header a:focus-visible,
.tpc-header button:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 3px;
	border-radius: 2px;
}

.tpc-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tpc-nav li {
	margin: 0;
	padding: 0;
}

/* Sub-menu toggle (caret button, injected by header.js) */
.tpc-nav__sub-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	margin: 0;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
}

.tpc-nav__sub-toggle::before {
	content: "";
	width: 8px;
	height: 8px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: translateY(-2px) rotate(45deg);
	transition: transform 200ms ease;
}

.tpc-nav .is-open > .tpc-nav__sub-toggle::before {
	transform: translateY(2px) rotate(-135deg);
}

/* ==========================================================================
   Desktop (>= 1200px)
   ========================================================================== */

@media (min-width: 1200px) {

	.tpc-header__toggle {
		display: none;
	}

	.tpc-nav {
		display: flex;
		align-items: center;
		gap: 36px;
	}

	.tpc-nav__menu {
		display: flex;
		align-items: center;
		gap: 4px 30px;
	}

	.tpc-nav__menu > li {
		position: relative;
		display: flex;
		align-items: center;
		gap: 6px;
	}

	.tpc-nav__menu > li > a {
		display: block;
		padding: 10px 0;
		font-size: 20px;
		line-height: 1.2;
		white-space: nowrap;
	}

	.tpc-nav__sub-toggle {
		width: 20px;
		height: 32px;
	}

	/* Dropdown */
	.tpc-nav .sub-menu {
		position: absolute;
		top: 100%;
		left: -24px;
		min-width: 240px;
		padding: 10px 0;
		background-color: var(--tpc-blue);
		box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
		opacity: 0;
		visibility: hidden;
		transform: translateY(6px);
		transition: opacity 150ms ease, transform 150ms ease, visibility 0s linear 150ms;
	}

	.tpc-nav__menu > li:hover > .sub-menu,
	.tpc-nav__menu > li:focus-within > .sub-menu,
	.tpc-nav__menu > li.is-open > .sub-menu {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
		transition-delay: 0s;
	}

	.tpc-nav .sub-menu a {
		display: block;
		padding: 10px 24px;
		font-size: 18px;
		white-space: nowrap;
	}

	.tpc-nav .sub-menu a:hover {
		background-color: var(--tpc-blue-dark);
	}

	/* Phone + My List, separated from the main links */
	.tpc-nav .tpc-nav__extras {
		display: flex;
		align-items: center;
		gap: 24px;
		padding-left: 36px;
		border-left: 1px solid rgba(255, 255, 255, 0.35);
	}

	.tpc-nav__extras a {
		display: inline-flex;
		align-items: center;
		gap: 0.3em;
		white-space: nowrap;
	}

	.tpc-nav__phone a {
		font-size: 20px;
	}

	.tpc-nav__mylist a {
		font-size: 16px;
	}

	.tpc-nav__mylist .icon-header-user-icon {
		margin-left: 6px;
	}

	.tpc-nav__login {
		display: none;
	}
}

/* Tighter spacing on smaller desktops so everything stays on one line. */
@media (min-width: 1200px) and (max-width: 1399.98px) {
	.tpc-nav { gap: 28px; }
	.tpc-nav__menu { gap: 4px 22px; }
	.tpc-nav__menu > li > a,
	.tpc-nav__phone a { font-size: 18px; }
	.tpc-nav .tpc-nav__extras { gap: 18px; padding-left: 28px; }
	.tpc-nav__phone-label { display: none; }
}

/* ==========================================================================
   Mobile & tablet (< 1200px)
   ========================================================================== */

@media (max-width: 1199.98px) {

	/* Hamburger */
	.tpc-header__toggle {
		position: relative;
		display: block;
		flex: 0 0 auto;
		width: 44px;
		height: 44px;
		margin-right: -8px; /* optically align bars with the gutter */
		padding: 0;
		border: 0;
		background: none;
		color: var(--tpc-text);
		cursor: pointer;
	}

	.tpc-header__toggle-bar {
		position: absolute;
		left: 10px;
		width: 24px;
		height: 2px;
		border-radius: 2px;
		background-color: currentColor;
		transition: transform 250ms ease, opacity 150ms ease;
	}

	.tpc-header__toggle-bar:nth-of-type(2) { top: 14px; }
	.tpc-header__toggle-bar:nth-of-type(3) { top: 21px; }
	.tpc-header__toggle-bar:nth-of-type(4) { top: 28px; }

	.tpc-header.is-open .tpc-header__toggle-bar:nth-of-type(2) { transform: translateY(7px) rotate(45deg); }
	.tpc-header.is-open .tpc-header__toggle-bar:nth-of-type(3) { opacity: 0; }
	.tpc-header.is-open .tpc-header__toggle-bar:nth-of-type(4) { transform: translateY(-7px) rotate(-45deg); }

	/* Slide-down panel, sits directly under the header bar */
	.tpc-nav {
		position: fixed;
		top: var(--tpc-nav-top, var(--tpc-bar-height));
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 199;
		display: flex;
		flex-direction: column;
		padding: 8px var(--tpc-gutter) 40px;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
		background-color: var(--tpc-blue);
		border-top: 1px solid rgba(255, 255, 255, 0.15);
		opacity: 0;
		visibility: hidden;
		transform: translateY(-8px);
		transition: opacity 200ms ease, transform 200ms ease, visibility 0s linear 200ms;
	}

	.tpc-header.is-open .tpc-nav {
		opacity: 1;
		visibility: visible;
		transform: none;
		transition-delay: 0s;
	}

	.tpc-nav__menu > li {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		border-bottom: 1px solid rgba(255, 255, 255, 0.15);
	}

	.tpc-nav__menu > li > a {
		flex: 1 1 auto;
		display: block;
		padding: 16px 0;
		font-size: 22px;
		line-height: 1.2;
	}

	.tpc-nav__sub-toggle {
		width: 48px;
		height: 48px;
		margin-right: -12px;
	}

	/* Accordion sub-menu */
	.tpc-nav .sub-menu {
		display: none;
		flex: 0 0 100%;
		padding: 0 0 12px 16px;
	}

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

	.tpc-nav .sub-menu a {
		display: block;
		padding: 10px 0;
		font-size: 19px;
		opacity: 0.9;
	}

	/* Phone, My List, Login */
	.tpc-nav .tpc-nav__extras {
		display: flex;
		flex-direction: column;
		gap: 12px;
		margin-top: 28px;
	}

	.tpc-nav__extras a {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 0.3em;
		min-height: 52px;
		padding: 12px 20px;
		border: 1px solid rgba(255, 255, 255, 0.6);
		border-radius: 6px;
		font-size: 19px;
		text-align: center;
	}

	.tpc-nav__phone a {
		background-color: #ffffff;
		border-color: #ffffff;
		color: var(--tpc-blue);
		font-weight: 600;
	}

	.tpc-header .tpc-nav__phone a:hover {
		color: var(--tpc-blue);
	}

	.tpc-nav__mylist .icon-header-user-icon {
		margin-left: 8px;
	}

	/* Stop the page scrolling behind the open menu */
	html.tpc-nav-open,
	html.tpc-nav-open body {
		overflow: hidden;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tpc-header *,
	.tpc-header *::before,
	.tpc-header *::after {
		transition: none !important;
	}
}
