/**
 * Native mega-menu dropdown variants (full / half / 3-column), rendered by
 * the Ron_Mega_Menu walker (inc/mega-menu/class-ron-mega-menu.php).
 */

.ron-megamenu.ron-megamenu-full {
	left: 0;
	right: 0;
	width: 100%;
	max-width: var(--ron-container-width);
	margin: 0 auto;
	display: none;
	padding: 24px;
	grid-template-columns: repeat(4, 1fr);
	gap: 24px;
}

/* `.ron-primary-nav--below` (Header Layout 1's own separate nav row —
   see templates/header/logo-search-cart.php) added alongside
   `.ron-header-row` so this full-width centered treatment applies
   whenever the mega-menu's parent `<li>` has had its own `position`
   stripped (see the matching `.ron-has-megamenu { position: static }`
   rules in ron-header-footer.css, and the long comment there) —
   Header Layouts 2/3 always had their nav inside `.ron-header-row`, so
   they always got this; Layout 1 needed the same treatment extended to
   its own separate row.

   Follow-up fix: scoped to `.ron-mega-width-full` — reported live:
   "need to add grid css for .ron-megamenu-half, if i set half then
   showing full width". This rule used to match ANY `.ron-has-megamenu`
   regardless of its chosen width, so a half or 3-column mega item's wrap
   was unconditionally stretched to `width: 100%; max-width: var(--ron-
   container-width)` — full container width — no matter what "Mega-menu
   dropdown width" was actually set to. Half/3col items are no longer
   promoted to `position: static` at all (see ron-header-footer.css), so
   their wrap stays anchored to their own `<li>` like a plain dropdown —
   this selector only needs to keep matching the full-width case now. */
.ron-header-row .ron-menu-item.ron-has-megamenu.ron-mega-width-full:hover .ron-submenu-wrap,
.ron-primary-nav--below .ron-menu-item.ron-has-megamenu.ron-mega-width-full:hover .ron-submenu-wrap {
	display: block;
	left: 50%;
	transform: translateX(-50%);
	width: 100%;
	max-width: var(--ron-container-width);
}

.ron-megamenu.ron-megamenu-full,
.ron-megamenu.ron-megamenu-half,
.ron-megamenu.ron-megamenu-3col {
	display: grid;
}

.ron-menu-item.ron-has-megamenu:hover .ron-megamenu {
	display: grid;
}

/* Follow-up fix: this rule used to be ONLY `min-width: 480px`, with no
   `grid-template-columns` of its own at all — so a "Half width" mega
   menu never actually became a multi-column grid; it fell back to CSS
   Grid's own default (`grid-template-columns: none`, a single implicit
   column), and — combined with the wrap always stretching to full
   container width, fixed above — rendered as one column of items
   stretched across the whole page instead of a compact two-column
   panel. `repeat(2, 1fr)` gives it the same real grid treatment "Full
   width" (4 columns) and "3-Column width" (3 columns) already had. */
.ron-megamenu-half {
	grid-template-columns: repeat(2, 1fr);
	min-width: 480px;
	padding: 24px;
	gap: 24px;
}

.ron-megamenu-3col {
	grid-template-columns: repeat(3, 1fr);
	min-width: 640px;
}

/* Follow-up feature: per-sub-item thumbnail image (see the long comment
   on `$has_thumb` in class-ron-mega-menu.php `start_el()`). `.ron-menu-
   link-row` is the inner flex row (icon/label/badge/caret) a thumb link
   uses instead of putting those directly in `.ron-menu-link` itself —
   `.ron-menu-link--thumb` (ron-header-footer.css) switches the OUTER
   link to a column so the thumbnail image and this row stack vertically. */
.ron-megamenu .ron-menu-link-row {
	display: flex;
	align-items: center;
	gap: 6px;
}

