/* Header mega menu — see inc/mega-menu.php */

.ct-main-menu .mega-desc,
.ct-main-menu .mega-icon {
	display: none;
}

@media screen and (max-width: 1199px) {
	/* Keep long register names clear of the accordion toggle */
	.ct-main-menu li.ct-mega .sub-menu li.menu-item-has-children > a {
		padding-right: 40px;
	}
}

@media screen and (min-width: 1200px) {
	#ct-header-elementor .elementor-widget-ct_menu:has(.ct-mega),
	#ct-header-elementor .ct-main-menu > li.ct-mega {
		position: static;
	}

	/* The theme's hover underline would stretch across the header (li is static); the panel's top border replaces it */
	#ct-header-elementor .ct-main-menu > li.ct-mega::before {
		display: none;
	}

	/* Panel */
	#ct-header-elementor .ct-main-menu > li.ct-mega > .sub-menu {
		display: grid;
		grid-template-columns: repeat(4, minmax(0, 1fr));
		grid-template-rows: auto auto 1fr;
		left: 15px;
		right: 15px;
		min-width: 0;
		margin-top: 0; /* no slide-in: the hover bridge must be in place the moment the panel opens */
		padding: 0;
		background: #fff;
		border-top: 3px solid #7f71f0;
		border-radius: 0 0 8px 8px;
		box-shadow: 0 32px 64px -24px rgba(16, 22, 40, .28), 0 0 0 1px rgba(16, 22, 40, .05);
		overflow: visible; /* hidden would clip the hover bridge below */
	}

	/* Hover bridge across the gap between the top link and the panel.
	   Hangs off the link itself so it covers only the area under "Услуги", not the neighbouring menu items. */
	#ct-header-elementor .ct-main-menu > li.ct-mega > a {
		position: relative;
	}
	#ct-header-elementor .ct-main-menu > li.ct-mega:hover > a::before {
		content: "";
		display: block;
		position: absolute;
		left: 0;
		right: 0;
		top: 100%;
		height: 16px;
		background: none;
	}

	/* Columns: title / description / links share rows across columns so they line up */
	#ct-header-elementor li.ct-mega > .sub-menu > li {
		display: grid;
		grid-row: 1 / span 3;
		grid-template-rows: subgrid;
		align-content: start;
		padding: 34px 30px 30px;
		white-space: normal;
		border-right: 1px solid #eceaf6;
	}

	#ct-header-elementor li.ct-mega > .sub-menu > li:nth-child(4n) {
		border-right: 0;
	}

	#ct-header-elementor .ct-main-menu li.ct-mega > .sub-menu > li > a {
		align-self: start;
		padding: 0;
		border: 0;
		font-family: "Playfair Display", serif;
		font-size: 18px;
		font-weight: 700;
		line-height: 1.3;
		color: #1b1f2e;
		transition: color .2s ease;
	}

	#ct-header-elementor .ct-main-menu li.ct-mega > .sub-menu > li > a::before,
	#ct-header-elementor .ct-main-menu li.ct-mega > .sub-menu > li > a::after {
		display: none;
	}

	#ct-header-elementor .ct-main-menu li.ct-mega > .sub-menu > li > a[href]:hover,
	#ct-header-elementor .ct-main-menu li.ct-mega > .sub-menu > li.current-menu-item > a {
		color: #7f71f0;
	}

	/* Column titles without a link */
	#ct-header-elementor .ct-main-menu li.ct-mega > .sub-menu > li > a:not([href]) {
		cursor: default;
	}

	#ct-header-elementor li.ct-mega > .sub-menu > li > a > span:has(.mega-icon) {
		display: flex;
		align-items: center;
		gap: 14px;
	}

	#ct-header-elementor li.ct-mega .mega-icon {
		display: inline-flex;
		flex: 0 0 44px;
		align-items: center;
		justify-content: center;
		width: 44px;
		height: 44px;
		border-radius: 10px;
		background: #f3f1fd;
		color: #7f71f0;
		transition: background .2s ease, color .2s ease;
	}

	#ct-header-elementor li.ct-mega .mega-icon svg {
		width: 22px;
		height: 22px;
	}

	#ct-header-elementor li.ct-mega > .sub-menu > li > a[href]:hover .mega-icon {
		background: #7f71f0;
		color: #fff;
	}

	#ct-header-elementor li.ct-mega .mega-desc {
		display: block;
		margin: 14px 0 18px;
		font-size: 13px;
		line-height: 1.6;
		color: #80838f;
	}

	/* Service links inside a column */
	#ct-header-elementor .ct-main-menu li.ct-mega .sub-menu .sub-menu {
		position: static;
		visibility: inherit;
		opacity: 1;
		clip: auto;
		min-width: 0;
		margin: 0;
		padding: 12px 0 0;
		background: none;
		box-shadow: none;
		border-top: 1px solid #eceaf6;
		transition: none;
	}

	#ct-header-elementor .ct-main-menu li.ct-mega .sub-menu .sub-menu li {
		padding: 0;
		white-space: normal;
	}

	#ct-header-elementor .ct-main-menu li.ct-mega .sub-menu .sub-menu li a {
		display: block;
		position: relative;
		padding: 7px 18px 7px 0;
		border: 0;
		font-size: 14px;
		line-height: 1.45;
		color: #4a4f5c;
		transition: color .2s ease, padding .2s ease;
	}

	#ct-header-elementor .ct-main-menu li.ct-mega .sub-menu .sub-menu li a::before {
		display: none;
	}

	#ct-header-elementor .ct-main-menu li.ct-mega .sub-menu .sub-menu li a::after {
		content: "→";
		position: absolute;
		right: 4px;
		top: 50%;
		transform: translate(-6px, -50%);
		opacity: 0;
		color: #7f71f0;
		transition: opacity .2s ease, transform .2s ease;
	}

	#ct-header-elementor .ct-main-menu li.ct-mega .sub-menu .sub-menu li a:hover,
	#ct-header-elementor .ct-main-menu li.ct-mega .sub-menu .sub-menu li.current-menu-item a {
		color: #7f71f0;
		padding-left: 4px;
	}

	#ct-header-elementor .ct-main-menu li.ct-mega .sub-menu .sub-menu li a:hover::after {
		opacity: 1;
		transform: translate(0, -50%);
	}
}
