/**
 * Mega Menu — front-end styles.
 * All tunable values come from CSS variables printed by the settings page
 * (see class-settings.php :: print_css_vars). Fallbacks match the defaults.
 */

.megamenu {
	--mm-font: inherit;
	--mm-bar-size: 17px;
	--mm-bar-weight: 600;
	--mm-title-size: 18px;
	--mm-title-weight: 700;
	--mm-desc-size: 15px;
	--mm-desc-weight: 400;
	--mm-bar-text: #1b1b4d;
	--mm-bar-hover: #1b1b4d;
	--mm-accent: #e0a800;
	--mm-title: #1b1b4d;
	--mm-desc: #6b7280;
	--mm-panel-bg: #fff;
	--mm-panel-brd: #eceef3;
	--mm-icon-bg: #f3f4f8;
	--mm-icon: #1b1b4d;
	--mm-panel-max: 960px;
	--mm-panel-pad: 28px;
	--mm-panel-radius: 18px;
	--mm-icon-size: 52px;
	--mm-icon-radius: 14px;
	--mm-item-gap: 28px;
	--mm-bar-gap: 36px;
	--mm-shadow: 0 24px 60px rgba(20, 22, 60, 0.14);

	/* Mobile drawer */
	--mm-m-link-size: 18px;
	--mm-m-link-weight: 500;
	--mm-m-link-pad: 16px;
	--mm-m-text: #1b1b4d;
	--mm-m-divider: #eceef3;
	--mm-m-divider-w: 1px;
	--mm-m-drawer-bg: #fff;

	/* Hamburger */
	--mm-burger-size: 24px;
	--mm-burger-color: #1b1b4d;
	--mm-burger-thickness: 2px;

	/* Close (X) button */
	--mm-x-icon-size: 22px;
	--mm-x-color: #d6336c;
	--mm-x-bg: transparent;
	--mm-x-border: #e9b8c9;
	--mm-x-border-w: 1px;
	--mm-x-size: 44px;
	--mm-x-radius: 12px;

	font-family: var(--mm-font);
	position: relative;
	z-index: 100;
}

.megamenu *,
.megamenu *::before,
.megamenu *::after {
	box-sizing: border-box;
}

/* ---------- Top bar ---------- */
.megamenu__bar {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	gap: var(--mm-bar-gap, 36px);
	flex-wrap: wrap;
}

.megamenu__item {
	position: static; /* panel is positioned relative to the bar/nav */
}

.megamenu__link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 10px 2px;
	color: var(--mm-bar-text);
	font-size: var(--mm-bar-size);
	font-weight: var(--mm-bar-weight);
	line-height: 1.2;
	text-decoration: none;
	border: 0;
	background: none;
	cursor: pointer;
	position: relative;
	white-space: nowrap;
}

.megamenu__link::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 2px;
	height: 2px;
	background: var(--mm-accent);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform 0.22s ease;
}

.megamenu__item.is-current > .megamenu__link::after,
.megamenu__item:hover > .megamenu__link::after,
.megamenu__item:focus-within > .megamenu__link::after,
.megamenu__item.is-open > .megamenu__link::after {
	transform: scaleX(1);
}

.megamenu__item:hover > .megamenu__link,
.megamenu__item.is-open > .megamenu__link {
	color: var(--mm-bar-hover);
}

.megamenu__caret {
	transition: transform 0.22s ease;
}

/* point the chevron down by default, flip up when open (icon drawn as a "^") */
.megamenu__caret {
	transform: rotate(180deg);
}

.megamenu__item:hover > .megamenu__link .megamenu__caret,
.megamenu__item.is-open > .megamenu__link .megamenu__caret,
.megamenu__item:focus-within > .megamenu__link .megamenu__caret {
	transform: rotate(0deg);
}

