/* ---------------------------------------------------------------------------
 * Mobile navigation — turn the Mega Menu's accordion into a panel stack.
 *
 * The widget already holds everything the design needs: each item pairs a
 * title with its content, and the WordPress menu for that section is inside
 * it. What it does not do is replace the list with the section — it expands
 * underneath. Nothing here rebuilds the menu; it changes which of the two is
 * on screen.
 *
 * TO USE: add the class `ld-drill` to the Mega Menu widget **inside the mobile
 * popup**, and to nothing else. The popup is only shown on mobile, so the menu
 * in it is always the mobile one — which is why there is no breakpoint and no
 * media query here. The header's own menu is the desktop one and must not
 * carry the class: it would lose its horizontal bar.
 *
 * The open section is Elementor's own business: it sets aria-expanded on the
 * item's dropdown control, and that is what these rules read. Nothing here
 * opens or closes anything, so the taps, the keyboard and the aria all stay
 * with the widget.
 * ------------------------------------------------------------------------- */

/* The widget sits centred and only as wide as its longest label, so aligning
 * the text inside it moves nothing — the whole block is in the middle. It has
 * to be the widget that stretches.
 *
 * Elementor writes this in the popup's own per-element CSS, four classes deep,
 * which is why it takes !important rather than a longer selector: matching it
 * would mean naming the popup and the element id, and that breaks the day
 * either changes.
 *
 * Worth knowing: Advanced → Layout → Align Self and Width now do nothing on a
 * menu carrying ld-drill. If the design ever wants this menu narrower or
 * centred, it is these three lines that decide, not the panel.
 */
.ld-drill {
	align-self: stretch !important;
	width: 100% !important;
	max-width: 100% !important;

	/* One left edge for the whole menu.
	 *
	 * Three different widgets decide it otherwise — the Mega Menu's title
	 * padding, the WordPress Menu's item padding inside each panel, and the
	 * back button — so the section names, the links under them and the back
	 * arrow each started at a different place. Change this number and all
	 * three move together. */
	--ld-drill-inset: 20px;

	/* Same story vertically: the section names, the back arrow and the links
	   inside a panel are three widgets with three padding controls, so the
	   rhythm changed as you walked into a section. These two decide it for all
	   three — gap between rows, and the breathing room above and below a list.
	   Both are the comp's. */
	--ld-drill-gap: 24px;
	--ld-drill-pad-block: 16px;
}

.ld-drill .e-n-menu-title-container,
.ld-drill .ld-mnav__back,
.ld-drill .e-n-menu-content .elementor-nav-menu > li > a {
	padding-left: var(--ld-drill-inset);
	padding-right: var(--ld-drill-inset);
	padding-top: 0;
	padding-bottom: 0;
}

/* The 24px is a gap, not padding doubled up between neighbours: that way the
   number in the comp is the number in the file, and a row's height stays the
   height of its text. */
.ld-drill .e-n-menu-heading,
.ld-drill .e-n-menu-content .elementor-nav-menu,
.ld-drill .e-n-menu-content .sub-menu {
	display: flex;
	flex-direction: column;
	gap: var(--ld-drill-gap);
}

/* The 16px belongs to the outer list only. A panel opens inside it, so its own
   list adding the same padding again gave two of them stacked — 32px above the
   first link and none of it in the comp. */
.ld-drill .e-n-menu-heading {
	padding-top: var(--ld-drill-pad-block);
	padding-bottom: var(--ld-drill-pad-block);
}

.ld-drill .e-n-menu-content .elementor-nav-menu {
	padding-top: 0;
	padding-bottom: 0;
}

/* The one gap the panel does need: between the back row and the box below it,
   the same 16 as everywhere else. */
.ld-drill .ld-mnav__back {
	margin-bottom: var(--ld-drill-pad-block);
}

.ld-drill .e-n-menu-content > .e-con {
	padding-top: var(--ld-drill-pad-block);
	padding-bottom: var(--ld-drill-pad-block);
}