/* CSS Grid items default to `align-items: stretch`, so once any column
   in a mega-menu row carries a thumbnail (making that row taller), every
   OTHER column's `<li>` in the same row stretches to match — but a link
   with no thumbnail of its own would then just sit pinned to the top of
   that now-taller cell with dead space below it, looking accidental
   rather than intentional. Filling the `<li>`'s full stretched height and
   centering its content keeps a plain icon+label link looking deliberate
   next to a taller thumbnail column in the same row. */
.ron-megamenu li:not(.ron-megamenu-static) > .ron-menu-link {
	height: 100%;
	justify-content: center;
}

.ron-megamenu li:not(.ron-megamenu-static) > .ron-menu-link--thumb {
	justify-content: flex-start;
}

/* Follow-up fix, reported after 1.0.15 shipped: "Enabled mega-menu
   dropdown and promo attached image not showing with image promo link."
   The walker (class-ron-mega-menu.php) was already correctly outputting
   the `<li class="ron-megamenu-static"><a href="..."><img ...></a></li>`
   markup whenever a promo image is set — confirmed by running the actual
   shipped PHP class directly against test data outside WordPress, not
   just reading it. The bug was here instead: this grid cell had no
   height of its own beyond `grid-column: span 1`, and the `img` rule
   below it used `height: auto`, which only ever resolves to the image's
   OWN natural size — nothing forced this cell to be as tall as an actual
   promo photo, only as tall as whatever the row's OTHER cells needed
   (the plain category links next to it, a single line of text). Grid
   rows auto-size to their tallest cell, so if the image hasn't finished
   loading yet, or the browser hasn't laid out its intrinsic size before
   first paint, or a slow connection delays it, the whole row — and with
   it this cell — can render at basically zero usable height, making a
   perfectly correctly-saved image effectively invisible: present in the
   DOM, occupying no visible space next to it. Confirmed exactly this
   zero-height collapse in a local reproduction of the real walker output.
   Fixed with an explicit `min-height` on the cell itself (guarantees the
   row can never collapse below a sensible size regardless of image load
   timing) and switching the image to `height: 100%; object-fit: cover`
   (fills that guaranteed space immediately, no longer waiting on its own
   natural size to determine layout). */
.ron-megamenu-static {
	grid-column: span 1;
	min-height: 180px;
	display: block;
}

.ron-megamenu-static a {
	display: block;
	height: 100%;
}

.ron-megamenu-static img {
	border-radius: var(--ron-border-radius);
	width: 100%;
	height: 100%;
	min-height: 180px;
	object-fit: cover;
	display: block;
}

.ron-megamenu .ron-submenu-wrap {
	position: static;
	box-shadow: none;
}

@media (max-width: 960px) {
	.ron-megamenu,
	.ron-megamenu-half,
	.ron-megamenu-3col {
		display: block !important;
		position: static;
		min-width: 0;
		grid-template-columns: 1fr;
		box-shadow: none;
		padding: 0 0 0 16px;
	}
}

/* Mobile off-canvas nav (JS toggled — see assets/js/ron-theme.js) */

@media (max-width: 960px) {
	.ron-primary-nav.ron-mobile-open {
		display: block;
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		width: 300px;
		max-width: 85vw;
		background: #fff;
		z-index: 999;
		overflow-y: auto;
		box-shadow: 8px 0 30px rgba(0,0,0,0.15);
		padding: 20px;
	}

	.ron-primary-nav.ron-mobile-open ul.ron-reset {
		flex-direction: column;
	}

	.ron-primary-nav .ron-submenu-wrap {
		position: static;
		box-shadow: none;
		display: none;
	}

	.ron-primary-nav .ron-menu-item.ron-submenu-open > .ron-submenu-wrap {
		display: block;
	}

	.ron-mobile-nav-overlay {
		display: none;
		position: fixed;
		inset: 0;
		background: rgba(0,0,0,0.4);
		z-index: 998;
	}

	.ron-mobile-nav-overlay.ron-active {
		display: block;
	}
}
