/**
 * File: bps-menu.css
 * Path: assets/themer/bps-menu.css
 * Version: 1.0.0
 * Last Modified: 2026-07-28
 *
 * Front-end behaviour styles for the BPS nav_menu Themer widget
 * (BPS_Themer_Widget_Renderers::nav_menu). First front-end stylesheet in the
 * widget system — deliberately structural: layout, dropdown/mega/overlay
 * mechanics, collapse states. Colours/spacing inherit from the site unless a
 * --bps-menu-* custom property overrides them.
 *
 * State model (set by bps-menu.js):
 *   .bps-menu--collapsed  below the instance breakpoint (or always, overlay)
 *   .is-open              on the nav  = toggle panel open
 *   .is-open              on an item  = submenu expanded (accordion/touch)
 * No-JS fallback: no collapse class ever applies, so the menu renders
 * expanded with hover/focus-within dropdowns — fully usable.
 */

/* ── Base / reset ────────────────────────────────────────────────────────── */

.bps-menu {
	--bps-menu-gap: 4px;
	--bps-menu-pad: 10px 14px;
	--bps-menu-sub-w: 220px;
	--bps-menu-bg: var(--bps-menu-panel-bg, #fff);
	--bps-menu-border: var(--bps-menu-panel-border, rgba(0, 0, 0, 0.12));
	position: relative;
}

.bps-menu ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.bps-menu__link {
	display: block;
	padding: var(--bps-menu-pad);
	text-decoration: none;
	white-space: nowrap;
}

.bps-menu__item {
	position: relative;
}

.bps-menu .screen-reader-text {
	position: absolute;
	clip-path: inset(50%);
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ── Toggle button (hamburger) — hidden until a collapse state applies ───── */

.bps-menu__toggle {
	display: none;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	background: transparent;
	border: 1px solid var(--bps-menu-border);
	border-radius: 4px;
	cursor: pointer;
	font: inherit;
	color: inherit;
}

.bps-menu__toggle-icon {
	display: inline-flex;
	flex-direction: column;
	gap: 4px;
	width: 18px;
}

.bps-menu__toggle-icon span {
	display: block;
	height: 2px;
	width: 100%;
	background: currentColor;
	border-radius: 1px;
	transition: transform 0.2s ease, opacity 0.2s ease;
}

.bps-menu.is-open > .bps-menu__toggle .bps-menu__toggle-icon span:nth-child(1) {
	transform: translateY(6px) rotate(45deg);
}

.bps-menu.is-open > .bps-menu__toggle .bps-menu__toggle-icon span:nth-child(2) {
	opacity: 0;
}

.bps-menu.is-open > .bps-menu__toggle .bps-menu__toggle-icon span:nth-child(3) {
	transform: translateY(-6px) rotate(-45deg);
}

/* ── Submenu toggle (caret button) ───────────────────────────────────────── */

.bps-menu__sub-toggle {
	background: transparent;
	border: 0;
	padding: 6px;
	cursor: pointer;
	color: inherit;
	line-height: 1;
}

.bps-menu__caret {
	display: inline-block;
	width: 7px;
	height: 7px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	transition: transform 0.15s ease;
}

.bps-menu__item.is-open > .bps-menu__sub-toggle .bps-menu__caret {
	transform: rotate(225deg);
}

/* ── Expanded (desktop) layout — any .bps-menu NOT collapsed ─────────────── */

.bps-menu:not(.bps-menu--collapsed) > .bps-menu__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--bps-menu-gap);
}

.bps-menu:not(.bps-menu--collapsed) .bps-menu__item.has-children {
	display: flex;
	align-items: center;
}

/* Dropdown panels */
.bps-menu:not(.bps-menu--collapsed) .bps-menu__sub {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: var(--bps-menu-sub-w);
	background: var(--bps-menu-bg);
	border: 1px solid var(--bps-menu-border);
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
	padding: 6px 0;
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
	z-index: 9990;
}

.bps-menu:not(.bps-menu--collapsed) .bps-menu__sub .bps-menu__link {
	white-space: normal;
}

/* Level 3+ fly out sideways */
.bps-menu:not(.bps-menu--collapsed) .bps-menu__sub .bps-menu__sub {
	top: 0;
	left: 100%;
	transform: translateX(6px);
}

