/*
 * Cascading mega menu (desktop). Panel spans the header container width.
 */

.header-main .header-inner {
	position: relative;
}

/* Let the panel position against .header-inner instead of the nav / item */
.header-main .header-nav-main,
.header-main .header-nav-main > li.tipa-mega-item {
	position: static;
}

/* Keep Flatsome's underline (a::before) sized to the link, not the whole header */
.header-main .header-nav-main > li.tipa-mega-item > a {
	position: relative;
}

.tipa-mega {
	position: absolute;
	top: 100%;
	left: 15px;
	right: 15px;
	z-index: 30;
	display: grid;
	grid-template-columns: 1fr 56px;
	overflow: hidden;
	border-radius: 0 0 12px 12px;
	background: var(--tipa-white);
	box-shadow: 0 24px 48px rgba(15, 43, 12, .12);
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
	text-transform: none;
	letter-spacing: 0;
}

.tipa-mega-item.is-open > .tipa-mega {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity .2s ease, transform .2s ease, visibility 0s;
}

.tipa-mega__cols {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tipa-mega__col {
	min-height: 100%;
	padding: 16px 0;
}

/* Thin dividers between columns */
.tipa-mega__col--2,
.tipa-mega__col--3 {
	border-left: 1px solid var(--tipa-green-100);
}

/*
 * Branch with only two levels: drop the third column and shrink the panel to two columns.
 * Each column keeps its width (1/3 of the full panel), so the first two columns do not jump.
 * 86px = 15px + 15px side offsets + 56px close button column.
 */
.tipa-mega.is-two-levels {
	right: auto;
	width: calc((100% - 86px) * 2 / 3 + 56px);
}

.tipa-mega.is-two-levels .tipa-mega__cols {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tipa-mega.is-two-levels .tipa-mega__col--3 {
	display: none;
}

.tipa-mega__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tipa-mega__list[hidden] {
	display: none;
}

.tipa-mega__list li {
	margin: 0;
	list-style: none;
}

.header-main .tipa-mega .tipa-mega__link {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 12px 48px 12px 24px;
	color: var(--tipa-ink);
	font-size: 15px;
	font-weight: 500;
	line-height: 1.4;
	text-transform: none;
	letter-spacing: 0;
	transition: background-color .15s ease, color .15s ease;
}

/* Chevron for items with children */
.tipa-mega__link.has-children::after {
	content: "";
	position: absolute;
	right: 24px;
	top: 50%;
	width: 7px;
	height: 7px;
	border-top: 1.5px solid currentColor;
	border-right: 1.5px solid currentColor;
	transform: translateY(-50%) rotate(45deg);
	opacity: .6;
}

.header-main .tipa-mega .tipa-mega__link:hover,
.header-main .tipa-mega .tipa-mega__link.is-active {
	background: var(--tipa-green-100);
	color: var(--tipa-green-700);
}

.tipa-mega__link.is-active::after {
	opacity: 1;
}

.tipa-mega__close {
	position: relative;
	align-self: start;
	width: 40px;
	height: 40px;
	margin: 12px 8px 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--tipa-ink);
	cursor: pointer;
	transition: background-color .15s ease;
}

.tipa-mega__close::before,
.tipa-mega__close::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 18px;
	height: 1.5px;
	background: currentColor;
}

.tipa-mega__close::before { transform: translate(-50%, -50%) rotate(45deg); }
.tipa-mega__close::after { transform: translate(-50%, -50%) rotate(-45deg); }

.tipa-mega__close:hover {
	background: var(--tipa-green-100);
}

.tipa-mega__close:focus-visible,
.header-main .tipa-mega .tipa-mega__link:focus-visible {
	outline: 2px solid var(--tipa-green);
	outline-offset: -2px;
}

/* Keep the top item underlined while its panel is open */
.header-main .header-nav-main > li.tipa-mega-item.is-open > a {
	color: var(--tipa-green);
}

.header-main .nav-line-bottom > li.tipa-mega-item.is-open > a::before {
	opacity: 1;
}

/* The desktop nav is hidden below 850px; the mobile menu uses Flatsome's accordion */
@media (max-width: 849px) {
	.tipa-mega { display: none; }
}

/*
 * Regular dropdowns in the main menu (e.g. "Connect with us"):
 * same look as the mega menu panel.
 */
.header-main .header-nav-main .nav-dropdown-default {
	min-width: 260px;
	padding: 12px 0;
	border: 0;
	border-radius: 0 0 12px 12px;
	background: var(--tipa-white);
	box-shadow: 0 24px 48px rgba(15, 43, 12, .12);
	text-transform: none;
	letter-spacing: 0;
}

/* No arrow / grey top border from Flatsome */
.header-main .header-nav-main > li.has-dropdown::before,
.header-main .header-nav-main > li.has-dropdown::after {
	display: none;
}

.header-main .header-nav-main .nav-dropdown-default > li {
	margin: 0;
	border: 0;
}

.header-main .header-nav-main .nav-dropdown-default > li > a {
	display: block;
	margin: 0;
	padding: 12px 24px;
	border: 0;
	color: var(--tipa-ink);
	font-size: 15px;
	font-weight: 500;
	line-height: 1.4;
	text-transform: none;
	letter-spacing: 0;
	transition: background-color .15s ease, color .15s ease;
}

.header-main .header-nav-main .nav-dropdown-default > li > a:hover,
.header-main .header-nav-main .nav-dropdown-default > li.current-menu-item > a {
	background: var(--tipa-green-100);
	color: var(--tipa-green-700);
}

.header-main .header-nav-main .nav-dropdown-default > li > a:focus-visible {
	outline: 2px solid var(--tipa-green);
	outline-offset: -2px;
}