/* ---------- Panel ---------- */
.megamenu__panel {
	position: absolute;
	left: 50%;
	transform: translate(-50%, 8px);
	top: 100%;
	width: min(var(--mm-panel-max), calc(100vw - 32px));
	background: var(--mm-panel-bg);
	border: 1px solid var(--mm-panel-brd);
	border-radius: var(--mm-panel-radius);
	box-shadow: var(--mm-shadow);
	padding: var(--mm-panel-pad);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

.megamenu__item:hover > .megamenu__panel,
.megamenu__item:focus-within > .megamenu__panel,
.megamenu__item.is-open > .megamenu__panel {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translate(-50%, 12px);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Invisible hover bridge: spans the gap between the bar item and the panel so
   moving the cursor down into the panel never drops :hover (which would close
   it). Only active while the panel is open (panel has pointer-events then). */
.megamenu__panel::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: -18px;
	height: 18px;
}

.megamenu__panel-inner {
	display: flex;
	gap: var(--mm-panel-pad);
	align-items: stretch;
}

.megamenu__content {
	flex: 1 1 auto;
	min-width: 0;
}

/* ---------- Cards ---------- */
.megamenu__cards {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: var(--mm-item-gap);
}

.megamenu__panel--flat .megamenu__cards {
	grid-template-columns: 1fr;
}

/* columns layout */
.megamenu__panel--columns .megamenu__content {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: var(--mm-panel-pad);
}

.megamenu__col-title {
	display: block;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--mm-desc);
	margin: 0 0 14px;
	text-decoration: none;
}
a.megamenu__col-title:hover {
	color: var(--mm-accent);
}

.megamenu__card {
	margin: 0;
}

.megamenu__card-link {
	display: flex;
	align-items: flex-start;
	gap: 18px;
	padding: 10px;
	margin: -10px;
	border-radius: 12px;
	text-decoration: none;
	transition: background 0.18s ease;
}

.megamenu__card-link:hover,
.megamenu__card-link:focus-visible {
	background: var(--mm-icon-bg);
	outline: none;
}

.megamenu__card-icon {
	flex: 0 0 var(--mm-icon-size);
	width: var(--mm-icon-size);
	height: var(--mm-icon-size);
	border-radius: var(--mm-icon-radius);
	background: var(--mm-icon-bg);
	display: grid;
	place-items: center;
	color: var(--mm-icon);
	overflow: hidden;
}

.megamenu__card-icon-img {
	width: 56%;
	height: 56%;
	object-fit: contain;
	display: block;
}

.megamenu__card-body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding-top: 2px;
	min-width: 0;
}

.megamenu__card-title {
	color: var(--mm-title);
	font-size: var(--mm-title-size);
	font-weight: var(--mm-title-weight);
	line-height: 1.25;
}

.megamenu__card-desc {
	color: var(--mm-desc);
	font-size: var(--mm-desc-size);
	font-weight: var(--mm-desc-weight);
	line-height: 1.4;
}

/* ---------- Promo ---------- */
.megamenu__panel--has-promo .megamenu__promo {
	flex: 0 0 38%;
	max-width: 38%;
	border-radius: 14px;
	overflow: hidden;
	background: var(--mm-icon-bg);
}

.megamenu__promo-link {
	display: block;
	height: 100%;
	text-decoration: none;
	color: inherit;
}

.megamenu__promo-media,
.megamenu__promo-img {
	display: block;
	width: 100%;
}

.megamenu__promo-img {
	height: auto;
	object-fit: cover;
}

.megamenu__promo-body {
	display: block;
	padding: 18px 20px;
}

.megamenu__promo-title {
	display: block;
	color: var(--mm-title);
	font-size: var(--mm-title-size);
	font-weight: var(--mm-title-weight);
	margin-bottom: 6px;
}

.megamenu__promo-text {
	display: block;
	color: var(--mm-desc);
	font-size: var(--mm-desc-size);
	line-height: 1.45;
}

.megamenu__promo-btn {
	display: inline-block;
	margin-top: 14px;
	padding: 9px 18px;
	border-radius: 999px;
	background: var(--mm-accent);
	color: #1b1b4d;
	font-weight: 600;
	font-size: 14px;
}

