/**
 * Mega Menu Frontend — 3 preset styles (Bordered, Minimal, Feature)
 *
 * All presets inherit theme dark/light mode tokens via --cc-* variables.
 *
 * @package CyberCanvas
 */

/* ─── Base Layout ─────────────────────────────────────────── */
.cc-megamenu {
	width: 100%;
	--cc-megamenu-border-color: var(--cc-primary, #bc7c22);
	--cc-megamenu-columns: 4;
	--cc-megamenu-max-width: none;
}

/* Panel-level default overrides — consumed by element rules below */
.cc-megamenu[style*="--ccm-default-bg-color"] {
	background-color: var(--ccm-default-bg-color) !important;
}

/* ─── When hosted inside the native-nav hover panel ──────── */
/*
 * The .cc-header-mega-panel wrapper in theme.css already provides the
 * panel's background, border, border-radius, box-shadow and animation.
 * Remove all duplicate box styling from the .cc-megamenu content node
 * so the panel background matches the regular sub-menu dropdowns.
 */
.cc-header-mega-panel > .cc-megamenu,
.cc-header-mega-panel > .cc-megamenu[class*="cc-megamenu-preset-"] {
	background: none !important;
	border: none !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	padding: 0 !important;
	width: 100%;
}

/* Direct HTML-block panels should span the full panel width */
.cc-megamenu-direct-block .cc-megamenu-col {
	grid-column: 1 / -1;
}

.cc-megamenu-grid {
	display: grid;
	grid-template-columns: repeat(var(--cc-megamenu-columns, 4), 1fr);
	width: 100%;
}

/* Column gap presets */
.cc-megamenu-gap-tight .cc-megamenu-grid { gap: 0.5rem; }
.cc-megamenu-gap-normal .cc-megamenu-grid { gap: 1rem; }
.cc-megamenu-gap-wide .cc-megamenu-grid { gap: 1.5rem; }

/* ─── Column Headings ─────────────────────────────────────── */
.cc-megamenu-col-heading {
	font-weight: var(--ccm-heading-weight, 700);
	font-size: var(--ccm-heading-size, var(--ccm-default-heading-size, var(--ccm-global-heading-size, 0.8rem)));
	margin-bottom: 0.625rem;
	letter-spacing: 0.04em;
	line-height: 1.3;
	color: var(--ccm-heading-color, var(--ccm-default-heading-color, inherit));
}

/* ─── Links Column ────────────────────────────────────────── */
.cc-megamenu-links {
	list-style: none;
	margin: 0 -0.5rem;
	padding: 0;
}

.cc-megamenu-link-item { margin-bottom: 0; }

.cc-megamenu-link {
	display: flex;
	align-items: center;
	gap: 0.625rem;
	padding: 0.5rem 0.5rem;
	border-radius: var(--ccm-border-radius, var(--ccm-global-item-radius, var(--cc-radius-md, 8px)));
	text-decoration: none;
	transition: background-color 150ms, color 150ms;
}

.cc-megamenu-link:hover {
	background: var(--ccm-hover-bg, color-mix(in srgb, var(--cc-primary, #bc7c22) 8%, transparent));
}

.cc-megamenu-link-img {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: 6px;
}

.cc-megamenu-link-body {
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
	min-width: 0;
}

.cc-megamenu-link-name {
	font-size: var(--ccm-link-size, var(--ccm-default-link-size, var(--ccm-global-link-size, 0.9rem)));
	font-weight: var(--ccm-text-weight, 500);
	color: var(--ccm-link-color, var(--ccm-default-link-color, color-mix(in srgb, var(--cc-text, #1e1e1e) 88%, transparent)));
	line-height: 1.3;
	transition: color 150ms;
}

.cc-megamenu-link:hover .cc-megamenu-link-name {
	color: var(--ccm-link-hover-color, var(--ccm-default-link-hover-color, var(--cc-primary, #bc7c22)));
}

.cc-megamenu-link-note {
	font-size: var(--ccm-text-size, var(--ccm-default-text-size, var(--ccm-global-text-size, 0.72rem)));
	color: var(--ccm-text-color, var(--ccm-default-text-color, color-mix(in srgb, var(--cc-text, #1e1e1e) 52%, transparent)));
	line-height: 1.3;
}

.cc-megamenu-link-badge {
	display: inline-flex;
	align-items: center;
	padding: 1px 6px;
	border-radius: var(--cc-radius-pill, 999px);
	font-size: var(--ccm-badge-size, 0.65rem);
	font-weight: 700;
	background: var(--ccm-badge-bg, color-mix(in srgb, var(--cc-primary, #bc7c22) 14%, transparent));
	color: var(--ccm-badge-color, var(--cc-primary, #bc7c22));
}

/* ─── Product Items ───────────────────────────────────────── */
.cc-megamenu-products {
	list-style: none;
	margin: 0 -0.5rem;
	padding: 0;
}

.cc-megamenu-product-item {
	border-bottom: 1px solid color-mix(in srgb, var(--cc-border, #ece4d5) 60%, transparent);
	padding: 0.375rem 0;
}

.cc-megamenu-product-item:last-child { border-bottom: none; }

.cc-megamenu-product-link {
	display: flex;
	align-items: flex-start;
	gap: 0.625rem;
	text-decoration: none;
	color: inherit;
	padding: 0.375rem 0.5rem;
	border-radius: var(--ccm-border-radius, var(--ccm-global-item-radius, var(--cc-radius-md, 8px)));
	transition: background-color 150ms, opacity 150ms;
}

.cc-megamenu-product-link:hover {
	background: var(--ccm-hover-bg, color-mix(in srgb, var(--cc-primary, #bc7c22) 8%, transparent));
}

.cc-megamenu-product-thumb {
	flex-shrink: 0;
}

/* Thumbnail style */
.cc-megamenu-products--thumb .cc-megamenu-product-img {
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: 6px;
}

/* Card style */
.cc-megamenu-products--card .cc-megamenu-product-img {
	width: 64px;
	height: 64px;
	object-fit: cover;
	border-radius: 8px;
}

.cc-megamenu-product-info {
	display: flex;
	flex-direction: column;
	gap: 0.125rem;
	min-width: 0;
}

.cc-megamenu-product-name {
	font-size: var(--ccm-text-size, var(--ccm-default-text-size, var(--ccm-global-text-size, 0.85rem)));
	font-weight: var(--ccm-text-weight, 500);
	color: var(--ccm-text-color, var(--ccm-default-text-color, var(--cc-heading, #1a1a1a)));
	display: -webkit-box;
	line-height: 1.35;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	white-space: normal;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

.cc-megamenu-product-price {
	font-size: var(--ccm-price-size, 0.8rem);
	color: var(--ccm-price-color, var(--cc-primary, #bc7c22));
	font-weight: 600;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.35rem;
}

.cc-megamenu-product-price del,
.cc-megamenu-product-price ins {
	display: inline-flex;
	align-items: center;
}

.cc-megamenu-product-price ins {
	text-decoration: none;
}

/* ─── Image + CTA Column ─────────────────────────────────── */
.cc-megamenu-image-cta {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.cc-megamenu-cta-img {
	width: 100%;
	height: auto;
	border-radius: var(--ccm-border-radius, var(--ccm-global-item-radius, 8px));
	object-fit: cover;
}

.cc-megamenu-cta-heading {
	font-weight: var(--ccm-heading-weight, 700);
	font-size: var(--ccm-heading-size, var(--ccm-default-heading-size, 0.95rem));
	color: var(--ccm-heading-color, var(--ccm-default-heading-color, var(--cc-heading, #1a1a1a)));
}

.cc-megamenu-cta-desc {
	font-size: var(--ccm-text-size, var(--ccm-default-text-size, 0.8rem));
	color: var(--ccm-text-color, var(--ccm-default-text-color, color-mix(in srgb, var(--cc-text, #1e1e1e) 75%, transparent)));
	margin: 0;
	line-height: 1.4;
}

.cc-megamenu-cta-btn {
	display: inline-flex;
	align-items: center;
	padding: 0.4rem 0.875rem;
	border-radius: var(--ccm-border-radius, var(--ccm-global-item-radius, var(--cc-radius-md, 8px)));
	background: var(--ccm-btn-bg, var(--cc-primary, #bc7c22));
	color: var(--ccm-btn-color, #fff);
	font-size: 0.8rem;
	font-weight: 600;
	text-decoration: none;
	transition: opacity 150ms;
	align-self: flex-start;
}

.cc-megamenu-cta-btn:hover { opacity: 0.85; color: var(--ccm-btn-color, #fff); }

/* ───────────────────────────────────────────────────────────
   PRESET: Bordered (Default)
   Gold/accent border, dark surface, uppercase headings.
   ─────────────────────────────────────────────────────────── */
.cc-megamenu-preset-bordered {
	border: 2px solid var(--cc-megamenu-border-color);
	border-radius: var(--ccm-global-panel-radius, var(--cc-radius-xl, 21px));
	background: color-mix(in srgb, var(--cc-surface, #f2efe9) calc(var(--ccm-panel-bg-opacity, 96) * 1%), transparent);
	padding: clamp(0.75rem, 2vw, 1.25rem);
	box-shadow: 0 16px 42px rgba(15, 23, 42, 0.14);
}

.cc-megamenu-preset-bordered .cc-megamenu-col-heading {
	text-transform: uppercase;
	color: var(--cc-megamenu-border-color);
	padding-bottom: 0.375rem;
	border-bottom: 1px solid color-mix(in srgb, var(--cc-megamenu-border-color) 25%, transparent);
}

.cc-megamenu-preset-bordered .cc-megamenu-col {
	padding-right: 0.75rem;
	border-right: 1px solid color-mix(in srgb, var(--cc-border, #ece4d5) 40%, transparent);
}

.cc-megamenu-preset-bordered .cc-megamenu-col:last-child {
	border-right: none;
	padding-right: 0;
}

.cc-megamenu-preset-bordered .cc-megamenu-product-price {
	color: var(--cc-megamenu-border-color);
}

/* ───────────────────────────────────────────────────────────
   PRESET: Minimal
   Clean, no border, subtle shadow, text-focused.
   ─────────────────────────────────────────────────────────── */
.cc-megamenu-preset-minimal {
	border: none;
	border-radius: var(--ccm-global-panel-radius, var(--cc-radius-lg, 16px));
	background: color-mix(in srgb, var(--cc-surface, #f2efe9) calc(var(--ccm-panel-bg-opacity, 100) * 1%), transparent);
	padding: clamp(0.75rem, 2vw, 1.25rem);
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.cc-megamenu-preset-minimal .cc-megamenu-col-heading {
	text-transform: none;
	color: var(--cc-heading, #1a1a1a);
	font-size: 0.85rem;
}

.cc-megamenu-preset-minimal .cc-megamenu-product-item {
	border-bottom-color: color-mix(in srgb, var(--cc-border, #ece4d5) 30%, transparent);
}

/* ───────────────────────────────────────────────────────────
   PRESET: Feature
   Gradient background, large images, bold CTAs.
   ─────────────────────────────────────────────────────────── */
.cc-megamenu-preset-feature {
	border: 1px solid color-mix(in srgb, var(--cc-primary, #bc7c22) 18%, var(--cc-border, #ece4d5));
	border-radius: var(--ccm-global-panel-radius, var(--cc-radius-xl, 21px));
	background:
		linear-gradient(135deg, color-mix(in srgb, var(--cc-primary, #bc7c22) 10%, transparent), transparent 34%),
		color-mix(in srgb, var(--cc-surface, #f2efe9) calc(var(--ccm-panel-bg-opacity, 96) * 1%), transparent);
	padding: clamp(1rem, 2.5vw, 1.5rem);
	box-shadow: 0 20px 52px rgba(15, 23, 42, 0.16);
}

.cc-megamenu-preset-feature .cc-megamenu-col-heading {
	text-transform: uppercase;
	color: var(--cc-primary, #bc7c22);
	font-size: 0.85rem;
}

/* Larger product images in feature preset */
.cc-megamenu-preset-feature .cc-megamenu-products--thumb .cc-megamenu-product-img {
	width: 48px;
	height: 48px;
	border-radius: 8px;
}

.cc-megamenu-preset-feature .cc-megamenu-products--card .cc-megamenu-product-img {
	width: 80px;
	height: 80px;
	border-radius: 10px;
}

/* Bold CTA buttons instead of text links in feature */
.cc-megamenu-preset-feature .cc-megamenu-col-cta {
	display: inline-flex;
	padding: 0.35rem 0.75rem;
	border-radius: var(--cc-radius-md, 8px);
	background: color-mix(in srgb, var(--cc-primary, #bc7c22) 12%, transparent);
	font-size: 0.78rem;
}

.cc-megamenu-preset-feature .cc-megamenu-col-cta:hover {
	background: color-mix(in srgb, var(--cc-primary, #bc7c22) 22%, transparent);
	opacity: 1;
}

/* ─── Divider ─────────────────────────────────────────────── */
.cc-megamenu-divider {
	border: none;
	border-top: 1px solid color-mix(in srgb, var(--cc-border, #ece4d5) 60%, transparent);
	margin: 1rem 0;
	width: 100%;
}

/* ─── CTA Column Link Hover (with per-element override) ──── */
.cc-megamenu-col-cta {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	margin-top: 0.5rem;
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--ccm-link-color, var(--ccm-default-link-color, var(--cc-primary, #bc7c22)));
	text-decoration: none;
	transition: opacity 150ms, color 150ms;
}

.cc-megamenu-col-cta:hover {
	color: var(--ccm-link-hover-color, var(--ccm-default-link-hover-color, var(--cc-primary, #bc7c22)));
	opacity: 0.75;
}

/* ─── Mobile Responsive ──────────────────────────────────── */

/*
 * On mobile, mega menu panels are hidden from the desktop header
 * (handled via elementor-compat.css breakpoint rules).
 * These rules handle the case where a mega menu is somehow visible
 * on a small viewport — collapse the multi-column grid to a single
 * column and reduce sizing.
 */
@media (max-width: 1023px) {
	.cc-megamenu {
		--cc-megamenu-columns: 1;
	}

	.cc-megamenu-grid {
		grid-template-columns: 1fr;
		gap: 1rem;
	}

	.cc-megamenu-preset-bordered .cc-megamenu-col,
	.cc-megamenu-preset-minimal .cc-megamenu-col,
	.cc-megamenu-preset-feature .cc-megamenu-col {
		border-right: none;
		padding-right: 0;
		border-bottom: 1px solid color-mix(in srgb, var(--cc-border, #ece4d5) 40%, transparent);
		padding-bottom: 0.75rem;
	}

	.cc-megamenu-preset-bordered .cc-megamenu-col:last-child,
	.cc-megamenu-preset-minimal .cc-megamenu-col:last-child,
	.cc-megamenu-preset-feature .cc-megamenu-col:last-child {
		border-bottom: none;
		padding-bottom: 0;
	}

	/* Reduce padding on mobile panels */
	.cc-megamenu-preset-bordered,
	.cc-megamenu-preset-minimal,
	.cc-megamenu-preset-feature {
		padding: 0.75rem;
	}
}

@media (max-width: 640px) {
	.cc-megamenu-products--card .cc-megamenu-product-img {
		width: 48px;
		height: 48px;
	}

	.cc-megamenu-cta-img {
		max-height: 140px;
	}
}
