/* =====================================================================
 * 40-mobile-menu.css — the phone/tablet header and the menu panel
 * ---------------------------------------------------------------------
 * Ricky 2026-11-28: "some things like the menu look crappy".
 * Measured 2026-11-28 at 390px (fb2/mobile/results/10-home-390-*.json):
 *   - item text starts at x=0, flush to the screen edge; the chevron
 *     buttons run to x=420 on a 390px screen
 *   - 16px title-case labels in 42px rows; Home is a solid #7A1FB8 slab
 *   - the menu button is a 21x21px target
 *   - the open menu pushes the page down; the header is not sticky, so
 *     after any scroll there is no way back to the menu
 *
 * Why the text is flush: Avada pulls the holder out 30px each side
 * (`.fusion-mobile-menu-design-modern.fusion-header-v4
 * .fusion-mobile-nav-holder { margin: 0 -30px }`) to cancel band padding
 * that 13-header-boxed.css:337-340 sets to 0 at every width. Zeroing the
 * margins puts the labels back on the 30px gutter, level with the logo.
 *
 * Breakpoint 1024px: the one 13- and 23- were written for. Avada's own
 * header breakpoint (side_header_break_point, measured 800) must be set
 * to 1024 too, or 801-1024 keeps the desktop nav (plan S1, step 1).
 *
 * Specificity: Avada's mobile-menu rules reach 0,3,3 and load after this
 * file. Selectors here lead with body plus the header classes to win on
 * specificity; !important appears only where an existing child-theme
 * rule already uses it (07-mobile-header.css, 13-header-boxed.css).
 * ===================================================================== */

