/**
 * Mega menu under «خدماتنا» (hs-base inc/mega-menu.php). Colours are the
 * theme's own: --hsb-a1 (dark), --hsb-a2 (accent), --hsb-a-soft (tint).
 *
 * Two looks, chosen by mega.js from the menu's own layout:
 *   .is-drop   — a horizontal menu: the panel opens under the header;
 *   .is-inline — a menu in a phone drawer: the groups open like an accordion.
 */

.hsb-has-mega {
	position: relative;
}

.hsb-mega[hidden] {
	display: none;
}

.hsb-mega {
	color: var(--hsb-a1, #1f2937);
	font-size: 15px;
	line-height: 1.6;
	text-align: start;
}

/* ---- Shared ---- */

.hsb-mega__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	inline-size: 100%;
	min-block-size: 44px;
	padding: 6px 2px;
	border: 0;
	background: none;
	color: var(--hsb-a1, #1f2937);
	font: inherit;
	font-weight: 700;
	text-align: start;
	cursor: pointer;
}

.hsb-mega__head > svg {
	margin-inline-start: auto;
	transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.hsb-mega__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: 34px;
	block-size: 34px;
	border-radius: 10px;
	background: #fff;
	color: var(--hsb-a2, #2563eb);
	box-shadow: 0 2px 8px rgb(15 23 42 / 12%);
}

.hsb-mega__list {
	margin: 4px 0 0;
	padding: 0;
	list-style: none;
}

.hsb-mega__list li {
	margin: 0;
	padding: 0;
}

.hsb-mega__list :is(a, button) {
	display: flex;
	align-items: center;
	gap: 6px;
	inline-size: 100%;
	min-block-size: 40px;
	padding: 6px 4px;
	border: 0;
	border-radius: 8px;
	background: none;
	color: inherit;
	font: inherit;
	font-weight: 500;
	text-align: start;
	text-decoration: none;
	cursor: pointer;
}

.hsb-mega__list svg {
	flex: none;
	inline-size: 16px;
	block-size: 16px;
	color: var(--hsb-a2, #2563eb);
}

.hsb-mega__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: 32px;
	block-size: 32px;
	margin-inline-start: 2px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: inherit;
	vertical-align: middle;
	cursor: pointer;
	touch-action: manipulation;
}

.hsb-mega__toggle svg {
	transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.hsb-mega__toggle[aria-expanded="true"] svg {
	transform: rotate(180deg);
}

/* A computer header opens the panel on hover: the chevron takes no room in
   the header (it showed on a line of its own and made headers taller). It
   stays reachable by keyboard and shows when focused. */
@media (hover: hover) and (pointer: fine) {
	.hsb-has-mega:not(.hsb-mega-stack) > .hsb-mega__toggle {
		position: absolute;
		inset-block-start: 50%;
		inset-inline-end: -14px;
		inline-size: 1px;
		block-size: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.hsb-has-mega:not(.hsb-mega-stack) > .hsb-mega__toggle:focus-visible {
		inline-size: 24px;
		block-size: 24px;
		clip-path: none;
		transform: translateY(-50%);
	}
}

/* ---- Under the header ---- */

.hsb-mega.is-drop {
	position: fixed;
	z-index: 1000;
	inset-block-start: var(--hsb-mega-top, 80px);
	inset-inline-start: 16px;

	/* As wide as its cards (--hsb-mega-cols, 1–4): no empty space. */
	inline-size: min(calc(var(--hsb-mega-cols, 4) * 250px + (var(--hsb-mega-cols, 4) - 1) * 16px + 42px), calc(100vw - 32px));
	max-block-size: calc(100vh - var(--hsb-mega-top, 80px) - 16px);
	padding: 20px;
	overflow-y: auto;
	overscroll-behavior: contain;
	border: 1px solid color-mix(in srgb, var(--hsb-a1, #1f2937) 12%, transparent);
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 24px 60px rgb(15 23 42 / 18%);
	animation: hsb-mega-in 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes hsb-mega-in {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
}

.hsb-mega.is-drop .hsb-mega__groups {
	display: grid;
	grid-template-columns: repeat(var(--hsb-mega-cols, 4), minmax(0, 1fr));
	align-items: start;
	gap: 16px;
}

/* The gap between «خدماتنا» and the panel still counts as «over the menu». */
.hsb-mega.is-drop::before {
	content: "";
	position: absolute;
	inset-block-end: 100%;
	inset-inline: 0;
	block-size: var(--hsb-mega-bridge, 12px);
}

.hsb-mega.is-drop .hsb-mega__group {
	padding: 12px;
	border-radius: 12px;
	background: var(--hsb-a-soft, #f3f6fb);
}

.hsb-mega.is-drop .hsb-mega__head {
	cursor: default;
}

.hsb-mega.is-drop .hsb-mega__head > svg {
	display: none;
}

.hsb-mega.is-drop .hsb-mega__thumb {
	display: block;
	position: relative;
	flex-basis: 100%;
	margin-block-end: 4px;
	overflow: hidden;
	border-radius: 10px;
	aspect-ratio: 3 / 2;
	background: color-mix(in srgb, var(--hsb-a2, #2563eb) 14%, #fff);
}

.hsb-mega.is-drop .hsb-mega__thumb img {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
}



/* ---- Inside a phone menu ---- */

.hsb-mega.is-inline {
	position: static;
	inline-size: 100%;
	padding-block: 6px 10px;
}

.hsb-mega.is-inline .hsb-mega__thumb {
	display: none;
}

/* In a phone drawer the panel takes the drawer's own colours. */
.hsb-mega.is-inline,
.hsb-mega.is-inline .hsb-mega__head,
.hsb-mega.is-inline .hsb-mega__list svg {
	color: inherit;
}

.hsb-mega.is-inline .hsb-mega__icon {
	background: color-mix(in srgb, currentcolor 12%, transparent);
	color: inherit;
	box-shadow: none;
}

.hsb-mega.is-inline .hsb-mega__group + .hsb-mega__group {
	border-block-start: 1px solid color-mix(in srgb, var(--hsb-a1, #1f2937) 10%, transparent);
}

.hsb-mega.is-inline .hsb-mega__list {
	display: none;
}

.hsb-mega.is-inline .hsb-mega__head[aria-expanded="true"] + .hsb-mega__list {
	display: block;
}

.hsb-mega.is-inline .hsb-mega__head[aria-expanded="true"] > svg {
	transform: rotate(180deg);
}

.hsb-mega__toggle:focus-visible,
.hsb-mega :is(.hsb-mega__head, .hsb-mega__list a, .hsb-mega__list button):focus-visible {
	outline: 2px solid var(--hsb-a2, #2563eb);
	outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
	.hsb-mega__list :is(a, button):hover {
		background: color-mix(in srgb, var(--hsb-a2, #2563eb) 10%, #fff);
		color: var(--hsb-a1, #1f2937);
	}
}

@media (prefers-reduced-motion: reduce) {
	.hsb-mega.is-drop,
	.hsb-mega__toggle svg,
	.hsb-mega__head > svg {
		animation: none;
		transition: none;
	}
}