/* Open on hover (unless click-trigger), keyboard focus, or JS is-open (touch/click) */
.bps-menu:not(.bps-menu--collapsed):not(.bps-menu--click-trigger) .bps-menu__item:hover > .bps-menu__sub,
.bps-menu:not(.bps-menu--collapsed) .bps-menu__item:focus-within > .bps-menu__sub,
.bps-menu:not(.bps-menu--collapsed) .bps-menu__item.is-open > .bps-menu__sub {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.bps-menu:not(.bps-menu--collapsed):not(.bps-menu--click-trigger) .bps-menu__sub .bps-menu__item:hover > .bps-menu__sub,
.bps-menu:not(.bps-menu--collapsed) .bps-menu__sub .bps-menu__item:focus-within > .bps-menu__sub,
.bps-menu:not(.bps-menu--collapsed) .bps-menu__sub .bps-menu__item.is-open > .bps-menu__sub {
	transform: translateX(0);
}

/* ── Mega panel — level-2 items become columns ───────────────────────────── */

.bps-menu:not(.bps-menu--collapsed) .bps-menu__item--mega {
	position: static;
}

.bps-menu:not(.bps-menu--collapsed) .bps-menu__mega {
	left: 0;
	right: 0;
	width: 100%;
	min-width: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 8px 24px;
	padding: 18px 20px;
}

/* Column heading = the level-2 item's own link */
.bps-menu:not(.bps-menu--collapsed) .bps-menu__mega > .bps-menu__item > .bps-menu__link {
	font-weight: 600;
}

/* Optional column image (BPS_Themer_Nav_Menu_Item_Fields, level-1 mega items only).
 * Lives inside the mega panel as its own grid cell. max-height + object-fit are
 * load-bearing: without them an arbitrary-resolution upload sets the panel height. */
.bps-menu__mega-image {
	display: block;
}

.bps-menu__item-image {
	display: block;
	width: 100%;
	height: auto;
	max-height: 160px;
	object-fit: cover;
	border-radius: 4px;
	margin-bottom: 8px;
}

/* Column contents (level 3) render inline — always visible inside the panel */
.bps-menu:not(.bps-menu--collapsed) .bps-menu__mega > .bps-menu__item {
	display: block;
}

.bps-menu:not(.bps-menu--collapsed) .bps-menu__mega > .bps-menu__item > .bps-menu__sub-toggle {
	display: none;
}

.bps-menu:not(.bps-menu--collapsed) .bps-menu__mega .bps-menu__sub {
	position: static;
	opacity: 1;
	visibility: visible;
	transform: none;
	border: 0;
	box-shadow: none;
	background: transparent;
	min-width: 0;
	padding: 0;
}

/* ── Collapsed (mobile) layout — accordion under the hamburger ───────────── */

.bps-menu--collapsed > .bps-menu__toggle {
	display: inline-flex;
}

.bps-menu--collapsed > .bps-menu__list {
	display: none;
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	min-width: 260px;
	background: var(--bps-menu-bg);
	border: 1px solid var(--bps-menu-border);
	border-radius: 6px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
	padding: 6px 0;
	z-index: 9995;
}

.bps-menu--collapsed.is-open > .bps-menu__list {
	display: block;
}

.bps-menu--collapsed .bps-menu__item {
	display: block;
}

.bps-menu--collapsed .bps-menu__item.has-children {
	display: grid;
	grid-template-columns: 1fr auto;
	align-items: center;
}

.bps-menu--collapsed .bps-menu__link {
	white-space: normal;
}

.bps-menu--collapsed .bps-menu__sub {
	grid-column: 1 / -1;
	display: none;
	padding-left: 16px;
}

.bps-menu--collapsed .bps-menu__item.is-open > .bps-menu__sub {
	display: block;
}

.bps-menu--collapsed .bps-menu__sub-toggle {
	padding: 10px 14px;
}

/* ── Overlay mode — fullscreen panel, always toggle-driven ───────────────── */

.bps-menu--overlay.bps-menu--collapsed.is-open > .bps-menu__list {
	position: fixed;
	inset: 0;
	border: 0;
	border-radius: 0;
	overflow-y: auto;
	padding: 72px 24px 40px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	z-index: 99990;
}

.bps-menu--overlay.is-open > .bps-menu__toggle {
	position: fixed;
	top: 16px;
	right: 16px;
	z-index: 99991;
	background: var(--bps-menu-bg);
}

.bps-menu--overlay.bps-menu--collapsed.is-open .bps-menu__link {
	font-size: 1.15em;
}

body.bps-menu-open {
	overflow: hidden;
}

/* ── Scroll behaviour — sticky / sticky-shrink / hide-on-scroll / transparent-to-solid ──
 *
 * State model (set by bps-menu.js's scroll handler, additive to the base model above):
 *   .bps-menu--has-scroll-behaviour   sticky_mode !== 'none' (any of the 3 non-default modes)
 *   .is-stuck                         scrollY has passed the instance's shrink_threshold
 *   .bps-menu--transparent            transparent_start = true, present at initial paint
 *   .bps-menu--transparent-solid      added once .is-stuck (transparent -> solid transition)
 *   .is-hidden                        hide-on-scroll mode, scrolling down past threshold
 *
 * 🔴 `position: fixed` (on .is-stuck), NOT `position: sticky` — deliberate, and do not
 * "simplify" it back. BPS ships a global `body { overflow-x: clip }` (assets/scss/
 * bps-framework.scss:1008, the BUG-234 fix). That comment correctly notes clip does not
 * create a SCROLL container — but any non-`visible` overflow on <body> still makes it the
 * containing block for sticky descendants, and <body> itself never scrolls (the document
 * does), so `position: sticky` moves 1:1 with the page and never pins. Measured on the
 * sandbox: computed position was `sticky`, top `0px`, no interfering ancestor — and
 * getBoundingClientRect().top after a 500px scroll was exactly original−500, i.e. zero
 * pinning. The estate's own .bps-sticky-header (bps-framework.scss:41-59) uses
 * position:fixed for exactly this reason; this follows that proven precedent, including its
 * admin-bar offset.
 *
 * Because fixed removes the nav from flow, bps-menu.js inserts a same-height spacer <div>
 * so content below does not jump when the nav sticks.
 *
 * Colour/shadow/height are themeable via --bps-menu-* (rung-3/4 override seam, CSS
 * escalation ladder) rather than hardcoded. Applies to the .bps-menu element itself — this
 * widget controls its own <nav>, not a wrapping header container, so a "sticky whole header"
 * composition (logo + CTA alongside nav_menu) needs the site's header container built around
 * this widget. Out of scope for the widget itself.
 */

.bps-menu--has-scroll-behaviour {
	background: var(--bps-menu-bg);
	transition: background-color 0.2s ease, box-shadow 0.2s ease, padding 0.2s ease, transform 0.25s ease;
}

.bps-menu--has-scroll-behaviour.is-stuck {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 9980;
	box-shadow: var(--bps-menu-shadow, 0 2px 12px rgba(0, 0, 0, 0.08));
}

/* Match the estate convention (bps-framework.scss:59) so the stuck nav clears the WP bar. */
.admin-bar .bps-menu--has-scroll-behaviour.is-stuck {
	top: 32px;
}

@media screen and (max-width: 782px) {
	.admin-bar .bps-menu--has-scroll-behaviour.is-stuck {
		top: 46px;
	}
}

/* Spacer injected by bps-menu.js — holds the nav's original height while it is fixed. */
.bps-menu__sticky-spacer {
	display: none;
}

.bps-menu__sticky-spacer.is-active {
	display: block;
}

/* sticky-shrink: actually reduce the nav's vertical size once stuck. Without this the
 * "Sticky + shrink on scroll" control promises behaviour nothing implements — measured
 * identical heights (694.39px) before and after crossing the threshold. */
.bps-menu--shrink.is-stuck .bps-menu__link {
	padding-top: 6px;
	padding-bottom: 6px;
}

.bps-menu--shrink.is-stuck .bps-menu__item-image {
	max-height: 96px;
}

.bps-menu--transparent {
	background: transparent;
	box-shadow: none;
}

.bps-menu--transparent.bps-menu--transparent-solid {
	background: var(--bps-menu-bg);
}

.bps-menu--has-scroll-behaviour.is-hidden {
	transform: translateY(-100%);
}
