/**
 * Services mega menu (Figma "mega menu" 2844:3): categories on the left,
 * the selected category's service cards on the right. Desktop opens on
 * hover or keyboard focus; the mobile menu opens it with the arrow button.
 *
 * @package WebSolex
 */

.mega {
	--mega-bg: #ebf7ff;
	--mega-col: #a9d9fb;
	display: none;
	flex-basis: 100%;
}

.menu__item--mega.is-open > .mega,
.no-js .menu__item--mega > .mega {
	display: block;
}

.mega__inner {
	position: relative;
	display: grid;
	gap: 10px;
	padding: 10px;
	margin-bottom: 12px;
	background: var(--mega-bg);
	border-radius: 12px;
}

.mega__cats {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.mega__cat {
	min-height: 38px;
	padding: 0 12px;
	font-family: var(--f-head);
	font-size: 15px;
	font-weight: 400;
	line-height: 1.2;
	color: var(--c-black);
	text-align: left;
	background: var(--c-white);
	border-radius: 5px;
	transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.mega__cat:hover {
	color: var(--c-primary);
}

.mega__cat[aria-selected='true'] {
	font-weight: 500;
	color: var(--c-white);
	background: var(--c-primary);
}

.mega__cards {
	display: grid;
	gap: 8px;
}

.mega__cards[hidden] {
	display: none;
}

.no-js .mega__cards[hidden] {
	display: grid;
}

.mega__card {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 4px 12px;
	min-height: 54px;
	height: 100%;
	padding: 8px 14px;
	font-family: var(--f-head);
	font-size: 16px;
	line-height: 1.2;
	color: var(--c-black);
	text-align: center;
	background: var(--c-white);
	border: 1px solid #f3f3f3;
	border-radius: 10px;
	transition: box-shadow 0.25s var(--ease), color 0.2s var(--ease), translate 0.25s var(--ease);
}

a.mega__card:hover,
a.mega__card:focus-visible {
	color: var(--c-primary);
	box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
}

.mega__icon {
	flex: none;
	width: auto;
	max-height: 24px;
}

/* Temporary local preview (inc/mega-menu.php): a small tag in the corner of
   the services whose page is not built yet. */
.mega__card--preview {
	position: relative;
}

.mega__preview {
	position: absolute;
	top: 6px;
	right: 8px;
	padding: 1px 7px;
	font-family: var(--f-body);
	font-size: 11px;
	font-weight: 600;
	line-height: 1.5;
	letter-spacing: 0.04em;
	color: #8a5a00;
	text-transform: uppercase;
	background: #fff4d6;
	border-radius: 999px;
}

/* Only logged-in editors see services whose page is not published yet. */
.mega__card--draft {
	border: 1px dashed var(--c-primary);
}

.mega__note {
	flex-basis: 100%;
	font-family: var(--f-body);
	font-size: 12px;
	color: var(--c-text-muted);
}

@media (min-width: 600px) {
	.mega__cards {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* Cards of the chosen category come in one after another. */
@media (prefers-reduced-motion: no-preference) {
	.js .mega__cards:not([hidden]) > li {
		animation: mega-card-in 0.4s var(--ease) both;
		animation-delay: calc(var(--ci, 0) * 0.05s);
	}
}

@keyframes mega-card-in {
	from {
		opacity: 0;
		translate: 0 10px;
	}
}

/* ---------------------------------------------------------------- Desktop */
@media (min-width: 1100px) {
	.menu__item--mega {
		position: static;
	}

	/* The panel spans the header, centred like the page container. */
	.menu__item--mega > .mega,
	.menu__item--mega.is-open > .mega,
	.no-js .menu__item--mega > .mega {
		position: absolute;
		top: calc(100% + 6px);
		left: 0;
		right: 0;
		display: flex;
		justify-content: center;
		padding: 0 16px;
		visibility: hidden;
		opacity: 0;
		translate: 0 10px;
		transition: opacity 0.25s var(--ease), translate 0.25s var(--ease), visibility 0s linear 0.25s;
	}

	/* A bridge over the gap below the link, so the pointer can reach the panel. */
	.mega::before {
		content: '';
		position: absolute;
		left: 0;
		right: 0;
		bottom: 100%;
		height: 40px;
	}

	.menu__item--mega.is-open > .mega,
	.no-js .menu__item--mega:hover > .mega,
	.no-js .menu__item--mega:focus-within > .mega {
		visibility: visible;
		opacity: 1;
		translate: none;
		transition-delay: 0s;
	}

	.mega__inner {
		grid-template-columns: clamp(250px, 158px + 9.27vw, 336px) minmax(0, 1fr);
		column-gap: clamp(14px, 8px + 0.6vw, 19px);
		align-items: start;
		width: min(100%, 1440px);
		min-height: clamp(380px, 330px + 4.5vw, 439px);
		margin: 0;
		padding: 0 16px 0 10px;
		background: var(--mega-bg);
		border-radius: 21px;
		box-shadow: 0 2px 7.9px rgba(0, 0, 0, 0.25);
	}

	/* The pointer above the panel sits under "Services" (main.js sets --arrow-x). */
	.mega__inner::before {
		content: '';
		position: absolute;
		bottom: 100%;
		left: var(--arrow-x, 50%);
		border-right: 13.4px solid transparent;
		border-bottom: 18.3px solid var(--mega-bg);
		border-left: 13.4px solid transparent;
		filter: drop-shadow(0 -2px 2px rgba(0, 0, 0, 0.09));
		translate: -50% 0;
	}

	.mega__cats {
		flex-direction: column;
		flex-wrap: nowrap;
		gap: 4px;
		align-self: stretch;
		padding: 24px 18px 20px 23px;
		background: var(--mega-col);
		border-radius: 21px 0 0 21px;
	}

	.mega__cat {
		min-height: clamp(44px, 32.6px + 1.04vw, 53px);
		padding: 0 clamp(16px, 7px + 1vw, 27px);
		font-size: clamp(18px, 9.95px + 0.732vw, 24px);
		background: var(--mega-bg);
	}

	.mega__cat[aria-selected='true'] {
		color: var(--c-primary);
		background: var(--c-white);
	}

	.mega__panels {
		padding-top: 24px;
	}

	.mega__cards {
		gap: 11px;
	}

	.mega__card {
		gap: 4px clamp(10px, 6px + 0.4vw, 14px);
		min-height: clamp(96px, 54.4px + 3.95vw, 130px);
		font-size: clamp(18px, 9.95px + 0.732vw, 24px);
		border-radius: 15px;
	}

	.mega__icon {
		max-height: none;
	}
}

/* Reduced motion: the panel appears and disappears without fading or moving. */
@media (prefers-reduced-motion: reduce) {
	.mega,
	.menu__item--mega > .mega,
	.menu__item--mega.is-open > .mega {
		translate: none;
		transition: none;
	}
}
