/* ===========================================================================
   Custom Mega Menu - frontend styles
   - Horizontal top menu (Home | About | Contact | Shop).
   - Enabled items open a mega panel directly below them on hover (desktop).
   - 12-column grid; multiple headings stack vertically inside a column.
   - Mobile: accordion (panels open on click, columns stack).
   =========================================================================== */

.cmm-menu {
	--cmm-accent: #4f46e5;
	--cmm-border: #e6e6ef;
	--cmm-bg: #ffffff;
	--cmm-muted: #6b6b86;

	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px;
	position: relative; /* anchor for full-width panels */
}

.cmm-menu li {
	margin: 0;
}

.cmm-menu a {
	display: block;
	padding: 14px 16px;
	text-decoration: none;
	color: #1e1e2e;
	border-radius: 6px;
	transition: background-color 0.15s ease, color 0.15s ease;
}

/* Highlight on hover / focus / active item. */
.cmm-menu > li:hover > a,
.cmm-menu > li:focus-within > a,
.cmm-menu > li.current-menu-item > a {
	background: #f0f0fa;
	color: var(--cmm-accent);
}

/* ----- Mega panel ----- */
.cmm-mega-parent {
	position: relative;
}

/* The +/- button is a mobile control; hover is used on desktop. */
.cmm-parent-toggle {
	display: none;
	background: transparent;
	border: 0;
	cursor: pointer;
	padding: 0;
	color: #1e1e2e;
}

.cmm-parent-toggle-icon {
	position: relative;
	display: inline-block;
	width: 14px;
	height: 14px;
}

.cmm-parent-toggle-icon::before,
.cmm-parent-toggle-icon::after {
	content: "";
	position: absolute;
	background: currentColor;
}

.cmm-parent-toggle-icon::before {
	top: 50%;
	left: 0;
	right: 0;
	height: 2px;
	margin-top: -1px;
}

.cmm-parent-toggle-icon::after {
	left: 50%;
	top: 0;
	bottom: 0;
	width: 2px;
	margin-left: -1px;
	transition: opacity 0.15s ease;
}

/* Open => "minus": hide the vertical bar. */
.cmm-mega-parent.cmm-open .cmm-parent-toggle-icon::after {
	opacity: 0;
}

/* Full-width items use the menu (ul) as the positioning context. */
.cmm-mega-panel {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 99999;
	min-width: 560px;
	max-width: 95vw;
	background: var(--cmm-bg);
	border: 1px solid var(--cmm-border);
	border-radius: 12px;
	box-shadow: 0 18px 40px rgba(20, 20, 50, 0.16);
	padding: 16px 18px;

	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s, width 0.18s ease, min-width 0.18s ease;
}

/*
 * Collapsed state (tabs layout): no tab is open yet, so the panel shrinks to
 * just the vertical tab rail. As soon as a tab becomes active, JS removes this
 * class and the panel grows back to its configured width. !important is needed
 * to win over the inline custom-width style.
 */
.cmm-mega-panel.cmm-collapsed {
	width: 240px !important;
	min-width: 240px !important;
}

/*
 * Full width variant. We use a viewport "break-out" so the panel spans the full
 * window width while staying anchored to (and positioned by) the parent <li>.
 * This avoids depending on the theme's <ul> being a positioned ancestor.
 */
.cmm-mega-panel.cmm-w-full {
	left: 50%;
	margin-left: -50vw;
	width: 100vw;
	min-width: 0;
	max-width: 100vw;
	border-radius: 0;
}

/*
 * Theme compatibility reset.
 * Many themes hide nested <ul> sub-menus (display:none / off-screen) and reveal
 * only direct children on hover. Our panel builds its own nested lists, so force
 * everything inside the panel to render normally. Scoped to .cmm-mega-panel so
 * it never affects the theme's own menus. (Width is left alone so the fixed tab
 * column width keeps working.)
 */
.cmm-mega-panel ul,
.cmm-mega-panel li {
	position: static !important;
	left: auto !important;
	right: auto !important;
	top: auto !important;
	margin: 0;
	padding: 0;
	float: none !important;
	display: block !important;
	visibility: visible !important;
	opacity: 1 !important;
	background: transparent !important;
	box-shadow: none !important;
	list-style: none !important;
	transform: none !important;
	transition: none !important;
}

.cmm-mega-panel .cmm-item-link,
.cmm-mega-panel .cmm-tab-btn {
	display: flex !important;
}

/* Keep item/heading text using our colours even if the theme forces a color. */
.cmm-mega-panel .cmm-item-title,
.cmm-mega-panel .cmm-tab-label {
	color: inherit;
}

