/*
 * Bali Sands main menu (design 6a).
 *
 * 1. Menu images: the thumbnail + label + description rows added by
 *    includes/menu-thumbnails.php. Works in any menu.
 * 2. Dropdown panel defaults for the JetMenu "Mega Menu" widget that has the
 *    CSS class "bs-main-menu" (set by the setup on the header's menu widget).
 *    Anything you set in the widget's Style tab overrides these.
 *
 * Colours read Elementor's Global Colors.
 */

/* 1. Menu images ---------------------------------------------------------- */

.bs-has-thumb {
	--bs-menu-thumb-size: 36px;
	--bs-menu-thumb-radius: 7px;
	--bs-menu-thumb-gap: 12px;
}

.bs-menu-thumb {
	flex: none;
	display: inline-flex;
	width: var(--bs-menu-thumb-size);
	height: var(--bs-menu-thumb-size);
	margin-right: var(--bs-menu-thumb-gap);
	overflow: hidden;
	border-radius: var(--bs-menu-thumb-radius);
	background: var(--e-global-color-bs_photo, #E2D6BF);
	vertical-align: middle;
}

.bs-menu-thumb__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

.bs-menu-thumb__text {
	display: inline-flex;
	flex-direction: column;
	vertical-align: middle;
	text-align: left;
}

.bs-menu-thumb__label {
	white-space: nowrap;
	font-weight: 700;
	font-size: 15.5px;
	line-height: 1.25;
	color: var(--e-global-color-primary, #2F4034);
}

.bs-menu-thumb__desc {
	margin-top: 2px;
	font-weight: 400;
	font-size: 12.5px;
	line-height: 1.4;
	color: var(--e-global-color-bs_muted, #6B6355);
	white-space: nowrap;
}

/* On phones the panel can't be 400px wide, so let descriptions wrap there. */
@media (max-width: 767px) {
	.bs-menu-thumb__desc {
		white-space: normal;
	}
}

/*
 * The description is already shown beside the image, so hide the copy that
 * JetMenu (or a theme walker) prints under the item from the same field.
 */
.bs-has-thumb .jet-mega-menu-item__desc,
.bs-has-thumb .menu-item-description,
.bs-has-thumb .sub-menu-item-description {
	display: none !important;
}

/* Rows: thumbnail and text side by side, whatever wraps the title. */
.bs-has-thumb > a,
.bs-has-thumb .jet-mega-menu-item__link,
.bs-has-thumb .jet-mega-menu-item__title,
.bs-has-thumb .jet-mega-menu-item__label {
	display: flex;
	align-items: center;
}

/* 2. JetMenu dropdown panel ---------------------------------------------- */

.bs-main-menu .jet-mega-menu-item__link,
.bs-main-menu .jet-mega-menu-item__title {
	font-family: var(--e-global-typography-bs_nav-font-family, "Open Sans"), sans-serif;
}

/*
 * Dropdown size and spacing. JetMenu adds its own padding to several layers of
 * each row, so these are forced; change the custom properties to adjust:
 *   --bs-dropdown-width    minimum panel width
 *   --bs-dropdown-padding  space inside the panel border
 *   --bs-dropdown-row      padding inside each row (vertical horizontal)
 */
.bs-main-menu {
	--bs-dropdown-width: 400px;
	--bs-dropdown-padding: 8px;
	--bs-dropdown-row: 7px 10px;
}

@media (min-width: 1025px) {
	.bs-main-menu .jet-mega-menu-sub-menu,
	.bs-main-menu .jet-mega-menu-sub-menu__list {
		min-width: var(--bs-dropdown-width) !important;
	}
}

.bs-main-menu .jet-mega-menu .jet-mega-menu-sub-menu,
.bs-main-menu .jet-mega-menu-sub-menu {
	background: var(--e-global-color-bs_white, #FFFFFF);
	border: 2px solid var(--e-global-color-primary, #2F4034);
	border-radius: 14px;
	box-shadow: 0 18px 40px rgba(32, 28, 23, .16);
	padding: var(--bs-dropdown-padding) !important;
}

.bs-main-menu .jet-mega-menu-sub-menu__list {
	padding: 0 !important;
	margin: 0 !important;
	gap: 2px;
}

/* Only the link carries padding; the item and its wrapper add none. */
.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item,
.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item__inner {
	padding: 0 !important;
	margin: 0 !important;
}

/* Rows span the full panel width, so the hover tint does too. */
.bs-main-menu .jet-mega-menu-sub-menu__list {
	display: flex;
	flex-direction: column;
	align-items: stretch;
}

.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item,
.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item__inner,
.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item__link {
	width: 100%;
	max-width: none;
	box-sizing: border-box;
}

.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item__inner {
	display: flex;
}

.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item__link {
	display: flex;
	flex: 1 1 auto;
	justify-content: flex-start;
}

.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item__inner,
.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item__link {
	border-radius: 8px;
	background: transparent;
}

.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item__link {
	padding: var(--bs-dropdown-row) !important;
}

.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item__title,
.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item__label {
	padding: 0 !important;
	margin: 0 !important;
}

.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item:hover > .jet-mega-menu-item__inner,
.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item:hover > .jet-mega-menu-item__inner > .jet-mega-menu-item__link,
.bs-main-menu .jet-mega-menu-sub-menu .jet-mega-menu-item.jet-mega-menu-item--hover > .jet-mega-menu-item__inner {
	background: var(--e-global-color-bs_green_tint, #EEF4EA);
}

/*
 * Current section: the top-level item for the page you're on (or its parent)
 * is green with an underline, e.g. "Soils" on the Soils page.
 */
.bs-main-menu .jet-mega-menu-item--top-level.current-menu-item > .jet-mega-menu-item__inner > .jet-mega-menu-item__link,
.bs-main-menu .jet-mega-menu-item--top-level.current-menu-ancestor > .jet-mega-menu-item__inner > .jet-mega-menu-item__link,
.bs-main-menu .jet-mega-menu-item--top-level.current-menu-parent > .jet-mega-menu-item__inner > .jet-mega-menu-item__link,
.bs-main-menu .elementor-nav-menu--main > ul > li.current-menu-item > a,
.bs-main-menu .elementor-nav-menu--main > ul > li.current-menu-ancestor > a {
	color: var(--e-global-color-primary, #2F4034);
	box-shadow: inset 0 -2px 0 var(--e-global-color-primary, #2F4034);
}

/* "See all …" link at the foot of each dropdown. */
.bs-main-menu .jet-mega-menu-sub-menu .bs-see-all,
.bs-main-menu .bs-see-all {
	margin: 6px 0 0 !important;
	padding-top: 2px !important;
	border-top: 1px solid var(--e-global-color-bs_line, #ECE6DA);
}

.bs-main-menu .jet-mega-menu-sub-menu .bs-see-all .jet-mega-menu-item__link,
.bs-main-menu .bs-see-all > a {
	padding: 10px 6px 4px !important;
	font-weight: 700;
	font-size: 13.5px;
	color: var(--e-global-color-primary, #2F4034);
}

.bs-main-menu .bs-see-all:hover > .jet-mega-menu-item__inner,
.bs-main-menu .bs-see-all:hover .jet-mega-menu-item__link {
	background: transparent;
}

.bs-main-menu .bs-see-all .jet-mega-menu-item__label::after,
.bs-main-menu .bs-see-all > a::after {
	content: " →";
}

/*
 * Landscape supplies mega menu (JetMenu mega content, layout-mega-menu.php).
 * Same panel look as the dropdowns. On desktop it hangs from the header's
 * content box (the boxed header bar) and spans its full width, from the logo
 * to the "Get a quote" button. JetMenu would otherwise position it from the
 * menu item.
 */
@media (min-width: 1025px) {
	/* Everything between the panel and the header bar's content box stops being its anchor… */
	.bs-header .e-con:has(.bs-main-menu),
	.bs-header .bs-main-menu,
	.bs-main-menu > .elementor-widget-container,
	.bs-main-menu .jet-mega-menu,
	.bs-main-menu .jet-mega-menu-container,
	.bs-main-menu .jet-mega-menu-list,
	.bs-main-menu .jet-mega-menu-item--top-level:has(.jet-mega-menu-mega-container),
	.bs-main-menu .jet-mega-menu-item--top-level.bs-mega-item {
		position: static !important;
	}

	/* Ordinary dropdowns (Bali imports) still open under their own item. */
	.bs-main-menu .jet-mega-menu-item--top-level:not(.bs-mega-item):not(:has(.jet-mega-menu-mega-container)) {
		position: relative !important;
	}

	/*
	 * The menu fills the header bar's height, so every dropdown (and the mega
	 * panel) opens flush with the bar's bottom edge, with no gap to cross.
	 */
	.bs-header .e-con:has(.bs-main-menu),
	.bs-header .bs-main-menu {
		align-self: stretch !important;
	}

	.bs-main-menu > .elementor-widget-container,
	.bs-main-menu .jet-mega-menu,
	.bs-main-menu .jet-mega-menu-container,
	.bs-main-menu .jet-mega-menu-list {
		height: 100%;
	}

	.bs-main-menu .jet-mega-menu-list {
		align-items: stretch !important;
	}

	.bs-main-menu .jet-mega-menu-item--top-level {
		display: flex !important;
		align-items: center;
	}

	.bs-main-menu .jet-mega-menu-item--top-level > .jet-mega-menu-sub-menu {
		top: 100% !important;
		margin-top: 0 !important;
	}

	/* …so the boxed content area is. */
	.bs-header .e-con-inner:has(.bs-main-menu) {
		position: relative;
	}

	.bs-main-menu .jet-mega-menu-mega-container {
		width: auto !important;
		max-width: none !important;
		top: 100% !important;
		left: 0 !important;
		right: 0 !important;
		transform: none !important;
	}

	/* An invisible strip above the panel, so the pointer can move from the menu item to the panel without it closing. */
	.bs-main-menu .jet-mega-menu-mega-container::before {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		bottom: 100%;
		height: 32px;
	}
}

.bs-main-menu .jet-mega-menu-mega-container__inner {
	padding: 0 !important;
	background: var(--e-global-color-bs_white, #FFFFFF);
	border: 2px solid var(--e-global-color-primary, #2F4034);
	border-radius: 14px;
	box-shadow: 0 18px 40px rgba(32, 28, 23, .16);
	overflow: hidden;
}

/*
 * Mega menu content (layout-mega-menu.php): category tabs on the left, the
 * active category's pane on the right (assets/js/mega-menu.js switches them).
 */
.bs-mega a,
.bs-mega a:hover {
	color: inherit;
	text-decoration: none;
}

.bs-mega__thumb img {
	display: block;
	object-fit: cover;
}

/* Tabs: the active one is white with an arrow. */
.bs-mega__tab {
	transition: background-color .15s ease;
}

.bs-mega__tab.is-active {
	background: var(--e-global-color-bs_white, #FFFFFF);
	--background-color: var(--e-global-color-bs_white, #FFFFFF);
}

.bs-mega__tab .bs-mega__arrow {
	visibility: hidden;
}

.bs-mega__tab.is-active .bs-mega__arrow {
	visibility: visible;
}

/* Only the active pane shows. */
.bs-mega__pane:not(.is-active) {
	display: none !important;
}

.bs-mega__title .elementor-heading-title {
	font-weight: 800;
}

/* Sub-category cards: green border on hover. */
.bs-mega__card {
	transition: border-color .15s ease, box-shadow .15s ease;
}

.bs-mega__card:hover {
	border-color: var(--e-global-color-primary, #2F4034) !important;
	box-shadow: 0 6px 16px rgba(32, 28, 23, .08);
}

/*
 * Products in the pane ([bs_mega_products]): the same cards. While a category
 * has Products, its sub-category cards are hidden; with none, the shortcode
 * prints nothing and the sub-category cards show.
 */
.bs-mega-products {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 12px;
	margin-top: 18px;
}

.bs-mega__pane:has(.bs-mega-products) .bs-mega__cards {
	display: none !important;
}

.bs-mega .bs-mega-product {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 8px;
	border: 1px solid var(--e-global-color-bs_line, #ECE6DA);
	border-radius: 12px;
	background: var(--e-global-color-bs_white, #FFFFFF);
	color: var(--e-global-color-bs_ink, #201C17);
	transition: border-color .15s ease, box-shadow .15s ease;
}

.bs-mega .bs-mega-product:hover {
	border-color: var(--e-global-color-primary, #2F4034);
	box-shadow: 0 6px 16px rgba(32, 28, 23, .08);
	color: var(--e-global-color-bs_ink, #201C17);
}

.bs-mega-product__thumb {
	flex: none;
	width: 52px;
	height: 52px;
	overflow: hidden;
	border-radius: 8px;
	background: var(--e-global-color-bs_photo, #E2D6BF);
}

.bs-mega-product__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	border-radius: 0;
}

.bs-mega-product__name {
	min-width: 0;
	font-family: var(--e-global-typography-bs_card-font-family, "Open Sans"), sans-serif;
	font-weight: var(--e-global-typography-bs_card-font-weight, 700);
	font-size: var(--e-global-typography-bs_card-font-size, 15.5px);
	line-height: 1.25;
}

.bs-mega__cards {
	grid-template-rows: none !important;
	grid-auto-rows: auto !important;
	--e-con-grid-template-rows: none;
	align-content: start;
}

/* Same panel look for Elementor Pro's Nav Menu if it is used instead of JetMenu. */
.bs-main-menu .elementor-nav-menu--main .sub-menu {
	min-width: min(var(--bs-dropdown-width), calc(100vw - 32px)) !important;
	padding: var(--bs-dropdown-padding);
	background: var(--e-global-color-bs_white, #FFFFFF);
	border: 2px solid var(--e-global-color-primary, #2F4034);
	border-radius: 14px;
	box-shadow: 0 18px 40px rgba(32, 28, 23, .16);
}

.bs-main-menu .elementor-nav-menu--main .sub-menu a {
	width: 100%;
	box-sizing: border-box;
	border-radius: 8px;
	padding: var(--bs-dropdown-row) !important;
}

.bs-main-menu .elementor-nav-menu--main .sub-menu a:hover {
	background: var(--e-global-color-bs_green_tint, #EEF4EA);
}

/*
 * Phones and tablets (JetMenu's mobile menu, under the ✕ / ☰ toggle).
 * The menu panel drops down under the header bar at the full screen width,
 * instead of inside the narrow column the toggle sits in, and scrolls if it's
 * taller than the screen. Sub-menus and the Landscape supplies mega content
 * open inline, indented, without the desktop panel's border and shadow.
 * Matches the widget's mobile breakpoint (Tablet, 1024px) in its settings.
 */
@media (max-width: 1024px) {
	/* The header bar is the panel's anchor; nothing between them is. */
	.bs-header > .e-con:has(.bs-main-menu) {
		position: relative !important;
	}

	.bs-header .e-con-inner:has(.bs-main-menu),
	.bs-header .e-con .e-con:has(.bs-main-menu),
	.bs-header .bs-main-menu,
	.bs-main-menu > .elementor-widget-container,
	.bs-main-menu .jet-mega-menu {
		position: static !important;
	}

	/*
	 * Only the panel's position is set here. JetMenu shows and hides it (it may
	 * collapse it rather than remove it), so its look goes on the list inside:
	 * nothing shows under the header while the menu is closed.
	 */
	.bs-main-menu .jet-mega-menu-container {
		position: absolute !important;
		top: 100% !important;
		left: 0 !important;
		right: 0 !important;
		width: auto !important;
		max-width: none !important;
		z-index: 100;
	}

	.bs-main-menu .jet-mega-menu-list {
		flex-direction: column !important;
		flex-wrap: nowrap !important;
		align-items: stretch;
		width: 100%;
		max-height: calc(100vh - 120px);
		overflow-y: auto;
		box-sizing: border-box;
		margin: 0 !important;
		padding: 8px 16px 16px !important;
		background: var(--e-global-color-bs_white, #FFFFFF);
		border-top: 1px solid var(--e-global-color-bs_line, #ECE6DA);
		box-shadow: 0 18px 40px rgba(32, 28, 23, .16);
	}

	/* Every top-level row the same height, with or without a dropdown. */
	.bs-main-menu .jet-mega-menu-item--top-level {
		margin: 0 !important;
		padding: 0 !important;
		min-height: 0 !important;
		border-bottom: 1px solid var(--e-global-color-bs_line, #ECE6DA);
	}

	.bs-main-menu .jet-mega-menu-item--top-level > .jet-mega-menu-item__inner {
		display: flex !important;
		align-items: center;
		margin: 0 !important;
		padding: 0 !important;
		min-height: 0 !important;
	}

	.bs-main-menu .jet-mega-menu-item--top-level > .jet-mega-menu-item__inner > .jet-mega-menu-item__link {
		display: flex;
		flex: 1 1 auto;
		align-items: center;
		margin: 0 !important;
		padding: 14px 4px !important;
		min-height: 0 !important;
		font-size: 16px;
		line-height: 1.4;
	}

	/* The dropdown arrow adds no height of its own. */
	.bs-main-menu .jet-mega-menu-item--top-level > .jet-mega-menu-item__inner > .jet-mega-menu-item__dropdown {
		flex: none;
		align-self: stretch;
		display: flex;
		align-items: center;
		margin: 0 !important;
		padding: 0 8px !important;
		min-height: 0 !important;
	}

	/* No current-section underline in the list; the label stays green. */
	.bs-main-menu .jet-mega-menu-item--top-level > .jet-mega-menu-item__inner > .jet-mega-menu-item__link {
		box-shadow: none !important;
	}

	.bs-main-menu .jet-mega-menu .jet-mega-menu-sub-menu,
	.bs-main-menu .jet-mega-menu-sub-menu,
	.bs-main-menu .jet-mega-menu-mega-container {
		position: static !important;
		width: auto !important;
		min-width: 0 !important;
		max-width: none !important;
		transform: none !important;
		/* No margin or padding here: JetMenu collapses this box when closed, so
		   anything on it would still take up room. Spacing goes on the inside. */
		margin: 0 !important;
		padding: 0 !important;
		border: 0 !important;
		border-radius: 0 !important;
		box-shadow: none !important;
	}

	.bs-main-menu .jet-mega-menu-sub-menu__list {
		min-width: 0 !important;
		padding: 0 0 10px 8px !important;
	}

	.bs-main-menu .jet-mega-menu-mega-container__inner {
		border: 0;
		border-radius: 0;
		box-shadow: none;
		padding: 0 0 10px !important;
	}

	.bs-main-menu .bs-menu-thumb__label,
	.bs-main-menu .bs-menu-thumb__desc {
		white-space: normal;
	}

	/* A row's dropdown or mega content opens below it, not beside it; rows
	   never squash to fit the screen (the list scrolls instead). */
	.bs-main-menu .jet-mega-menu-item--top-level {
		display: block !important;
		flex-shrink: 0 !important;
	}

	/*
	 * Landscape supplies on phones: no tab list; every category's pane stacked,
	 * with its sub-categories as plain links (no thumbnails or card borders).
	 */
	.bs-main-menu .bs-mega {
		display: block !important;
		padding: 0 0 6px 8px !important;
		background: transparent !important;
	}

	.bs-main-menu .bs-mega__nav,
	.bs-main-menu .bs-mega__pane > .elementor-widget-heading,
	.bs-main-menu .bs-mega__thumb,
	.bs-main-menu .bs-mega__all {
		display: none !important;
	}

	.bs-main-menu .bs-mega__panes {
		padding: 0 !important;
		--padding-top: 0px;
		--padding-right: 0px;
		--padding-bottom: 0px;
		--padding-left: 0px;
	}

	.bs-main-menu .bs-mega__pane,
	.bs-main-menu .bs-mega__pane:not(.is-active) {
		display: flex !important;
		margin-bottom: 10px;
	}

	.bs-main-menu .bs-mega__title .elementor-heading-title {
		font-size: 15.5px;
	}

	.bs-main-menu .bs-mega__cards {
		margin-top: 4px !important;
		--margin-top: 4px;
		gap: 0 !important;
		--gap: 0px;
		--row-gap: 0px;
		--column-gap: 16px;
		grid-template-columns: 1fr 1fr !important;
	}

	.bs-main-menu .bs-mega__card {
		padding: 6px 0 !important;
		border: 0 !important;
		box-shadow: none !important;
		background: transparent !important;
	}

	.bs-main-menu .bs-mega__card .elementor-heading-title {
		font-weight: 400;
		color: var(--e-global-color-text, #4D463B);
	}
}
