/* Pulse Mega Menu — base styles with design token variables */

.pmm-mega-menu {
	/* Safe defaults are injected via PHP inline style; these are emergency CSS fallbacks only.
	   The self-referential pattern (--x: var(--x, val)) is intentionally avoided — it is cyclic
	   and makes the custom property invalid at computed-value time, causing transparent backgrounds. */
	position: relative;
	z-index: var(--pmm-z-index, 99999);
	overflow-x: clip; /* prevent visibility:hidden panels from creating body X-scroll */
	background: var(--pmm-color-bg, #ffffff);
	border-bottom: 1px solid var(--pmm-color-border, #e5e7eb);
	font-family: var(--pmm-type-font-family, system-ui, -apple-system, sans-serif);
	font-size: var(--pmm-type-font-size-base, 15px);
	line-height: var(--pmm-type-line-height, 1.5);
	color: var(--pmm-color-text, #111827);
}

/* Force our font and remove underlines on all descendants regardless of theme CSS */
.pmm-mega-menu * {
	font-family: var(--pmm-type-font-family) !important;
}

.pmm-mega-menu a {
	text-decoration: none;
}

.pmm-menu-bar {
	display: flex;
	align-items: center;
	max-width: 1280px;
	margin: 0 auto;
	padding: 0 16px;
}

/* Mobile toggle */
.pmm-mobile-toggle {
	display: none;
	background: none;
	border: none;
	padding: 12px;
	cursor: pointer;
	color: var(--pmm-color-text);
}

.pmm-hamburger {
	display: block;
	width: 20px;
	height: 2px;
	background: currentColor;
	position: relative;
}

.pmm-hamburger::before,
.pmm-hamburger::after {
	content: "";
	display: block;
	width: 20px;
	height: 2px;
	background: currentColor;
	position: absolute;
	left: 0;
}

.pmm-hamburger::before { top: -6px; }
.pmm-hamburger::after  { top: 6px; }

/* Menu items */
.pmm-menu-items {
	display: flex;
	list-style: none;
	margin: 0;
	padding: 0;
	gap: var(--pmm-spacing-gap);
}

.pmm-menu-item {
	position: relative;
}

.pmm-menu-link {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: var(--pmm-spacing-item-padding);
	color: var(--pmm-color-text);
	text-decoration: none;
	font-weight: var(--pmm-type-font-weight-normal);
	white-space: nowrap;
	transition: color 0.15s ease;
}

.pmm-menu-link:hover,
.pmm-menu-link:focus-visible,
.pmm-menu-link[aria-expanded="true"] {
	color: var(--pmm-color-accent);
}

.pmm-menu-link:focus-visible {
	outline: 2px solid var(--pmm-color-accent);
	outline-offset: -2px;
	border-radius: 4px;
}

.pmm-icon {
	flex-shrink: 0;
	width: 20px;
	height: 20px;
}

.pmm-chevron {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	margin-top: -2px;
	margin-left: 2px;
	transition: transform 0.2s ease;
}

.pmm-menu-link[aria-expanded="true"] .pmm-chevron {
	transform: rotate(-135deg);
	margin-top: 2px;
}

/* Mega panel — visibility/opacity/transform keeps links in DOM for crawlers (zero CLS) */
.pmm-panel {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: min(600px, calc(100vw - 2rem));
	max-width: min(900px, calc(100vw - 2rem));
	background: var(--pmm-color-bg-panel);
	border: 1px solid var(--pmm-color-border);
	border-radius: var(--pmm-radius);
	box-shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 16px 48px -8px rgba(0,0,0,0.12);
	/* z-index is set by JS on portaled panels; this fallback is for non-portaled states */
	visibility: hidden;
	opacity: 0;
	transform: translateY(-6px);
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

/* Non-portaled (mobile inline) open state */
.pmm-menu-item.pmm-panel-open > .pmm-panel,
/* Portaled (body-level) open state */
.pmm-panel.pmm-panel-visible {
	visibility: visible;
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.pmm-panel-inner {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: var(--pmm-spacing-gap);
	padding: var(--pmm-spacing-panel-padding);
}

.pmm-panel-group {
	min-width: 0;
}

.pmm-group-heading {
	font-size: var(--pmm-type-font-size-heading);
	font-weight: var(--pmm-type-font-weight-bold);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--pmm-color-text-muted);
	margin: 0 0 8px;
	padding: 0 8px;
}

.pmm-group-links {
	list-style: none;
	margin: 0;
	padding: 0;
}

.pmm-group-link {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 8px;
	border-radius: calc(var(--pmm-radius) - 2px);
	color: var(--pmm-color-text);
	text-decoration: none;
	transition: background 0.15s ease;
}

.pmm-group-link:hover,
.pmm-group-link:focus-visible {
	background: rgba(0, 0, 0, 0.04);
}

.pmm-group-link:focus-visible {
	outline: 2px solid var(--pmm-color-accent);
	outline-offset: -2px;
}

.pmm-link-image {
	width: 40px;
	height: 40px;
	border-radius: 4px;
	object-fit: cover;
	flex-shrink: 0;
}

.pmm-link-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.pmm-link-label {
	font-weight: var(--pmm-type-font-weight-normal);
	color: var(--pmm-color-text);
}

.pmm-link-desc {
	font-size: 0.85em;
	color: var(--pmm-color-text-muted);
	margin-top: 2px;
}

/* Mobile styles */
@media (max-width: 768px) {
	.pmm-mobile-toggle {
		display: block;
	}

	.pmm-menu-items {
		display: flex;
		flex-direction: column;
		position: fixed;
		top: 0;
		left: 0;
		width: 85vw;
		max-width: 360px;
		height: 100vh;
		background: var(--pmm-color-bg, #ffffff);
		box-shadow: 4px 0 32px rgba(0, 0, 0, 0.18);
		padding: 0;
		overflow-y: auto;
		z-index: calc(var(--pmm-z-index, 99999) + 2);
		transform: translateX(-100%);
		visibility: hidden;
		transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.28s;
	}

	.pmm-menu-items.pmm-drawer-open {
		transform: translateX(0);
		visibility: visible;
	}

	/* Drawer header (injected by JS) */
	.pmm-drawer-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 16px;
		height: 60px;
		min-height: 60px;
		border-bottom: 1px solid var(--pmm-color-border, #e5e7eb);
		background: var(--pmm-color-bg, #ffffff);
		position: sticky;
		top: 0;
		z-index: 1;
		list-style: none;
	}

	.pmm-drawer-header__title {
		font-weight: 700;
		font-size: 16px;
		color: var(--pmm-color-text, #111827);
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		max-width: calc(100% - 48px);
	}

	.pmm-drawer-close {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 36px;
		height: 36px;
		background: none;
		border: none;
		cursor: pointer;
		color: var(--pmm-color-text-muted, #6b7280);
		font-size: 20px;
		line-height: 1;
		border-radius: 8px;
		flex-shrink: 0;
		transition: background 0.15s ease, color 0.15s ease;
	}

	.pmm-drawer-close:hover {
		background: rgba(0, 0, 0, 0.06);
		color: var(--pmm-color-text, #111827);
	}

	/* Drawer menu items */
	.pmm-menu-item {
		border-bottom: 1px solid var(--pmm-color-border, #e5e7eb);
	}

	.pmm-menu-item:last-child {
		border-bottom: none;
	}

	.pmm-menu-link {
		min-height: 54px;
		font-size: 16px !important;
		padding: 0 20px !important;
		font-weight: 500 !important;
		border-radius: 0 !important;
	}

	.pmm-has-panel > .pmm-menu-link {
		justify-content: space-between;
	}

	.pmm-panel {
		display: none;
		position: static;
		min-width: 0;
		max-width: none;
		border: none;
		border-radius: 0;
		box-shadow: none;
		background: rgba(0, 0, 0, 0.02);
		border-top: 1px solid var(--pmm-color-border, #e5e7eb);
		/* Reset desktop animation for mobile drawer */
		visibility: visible;
		opacity: 1;
		transform: none;
		pointer-events: auto;
		transition: none;
	}

	.pmm-menu-item.pmm-panel-open > .pmm-panel {
		display: block;
	}

	.pmm-panel-inner {
		grid-template-columns: 1fr;
		padding: 12px 16px 16px;
		gap: 12px;
	}

	.pmm-group-heading {
		padding: 8px 8px 4px;
	}

	.pmm-group-link {
		min-height: 44px;
		align-items: center;
		padding: 10px 8px;
	}
}

.pmm-drawer-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.4);
	z-index: calc(var(--pmm-z-index, 99999) + 1);
}

.pmm-drawer-overlay.pmm-overlay-active {
	display: block;
}

/* RTL — direction:rtl is inherited from [dir="rtl"], so flex-direction:row already flows
   right-to-left. No row-reverse needed. */

/* RTL panel: right edge aligns with the hovered item's right edge */
[dir="rtl"] .pmm-panel {
	left: auto;
	right: 0;
}

@media (max-width: 768px) {
	[dir="rtl"] .pmm-menu-items {
		flex-direction: column;
		left: auto;
		right: 0;
		transform: translateX(100%);
	}

	[dir="rtl"] .pmm-menu-items.pmm-drawer-open {
		transform: translateX(0);
	}
}

/* ── Rich block types ── */

/* Featured posts */
.pmm-featured-posts {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.pmm-post-card {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	text-decoration: none;
	color: var(--pmm-color-text);
	padding: 8px;
	border-radius: calc(var(--pmm-radius) / 2);
	transition: background 0.15s ease;
}

.pmm-post-card:hover {
	background: rgba(0, 0, 0, 0.04);
	color: var(--pmm-color-accent);
}

.pmm-post-card__img {
	flex-shrink: 0;
	width: 56px;
	height: 56px;
	overflow: hidden;
	border-radius: calc(var(--pmm-radius) / 2);
}

.pmm-post-card__img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.pmm-post-card__body {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

.pmm-post-card__title {
	font-weight: var(--pmm-type-font-weight-bold);
	font-size: var(--pmm-type-font-size-base);
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.pmm-post-card__desc {
	font-size: 12px;
	color: var(--pmm-color-text-muted);
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Search block */
.pmm-panel-search {
	display: flex;
	align-items: center;
	gap: 6px;
	border: 1px solid var(--pmm-color-border);
	border-radius: var(--pmm-radius);
	padding: 6px 10px;
	background: var(--pmm-color-bg);
	transition: border-color 0.15s ease;
}

.pmm-panel-search:focus-within {
	border-color: var(--pmm-color-accent);
}

.pmm-panel-search__input {
	flex: 1;
	border: none;
	outline: none;
	background: transparent;
	font-size: var(--pmm-type-font-size-base);
	color: var(--pmm-color-text);
	font-family: var(--pmm-type-font-family);
	min-width: 0;
}

.pmm-panel-search__input::placeholder {
	color: var(--pmm-color-text-muted);
}

.pmm-panel-search__btn {
	background: none;
	border: none;
	cursor: pointer;
	color: var(--pmm-color-text-muted);
	padding: 0;
	display: flex;
	align-items: center;
	flex-shrink: 0;
}

.pmm-panel-search__btn:hover {
	color: var(--pmm-color-accent);
}

/* Promo card */
.pmm-promo-card {
	display: block;
	text-decoration: none;
	border-radius: var(--pmm-radius);
	overflow: hidden;
	border: 1px solid var(--pmm-color-border);
	transition: box-shadow 0.2s ease;
}

.pmm-promo-card:hover {
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.pmm-promo-card__img img {
	width: 100%;
	height: 130px;
	object-fit: cover;
	display: block;
}

.pmm-promo-card__body {
	padding: 12px 16px;
}

.pmm-promo-card__title {
	display: block;
	font-weight: var(--pmm-type-font-weight-bold);
	color: var(--pmm-color-text);
	margin-bottom: 4px;
	font-size: var(--pmm-type-font-size-base);
}

.pmm-promo-card__desc {
	display: block;
	font-size: 13px;
	color: var(--pmm-color-text-muted, #6b7280);
	line-height: 1.4;
}

/* Featured item card (dynamic single-item block) */
.pmm-featured-item-card {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	text-decoration: none;
	color: var(--pmm-color-text, #111827);
	padding: 12px;
	border-radius: var(--pmm-radius, 10px);
	border: 1px solid var(--pmm-color-border, #e5e7eb);
	transition: box-shadow 0.2s ease, background 0.15s ease;
}

.pmm-featured-item-card:hover {
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
	background: rgba(0, 0, 0, 0.02);
	color: var(--pmm-color-accent, #2563eb);
}

.pmm-featured-item-card__img {
	flex-shrink: 0;
	width: 72px;
	height: 72px;
	overflow: hidden;
	border-radius: calc(var(--pmm-radius, 10px) / 2);
}

.pmm-featured-item-card__img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.pmm-featured-item-card__body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.pmm-featured-item-card__title {
	font-weight: var(--pmm-type-font-weight-bold, 600);
	font-size: var(--pmm-type-font-size-base, 15px);
	line-height: 1.3;
}

.pmm-featured-item-card__desc {
	font-size: 12px;
	color: var(--pmm-color-text-muted, #6b7280);
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
