/*
 * Header dropdowns — replaces the old full-width sub-nav bar.
 * Enqueued after style.css so it can override the existing nav rules.
 * Supports three levels: top item > dropdown > flyout.
 */

:root {
	--tnav-purple: #6d1e75;
	--tnav-purple-dark: #5a1861;
	--tnav-magenta: #a71580;
	--tnav-white: #fff;
	--tnav-font: 'gotham-book', 'HelveticaNeueW01-45Ligh', "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* Only apply to the desktop header nav — the mobile/tablet menus keep their
   own existing behaviour. */
header.main-header nav ul,
header.homepage-header nav ul {
	position: relative;
}

header.main-header nav li,
header.homepage-header nav li {
	position: relative;
}

/*
 * .header-main is `flex-wrap: wrap`, so whether the phone number shares a row
 * with the nav depends purely on how wide the nav happens to be. Moving "How
 * we do it" into a dropdown dropped a top-level item and narrowed the nav
 * enough to stop it wrapping. Claim the full row so the position is fixed
 * rather than a side effect of the item count.
 */
header.homepage-header .contact-meta {
	flex-basis: 100%;
}

/* ---------- Level 2 + 3 panels ---------- */

header.main-header nav ul ul,
header.homepage-header nav ul ul {
	/*
	 * style.css sets `header nav ul { display:flex; justify-content:flex-end }`,
	 * and that selector matches nested lists too — which lays sub-menu items
	 * out in a row. Force them back to a stacked column.
	 */
	display: block;
	justify-content: flex-start;
	align-items: stretch;
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 999;
	min-width: 232px;
	margin: 0;
	padding: 6px 0;
	list-style: none;
	background: var(--tnav-purple);
	box-shadow: 0 12px 30px -8px rgba(30, 8, 34, .45);
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
	text-align: left;
}

/* Third level flies out to the side of its parent, same ground as level two. */
header.main-header nav ul ul ul,
header.homepage-header nav ul ul ul {
	top: 0;
	left: 100%;
	margin-left: 0;
	background: var(--tnav-purple);
}

/*
 * Bridge the seam between a flyout parent and its panel. Without it the
 * pointer is briefly over neither element while crossing, :hover drops, and
 * the panel starts fading before you arrive.
 */
header.main-header nav ul ul li.menu-item-has-children > a:before,
header.homepage-header nav ul ul li.menu-item-has-children > a:before {
	content: '';
	position: absolute;
	top: 0;
	right: -12px;
	width: 12px;
	height: 100%;
	background: transparent;
}

header.main-header nav ul ul li.menu-item-has-children,
header.homepage-header nav ul ul li.menu-item-has-children {
	position: relative;
}

header.main-header nav li:hover > ul,
header.main-header nav li:focus-within > ul,
header.main-header nav li.is-open > ul,
header.homepage-header nav li:hover > ul,
header.homepage-header nav li:focus-within > ul,
header.homepage-header nav li.is-open > ul {
	opacity: 1;
	visibility: visible;
	transform: none;
}

/* ---------- Items inside a panel ---------- */

/*
 * style.css gives every nav item `padding: 0 10px` and a left border, then
 * only zeroes them for :first-child and :last-child. Inside a panel that
 * leaves the middle rows indented by 10px with a stray divider — so reset
 * all of it here rather than relying on position.
 */
header.main-header nav ul ul li,
header.homepage-header nav ul ul li {
	display: block;
	margin: 0;
	padding: 0;
	float: none;
	width: auto;
	border: 0;
}

header.main-header nav ul ul li a,
header.homepage-header nav ul ul li a {
	display: block;
	padding: 9px 20px;
	font-family: var(--tnav-font);
	font-weight: normal;
	font-size: 15px;
	line-height: 1.35;
	color: var(--tnav-white);
	text-decoration: none;
	white-space: normal;
	transition: background .18s ease, color .18s ease;
}

/*
 * style.css styles the final top-level item as the magenta "Contact Us"
 * button via `header nav li:last-child a`. That selector also matches the
 * last item of every dropdown, giving each panel one odd magenta row.
 * Reset it inside panels so every item shares one background.
 */
header.main-header nav ul ul li:last-child a,
header.homepage-header nav ul ul li:last-child a,
header.main-header nav ul ul li:first-child a,
header.homepage-header nav ul ul li:first-child a {
	background: transparent;
	padding: 9px 20px;
	color: var(--tnav-white);
}

header.main-header nav ul ul li a:hover,
header.main-header nav ul ul li a:focus,
header.main-header nav ul ul li:last-child a:hover,
header.main-header nav ul ul li:last-child a:focus,
header.homepage-header nav ul ul li a:hover,
header.homepage-header nav ul ul li a:focus,
header.homepage-header nav ul ul li:last-child a:hover,
header.homepage-header nav ul ul li:last-child a:focus {
	background: var(--tnav-magenta);
	color: var(--tnav-white);
}

header.main-header nav ul ul li.current-menu-item > a,
header.homepage-header nav ul ul li.current-menu-item > a {
	background: var(--tnav-magenta);
}

/* The theme draws decorative pseudo-elements on top-level items only —
   stop them leaking into the panels. */
header.main-header nav ul ul li:before,
header.main-header nav ul ul li:after,
header.homepage-header nav ul ul li:before,
header.homepage-header nav ul ul li:after {
	display: none !important;
}

/* No chevrons on desktop — the panels speak for themselves. */

/* Keep the last dropdown from running off the right edge. */
header.main-header nav > ul > li:last-child ul,
header.homepage-header nav > ul > li:last-child ul {
	left: auto;
	right: 0;
}

header.main-header nav > ul > li:last-child ul ul,
header.homepage-header nav > ul > li:last-child ul ul {
	left: auto;
	right: 100%;
	margin-right: 1px;
	margin-left: 0;
}

/* ---------- Mobile / tablet ---------- */

/*
 * Only flatten the panels where the theme actually swaps away from the
 * desktop header. style.css does that with:
 *     @media only screen and (max-width:65em) and (orientation: portrait)
 * so the orientation term has to be matched here too. Without it, a landscape
 * viewport under 1040px keeps the desktop header but loses its dropdowns —
 * they render inline and permanently expanded.
 */
@media only screen and (max-width: 65em) and (orientation: portrait) {
	header.main-header nav ul ul,
	header.homepage-header nav ul ul,
	header.main-header nav ul ul ul,
	header.homepage-header nav ul ul ul {
		position: static;
		opacity: 1;
		visibility: visible;
		transform: none;
		box-shadow: none;
		background: transparent;
		min-width: 0;
		padding: 0;
	}
}

/* The tablet/mobile menus render nested lists inline — indent them so the
   hierarchy is readable. .tablet-nav sits inside header.micro-header, so it
   inherits the same `header nav ul { display:flex }` rule and needs the same
   correction. */
.tablet-nav ul,
.tablet-nav ul ul,
.mobile-nav ul,
.mobile-nav ul ul {
	display: block;
	justify-content: flex-start;
	align-items: stretch;
}

/* No indent — levels are distinguished by the accordion, not by margin. */
.tablet-nav ul ul,
.mobile-nav ul ul {
	margin: 0;
	padding-left: 0;
	list-style: none;
}

.tablet-nav ul ul li,
.mobile-nav ul ul li {
	display: block;
	float: none;
	width: auto;
	padding: 0;
	border: 0;
}

/* ---------- Accordion ---------- */

/* Collapsed by default; JS adds .is-open to the parent li. */
.tablet-nav li.menu-item-has-children > ul,
.mobile-nav li.menu-item-has-children > ul {
	display: none;
}

.tablet-nav li.menu-item-has-children.is-open > ul,
.mobile-nav li.menu-item-has-children.is-open > ul {
	display: block;
}

/* The row needs to contain the absolutely-placed toggle. */
.tablet-nav li.menu-item-has-children,
.mobile-nav li.menu-item-has-children {
	position: relative;
}

/* Toggle sits at the right of its own row and never covers the link text. */
.tnav-toggle {
	position: absolute;
	top: 0;
	right: 0;
	width: 52px;
	height: 44px;
	padding: 0;
	margin: 0;
	background: transparent;
	border: 0;
	cursor: pointer;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	-webkit-appearance: none;
	appearance: none;
}

/* Chevron — down when closed, flipped to up when open. */
.tnav-toggle:before {
	content: '';
	display: block;
	width: 9px;
	height: 9px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translate(-2px, -2px);
	transition: transform .22s ease;
	opacity: .9;
}

.tnav-toggle[aria-expanded="true"]:before {
	transform: rotate(-135deg) translate(-2px, -2px);
}

.tnav-toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -4px;
}

