/*
 * Promantia Mega Menu
 *
 * Expected menu structure (Appearance → Menus, primary menu):
 *
 *   Offerings                      <- CSS class: pmm-mega
 *     Products                     <- CSS classes: pmm-col pmm-col--products   (custom link, "#")
 *       FAC Suite
 *       POSpire
 *     Platforms                    <- pmm-col pmm-col--platforms
 *     Services                     <- pmm-col pmm-col--services
 *
 * Designed for three or four columns; each takes an equal share of the panel.
 *
 * Everything is scoped to `#top-menu li.pmm-mega`, and only applies at
 * desktop width (Divi swaps to its own mobile menu below 981px).
 *
 * Divi's own rules for these selectors carry `!important` in places (the
 * Divi-child theme adds more), so the overrides here do too, with the extra
 * `.pmm-mega` class in the selector to win on specificity.
 */

:root {
	--pmm-icon-products: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%232f2583' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z'/%3E%3Cpath d='m3.3 7 8.7 5 8.7-5'/%3E%3Cpath d='M12 22V12'/%3E%3C/svg%3E");
	--pmm-icon-platforms: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%232f2583' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z'/%3E%3Cpath d='m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65'/%3E%3Cpath d='m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65'/%3E%3C/svg%3E");
	--pmm-icon-services: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%232f2583' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E");
	--pmm-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%232f2583' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	--pmm-indigo:      #2f2583;
	--pmm-text:        #555555;
	--pmm-tile-bg:     #f1f0fb;
	--pmm-divider:     #ececf2;
}

@media only screen and (min-width: 981px) {

	/* Anchor the panel to the nav, not to the "Offerings" <li>. */
	#top-menu li.pmm-mega {
		position: static;
	}

	/* --- Top-level "Offerings" link: chevron + underline when open ------- */

	#top-menu li.pmm-mega > a {
		position: relative;
		padding-right: 22px !important;
	}

	#top-menu li.pmm-mega > a::after {
		content: "";
		position: absolute;
		top: 50%;
		right: 4px;
		width: 14px;
		height: 14px;
		margin-top: -5px;
		font-family: inherit;
		background: var(--pmm-chevron) center / 14px 14px no-repeat;
	}

	#top-menu li.pmm-mega > a::before {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		height: 2px;
		background: var(--pmm-indigo);
		opacity: 0;
		transition: opacity 0.2s ease;
	}

	#top-menu li.pmm-mega:hover > a,
	#top-menu li.pmm-mega:focus-within > a,
	#top-menu li.pmm-mega.et-hover > a,
	#top-menu li.pmm-mega.et-touch-hover > a,
	#top-menu li.pmm-mega.current-menu-ancestor > a {
		color: var(--pmm-indigo) !important; /* Divi's sticky header forces its own link colour */
	}

	#top-menu li.pmm-mega:hover > a::before,
	#top-menu li.pmm-mega:focus-within > a::before,
	#top-menu li.pmm-mega.et-hover > a::before,
	#top-menu li.pmm-mega.et-touch-hover > a::before {
		opacity: 1;
	}

	/* --- The panel ------------------------------------------------------- */

	#top-menu li.pmm-mega > ul.sub-menu {
		display: flex;
		align-items: stretch;
		position: absolute;
		top: auto;
		right: 12px;
		left: auto;
		width: 700px;
		width: min(700px, calc(100vw - 130px)); /* anchored right, so keep clear of the left edge */
		margin: 0;
		padding: 24px 0 !important;
		border: 0 !important;
		border-radius: 10px;
		background: #fff;
		box-shadow: 0 8px 30px rgba(20, 16, 70, 0.14), 0 1px 3px rgba(20, 16, 70, 0.08);
		text-align: left;
	}

	#top-menu li.pmm-mega:focus-within > ul.sub-menu {
		visibility: visible;
		opacity: 1;
	}

	/* --- Columns ----------------------------------------------------------- */

	#top-menu li.pmm-mega > ul.sub-menu > li {
		display: block;
		flex: 1 1 0;
		min-width: 0;
		margin: 0;
		padding: 0 18px !important;
		float: none;
		line-height: 1.4;
	}

	#top-menu li.pmm-mega > ul.sub-menu > li + li {
		border-left: 1px solid var(--pmm-divider);
	}

	/* Column heading: icon tile above an uppercase label. Not a real link. */
	#top-menu li.pmm-mega > ul.sub-menu > li > a {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: 14px;
		width: auto;
		padding: 0 0 18px !important;
		border: 0 !important;
		background: none;
		color: var(--pmm-indigo) !important;
		font-size: 14px !important;
		font-weight: 600;
		letter-spacing: 0.02em;
		line-height: 1.2;
		text-transform: uppercase;
		pointer-events: none;
		cursor: default;
	}

	#top-menu li.pmm-mega > ul.sub-menu > li > a::after {
		content: none; /* Divi's arrow for "has children" */
	}

	#top-menu li.pmm-mega > ul.sub-menu > li > a::before {
		content: "";
		width: 44px;
		height: 44px;
		border-radius: 10px;
		background-color: var(--pmm-tile-bg);
		background-position: center;
		background-repeat: no-repeat;
		background-size: 22px 22px;
	}

	#top-menu li.pmm-mega .pmm-col--products > a::before  { background-image: var(--pmm-icon-products); }
	#top-menu li.pmm-mega .pmm-col--platforms > a::before { background-image: var(--pmm-icon-platforms); }
	#top-menu li.pmm-mega .pmm-col--services > a::before  { background-image: var(--pmm-icon-services); }

	/* --- Links inside a column -------------------------------------------- */

	/* Divi flies third-level lists out to the right; pin them in the column. */
	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu {
		display: block;
		position: static;
		visibility: visible;
		opacity: 1;
		width: auto;
		margin: 0;
		padding: 0 !important;
		border: 0 !important;
		background: none;
		box-shadow: none;
		transform: none;
	}

	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li {
		display: block; /* Divi makes every nav <li> inline-block */
		margin: 0;
		padding: 0 !important;
		float: none;
	}

	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li > a {
		display: block;
		width: auto;
		padding: 11px 0 !important;
		border: 0 !important;
		border-bottom: 1px solid var(--pmm-divider) !important;
		border-radius: 0;
		background: none;
		color: var(--pmm-text) !important;
		font-size: 14px !important;
		font-weight: 400;
		line-height: 1.4;
		text-transform: none;
		white-space: normal;
	}

	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li:first-child > a {
		padding-top: 0 !important;
	}

	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li:last-child > a {
		padding-bottom: 0 !important;
		border-bottom: 0 !important;
	}

	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li > a:hover,
	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li > a:focus {
		background: none;
		color: var(--pmm-indigo) !important;
		opacity: 1;
	}
}

