/**
 * Mobile mega drawer — theme overlay only (Mega Menu plugin frozen).
 * Forces a full-viewport scrollable menu so visitors see all items, not a ~215px strip.
 *
 * @package B2B_Manufacturing_Base
 */

@media (max-width: 1024px) {
	/*
	 * Use --rmm-header-height (stable), NOT --rmm-mega-offset.
	 * Mega offset is remeasured AFTER .is-open and includes the open list itself → wrong top.
	 */
	html.rekhi-rmm-scroll-lock .rekhi-hdr__nav-bar .rekhi-mega-menu__list.is-open,
	html.rekhi-rmm-scroll-lock .b2b-header-mega .rekhi-mega-menu__list.is-open,
	html.rekhi-rmm-scroll-lock .rekhi-mega-menu__list.is-open,
	.rekhi-hdr.is-menu-open .rekhi-mega-menu__list.is-open,
	.rekhi-hdr__nav-bar .rekhi-mega-menu__list.is-open,
	.b2b-header-mega .rekhi-mega-menu__list.is-open {
		display: flex !important;
		flex-direction: column !important;
		flex-wrap: nowrap !important;
		align-items: stretch !important;
		justify-content: flex-start !important;
		position: fixed !important;
		left: 0 !important;
		right: 0 !important;
		width: 100% !important;
		max-width: 100% !important;
		top: var(--b2b-drawer-top, var(--rmm-header-height, var(--b2b-header-h, 148px))) !important;
		bottom: 0 !important;
		height: auto !important;
		min-height: 70vh !important;
		max-height: none !important;
		z-index: 10050 !important; /* under header (10060) so hamburger stays clickable */
		margin: 0 !important;
		padding: 0 0 calc(24px + env(safe-area-inset-bottom, 0px)) !important;
		background: #0a0a0f !important;
		border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
		overflow-x: hidden !important;
		overflow-y: auto !important;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
		opacity: 1 !important;
		visibility: visible !important;
		transform: none !important;
		box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55) !important;
		pointer-events: auto !important;
	}

	html.rekhi-rmm-scroll-lock .rekhi-mega-menu__list.is-open > .rekhi-mega-menu__item,
	.rekhi-hdr.is-menu-open .rekhi-mega-menu__list.is-open > .rekhi-mega-menu__item,
	.rekhi-hdr__nav-bar .rekhi-mega-menu__list.is-open > .rekhi-mega-menu__item,
	.b2b-header-mega .rekhi-mega-menu__list.is-open > .rekhi-mega-menu__item {
		display: block !important;
		flex: 0 0 auto !important;
		width: 100% !important;
		min-height: 52px !important;
		opacity: 1 !important;
		visibility: visible !important;
	}

	html.rekhi-rmm-scroll-lock .rekhi-mega-menu__list.is-open .rekhi-mega-menu__link,
	.rekhi-hdr.is-menu-open .rekhi-mega-menu__list.is-open .rekhi-mega-menu__link {
		width: 100% !important;
		padding: 16px 20px !important;
		font-size: 1rem !important;
		justify-content: space-between !important;
	}

	body.admin-bar html.rekhi-rmm-scroll-lock .rekhi-mega-menu__list.is-open,
	body.admin-bar .rekhi-hdr.is-menu-open .rekhi-mega-menu__list.is-open,
	body.admin-bar .rekhi-hdr__nav-bar .rekhi-mega-menu__list.is-open {
		/* --b2b-drawer-top already includes admin-bar when set by theme.js */
		top: var(--b2b-drawer-top, calc(var(--rmm-header-height, var(--b2b-header-h, 148px)) + 46px)) !important;
	}

	@media (min-width: 783px) {
		body.admin-bar html.rekhi-rmm-scroll-lock .rekhi-mega-menu__list.is-open,
		body.admin-bar .rekhi-hdr.is-menu-open .rekhi-mega-menu__list.is-open,
		body.admin-bar .rekhi-hdr__nav-bar .rekhi-mega-menu__list.is-open {
			top: var(--b2b-drawer-top, calc(var(--rmm-header-height, var(--b2b-header-h, 148px)) + 32px)) !important;
		}
	}

	/* Keep header chrome above the drawer */
	html.rekhi-rmm-scroll-lock .rekhi-hdr,
	html.rekhi-rmm-scroll-lock #rekhi-header,
	.rekhi-hdr.is-menu-open {
		z-index: 10060 !important;
		overflow: visible !important;
	}

	/* Hide floating AI while menu is open so it does not cover links */
	html.rekhi-rmm-scroll-lock .rekhi-live-chat {
		opacity: 0 !important;
		pointer-events: none !important;
	}
}
