/*!
 * Yasiru Mega Menu — front-end styles.
 * Namespaced to .mega-menu-* (the same markup shape the yasiru-auto theme's
 * style.css already reserves two overrides for), so it never collides with
 * the theme's own .yap-nav / .yap-mega fallback — only one of the two ever
 * renders for a given location at a time.
 * Colors come from CSS custom properties printed inline by the plugin
 * (Yasiru_MM_Frontend::inline_colors()); the literal values below are only
 * a safety-net fallback if that inline block is ever stripped by caching.
 */

/*
 * The wrap stays unpositioned on purpose: "Full width" panels are placed
 * against the nearest positioned ancestor of the menu (in yasiru-auto that is
 * the edge-to-edge .yap-navbar), while "Container width" panels anchor to
 * their own top-level <li>.
 */
.mega-menu-wrap {
	position: static;
}

.mega-menu {
	display: flex;
	align-items: stretch;
	flex-wrap: wrap;
	gap: 2px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.mega-menu-item {
	position: relative;
	display: flex;
}

.mega-menu-link {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 15px 14px;
	font-family: var(--yap-font-heading, "Plus Jakarta Sans", sans-serif);
	font-weight: 600;
	font-size: 14px;
	letter-spacing: .3px;
	text-transform: uppercase;
	color: var(--mm-text, #101a2c);
	background-image: linear-gradient(var(--mm-accent, #e4232b), var(--mm-accent, #e4232b));
	background-repeat: no-repeat;
	background-size: 0 3px;
	background-position: right bottom;
	transition: background-size .22s ease, color .16s ease;
}

.mega-menu-link:hover,
.mega-menu-link:focus-visible,
.mega-menu-item.is-open > .mega-menu-link,
.mega-menu-item.current-menu-item > .mega-menu-link,
.mega-menu-item.current-menu-ancestor > .mega-menu-link,
.mega-menu-item.current_page_item > .mega-menu-link {
	background-size: 100% 3px;
	background-position: left bottom;
	color: var(--mm-accent, #e4232b);
}

.mega-menu-icon {
	font-size: 16px;
	line-height: 1.25;
}

.mega-menu-badge {
	display: inline-flex;
	align-items: center;
	padding: 1px 7px;
	border-radius: 999px;
	background: var(--mm-accent2, #f7941e);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .3px;
	text-transform: uppercase;
	line-height: 1.6;
}

.mega-menu-arrow {
	flex: none;
	transition: transform .2s ease;
}

.mega-menu-item.is-open > .mega-menu-link .mega-menu-arrow {
	transform: rotate(180deg);
}

.mega-menu-desc {
	display: block;
	margin-top: -6px;
	padding: 0 14px 8px;
	font-size: 11px;
	font-weight: 500;
	text-transform: none;
	letter-spacing: 0;
	color: #8a94a3;
}

/* Simple flyout — children present, mega panel not enabled on this item */
.mega-menu-item > .mega-sub-menu,
.mega-menu-link-item > .mega-sub-menu {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 240px;
	margin: 0;
	padding: 10px 0;
	list-style: none;
	background: var(--mm-panel-bg, #fff);
	border-top: 1px solid #eef1f5;
	border-radius: 0 0 12px 12px;
	box-shadow: 0 20px 38px var(--mm-panel-shadow, rgba(16, 26, 44, .14));
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity .18s ease, transform .18s ease, visibility .18s;
	z-index: 50;
}

.mega-menu-link-item > .mega-sub-menu {
	top: 0;
	left: 100%;
}

.mega-menu-item.is-open > .mega-sub-menu,
.mega-menu-link-item.is-open > .mega-sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.mega-menu-link-item {
	position: relative;
}

.mega-sub-menu .mega-menu-link {
	display: flex;
	padding: 9px 20px;
	font-size: 14px;
	font-weight: 500;
	text-transform: none;
	letter-spacing: 0;
	background-image: none;
}

.mega-sub-menu .mega-menu-link:hover,
.mega-sub-menu .mega-menu-link:focus-visible {
	color: var(--mm-accent2, #f7941e);
	background: #f8f9fb;
}

.mega-sub-menu .mega-menu-desc {
	padding: 0 20px 8px;
}

/* Mega panel — children present and the mega panel is enabled on this item */
.mega-menu-row {
	position: absolute;
	top: 100%;
	background: var(--mm-panel-bg, #fff);
	border-top: 1px solid #eef1f5;
	border-radius: 0 0 16px 16px;
	box-shadow: 0 26px 46px var(--mm-panel-shadow, rgba(16, 26, 44, .14));
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity .18s ease, transform .18s ease, visibility .18s;
	z-index: 45;
}

.mega-menu-width-container .mega-menu-row {
	left: 0;
	right: auto;
	width: min(1040px, 92vw);
}

.mega-menu-item:nth-last-child(-n+2).mega-menu-width-container .mega-menu-row {
	left: auto;
	right: 0;
}

.mega-menu-item.mega-menu-width-full {
	position: static;
}

.mega-menu-width-full .mega-menu-row {
	left: 0;
	right: 0;
	width: auto;
	border-radius: 0;
	box-shadow: 0 24px 44px var(--mm-panel-shadow, rgba(16, 26, 44, .14));
}

.mega-menu-item.is-open > .mega-menu-row {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.mega-menu-wrap[data-mm-sticky="1"] .mega-menu-row {
	max-height: calc(100vh - 96px);
	overflow-y: auto;
}

.mega-menu-columns {
	display: grid;
	grid-template-columns: repeat(var(--mm-columns, 4), minmax(0, 1fr));
	gap: 28px;
	max-width: 1280px;
	margin: 0 auto;
	padding: 26px 24px;
}

.mega-menu-columns--promo {
	grid-template-columns: repeat(var(--mm-columns, 4), minmax(0, 1fr)) minmax(0, 1.1fr);
}

/* Promo card — closes the panel, spanning every row of columns */
.mega-menu-promo {
	grid-column: -2 / -1;
	grid-row: 1 / span var(--mm-rows, 1);
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	padding: 24px;
	border-radius: 14px;
	background: linear-gradient(135deg, #101a2c, #1c2c45);
	color: #fff;
}

.mega-menu-promo__title {
	display: block;
	font-family: var(--yap-font-heading, "Plus Jakarta Sans", sans-serif);
	font-weight: 700;
	font-size: 20px;
	line-height: 1.1;
}

.mega-menu-promo__text {
	margin: 10px 0 0;
	font-size: 13.5px;
	line-height: 1.5;
	color: #aeb8c7;
}

.mega-menu-promo__btn {
	align-self: flex-start;
	margin-top: 18px;
	padding: 10px 18px;
	border-radius: 9px;
	background: var(--mm-accent2, #f7941e);
	color: #fff;
	font-family: var(--yap-font-heading, "Plus Jakarta Sans", sans-serif);
	font-weight: 600;
	font-size: 14px;
	line-height: normal;
	letter-spacing: .4px;
	text-transform: uppercase;
	transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}

.mega-menu-promo__btn:hover,
.mega-menu-promo__btn:focus-visible {
	color: #fff;
	filter: brightness(.92);
	transform: translateY(-2px);
	box-shadow: 0 12px 22px rgba(247, 148, 30, .4);
}

.mega-menu-column {
	min-width: 0;
}

.mega-menu-col-title {
	display: block;
	margin-bottom: 12px;
	padding-bottom: 8px;
	border-bottom: 1px solid #f0f2f6;
	font-family: var(--yap-font-heading, "Plus Jakarta Sans", sans-serif);
	font-weight: 700;
	font-size: 13px;
	line-height: normal;
	letter-spacing: .6px;
	text-transform: uppercase;
	color: var(--mm-accent, #e4232b);
}

a.mega-menu-col-title:hover,
a.mega-menu-col-title:focus-visible {
	color: var(--mm-accent2, #f7941e);
}

.mega-menu-col-desc {
	display: block;
	margin: -4px 0 10px;
	font-size: 12px;
	color: #8a94a3;
}

.mega-menu-col-links {
	list-style: none;
	margin: 0;
	padding: 0;
}

.mega-menu-col-links .mega-menu-link {
	display: block;
	padding: 6px 0;
	font-family: var(--yap-font-body, "Inter", sans-serif);
	font-size: 14.5px;
	line-height: normal;
	font-weight: 500;
	text-transform: none;
	letter-spacing: 0;
	color: #41505f;
	background-image: none;
}

.mega-menu-col-links .mega-menu-link:hover,
.mega-menu-col-links .mega-menu-link:focus-visible {
	color: var(--mm-accent2, #f7941e);
}

.mega-menu-col-links .mega-menu-desc {
	margin-top: -4px;
	padding: 0 0 6px;
}

.mega-menu-col-links .mega-sub-menu {
	position: static;
	visibility: visible;
	opacity: 1;
	transform: none;
	background: transparent;
	border: 0;
	box-shadow: none;
	padding: 0 0 0 14px;
}

/*
 * Brand logo grid layout — every rule is scoped to .mega-menu-brands, so
 * panels using the default link-column layout are never affected.
 */
.mega-menu-columns.mega-menu-brands {
	grid-template-columns: repeat(var(--mm-columns, 4), minmax(0, 1fr));
	gap: 14px;
}

.mega-menu-columns.mega-menu-brands.mega-menu-columns--promo {
	grid-template-columns: repeat(var(--mm-columns, 4), minmax(0, 1fr)) minmax(0, 1.5fr);
}

.mega-menu-brands .mega-menu-promo {
	margin-left: 14px;
}

.mega-menu-brands__head {
	grid-column: 1 / -1;
}

.mega-menu-brands.mega-menu-columns--promo .mega-menu-brands__head {
	grid-column: 1 / -2;
}

.mega-menu-brands__head .mega-menu-col-title {
	margin-bottom: 0;
}

.mega-menu-brand {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
	min-width: 0;
	padding: 12px 12px 13px;
	border: 1px solid #eef1f5;
	border-radius: 12px;
	background: #fff;
	text-align: center;
	transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.mega-menu-brand:hover,
.mega-menu-brand:focus-visible {
	border-color: rgba(228, 35, 43, .35);
	box-shadow: 0 12px 24px rgba(16, 26, 44, .08);
	transform: translateY(-2px);
}

.mega-menu-brand__logo {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 64px;
	margin-bottom: 7px;
	border-radius: 8px;
	overflow: hidden;
}

.mega-menu-brand__logo img {
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 10px;
}

/* Placeholder until a logo is set (menu item Logo field or the brand's thumbnail) */
.mega-menu-brand__logo--empty {
	flex-direction: column;
	gap: 2px;
	background: #f6f8fb;
	border: 1px dashed #d3dae4;
	color: #a7b1bf;
	font-family: var(--yap-font-body, "Inter", sans-serif);
	font-size: 10px;
	font-weight: 600;
	letter-spacing: .8px;
	text-transform: uppercase;
}

/* Name and count share one line; a long name truncates, the count never does */
.mega-menu-brand__label {
	display: flex;
	align-items: baseline;
	justify-content: center;
	gap: 5px;
	max-width: 100%;
	min-width: 0;
	white-space: nowrap;
}

.mega-menu-brand__name {
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-family: var(--yap-font-heading, "Plus Jakarta Sans", sans-serif);
	font-weight: 700;
	font-size: 13.5px;
	line-height: 1.2;
	letter-spacing: .5px;
	color: var(--mm-text, #101a2c);
	transition: color .16s ease;
}

.mega-menu-brand:hover .mega-menu-brand__name,
.mega-menu-brand:focus-visible .mega-menu-brand__name {
	color: var(--mm-accent, #e4232b);
}

.mega-menu-brand__sep,
.mega-menu-brand__meta {
	flex: none;
	font-family: var(--yap-font-body, "Inter", sans-serif);
	font-size: 12px;
	font-weight: 500;
	line-height: 1.2;
	color: #8a94a3;
}

.mega-menu-brand__sep {
	color: #c3cad5;
}

/* Optional "View all" tile that closes the grid */
.mega-menu-brand--all {
	flex-direction: row;
	justify-content: center;
	gap: 6px;
	border-style: dashed;
	border-color: #dfe4eb;
	background: #fafbfc;
	font-family: var(--yap-font-heading, "Plus Jakarta Sans", sans-serif);
	font-weight: 700;
	font-size: 13px;
	letter-spacing: .4px;
	text-transform: uppercase;
	color: var(--mm-accent, #e4232b);
}

.mega-menu-brand--all:hover,
.mega-menu-brand--all:focus-visible {
	color: var(--mm-accent2, #f7941e);
}

/* Slide-down open effect (alternative to the default fade) */
.mega-menu-wrap[data-mm-effect="slide"] .mega-menu-row,
.mega-menu-wrap[data-mm-effect="slide"] .mega-menu-item > .mega-sub-menu,
.mega-menu-wrap[data-mm-effect="slide"] .mega-menu-link-item > .mega-sub-menu {
	transform: translateY(-10px);
}

.mega-menu-wrap[data-mm-effect="slide"] .mega-menu-item.is-open > .mega-menu-row,
.mega-menu-wrap[data-mm-effect="slide"] .mega-menu-item.is-open > .mega-sub-menu,
.mega-menu-wrap[data-mm-effect="slide"] .mega-menu-link-item.is-open > .mega-sub-menu {
	transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
	.mega-menu-row,
	.mega-sub-menu,
	.mega-menu-arrow,
	.mega-menu-promo__btn,
	.mega-menu-brand,
	.mega-menu-brand__name {
		transition: none !important;
	}
}

/* Mobile — matches the yasiru-auto theme's own .yap-navbar breakpoint (900px) */
@media (max-width: 900px) {
	.mega-menu {
		flex-direction: column;
		align-items: stretch;
	}

	.mega-menu-item {
		display: block;
	}

	.mega-menu-link {
		width: 100%;
		padding: 13px 0;
	}

	/* Icon, text and badge stay together on the left; only the arrow goes right */
	.mega-menu-arrow {
		margin-left: auto;
	}

	.mega-menu-desc {
		padding: 0 0 8px;
	}

	.mega-menu-row,
	.mega-menu-width-full .mega-menu-row,
	.mega-menu-item > .mega-sub-menu,
	.mega-menu-link-item > .mega-sub-menu {
		position: static;
		display: none;
		width: auto;
		max-height: none;
		margin: 0;
		border: 0;
		border-radius: 0;
		box-shadow: none;
		opacity: 1;
		visibility: visible;
		transform: none;
	}

	.mega-menu-item.is-open > .mega-menu-row,
	.mega-menu-item.is-open > .mega-sub-menu,
	.mega-menu-link-item.is-open > .mega-sub-menu {
		display: block;
	}

	.mega-menu-columns,
	.mega-menu-columns--promo {
		grid-template-columns: 1fr;
		gap: 14px;
		padding: 4px 0 16px;
	}

	.mega-menu-promo {
		grid-column: auto;
		grid-row: auto;
		padding: 18px;
	}

	.mega-sub-menu .mega-menu-link-item > .mega-sub-menu {
		padding-left: 14px;
	}

	.mega-menu-columns.mega-menu-brands,
	.mega-menu-columns.mega-menu-brands.mega-menu-columns--promo {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 10px;
	}

	.mega-menu-brands__head,
	.mega-menu-brands.mega-menu-columns--promo .mega-menu-brands__head,
	.mega-menu-brands .mega-menu-promo {
		grid-column: 1 / -1;
	}

	.mega-menu-brands .mega-menu-promo {
		margin-left: 0;
	}

	.mega-menu-brand__logo {
		height: 48px;
	}

	.mega-menu-hide-mobile {
		display: none !important;
	}
}

@media (max-width: 480px) {
	.mega-menu-columns.mega-menu-brands,
	.mega-menu-columns.mega-menu-brands.mega-menu-columns--promo {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}