@media (max-width: 1024px) {

	/* ---- the header row: logo left, search + menu glyphs right ------- */

	/* Stays on screen. Position sticky needs no JS and no placeholder; the
	   nearest scroller is the viewport (#boxed-wrapper uses overflow-x:clip,
	   which does not create a scroll container). */
	body .fusion-header-wrapper {
		position: sticky;
		top: 0;
		z-index: 10040;
	}

	body .fusion-header-v4 .fusion-header {
		padding-top: 0 !important;      /* 07-mobile-header.css: 6px !important */
		padding-bottom: 0 !important;
	}
	body .fusion-header-v4 .fusion-logo {
		padding: 7px 0 !important;      /* 13-header-boxed.css: 6px 0 !important at every width */
	}
	body .fusion-header-v4 .fusion-header > .fusion-row {
		min-height: var(--fb-mhdr-row);
	}

	body .fusion-header-v4 .fusion-mobile-menu-icons {
		position: absolute;
		top: 0;
		right: -12px;                   /* 44px boxes; the glyph's right edge lands on the 30px gutter */
		height: var(--fb-mhdr-row);
		margin: 0;
		display: flex !important;       /* Avada toggles display; 07 uses !important at <=640px */
		align-items: center;
		gap: 2px;
	}
	body .fusion-header-v4 .fusion-mobile-menu-icons > a {
		float: none;
		margin: 0;
		width: 44px;
		height: 44px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		font-size: 20px;
		color: var(--fb-text);
		border-radius: var(--fb-radius-pill);
	}
	/* search sits left of the menu glyph, as on both reference sites */
	body .fusion-header-v4 .fusion-mobile-menu-icons > a.awb-icon-search {
		order: -1;
	}
	body .fusion-header-v4 .fusion-mobile-menu-icons > a:focus-visible {
		outline: 2px solid var(--fb-cyan);
		outline-offset: -4px;
	}

	/* Open: the bars become a close mark. Avada sets aria-expanded on this
	   link (avada-menu.js); the mark is drawn here, not an image file. */
	body .fusion-header-v4 .fusion-mobile-menu-icons > a.awb-icon-bars[aria-expanded="true"]::before {
		content: "";
		display: block;
		width: 20px;
		height: 20px;
		background: center / 18px 18px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23E8ECF4' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M4 4l12 12M16 4L4 16'/%3E%3C/svg%3E");
	}

	/* ---- the panel ---------------------------------------------------- */

	body .fusion-header-v4 .fusion-secondary-main-menu {
		position: relative;
	}

	/* Always absolutely placed (Avada shows and hides it with slideToggle),
	   so it never pushes the page down, including mid-animation. Full
	   height below the header, scrolls inside itself. */
	body .fusion-header-v4.fusion-mobile-menu-design-modern .fusion-mobile-nav-holder {
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		margin: 0;
		height: calc(100vh - var(--fb-mhdr-h));
		height: calc(100dvh - var(--fb-mhdr-h));
		overflow-y: auto;
		overscroll-behavior: contain;
		-webkit-overflow-scrolling: touch;
		padding: 6px 0 calc(32px + env(safe-area-inset-bottom, 0px));
		box-sizing: border-box;
		background:
			var(--fb-rule-aurora) top left / 100% 2px no-repeat,
			radial-gradient(130% 42% at 0% 0%, rgba(122, 31, 184, .30) 0%, rgba(122, 31, 184, 0) 62%),
			radial-gradient(120% 36% at 100% 0%, rgba(44, 192, 170, .16) 0%, rgba(44, 192, 170, 0) 60%),
			var(--fb-surface);
		box-shadow: 0 24px 48px rgba(0, 0, 0, .55);
	}
	body.admin-bar .fusion-header-v4.fusion-mobile-menu-design-modern .fusion-mobile-nav-holder {
		height: calc(100dvh - var(--fb-mhdr-h) - var(--wp-admin--admin-bar--height, 0px));
	}

	/* The page behind does not scroll while the panel is open. Set on body
	   (not html): body's overflow then propagates to the viewport, so the
	   sticky header keeps the viewport as its scroller. */
	body:has(.fusion-mobile-nav-holder.fusion-mobile-menu-expanded) {
		overflow: hidden !important;
	}

	/* ---- top-level rows ---------------------------------------------- */

	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder > ul > li.fusion-mobile-nav-item > a {
		height: auto;
		min-height: 52px;
		padding: 14px 72px 14px var(--fb-gutter-m);
		box-sizing: border-box;
		background: transparent;
		border-bottom: 1px solid var(--fb-hairline);
		color: var(--fb-text);
		font-size: 14px;
		font-weight: 600;
		line-height: 1.3;
		letter-spacing: .12em;
		text-transform: uppercase;
	}

	/* Current page: a violet edge and a fading wash, not a solid slab.
	   Overrides 07-mobile-header.css:73-78 (0,2,1 !important). */
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder li.fusion-mobile-nav-item.current-menu-item > a,
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder li.fusion-mobile-nav-item.current_page_item > a,
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder li.fusion-mobile-nav-item.fusion-mobile-current-nav-item > a {
		background: linear-gradient(90deg, rgba(122, 31, 184, .24) 0%, rgba(122, 31, 184, 0) 75%) !important;
		box-shadow: inset 3px 0 0 var(--fb-violet-lit);
		color: #FFFFFF !important;
	}

	/* Subscribe reads as the one call to action. Keyed on a class set on
	   the menu item (Appearance > Menus > CSS Classes: fb-subscribe), the
	   same way fb-mega / fb-nolink / fb-bonus already are. */
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder > ul > li.fusion-mobile-nav-item.fb-subscribe > a .menu-text {
		display: inline-flex;
		align-items: center;
		padding: 7px 16px;
		margin: -7px 0;
		border-radius: var(--fb-radius-pill);
		background: var(--fb-violet);
		color: var(--fb-on-accent);
	}

	/* ---- submenu toggles ---------------------------------------------- */

	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder .fusion-open-submenu {
		top: 0;
		right: 0;
		height: 52px;
		line-height: 52px;
		min-width: 64px;
		padding: 0 var(--fb-gutter-m) 0 0;
		color: var(--fb-text-dim);
		text-align: right;
	}
	/* Episodes, Shop, About and Account are not links (fb-nolink: Ricky
	   2026-11-19), so tapping the label did nothing; only a 57x42 chevron
	   opened them. The toggle now covers the whole row. */
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder li.fb-nolink > .fusion-open-submenu {
		left: 0;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		cursor: pointer;
	}
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder .fusion-open-submenu::before {
		transition: transform .2s ease;
	}
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder .fusion-open-submenu[aria-expanded="true"]::before {
		transform: rotate(180deg);
	}
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder .fusion-open-submenu:hover,
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder .fusion-open-submenu:focus-visible {
		color: var(--fb-violet-lit);    /* Avada's default hover is green #65bc7b */
	}

	/* ---- submenu rows -------------------------------------------------- */

	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder .sub-menu {
		background: rgba(6, 8, 15, .35);
		border-bottom: 1px solid var(--fb-hairline);
	}
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder .sub-menu li.fusion-mobile-nav-item > a {
		height: auto;
		min-height: 44px;
		padding: 11px var(--fb-gutter-m) 11px calc(var(--fb-gutter-m) + 16px);
		box-sizing: border-box;
		border-bottom: 1px solid rgba(255, 255, 255, .04);
		color: var(--awb-color2);
		font-size: 15px;
		font-weight: 400;
		line-height: 1.35;
		letter-spacing: .005em;
		text-transform: none;
	}
	/* Avada prefixes sub items with "-" (mobile_menu_submenu_indicator). */
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder .sub-menu a::before {
		content: none;
	}
	/* Live series counts from inc/fb-style.php: quieter than the name. */
	body .fusion-mobile-nav-holder .fb-menu-count {
		margin-left: .5em;
		color: var(--fb-text-dim);
		font-size: .8em;
		font-variant-numeric: tabular-nums;
	}

	/* ---- search, once Avada's mobile_menu_search is on ---------------- */
	/* Class names from Avada's templates/menu-mobile-search.php and
	   avada-menu.js (.fusion-mobile-menu-icons .awb-icon-search toggles
	   .fusion-mobile-menu-search). Confirm the DOM after enabling. */
	body .fusion-header-wrapper .fusion-mobile-menu-search {
		padding: 10px var(--fb-gutter-m) 12px;
		background: var(--fb-surface);
		border-bottom: 1px solid var(--fb-hairline);
	}
	body .fusion-header-wrapper .fusion-mobile-menu-search input[type="search"],
	body .fusion-header-wrapper .fusion-mobile-menu-search input[type="text"] {
		width: 100%;
		height: 44px;
		padding: 0 16px;
		box-sizing: border-box;
		background: var(--awb-color7) !important;
		border: 1px solid var(--awb-color3) !important;
		border-radius: var(--fb-radius-pill) !important;
		color: var(--fb-text) !important;
		font-size: 16px;                /* under 16px iOS zooms the page on focus */
	}
}

/* WordPress pins its admin bar from 601px up (wp-includes/css/admin-bar.css
   :789-791 and :1127-1129), so logged-in previews need the header to stick
   below it there and at the very top below 601px. */
@media (min-width: 601px) and (max-width: 1024px) {
	body.admin-bar .fusion-header-wrapper {
		top: var(--wp-admin--admin-bar--height, 0px);
	}
}

@media (prefers-reduced-motion: reduce) {
	body .fusion-mobile-menu-design-modern .fusion-mobile-nav-holder .fusion-open-submenu::before {
		transition: none;
	}
}