/* A child list opening inside a panel already sits under its parent's gap, so
   it does not start another one. */
.ld-drill .e-n-menu-content .sub-menu {
	padding-top: var(--ld-drill-gap);
}

/* Only the items. The heading is the flex column that owns --ld-drill-gap,
   declared above; making it a block here is what was quietly cancelling that
   gap, since a block has nothing to space out. */
.ld-drill .e-n-menu-item {
	display: block;
	width: 100%;
}

/* The widget's alignment control centres the titles, which is right for a
   horizontal bar and wrong for a stacked list. Stated here because the control
   is aiming at the desktop layout that no longer exists at this width. */
.ld-drill .e-n-menu-title-container {
	display: flex;
	width: 100%;
	justify-content: flex-start;
	text-align: left;
}

/* The gap between sections came from the widget's own spacing controls, which
   were spacing items in a horizontal bar. Cleared so --ld-drill-step is the
   only thing deciding how tall a row is — otherwise the list breathes twice as
   much as the panels and the two screens do not look related. */
.ld-drill .e-n-menu-title,
.ld-drill .e-n-menu-item {
	margin: 0;
	padding: 0;
}

/* Elementor closes a panel by hiding the container inside .e-n-menu-content,
   not the wrapper itself. On a wide screen that is invisible either way, but
   here the wrapper also holds the back button — so without this every section
   shows its own back button at once, stacked beside the list. */
.ld-drill .e-n-menu-item:not(:has(.e-n-menu-dropdown-icon[aria-expanded="true"])) .e-n-menu-content {
	display: none;
}

/* A section is open, so the items that are not it step aside… */
.ld-drill .e-n-menu-heading:has(.e-n-menu-dropdown-icon[aria-expanded="true"])
	.e-n-menu-item:not(:has(.e-n-menu-dropdown-icon[aria-expanded="true"])) {
	display: none;
}

/* …and so does its own title, leaving the panel in its place. */
.ld-drill .e-n-menu-item:has(.e-n-menu-dropdown-icon[aria-expanded="true"]) .e-n-menu-title {
	display: none;
}

/* On a wide screen a panel hangs under the bar as a dropdown: taken out of the
   flow, given a stretch width, offset below the title. Here it IS the menu, so
   all of that has to go or it floats over the CTA at a fraction of the width.
 *
 * !important earns its place on exactly these two: Elementor's rule carries six
 * classes, and matching it would mean writing a selector that breaks the day
 * the widget's markup changes. The properties are layout-only, so nothing an
 * editor sets in the panel is being overruled. */
.ld-drill .e-n-menu-content {
	position: static !important;
	inset: auto !important;
	width: 100%;
	max-width: 100%;

	/* The widget's "Distance from content" — the air between the bar and its
	   dropdown on a wide screen. Here there is no bar to hang from, so it lands
	   as a second 16px on top of the panel. It comes from a rule six classes
	   deep, which is why a plain `padding-block-start: 0` was losing silently. */
	padding-block-start: 0 !important;
}

/* The container inside carries `position: var(--position); width: var(--width)`
   as an inline style, and an inline style outranks any stylesheet. So it is not
   overruled — it is handed different values for the variables it is already
   reading. */
.ld-drill .e-n-menu-content > .e-con {
	--width: 100%;
	--position: static;

	max-width: 100%;
}

/* The chevron on each section: the promise that there is a screen behind it,
   which the panel then keeps. Drawn from borders so it is the same mark as the
   back arrow, pointing the other way, and always the colour of its text. */
.ld-drill .e-n-menu-title-container::after {
	content: "";
	flex: none;
	margin-left: auto;
	width: 0.45em;
	height: 0.45em;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(-45deg);
}

