/**
 * Product Category Menu for WooCommerce — front-end styles.
 *
 * Neutral, theme-friendly defaults. Customize via the CSS custom properties
 * below (override them in your theme, in the Customizer's Additional CSS,
 * or via the `wpcm_inline_css` PHP filter).
 *
 * This file contains only breakpoint-INDEPENDENT base styles. The desktop
 * (horizontal bar + dropdowns) and mobile (burger + off-canvas drawer)
 * blocks are generated in PHP (WPCM_Plugin::get_responsive_css()) and
 * attached inline, so the breakpoint follows Elementor's configured Site
 * Settings breakpoints when Elementor is active, and stays filterable via
 * `wpcm_breakpoints` otherwise (defaults: mobile 768px, desktop 1024px).
 */

:root {
	--wpcm-background: #ffffff;
	--wpcm-text-color: #222222;
	--wpcm-hover-background: #f5f5f5;
	--wpcm-border-color: #e5e5e5;
	--wpcm-accent-color: #2271b1;
	--wpcm-border-radius: 6px;
	--wpcm-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
	--wpcm-padding-y: 10px;
	--wpcm-padding-x: 14px;
	--wpcm-transition: 200ms ease;
	--wpcm-submenu-min-width: 220px;
	--wpcm-touch-target: 44px;
	--wpcm-z-index: 1000;
	/* The drawer must sit above sticky headers, popups, and page content —
	 * Elementor sticky sections commonly use z-index values in the 1000s. */
	--wpcm-drawer-z-index: 100000;
	--wpcm-drawer-width: 320px;
	--wpcm-overlay-color: rgba(0, 0, 0, 0.45);
}

/* ---------------------------------------------------------------------------
 * Base (all screen sizes)
 *
 * The item is a flex row: link first (taking the available space), then the
 * chevron toggle INLINE next to the label — never wrapped underneath it.
 * Selectors use li.wpcm-item to win against common theme menu resets.
 * ------------------------------------------------------------------------ */

.wpcm-item,
.wpcm-item * {
	box-sizing: border-box;
}

li.wpcm-item {
	position: relative;
	list-style: none;
	margin: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
}

li.wpcm-item > a,
li.wpcm-item > .wpcm-nolink {
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	min-width: 0;
	padding: var(--wpcm-padding-y) var(--wpcm-padding-x);
	color: inherit;
	text-decoration: none;
	cursor: pointer;
	transition: background-color var(--wpcm-transition), color var(--wpcm-transition);
	border-radius: var(--wpcm-border-radius);
}

li.wpcm-item > .wpcm-submenu-toggle {
	flex: 0 0 auto;
}

/* The submenu always breaks onto its own row (it is absolutely positioned
 * on desktop anyway, and an in-flow accordion panel in the drawer). */
li.wpcm-item > .wpcm-sub-menu {
	flex-basis: 100%;
	min-width: 0;
}

/* NOTE: hover backgrounds are desktop-only (in the generated desktop CSS).
 * No :hover styles apply on mobile — tapped items must not keep a stuck
 * hover state on touch screens. */

li.wpcm-item > a:focus-visible,
li.wpcm-item > .wpcm-nolink:focus-visible,
.wpcm-submenu-toggle:focus-visible,
.wpcm-burger:focus-visible,
.wpcm-close-button:focus-visible {
	outline: 2px solid var(--wpcm-accent-color);
	outline-offset: 2px;
}

li.wpcm-item.current-menu-item > a {
	color: var(--wpcm-accent-color);
	font-weight: 600;
}

li.wpcm-item.current-menu-ancestor > a {
	color: var(--wpcm-accent-color);
}

.wpcm-item-thumb {
	width: 24px;
	height: 24px;
	object-fit: cover;
	border-radius: calc(var(--wpcm-border-radius) / 2);
	flex-shrink: 0;
}

.wpcm-item-count {
	opacity: 0.65;
	font-size: 0.85em;
}

.wpcm-item-description {
	flex-basis: 100%;
	font-size: 0.8em;
	opacity: 0.7;
	line-height: 1.4;
}

