/**
 * WW Category Menu – Frontend Styles v1.0.5
 * Uses elevated specificity (body .ww-cat-menu) + !important on colours
 * to override Divi 5's aggressive global link and list resets.
 * Colours are injected as CSS custom properties via wp_add_inline_style().
 *
 * SPECIFICITY ORDER (low → high, all use !important so specificity decides):
 *   1. Base link styles            (~3 selectors)
 *   2. Depth-specific overrides    (~5 selectors)
 *   3. Active state overrides      (~6 selectors, includes depth + active)
 *   4. Hover on active             (~7 selectors)
 */

/* ── Variables (defaults – overridden by inline style from settings) ── */
body .ww-cat-menu {
	--ww-cm-normal-bg:           #ffffff;
	--ww-cm-normal-text:         #444444;
	--ww-cm-normal-border:       #e5e5e5;
	--ww-cm-active-bg:           #0073aa;
	--ww-cm-active-bg-light:     #66aecf;
	--ww-cm-active-text:         #ffffff;
	--ww-cm-active-border:       #005177;
	--ww-cm-active-border-light: #668fa3;
	--ww-cm-hover-bg:            #f0f4f8;
	--ww-cm-hover-text:          #222222;
}

/* ── Reset ── */
body .ww-cat-menu,
body .ww-cat-menu * {
	box-sizing: border-box;
}

/* ── Wrapper ── */
body .ww-cat-menu {
	width: 100%;
	font-size: 0.9em;
	line-height: 1.4;
	background: var(--ww-cm-normal-bg);
	border: 1px solid var(--ww-cm-normal-border);
	border-radius: 4px;
	overflow: hidden;
}

/* ── Heading (parent term title) – always full active colour ── */
body .ww-cat-menu .ww-cat-menu__heading {
	display: block !important;
	padding: 13px 16px !important;
	font-size: 0.78em !important;
	font-weight: 700 !important;
	letter-spacing: 0.1em !important;
	text-transform: uppercase !important;
	text-decoration: none !important;
	color: var(--ww-cm-active-text) !important;
	background-color: var(--ww-cm-active-bg) !important;
	border: none !important;
	box-shadow: none !important;
	transition: background-color 0.15s ease;
}

body .ww-cat-menu .ww-cat-menu__heading:hover,
body .ww-cat-menu .ww-cat-menu__heading:focus {
	background-color: var(--ww-cm-active-border) !important;
	color: var(--ww-cm-active-text) !important;
	outline: none !important;
	text-decoration: none !important;
}

/* ── Strip all list/bullet styles (Divi override) ── */
body .ww-cat-menu ul,
body .ww-cat-menu ul li,
body .ww-cat-menu .ww-cat-menu__list,
body .ww-cat-menu .ww-cat-menu__item {
	list-style: none !important;
	list-style-type: none !important;
	list-style-image: none !important;
	margin: 0 !important;
	padding: 0 !important;
	background: none;
	border: none;
}

/* Top border under the heading */
body .ww-cat-menu > .ww-cat-menu__list {
	border-top: 1px solid var(--ww-cm-normal-border) !important;
}

/* ── Item dividers ── */
body .ww-cat-menu .ww-cat-menu__item {
	border-bottom: 1px solid var(--ww-cm-normal-border) !important;
}

body .ww-cat-menu .ww-cat-menu__item:last-child {
	border-bottom: none !important;
}

/* ──────────────────────────────────────────────────────────────────────
   LAYER 1 – Base link styles (~3 selectors)
   ────────────────────────────────────────────────────────────────────── */
