/**
 * Mega Menu — Common base CSS ( loads for every style ).
 *
 * Owns the structural engine: the flex bar, the menu row, mega panel
 * positioning ( full-bar vs fit-content ), hover / click open states and the
 * mobile hamburger drawer with inline accordion panels. Per-style files paint
 * the bar, items and panel chrome. The --captwiki-mm-accent variable re-themes
 * every style at once.
 *
 * @package captain-widgets-kit
 * @since   1.6.0
 */

.captwiki-mega {
	--captwiki-mm-accent: #6d5efc;
	position: relative;
	width: 100%;
	box-sizing: border-box;
}

.captwiki-mega *,
.captwiki-mega *::before,
.captwiki-mega *::after {
	box-sizing: border-box;
}

/* ── Bar ───────────────────────────────────────────────── */
.captwiki-mega__bar {
	position: relative;
	display: flex;
	align-items: center;
	gap: 24px;
	padding: 10px 18px;
}

/* ── Brand ─────────────────────────────────────────────── */
.captwiki-mega__brand {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	text-decoration: none;
	flex-shrink: 0;
}

.captwiki-mega__brand-logo {
	display: block;
	height: 36px;
	width: auto;
}

.captwiki-mega__brand-text {
	font-size: 20px;
	font-weight: 800;
	line-height: 1;
	color: #111827;
}

/* ── Nav + menu ────────────────────────────────────────── */
.captwiki-mega__nav {
	flex: 1 1 auto;
	min-width: 0;
}

.captwiki-mega__menu {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.captwiki-mega__item {
	position: relative;
}

.captwiki-mega__link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	color: #374151;
	text-decoration: none;
	white-space: nowrap;
	border-radius: 8px;
	cursor: pointer;
	transition: color 0.2s ease, background-color 0.2s ease;
}

.captwiki-mega__item-icon {
	display: inline-flex;
	align-items: center;
	font-size: 16px;
	line-height: 1;
}

.captwiki-mega__item-icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.captwiki-mega__item-icon i {
	font-style: normal;
}

.captwiki-mega__badge {
	display: inline-flex;
	align-items: center;
	padding: 2px 7px;
	font-size: 10px;
	font-weight: 700;
	line-height: 1.4;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: #ffffff;
	background: var( --captwiki-mm-accent );
	border-radius: 999px;
}

/* ── Caret ─────────────────────────────────────────────── */
.captwiki-mega__caret {
	width: 8px;
	height: 8px;
	margin-left: 2px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate( 45deg ) translateY( -2px );
	transition: transform 0.25s ease;
	opacity: 0.7;
}

.captwiki-mega__item.is-open .captwiki-mega__caret {
	transform: rotate( -135deg ) translateY( -2px );
}

/* ── Mega panel ────────────────────────────────────────── */
.captwiki-mega__panel {
	position: absolute;
	top: 100%;
	z-index: 99;
	opacity: 0;
	visibility: hidden;
	transform: translateY( 10px );
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
	pointer-events: none;
}

/* Full-bar-width panels span the whole bar. */
.captwiki-mega__item--full .captwiki-mega__panel {
	left: 0;
	right: 0;
	width: 100%;
}

/* Fit-content panels sit under their item. */
.captwiki-mega__item--fit .captwiki-mega__panel {
	left: 0;
	min-width: 260px;
}

/* The full-bar panel is positioned against the bar, not the item. */
.captwiki-mega__bar {
	position: relative;
}

.captwiki-mega__item--full {
	position: static;
}

.captwiki-mega__panel-inner {
	padding: 22px;
}

/* Hover trigger ( desktop ). */
.captwiki-mega--hover .captwiki-mega__item--mega:hover .captwiki-mega__panel {
	opacity: 1;
	visibility: visible;
	transform: translateY( 0 );
	pointer-events: auto;
}

/* Click / open state ( and keyboard ). */
.captwiki-mega__item.is-open .captwiki-mega__panel {
	opacity: 1;
	visibility: visible;
	transform: translateY( 0 );
	pointer-events: auto;
}

/* ── Mobile toggle ─────────────────────────────────────── */
.captwiki-mega__toggle {
	display: none;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	gap: 5px;
	width: 44px;
	height: 44px;
	margin-left: auto;
	padding: 0;
	background: transparent;
	border: none;
	border-radius: 8px;
	cursor: pointer;
}

.captwiki-mega__toggle-bar {
	display: block;
	width: 24px;
	height: 2px;
	background: #111827;
	border-radius: 2px;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

.captwiki-mega.is-drawer-open .captwiki-mega__toggle-bar:nth-child(1) {
	transform: translateY( 7px ) rotate( 45deg );
}

.captwiki-mega.is-drawer-open .captwiki-mega__toggle-bar:nth-child(2) {
	opacity: 0;
}

.captwiki-mega.is-drawer-open .captwiki-mega__toggle-bar:nth-child(3) {
	transform: translateY( -7px ) rotate( -45deg );
}

/* ── Mobile layout ─────────────────────────────────────── */
.captwiki-mega.is-mobile .captwiki-mega__toggle {
	display: inline-flex;
}

.captwiki-mega.is-mobile .captwiki-mega__bar {
	flex-wrap: wrap;
}

.captwiki-mega.is-mobile .captwiki-mega__nav {
	flex: 1 1 100%;
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.35s ease;
}

.captwiki-mega.is-mobile.is-drawer-open .captwiki-mega__nav {
	max-height: 85vh;
	overflow-y: auto;
	margin-top: 10px;
}

.captwiki-mega.is-mobile .captwiki-mega__menu {
	flex-direction: column;
	align-items: stretch;
	flex-wrap: nowrap;
	gap: 2px;
}

.captwiki-mega.is-mobile .captwiki-mega__link {
	justify-content: space-between;
	width: 100%;
}

.captwiki-mega.is-mobile .captwiki-mega__item--mega {
	position: static;
}

/* Mobile panels become inline accordions instead of floating dropdowns. */
.captwiki-mega.is-mobile .captwiki-mega__panel {
	position: static;
	opacity: 1;
	visibility: visible;
	transform: none;
	pointer-events: auto;
	width: auto;
	min-width: 0;
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.35s ease;
}

.captwiki-mega.is-mobile .captwiki-mega__item.is-open .captwiki-mega__panel {
	max-height: 1500px;
}

.captwiki-mega.is-mobile .captwiki-mega--hover .captwiki-mega__item--mega:hover .captwiki-mega__panel,
.captwiki-mega.is-mobile.captwiki-mega--hover .captwiki-mega__item--mega:hover .captwiki-mega__panel {
	max-height: 0;
}

.captwiki-mega.is-mobile.captwiki-mega--hover .captwiki-mega__item.is-open .captwiki-mega__panel {
	max-height: 1500px;
}

/* Keep nested Elementor template content fluid inside the panel. */
.captwiki-mega__panel-inner img {
	max-width: 100%;
	height: auto;
}