/* --- Third level: accordion, not a flyout --------------------------------
 *
 * The WordPress Menu widget runs SmartMenus, which opens a child list as a
 * panel floating beside its parent. On a phone that lands half off screen —
 * "Purchase Rates" was covering the section it belongs to.
 *
 * SmartMenus keeps its job: it still decides when the list is open, sets
 * aria-expanded and shows it. All that changes is where the list is drawn.
 * Its positioning arrives as inline styles, which no stylesheet outranks, so
 * these carry !important. They are the only way to reach a value written on
 * the element itself.
 */
.ld-drill .e-n-menu-content .sub-menu {
	position: static !important;
	inset: auto !important;
	width: 100% !important;
	min-width: 0 !important;
	max-width: none !important;
	transform: none !important;

	/* SmartMenus dresses a flyout like a floating card — its own background,
	   border and shadow. Inside the panel it is not floating over anything, so
	   all of that reads as a stray white box. */
	background: none !important;
	border: 0 !important;
	box-shadow: none !important;
	margin: 0;
}

/* Set in from its parent, so the level reads as belonging to the item above
   rather than as three more links in the same list. */
.ld-drill .e-n-menu-content .sub-menu > li > a {
	padding-left: calc(var(--ld-drill-inset) * 1.75);
}

/* Open and closed are decided here, not by SmartMenus: it shows the list with
   an inline `display`, and a second tap on the parent follows its link instead
   of folding the list back. The class comes from the delegated handler in
   mobile-nav.js, and !important is what reaches past that inline style. */
.ld-drill .e-n-menu-content .menu-item-has-children > .sub-menu {
	display: none !important;
}

.ld-drill .e-n-menu-content .menu-item-has-children.ld-open > .sub-menu {
	display: flex !important;
}

/* A rule under the open group, so the three pages read as belonging to
   Purchase and not as more items in the list below it. */
