/**
 * Mobile navigation — accordion conversion for the JetMenu "Mega Menu" widget.
 *
 * JetMenu's public.css ships with no media queries at all: every level of
 * .jet-sub-menu is position:absolute, level 1 at `top:100%; left:0` and every
 * deeper level at `top:0; left:100%`. On a phone the level 1 dropdown is
 * already flush with the right edge of the viewport, so a level 2 flyout
 * starts one dropdown-width past it and lands off-screen.
 *
 * Everything below is scoped to (max-width: 1024px) — the same tablet
 * breakpoint the rest of this site uses — so the desktop flyout behaviour at
 * >= 1025px is completely untouched.
 */

/* The hamburger only ever exists on mobile/tablet. */
.jet-mobile-nav__toggle {
	display: none;
}

@media (max-width: 1024px) {

	/* ---------------------------------------------------------------
	   1. Nothing may extend past the viewport, in either direction.
	   --------------------------------------------------------------- */
	html,
	body {
		overflow-x: hidden;
		max-width: 100%;
	}

	/* The nav's section becomes the containing block for the panel. This is
	   what lets the panel be full width using plain `left:0; right:0` —
	   no 100vw, no translateX, so it can never overhang the viewport. */
	.jet-mobile-nav__scope {
		position: relative;
	}

	/* Only the wrappers between the menu and that section: Elementor makes
	   columns and widget wrappers `position:relative`, which would otherwise
	   pin the panel to the width of the narrow nav column. */
	.jet-mobile-nav__passthrough {
		position: static !important;
	}

	.jet-mobile-nav {
		position: static;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		width: 100%;
		max-width: 100%;
	}

	/* The panel is absolutely positioned, so its wrapper needs no box of its
	   own — otherwise it would fill the row and shove the hamburger inwards. */
	.jet-mobile-nav .jet-menu-inner {
		position: static;
		display: block;
		flex: 0 0 0;
		width: 0;
		height: 0;
	}

	/* ---------------------------------------------------------------
	   2. Hamburger toggle.
	   --------------------------------------------------------------- */
	.jet-mobile-nav__toggle {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 44px;
		height: 44px;
		padding: 0;
		margin: 0;
		border: 0;
		border-radius: 4px;
		background: transparent;
		color: #fff;
		cursor: pointer;
		-webkit-appearance: none;
		appearance: none;
		line-height: 0;
	}

	.jet-mobile-nav__toggle:hover,
	.jet-mobile-nav__toggle:focus-visible,
	.jet-mobile-nav__toggle[aria-expanded="true"] {
		color: #dd3333;
	}

	.jet-mobile-nav__bars {
		display: block;
		width: 24px;
	}

	.jet-mobile-nav__bars i {
		display: block;
		height: 2px;
		border-radius: 2px;
		background-color: currentColor;
		transition: transform .2s ease, opacity .2s ease;
	}

	.jet-mobile-nav__bars i + i {
		margin-top: 5px;
	}

	/* ☰ turns into ✕ while the panel is open. */
	.jet-mobile-nav__toggle[aria-expanded="true"] .jet-mobile-nav__bars i:nth-child(1) {
		transform: translateY(7px) rotate(45deg);
	}

	.jet-mobile-nav__toggle[aria-expanded="true"] .jet-mobile-nav__bars i:nth-child(2) {
		opacity: 0;
	}

	.jet-mobile-nav__toggle[aria-expanded="true"] .jet-mobile-nav__bars i:nth-child(3) {
		transform: translateY(-7px) rotate(-45deg);
	}

	/* ---------------------------------------------------------------
	   3. The menu itself becomes a full width vertical panel.
	   --------------------------------------------------------------- */
	.jet-mobile-nav > .jet-menu-inner > .jet-menu {
		display: none;
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		width: auto !important;
		max-width: 100%;
		margin: 0;
		padding: 0;
		/* The header menu is `flex-flow: row wrap` on desktop. Plain block flow
		   is used here instead of a flex column: with `display:flex`, rows that
		   overflow the capped panel height become unreachable — the scroll
		   container refuses to scroll to them. */
		/* The header's top level links are white because the header sits over a
		   dark hero, so the panel takes the same dark tone the theme already
		   gives .jet-sub-menu rather than white. */
		background-color: #091926;
		box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
		/* A deep accordion stays scrollable instead of running off the page.
		   mobile-nav.js narrows this to the real space below the header. */
		max-height: calc(100vh - 90px);
		overflow-y: auto;
		overflow-x: hidden;
		-webkit-overflow-scrolling: touch;
		z-index: 9999;
	}

	.jet-mobile-nav.is-open > .jet-menu-inner > .jet-menu {
		display: block;
	}

	/* Every row is a full width block. The `!important` is required because
	   JetMenu's roll-up feature sets a `hidden` attribute on top level items
	   that it thinks do not fit, and hides them at a higher specificity. */
	.jet-mobile-nav .jet-menu li.jet-menu-item {
		display: block !important;
		position: relative;
		width: 100%;
		max-width: 100%;
	}

	/* The roll-up "···" button is replaced by the real hamburger. The `li` is
	   needed to match the specificity of the rule above. */
	.jet-mobile-nav .jet-menu > li.jet-responsive-menu-available-items {
		display: none !important;
	}

	.jet-mobile-nav .jet-menu .top-level-link,
	.jet-mobile-nav .jet-menu .sub-level-link {
		display: flex !important;
		align-items: center;
		width: 100% !important;
		max-width: 100%;
		margin: 0 !important;
		padding: 12px 16px !important;
		border-bottom: 1px solid rgba(255, 255, 255, .09);
	}

	.jet-mobile-nav .jet-menu .jet-menu-item-wrapper {
		display: flex;
		flex-wrap: nowrap;
		align-items: center;
		width: 100%;
		min-width: 0;
	}

	.jet-mobile-nav .jet-menu .jet-menu-title {
		min-width: 0;
		overflow-wrap: break-word;
		white-space: normal;
	}

	/* ---------------------------------------------------------------
	   4. Submenus: absolute flyout -> in-flow accordion.
	   This is the actual bug fix. Killing position/left/right/transform
	   here is what stops the off-screen level 2 flyout.
	   --------------------------------------------------------------- */
	.jet-mobile-nav .jet-menu .jet-sub-menu,
	.jet-mobile-nav .jet-menu .jet-sub-mega-menu {
		display: none;
		position: static !important;
		top: auto !important;
		left: auto !important;
		right: auto !important;
		bottom: auto !important;
		transform: none !important;
		width: 100% !important;
		min-width: 0 !important;
		max-width: 100% !important;
		margin: 0 !important;
		padding: 0 !important;
		/* An inset bar marks each nesting level; the theme already gives
		   submenus their own background colour, which is left alone. */
		box-shadow: inset 3px 0 0 rgba(255, 255, 255, .16) !important;
		/* JetMenu reveals flyouts by flipping these on hover; on touch a tap
		   fires mouseenter, which is how the off-screen menu appeared. */
		opacity: 1 !important;
		visibility: visible !important;
		pointer-events: auto !important;
		transition: none !important;
		z-index: auto !important;
	}

	/* Opening a submenu only ever adds height to the panel. */
	.jet-mobile-nav .jet-menu li.jet-mobile-nav-expanded > .jet-sub-menu,
	.jet-mobile-nav .jet-menu li.jet-mobile-nav-expanded > .jet-sub-mega-menu {
		display: block;
	}

	/* Depth indentation. */
	.jet-mobile-nav .jet-menu .jet-sub-menu .sub-level-link {
		padding-left: 32px !important;
	}

	.jet-mobile-nav .jet-menu .jet-sub-menu .jet-sub-menu .sub-level-link {
		padding-left: 48px !important;
	}

	.jet-mobile-nav .jet-menu .jet-sub-menu .jet-sub-menu .jet-sub-menu .sub-level-link {
		padding-left: 64px !important;
	}

	/* ---------------------------------------------------------------
	   5. Dropdown arrows point down (▼) and flip when expanded.
	   --------------------------------------------------------------- */
	.jet-mobile-nav .jet-menu .jet-dropdown-arrow {
		display: flex;
		align-items: center;
		justify-content: center;
		flex: 0 0 auto;
		margin-left: auto !important;
		margin-right: 0 !important;
		min-width: 44px;
		min-height: 28px;
		transition: transform .2s ease;
	}

	/* Sub-level arrows ship as fa-angle-right; show angle-down instead. */
	.jet-mobile-nav .jet-menu .jet-dropdown-arrow.fa-angle-right::before {
		content: "\f107";
	}

	.jet-mobile-nav .jet-menu li.jet-mobile-nav-expanded > a .jet-dropdown-arrow {
		transform: rotate(180deg);
	}

	/* Keep desktop hover state from tinting rows on touch. */
	.jet-mobile-nav .jet-menu .jet-menu-item.jet-menu-hover > .jet-sub-menu {
		top: auto !important;
		left: auto !important;
	}
}