body .ww-cat-menu .ww-cat-menu__link {
	display: flex !important;
	align-items: center !important;
	justify-content: space-between !important;
	padding: 11px 16px !important;
	text-decoration: none !important;
	color: var(--ww-cm-normal-text) !important;
	background-color: var(--ww-cm-normal-bg) !important;
	border-left: 3px solid transparent !important;
	border-top: none !important;
	border-right: none !important;
	border-bottom: none !important;
	box-shadow: none !important;
	gap: 8px;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

body .ww-cat-menu .ww-cat-menu__link__label {
	flex: 1 1 auto;
	min-width: 0;
	word-break: break-word;
}

/* ──────────────────────────────────────────────────────────────────────
   LAYER 2 – Depth-specific overrides (~5 selectors)
   Tonal differences reinforce hierarchy. No active state here.
   ────────────────────────────────────────────────────────────────────── */

/* Depth-0: top-level siblings – slightly bolder */
body .ww-cat-menu .ww-cat-menu__list--depth-0 > .ww-cat-menu__item > .ww-cat-menu__link {
	font-weight: 500 !important;
	font-size: 0.94em !important;
	padding: 11px 16px !important;
	color: var(--ww-cm-normal-text) !important;
}

/* Depth-1 list: left rail + tinted bg */
body .ww-cat-menu .ww-cat-menu__list--depth-1 {
	border-top: 1px solid var(--ww-cm-normal-border) !important;
	border-left: 3px solid var(--ww-cm-normal-border) !important;
	margin-left: 12px !important;
	background-color: #f5f7f9 !important;
}

body .ww-cat-menu .ww-cat-menu__list--depth-1 > .ww-cat-menu__item > .ww-cat-menu__link {
	font-size: 0.87em !important;
	font-weight: 400 !important;
	padding: 9px 14px !important;
	color: #5a5a5a !important;
	background-color: #f5f7f9 !important;
}

/* Depth-2 list: deeper rail + darker tint */
body .ww-cat-menu .ww-cat-menu__list--depth-2 {
	border-top: 1px solid var(--ww-cm-normal-border) !important;
	border-left: 3px solid var(--ww-cm-normal-border) !important;
	margin-left: 12px !important;
	background-color: #ebeef2 !important;
}

body .ww-cat-menu .ww-cat-menu__list--depth-2 > .ww-cat-menu__item > .ww-cat-menu__link {
	font-size: 0.83em !important;
	font-weight: 400 !important;
	padding: 8px 14px !important;
	color: #666666 !important;
	background-color: #ebeef2 !important;
}

/* ──────────────────────────────────────────────────────────────────────
   LAYER 3 – Hover (~4 selectors, beats depth bg)
   ────────────────────────────────────────────────────────────────────── */
body .ww-cat-menu .ww-cat-menu__list--depth-0 > .ww-cat-menu__item > .ww-cat-menu__link:hover,
body .ww-cat-menu .ww-cat-menu__list--depth-0 > .ww-cat-menu__item > .ww-cat-menu__link:focus,
body .ww-cat-menu .ww-cat-menu__list--depth-1 > .ww-cat-menu__item > .ww-cat-menu__link:hover,
body .ww-cat-menu .ww-cat-menu__list--depth-1 > .ww-cat-menu__item > .ww-cat-menu__link:focus,
body .ww-cat-menu .ww-cat-menu__list--depth-2 > .ww-cat-menu__item > .ww-cat-menu__link:hover,
body .ww-cat-menu .ww-cat-menu__list--depth-2 > .ww-cat-menu__item > .ww-cat-menu__link:focus {
	background-color: var(--ww-cm-hover-bg) !important;
	color: var(--ww-cm-hover-text) !important;
	border-left-color: var(--ww-cm-active-bg) !important;
	outline: none !important;
	text-decoration: none !important;
}

/* ──────────────────────────────────────────────────────────────────────
   LAYER 4 – Active state (~6 selectors, beats depth rules)
   Uses the lighter tint of the active colour so heading stays dominant.
   ────────────────────────────────────────────────────────────────────── */
body .ww-cat-menu .ww-cat-menu__list--depth-0 > .ww-cat-menu__item--active > .ww-cat-menu__link,
body .ww-cat-menu .ww-cat-menu__list--depth-1 > .ww-cat-menu__item--active > .ww-cat-menu__link,
body .ww-cat-menu .ww-cat-menu__list--depth-2 > .ww-cat-menu__item--active > .ww-cat-menu__link {
	background-color: var(--ww-cm-active-bg-light) !important;
	color: var(--ww-cm-active-text) !important;
	border-left-color: var(--ww-cm-active-border-light) !important;
	font-weight: 600 !important;
	text-decoration: none !important;
}

/* ──────────────────────────────────────────────────────────────────────
   LAYER 5 – Hover on active (~7 selectors)
   ────────────────────────────────────────────────────────────────────── */
body .ww-cat-menu .ww-cat-menu__list--depth-0 > .ww-cat-menu__item--active > .ww-cat-menu__link:hover,
body .ww-cat-menu .ww-cat-menu__list--depth-1 > .ww-cat-menu__item--active > .ww-cat-menu__link:hover,
body .ww-cat-menu .ww-cat-menu__list--depth-2 > .ww-cat-menu__item--active > .ww-cat-menu__link:hover {
	background-color: var(--ww-cm-active-border-light) !important;
	color: var(--ww-cm-active-text) !important;
	text-decoration: none !important;
}

/* ── Count badge ── */
body .ww-cat-menu .ww-cat-menu__count {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	font-size: 0.72em !important;
	font-weight: 500 !important;
	color: inherit !important;
	opacity: 0.55;
	white-space: nowrap;
	flex-shrink: 0;
	background: none !important;
	border: none !important;
	padding: 0 !important;
	min-width: 18px;
}

body .ww-cat-menu .ww-cat-menu__list--depth-0 > .ww-cat-menu__item--active > .ww-cat-menu__link .ww-cat-menu__count,
body .ww-cat-menu .ww-cat-menu__list--depth-1 > .ww-cat-menu__item--active > .ww-cat-menu__link .ww-cat-menu__count,
body .ww-cat-menu .ww-cat-menu__list--depth-2 > .ww-cat-menu__item--active > .ww-cat-menu__link .ww-cat-menu__count {
	opacity: 0.85;
}

/* ── Chevron ── */
body .ww-cat-menu .ww-cat-menu__chevron {
	display: inline-block !important;
	width: 14px;
	height: 14px;
	flex-shrink: 0;
	opacity: 0.35;
	transition: transform 0.2s ease, opacity 0.15s ease;
	margin: 0 !important;
	padding: 0 !important;
	background: none !important;
}

body .ww-cat-menu .ww-cat-menu__chevron::before {
	content: '' !important;
	display: block;
	width: 6px;
	height: 6px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(-45deg) translateY(2px);
	margin: auto;
}

body .ww-cat-menu .ww-cat-menu__list--depth-0 > .ww-cat-menu__item--active > .ww-cat-menu__link .ww-cat-menu__chevron,
body .ww-cat-menu .ww-cat-menu__list--depth-1 > .ww-cat-menu__item--active > .ww-cat-menu__link .ww-cat-menu__chevron {
	opacity: 0.7;
	transform: rotate(90deg);
}