/* Neutralize theme button styling. Some theme resets give every <button> a
   border, radius, color and padding (e.g. reset.css `button{border:1px solid}`).
   Scoped to .megamenu so our toggle/close start from a clean slate; our own
   button rules below use `.megamenu .megamenu__*` to stay above this and the
   theme regardless of stylesheet load order. */
.megamenu button {
	font: inherit;
	color: inherit;
	line-height: normal;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	text-transform: none;
	-webkit-appearance: none;
	appearance: none;
}

/* ---------- Hamburger toggle (hidden on desktop) ---------- */
.megamenu .megamenu__toggle {
	display: none;
	border: 0;
	background: none;
	cursor: pointer;
	padding: 10px;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.megamenu__toggle span {
	display: block;
	height: var(--mm-burger-thickness, 2px);
	width: var(--mm-burger-size, 24px);
	background: var(--mm-burger-color, var(--mm-bar-text));
	border-radius: 2px;
	transition: transform 0.25s ease, opacity 0.2s ease;
}

.megamenu__toggle span + span {
	margin-top: calc(var(--mm-burger-size, 24px) * 0.28);
}

.megamenu .megamenu__toggle--custom {
	justify-content: center;
	align-items: center;
	padding: 6px;
}

.megamenu__toggle-img {
	width: var(--mm-burger-size, 24px);
	height: auto;
	object-fit: contain;
	display: block;
}

/* In-drawer close (X) button — hidden until the mobile drawer is active. */
.megamenu__close-li {
	display: none;
	list-style: none;
	margin: 0;
}

.megamenu .megamenu__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--mm-x-size);
	height: var(--mm-x-size);
	padding: 8px;
	border: var(--mm-x-border-w) solid var(--mm-x-border);
	background: var(--mm-x-bg);
	color: var(--mm-x-color);
	cursor: pointer;
	border-radius: var(--mm-x-radius);
	transition: opacity 0.18s ease, background 0.18s ease;
}

.megamenu .megamenu__close:hover,
.megamenu .megamenu__close:focus-visible {
	opacity: 0.75;
	outline: none;
}

/* Custom uploaded X: show the artwork alone, no button border/background/box. */
.megamenu .megamenu__close--custom {
	width: auto;
	height: auto;
	padding: 4px;
	border: 0;
	background: none;
	border-radius: 0;
}

.megamenu__close svg {
	width: var(--mm-x-icon-size, 22px);
	height: var(--mm-x-icon-size, 22px);
	display: block;
}

.megamenu__close-img {
	width: var(--mm-x-icon-size, 22px);
	height: var(--mm-x-icon-size, 22px);
	object-fit: contain;
	display: block;
}

/* ====================================================================== */
/* Mobile — an inline <head> script adds html.mm-mobile at or below the     */
/* configured breakpoint, BEFORE first paint, so there is no flash of the   */
/* desktop menu. The footer script then handles open/close behavior.        */
/* ====================================================================== */
.mm-mobile .megamenu .megamenu__toggle {
	display: flex;
	margin-left: auto;
}

.mm-mobile .megamenu.is-open .megamenu__toggle span:nth-child(1) {
	transform: translateY(calc(var(--mm-burger-size, 24px) * 0.28 + var(--mm-burger-thickness, 2px))) rotate(45deg);
}
.mm-mobile .megamenu.is-open .megamenu__toggle span:nth-child(2) {
	opacity: 0;
}
.mm-mobile .megamenu.is-open .megamenu__toggle span:nth-child(3) {
	transform: translateY(calc((var(--mm-burger-size, 24px) * 0.28 + var(--mm-burger-thickness, 2px)) * -1)) rotate(-45deg);
}