.ld-drill .e-n-menu-content .menu-item-has-children.ld-open {
	padding-bottom: var(--ld-drill-gap);
	border-bottom: 1px solid var(--color-neutral-lighter, #D9D9D9);
}

/* The chevron is placed against the anchor's own right edge rather than pushed
   there by `margin-left: auto`. That trick needs the anchor to be a full-width
   flex box, and the nav widget has its own opinion about both — so the mark
   was landing next to the label instead. Absolute positioning does not care
   what `display` won the argument. */
/* Keyed on WordPress's own `menu-item-has-children`, not on SmartMenus'
   `has-submenu`. SmartMenus adds its class when it initialises, and inside a
   panel that has never been shown it waits — so the chevron was missing until
   the section had been opened once. The WordPress class is in the HTML from
   the server, before any script runs. */
.ld-drill .e-n-menu-content .menu-item-has-children > a {
	position: relative;
	padding-right: calc(var(--ld-drill-inset) + 1em);
}

/* The extra classes are for weight, not for meaning. The nav widget's "pointer"
   effect hides the pseudo-elements of an item that is not hovered, focused or
   current — and the chevron is one of them, so it was invisible until touched.
   That rule carries five classes; this one needs to carry as many. */
.ld-drill .e-n-menu-content .elementor-nav-menu .menu-item-has-children > a.elementor-item::after {
	content: "";
	position: absolute;
	top: 50%;
	right: var(--ld-drill-inset);
	width: 0.45em;
	height: 0.45em;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: translateY(-75%) rotate(45deg);
	transition: transform 0.2s ease;
	opacity: 1;
}

/* Rotation follows `ld-open`, the class this code owns, for the same reason:
   aria-expanded is SmartMenus' and is not there until it has run. */
.ld-drill .e-n-menu-content .elementor-nav-menu .menu-item-has-children.ld-open > a.elementor-item::after {
	transform: translateY(-25%) rotate(-135deg);
}

/* Closed, the row is one of the list; open, it is the heading of what is under
   it. The colour is the only thing saying which, so it has to follow the state
   rather than the page.
 *
 * Purchase Rates happens to be the current page here, and Elementor paints the
 * current item with the active colour — which is why it arrived purple while
 * closed. These selectors are deep enough to outrank that: the widget is
 * answering "where are you", and this row is answering "is this open". */
.ld-drill .e-n-menu-content .elementor-nav-menu .menu-item-has-children:not(.ld-open) > a {
	color: var(--color-scheme-1-text, #000);
}

.ld-drill .e-n-menu-content .elementor-nav-menu .menu-item-has-children.ld-open > a {
	color: var(--color-accent-purple03, #7A3FF6);
}

@media (prefers-reduced-motion: reduce) {
	.ld-drill .e-n-menu-content .menu-item-has-children > a::after {
		transition: none;
	}
}

/* --- Back button ---------------------------------------------------------
 *
 * Injected into every panel of every menu, so it is hidden by default and
 * only the drilled menu shows it. Without that, the desktop dropdowns get one
 * too.
 */
.ld-mnav__back {
	display: none;
}

/* Every state is listed because the Kit styles bare <button> elements site
   wide — a 1px border and an 8rem radius, plus a different pair on hover and
   focus. Those rules carry a class and an element each, so leaving any state
   out brings the green pill back the moment the button is touched. */
.ld-drill .ld-mnav__back,
.ld-drill .ld-mnav__back:hover,
.ld-drill .ld-mnav__back:focus,
.ld-drill .ld-mnav__back:active {
	display: flex;
	align-items: center;
	gap: 0.6em;
	width: 100%;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	font: inherit;
	font-weight: 600;
	color: var(--color-accent-purple03, #7A3FF6);
	text-align: left;
	cursor: pointer;
}

.ld-mnav__back::before {
	content: "";
	flex: none;
	width: 0.5em;
	height: 0.5em;
	border-left: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
}

.ld-mnav__back:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

/* --- Phone and account take over the panel -------------------------------
 *
 * Both menus live in the same popup, and the navigation has no toggle of its
 * own there — its list is simply always on. So opening the phone did not
 * "cover" anything: the numbers appeared above a list that never went away.
 *
 * The design has the numbers replacing the menu, which is the same rule the
 * sections already follow: one screen at a time. Keyed off the icons menu
 * having an item open, read from anywhere in the document because the two
 * widgets are not related closely enough to share a scope.
 */
/* Inside the popup: the numbers take the place of the navigation, one screen
   at a time. Scoped away from .ld-sheet, which is the header's copy and covers
   the page instead. */
body:has( .ld-tap:not( .ld-sheet ) .e-n-menu-dropdown-icon[aria-expanded="true"] ) .ld-drill,
body:has( .ld-tap:not( .ld-sheet ) .e-n-menu-dropdown-icon[aria-expanded="true"] ) .ld-drill-extra {
	display: none !important;
}

/* --- The phone and account panel as a full-height sheet ------------------
 *
 * The numbers sit on white at the top and the page behind is dimmed and
 * blurred, so the panel reads as a layer over the site rather than as a strip
 * that happens to be in the header.
 *
 * Where the sheet begins is measured from the widget itself, in
 * mobile-nav.js — a header's height depends on the logo, the admin bar and
 * whichever breakpoint is in play, so writing a number here would be wrong on
 * someone's screen the first day.
 */
.ld-sheet .e-n-menu-content.e-active {
	position: fixed !important;
	inset: var(--ld-sheet-top, 64px) 0 0 0 !important;
	z-index: 100;
	overflow-y: auto;

	background: rgba(255, 255, 255, 0.45);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
}

/* The numbers keep a solid ground: text over a blur is hard to read, and the
   blur is there to push the page back, not to sit behind the content. */
.ld-sheet .e-n-menu-content.e-active > .e-con {
	background: #fff;
}

/* --- Header disclosures (phone, account) ---------------------------------
 *
 * Not part of the menu: two strips that open under the header. Which numbers
 * they show is decided by the plugin's own loan-officer stylesheet, through
 * the data-ld-lo attribute — not here.
 */
.ld-drop[hidden] {
	display: none;
}

.ld-drop-toggle {
	cursor: pointer;
}

.ld-drop-toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}