/* Open on hover / focus (desktop). */
.cmm-mega-parent:hover > .cmm-mega-panel,
.cmm-mega-parent:focus-within > .cmm-mega-panel,
.cmm-mega-parent.cmm-open > .cmm-mega-panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* ----- 12-column grid ----- */
.cmm-row {
	display: flex;
	flex-wrap: wrap;
	margin: 0 -10px;
}

.cmm-col {
	padding: 0 10px;
	box-sizing: border-box;
	margin-bottom: 8px;
}

.cmm-col-1  { flex: 0 0 8.3333%;  max-width: 8.3333%;  }
.cmm-col-2  { flex: 0 0 16.6666%; max-width: 16.6666%; }
.cmm-col-3  { flex: 0 0 25%;      max-width: 25%;      }
.cmm-col-4  { flex: 0 0 33.3333%; max-width: 33.3333%; }
.cmm-col-5  { flex: 0 0 41.6666%; max-width: 41.6666%; }
.cmm-col-6  { flex: 0 0 50%;      max-width: 50%;      }
.cmm-col-7  { flex: 0 0 58.3333%; max-width: 58.3333%; }
.cmm-col-8  { flex: 0 0 66.6666%; max-width: 66.6666%; }
.cmm-col-9  { flex: 0 0 75%;      max-width: 75%;      }
.cmm-col-10 { flex: 0 0 83.3333%; max-width: 83.3333%; }
.cmm-col-11 { flex: 0 0 91.6666%; max-width: 91.6666%; }
.cmm-col-12 { flex: 0 0 100%;     max-width: 100%;     }

/* ----- Sections (headings) inside a column ----- */
.cmm-section {
	margin-bottom: 14px;
}

.cmm-section:last-child {
	margin-bottom: 0;
}

.cmm-heading {
	margin: 0 0 6px;
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--cmm-muted);
	border-bottom: 1px solid var(--cmm-border);
	padding-bottom: 4px;
}

/* A heading can optionally be a link; keep it looking like a heading. */
.cmm-menu .cmm-heading-link {
	display: inline;
	padding: 0;
	border-radius: 0;
	color: inherit;
	text-decoration: none;
}

.cmm-menu .cmm-heading-link:hover,
.cmm-menu .cmm-heading-link:focus {
	color: var(--cmm-accent);
	background: transparent;
	text-decoration: underline;
}

.cmm-items {
	list-style: none;
	margin: 0;
	padding: 0;
}

.cmm-item {
	margin: 0;
}

/* Reset the inherited big menu link padding for items inside the panel. */
.cmm-menu .cmm-item-link {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 6px 8px;
	border-radius: 6px;
	color: #2a2a40;
}

.cmm-menu .cmm-item-link:hover {
	background: #f3f3fb;
	color: var(--cmm-accent);
}

.cmm-item-icon {
	font-size: 16px;
	line-height: 1.5;
	color: var(--cmm-accent);
}

.cmm-item-img {
	width: 24px;
	height: 24px;
	object-fit: cover;
	border-radius: 4px;
	flex: 0 0 auto;
}

.cmm-item-text {
	display: flex;
	flex-direction: column;
}

.cmm-item-title {
	font-weight: 500;
	font-size: 14px;
}

.cmm-item-desc {
	font-size: 12px;
	color: var(--cmm-muted);
	margin-top: 1px;
}

/* ===========================================================================
   Vertical Tabs layout (when an item's layout = "tabs").
   Tabs on the left, the active tab's items on the right.
   =========================================================================== */
.cmm-mega-panel.cmm-tabs-layout {
	min-width: 620px;
}

.cmm-vtabs {
	display: flex;
	align-items: stretch;
	gap: 14px;
}

.cmm-tablist {
	list-style: none;
	margin: 0;
	padding: 0;
	/* Fixed width, configurable per item via --cmm-tab-width (default 200px). */
	flex: 0 0 var(--cmm-tab-width, 200px);
	width: var(--cmm-tab-width, 200px);
	border-right: 1px solid var(--cmm-border);
}

/* The tab row: label/link on the left, chevron toggle on the right. The high
   specificity overrides the theme-compat reset that forces panel <li> to block. */
.cmm-mega-panel .cmm-tab {
	display: flex !important;
	flex-wrap: wrap;
	align-items: center;
	margin: 0;
}