/* Keep the label clear of the toggle. */
.tablet-nav li.menu-item-has-children > a,
.mobile-nav li.menu-item-has-children > a {
	padding-right: 56px;
}

/* ---------- Third level, mobile / tablet ---------- */

/*
 * Quieter than the levels above it: no dividers, tighter rows, a small
 * indent, and the magenta ($purple-4) rather than the violet ($purple-1)
 * the first two levels use.
 */
.mobile-nav ul ul ul li,
.tablet-nav ul ul ul li {
	border: 0;
	box-shadow: none;
}

.mobile-nav ul ul ul li > a,
.tablet-nav ul ul ul li > a {
	border: 0;
	box-shadow: none;
	padding: 5px 20px 5px 30px;
	color: var(--tnav-magenta);
	font-size: 15px;
	line-height: 1.35;
}

.mobile-nav ul ul ul li > a:hover,
.mobile-nav ul ul ul li > a:focus,
.tablet-nav ul ul ul li > a:hover,
.tablet-nav ul ul ul li > a:focus {
	color: var(--tnav-purple);
}

/* Give the group a little breathing room without reintroducing a rule. */
.mobile-nav ul ul ul,
.tablet-nav ul ul ul {
	padding: 4px 0 8px;
}

@media (prefers-reduced-motion: reduce) {
	.tnav-toggle:before { transition: none; }
}

@media (prefers-reduced-motion: reduce) {
	header.main-header nav ul ul,
	header.homepage-header nav ul ul {
		transition: none;
	}
}