.mm-mobile .megamenu .megamenu__bar {
	position: fixed;
	inset: 0 0 0 auto;
	width: min(420px, 88vw);
	flex-direction: column;
	align-items: stretch;
	gap: 0;
	background: var(--mm-m-drawer-bg);
	padding: 84px 22px 40px;
	overflow-y: auto;
	transform: translateX(100%);
	transition: transform 0.3s ease;
	box-shadow: var(--mm-shadow);
	z-index: 999;
}

.mm-mobile .megamenu.is-open .megamenu__bar {
	transform: translateX(0);
}

/* Respect the WordPress admin bar: start the fixed drawer below it. */
.admin-bar .mm-mobile .megamenu .megamenu__bar {
	top: 32px;
}
@media screen and (max-width: 782px) {
	.admin-bar .mm-mobile .megamenu .megamenu__bar {
		top: 46px;
	}
}

/* Show the close (X) button anchored to the drawer's top-right. */
.mm-mobile .megamenu .megamenu__close-li {
	display: block;
	position: absolute;
	top: 18px;
	right: 16px;
	z-index: 2;
}

.mm-mobile .megamenu.is-open::before {
	content: "";
	position: fixed;
	inset: 0;
	background: rgba(15, 16, 45, 0.45);
	z-index: 998;
}

.mm-mobile .megamenu .megamenu__item {
	border-bottom: var(--mm-m-divider-w) solid var(--mm-m-divider);
}

.mm-mobile .megamenu .megamenu__link {
	width: 100%;
	justify-content: space-between;
	padding: var(--mm-m-link-pad) 4px;
	font-size: var(--mm-m-link-size);
	font-weight: var(--mm-m-link-weight);
	color: var(--mm-m-text);
}

.mm-mobile .megamenu .megamenu__link::after {
	display: none;
}

.mm-mobile .megamenu .megamenu__caret {
	transform: rotate(90deg);
	flex: 0 0 auto;
}
.mm-mobile .megamenu .megamenu__item.is-open > .megamenu__link .megamenu__caret {
	transform: rotate(0deg);
}

/* On mobile the panel is an inline accordion, not a floating dropdown. */
.mm-mobile .megamenu .megamenu__panel {
	position: static;
	transform: none;
	width: auto;
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	border: 0;
	box-shadow: none;
	border-radius: 0;
	padding: 0;
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.3s ease;
}

.mm-mobile .megamenu .megamenu__item.is-open > .megamenu__panel {
	transform: none;
	max-height: 2000px;
	padding: 4px 0 18px;
}

/* No hover bridge needed in the accordion. */
.mm-mobile .megamenu .megamenu__panel::before {
	display: none;
}

.mm-mobile .megamenu .megamenu__panel-inner,
.mm-mobile .megamenu .megamenu__panel--columns .megamenu__content {
	display: block;
}

.mm-mobile .megamenu .megamenu__cards {
	gap: 18px;
}

.mm-mobile .megamenu .megamenu__col {
	margin-bottom: 18px;
}

.mm-mobile .megamenu .megamenu__panel--has-promo .megamenu__promo {
	max-width: 100%;
	flex-basis: auto;
	margin-top: 16px;
}

.mm-mobile .megamenu .megamenu__card-icon {
	--mm-icon-size: 46px;
	flex-basis: 46px;
	width: 46px;
	height: 46px;
}

/* Extra-small phones — tighten the drawer and each panel part further. */
@media (max-width: 420px) {
	.mm-mobile .megamenu .megamenu__bar {
		width: 100vw;
		padding: 76px 18px 32px;
	}
	.mm-mobile .megamenu .megamenu__card-link {
		gap: 14px;
	}
	.mm-mobile .megamenu .megamenu__card-title {
		font-size: 16px;
	}
	.mm-mobile .megamenu .megamenu__card-desc {
		font-size: 14px;
	}
	.mm-mobile .megamenu .megamenu__promo-body {
		padding: 14px 16px;
	}
}

/* Lock background scroll while the mobile drawer is open */
body.megamenu-locked {
	overflow: hidden;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
	.megamenu * {
		transition: none !important;
	}
}