/*
 * Footer "Mega Menu column" widgets. Divi floats every footer widget, so two of
 * them in one footer column (e.g. Products above Platforms) would sit side by
 * side; stack them instead.
 */
#footer-widgets .footer-widget .fwidget.pmm-footer-column {
	float: none;
	clear: both;
	width: 100%;
	margin-bottom: 22px !important;
}

#footer-widgets .footer-widget .fwidget.pmm-footer-column:last-child {
	margin-bottom: 0 !important;
}

/*
 * Item highlight (hover, keyboard focus, and "current product" opened from a page
 * breadcrumb). Every item gets the same inner padding so the highlight is evenly
 * centred around the text, and the accent bar sits in that padding, not on the text.
 * The negative side margin keeps the text aligned with the column heading.
 */
@media only screen and (min-width: 981px) {
	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu {
		margin: -11px 0 -11px !important; /* offsets the padding added to first / last item */
	}

	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li + li {
		border-top: 1px solid var(--pmm-divider);
	}

	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li > a,
	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li:first-child > a,
	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li:last-child > a {
		padding: 11px 16px !important;
		margin: 0 -16px;
		border: 0 !important;
		border-radius: 6px;
		box-shadow: inset 3px 0 0 transparent;
		transition: background-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
	}

	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li > a:hover,
	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li > a:focus,
	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li > a:focus-visible,
	#top-menu li.pmm-mega > ul.sub-menu > li > ul.sub-menu > li > a.pn-spot {
		background: #f1f0fb !important;
		color: var(--pmm-indigo) !important;
		box-shadow: inset 3px 0 0 #f47b2a;
		outline: 0 !important;
	}
}