/* Submenu toggle button (separate control from the link). */
.wpcm-submenu-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 0;
	padding: 0;
	margin: 0;
	cursor: pointer;
	color: inherit;
	transition: transform var(--wpcm-transition), background-color var(--wpcm-transition);
	border-radius: var(--wpcm-border-radius);
}

.wpcm-toggle-icon {
	display: block;
	width: 7px;
	height: 7px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(45deg);
	transition: transform var(--wpcm-transition);
	margin-top: -3px;
}

.wpcm-submenu-toggle[aria-expanded="true"] .wpcm-toggle-icon {
	transform: rotate(-135deg);
	margin-top: 3px;
}

/* Screen-reader helper (in case the theme does not define it). */
.wpcm-menu-container .screen-reader-text,
li.wpcm-item .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Standalone wrapper (shortcode / block / Elementor). */
.wpcm-standalone {
	max-width: 100%;
}

.wpcm-standalone .wpcm-menu {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Site logo shown left of the burger — mobile only. */
.wpcm-mobile-logo {
	display: none;
}

.wpcm-mobile-logo img {
	display: block;
	max-height: 40px;
	width: auto;
}

.wpcm-logo-text {
	font-weight: 600;
	text-decoration: none;
	color: inherit;
}

/* Burger + drawer chrome: hidden until the mobile breakpoint.
 * Icon-only button; the label is screen-reader-only. */
.wpcm-burger {
	display: none;
	align-items: center;
	justify-content: center;
	width: var(--wpcm-touch-target);
	height: var(--wpcm-touch-target);
	padding: 0;
	background: transparent;
	border: 1px solid var(--wpcm-border-color);
	border-radius: var(--wpcm-border-radius);
	color: inherit;
	font: inherit;
	cursor: pointer;
	transition: background-color var(--wpcm-transition);
}

.wpcm-burger-icon {
	display: inline-flex;
	flex-direction: column;
	justify-content: center;
	gap: 4px;
	width: 18px;
}

.wpcm-burger-icon span {
	display: block;
	height: 2px;
	width: 100%;
	background: currentColor;
	border-radius: 2px;
	transition: transform var(--wpcm-transition), opacity var(--wpcm-transition);
}

/* Burger morphs into an X while the drawer is open. */
.wpcm-drawer-open .wpcm-burger-icon span:nth-child(1) {
	transform: translateY(6px) rotate(45deg);
}

.wpcm-drawer-open .wpcm-burger-icon span:nth-child(2) {
	opacity: 0;
}

.wpcm-drawer-open .wpcm-burger-icon span:nth-child(3) {
	transform: translateY(-6px) rotate(-45deg);
}

.wpcm-overlay,
.wpcm-drawer-head {
	display: none;
}

/* Compact icon-only close (X) button. */
.wpcm-close-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--wpcm-touch-target);
	height: var(--wpcm-touch-target);
	padding: 0;
	background: transparent;
	border: 1px solid var(--wpcm-border-color);
	border-radius: var(--wpcm-border-radius);
	color: inherit;
	cursor: pointer;
	transition: background-color var(--wpcm-transition);
}

.wpcm-close-icon {
	position: relative;
	display: block;
	width: 16px;
	height: 16px;
}

.wpcm-close-icon::before,
.wpcm-close-icon::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 18px;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
}

.wpcm-close-icon::before {
	transform: translate(-50%, -50%) rotate(45deg);
}

.wpcm-close-icon::after {
	transform: translate(-50%, -50%) rotate(-45deg);
}

/* ---------------------------------------------------------------------------
 * Reduced motion
 * ------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {

	li.wpcm-item > a,
	li.wpcm-item .wpcm-sub-menu,
	.wpcm-submenu-toggle,
	.wpcm-toggle-icon,
	.wpcm-burger,
	.wpcm-burger-icon span,
	.wpcm-standalone .wpcm-drawer,
	.wpcm-standalone .wpcm-overlay {
		transition: none;
	}
}