.cmm-menu .cmm-tab-btn {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1 1 auto;
	min-width: 0;
	text-align: left;
	background: transparent;
	border: 0;
	border-radius: 8px;
	padding: 10px 12px;
	font-size: 14px;
	color: #2a2a40;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.cmm-menu .cmm-tab-btn:hover,
.cmm-tab.is-active .cmm-tab-btn {
	background: #eef0ff;
	color: var(--cmm-accent);
}

/* Chevron (>) toggle button shown on every tab. */
.cmm-menu .cmm-tab-toggle {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 0;
	border-radius: 8px;
	padding: 10px 12px;
	margin: 0;
	color: var(--cmm-muted);
	cursor: pointer;
	line-height: 0;
}

.cmm-menu .cmm-tab-toggle:hover {
	color: var(--cmm-accent);
}

.cmm-tab-arrow {
	display: inline-block;
	width: 7px;
	height: 7px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(-45deg); /* points right: > */
	transition: transform 0.15s ease;
}

/* When a tab is open, the chevron points down. */
.cmm-tab.is-active .cmm-tab-arrow {
	transform: rotate(45deg);
}

/* Tab icon (CSS icon class) and image variants. */
.cmm-tab-icon {
	font-size: 16px;
	line-height: 1;
	flex: 0 0 auto;
}

.cmm-tab-img {
	width: 20px;
	height: 20px;
	object-fit: cover;
	border-radius: 4px;
	flex: 0 0 auto;
}

.cmm-tab-label {
	flex: 1 1 auto;
	min-width: 0;
}

.cmm-tab-panels {
	flex: 1 1 auto;
	min-width: 0;
	padding: 2px 4px;
}

.cmm-tab-panel {
	display: none;
	animation: cmm-fade 0.18s ease;
}

.cmm-tab-panel.is-active {
	display: block;
}

@keyframes cmm-fade {
	from { opacity: 0; transform: translateY(4px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* In a tab panel, lay the items out in an auto grid. */
.cmm-items-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 2px 14px;
}

/* ===========================================================================
   Responsive: accordion on small screens.
   =========================================================================== */
@media (max-width: 782px) {
	.cmm-menu {
		flex-direction: column;
		align-items: stretch;
	}

	.cmm-menu > li {
		border-bottom: 1px solid var(--cmm-border);
	}

	/* Panels render inline (static) and toggle open via the +/- button.
	   Keep the parent relative so the +/- button can anchor to it. */
	.cmm-mega-parent,
	.cmm-mega-parent.is-full {
		position: relative;
	}

	/* Show the +/- toggle and give the label room so they do not overlap. */
	.cmm-parent-toggle {
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		top: 0;
		right: 0;
		width: 52px;
		height: 52px;
		z-index: 2;
	}

	.cmm-mega-parent > a {
		padding-right: 60px;
	}

	.cmm-mega-panel,
	.cmm-mega-panel.cmm-w-full {
		position: static;
		width: auto;
		min-width: 0;
		max-width: none;
		/* Reset the desktop full-width break-out offset. */
		left: auto;
		margin-left: 0;
		border: 0;
		border-radius: 0;
		box-shadow: none;
		padding: 6px 10px 12px;

		/* Hidden until the parent gets .cmm-open via JS. */
		display: none;
		opacity: 1;
		visibility: visible;
		transform: none;
	}

	.cmm-mega-parent.cmm-open > .cmm-mega-panel {
		display: block;
	}

	/* Vertical tabs stack: tablist on top, panels below. */
	.cmm-mega-panel.cmm-tabs-layout {
		min-width: 0;
	}

	.cmm-vtabs {
		flex-direction: column;
		gap: 8px;
	}

	/* Stack the tabs as accordion rows, each with its content directly below. */
	.cmm-tablist {
		flex-basis: auto;
		width: 100%;
		border-right: 0;
		display: block;
	}

	.cmm-mega-panel .cmm-tab {
		border-bottom: 1px solid var(--cmm-border);
	}

	/* The relocated tab panel wraps onto its own full-width row under the tab. */
	.cmm-mega-panel .cmm-tab .cmm-tab-panel {
		flex: 0 0 100%;
		width: 100%;
		padding: 0 4px 8px;
	}

	/* The shared (now empty) panel container is not needed on mobile. */
	.cmm-tab-panels {
		display: none;
	}

	.cmm-items-grid {
		grid-template-columns: 1fr;
	}

	/* Stack all columns full width. */
	.cmm-row {
		margin: 0;
	}

	.cmm-col,
	.cmm-col-1, .cmm-col-2, .cmm-col-3, .cmm-col-4, .cmm-col-5, .cmm-col-6,
	.cmm-col-7, .cmm-col-8, .cmm-col-9, .cmm-col-10, .cmm-col-11, .cmm-col-12 {
		flex: 0 0 100%;
		max-width: 100%;
		padding: 0;
	}
}
