/**
 * HM v2 Navigation styles — Task #115 (exclusive ownership).
 *
 * Covers: primary nav (13 items, 2-level dropdown), user toolbar
 * (logged-in: 4 buttons + status; guest: 2 buttons), cart icon with count,
 * mobile burger.
 *
 * All selectors scoped under .hm-v2 to avoid leaking into legacy pages.
 * Inserted AFTER components.css (which provides .hm-top-bar base) and only
 * extends/overrides what's needed for the new chrome.
 *
 * RTL: site is rtl; logical properties (inset-inline-*) used where helpful.
 */

/* ====================================================================== */
/* === Top bar layout overrides — fit 4 columns: brand | nav | actions === */
/* ====================================================================== */

.hm-v2 .hm-top-bar-inner {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: nowrap;
}

/* Brand stays at its natural width on the right (rtl), nav grows, actions
   stay at their natural width on the left. */
.hm-v2 .hm-top-bar-inner > .hm-brand { flex: 0 0 auto; }
.hm-v2 .hm-top-bar-inner > .hm-nav-main { flex: 1 1 auto; min-width: 0; }
.hm-v2 .hm-top-bar-inner > .hm-top-actions { flex: 0 0 auto; }

/* ====================================================================== */
/* === Primary nav (13 items, 2-level dropdown) === */
/* ====================================================================== */

.hm-v2 .hm-nav-main {
	display: block;
	min-width: 0;
}

/* Top-level only — do NOT cascade into .sub-menu (use child selector). */
.hm-v2 .hm-nav-main > ul,
.hm-v2 .hm-nav-main__list,
.hm-v2 #hm-primary-menu {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px 6px;
	justify-content: flex-start;
}

/* Reset list-style on ALL nested uls (sub-menus) so bullets don't show. */
.hm-v2 .hm-nav-main ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.hm-v2 .hm-nav-main li {
	position: relative;
	margin: 0;
}

.hm-v2 .hm-nav-main a {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 8px 10px;
	border-radius: 8px;
	color: var(--hm-forest-dark, #1a3a26);
	text-decoration: none;
	font-weight: 600;
	font-size: 14px;
	line-height: 1.2;
	white-space: nowrap;
	transition: background var(--hm-transition-base, 200ms ease), color var(--hm-transition-base, 200ms ease);
}

.hm-v2 .hm-nav-main a:hover,
.hm-v2 .hm-nav-main a:focus-visible {
	background: var(--hm-sand-light, #f4efe5);
	color: var(--hm-forest-dark, #112C19);
	outline: none;
}

.hm-v2 .hm-nav-main .current-menu-item > a,
.hm-v2 .hm-nav-main a[aria-current="page"] {
	background: var(--hm-mint-soft, rgba(125, 217, 168, 0.18));
	color: var(--hm-forest-dark, #112C19);
}

/* Chevron for items with children */
.hm-v2 .hm-nav-main .menu-item-has-children > a::after,
.hm-v2 .hm-nav-main li.has-children > a::after {
	content: "";
	display: inline-block;
	width: 7px;
	height: 7px;
	margin-inline-start: 4px;
	border-inline-end: 2px solid currentColor;
	border-block-end: 2px solid currentColor;
	transform: rotate(45deg);
	transform-origin: center;
	margin-block-start: -3px;
	opacity: 0.6;
	transition: transform 180ms ease, opacity 180ms ease;
}
.hm-v2 .hm-nav-main .menu-item-has-children:hover > a::after,
.hm-v2 .hm-nav-main .menu-item-has-children:focus-within > a::after {
	opacity: 1;
	transform: rotate(-135deg);
	margin-block-start: 3px;
}

/* Dropdown panel (level 2/3) — vertical column, explicit overrides so
   nothing from the top-level list rule leaks in. */
.hm-v2 .hm-nav-main .sub-menu {
	list-style: none;
	margin: 0;
	padding: 8px;
	position: absolute;
	top: calc(100% + 4px);
	inset-inline-end: 0;
	min-width: 260px;
	max-width: 340px;
	width: max-content; /* let it size to content but capped by max-width */
	background: var(--hm-white, #fff);
	border: 1px solid var(--hm-border, #e5e7eb);
	border-radius: 12px;
	box-shadow: 0 16px 40px rgba(20, 40, 30, 0.14);
	display: flex;
	flex-direction: column; /* vertical stack — the actual fix */
	flex-wrap: nowrap;      /* defeat inherited flex-wrap: wrap */
	align-items: stretch;   /* defeat inherited align-items: center */
	justify-content: flex-start;
	gap: 2px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-4px);
	transition: opacity 160ms ease, transform 160ms ease, visibility 160ms;
	z-index: 1001;
}
.hm-v2 .hm-nav-main li:hover > .sub-menu,
.hm-v2 .hm-nav-main li:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}
/* Each row in the dropdown must take the full width of the panel. */
.hm-v2 .hm-nav-main .sub-menu > li {
	width: 100%;
	display: block;
	margin: 0;
}
.hm-v2 .hm-nav-main .sub-menu a {
	display: block;
	width: 100%;
	white-space: normal;
	padding: 10px 12px;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.35;
	border-radius: 8px;
	text-align: start;
}
/* Level-3 panel opens to the side (rtl: to the start direction). */
.hm-v2 .hm-nav-main .sub-menu .sub-menu {
	top: 0;
	inset-inline-end: 100%;
	margin-inline-end: 8px;
}

/* ====================================================================== */
/* === Top actions container === */
/* ====================================================================== */

.hm-v2 .hm-top-actions {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: nowrap;
}

/* ====================================================================== */
/* === Cart icon with count === */
/* ====================================================================== */

.hm-v2 .hm-cart-icon {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border-radius: 10px;
	background: var(--hm-mint-soft, rgba(125, 217, 168, 0.22));
	color: var(--hm-forest-dark, #1a3a26);
	text-decoration: none;
	transition: background var(--hm-transition-base, 200ms ease), transform 180ms ease;
	flex-shrink: 0;
}
.hm-v2 .hm-cart-icon:hover,
.hm-v2 .hm-cart-icon:focus-visible {
	background: var(--hm-mint, rgba(125, 217, 168, 0.45));
	transform: translateY(-1px);
	outline: none;
}
.hm-v2 .hm-cart-icon__svg {
	width: 22px;
	height: 22px;
	stroke-width: 2;
}
.hm-v2 .hm-cart-icon__count {
	position: absolute;
	top: -4px;
	inset-inline-start: -4px;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9px;
	background: var(--hm-action, #ff9800);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
	box-shadow: 0 2px 5px rgba(255, 152, 0, 0.45);
}
.hm-v2 .hm-cart-icon__count[hidden],
.hm-v2 .hm-cart-icon__count[data-count="0"] { display: none; }

/* ====================================================================== */
/* === User toolbar === */
/* ====================================================================== */

.hm-v2 .hm-user-toolbar {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: nowrap;
}

.hm-v2 .hm-user-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 8px 12px;
	border-radius: 8px;
	font-weight: 600;
	font-size: 13px;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	min-height: 38px;
	border: 1px solid transparent;
	transition: background var(--hm-transition-base, 200ms ease), border-color var(--hm-transition-base, 200ms ease);
}
.hm-v2 .hm-user-btn--ghost {
	background: var(--hm-white, #fff);
	color: var(--hm-forest-dark, #1a3a26);
	border-color: var(--hm-border, #e5e7eb);
}
.hm-v2 .hm-user-btn--ghost:hover,
.hm-v2 .hm-user-btn--ghost:focus-visible {
	background: var(--hm-sand-light, #f4efe5);
	border-color: var(--hm-border-strong, #c8cbd1);
	outline: none;
}
.hm-v2 .hm-user-btn--action {
	background: var(--hm-action, #ff9800);
	color: #fff;
	border-color: var(--hm-action, #ff9800);
}
.hm-v2 .hm-user-btn--action:hover,
.hm-v2 .hm-user-btn--action:focus-visible {
	background: var(--hm-action-dark, #e08800);
	border-color: var(--hm-action-dark, #e08800);
	outline: none;
}
.hm-v2 .hm-user-btn__icon { font-size: 14px; }

.hm-v2 .hm-user-status {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-inline-start: 4px;
	padding: 4px 8px;
	font-size: 12px;
	font-weight: 500;
	color: var(--hm-slate-soft, #5a6470);
}
.hm-v2 .hm-user-status__name {
	max-width: 140px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.hm-v2 .hm-user-status__logout {
	color: var(--hm-coral-dark, #b44233);
	font-weight: 600;
	text-decoration: none;
}
.hm-v2 .hm-user-status__logout:hover,
.hm-v2 .hm-user-status__logout:focus-visible {
	text-decoration: underline;
	outline: none;
}

/* ====================================================================== */
/* === Burger (mobile) === */
/* ====================================================================== */

.hm-v2 .hm-burger {
	display: none;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 1px solid var(--hm-border, #e5e7eb);
	border-radius: 10px;
	background: var(--hm-white, #fff);
	cursor: pointer;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	flex-shrink: 0;
}
.hm-v2 .hm-burger__bar {
	display: block;
	width: 20px;
	height: 2px;
	background: var(--hm-forest-dark, #1a3a26);
	border-radius: 2px;
	transition: transform 200ms ease, opacity 200ms ease;
}
.hm-v2 .hm-burger[aria-expanded="true"] .hm-burger__bar:nth-child(1) {
	transform: translateY(6px) rotate(45deg);
}
.hm-v2 .hm-burger[aria-expanded="true"] .hm-burger__bar:nth-child(2) {
	opacity: 0;
}
.hm-v2 .hm-burger[aria-expanded="true"] .hm-burger__bar:nth-child(3) {
	transform: translateY(-6px) rotate(-45deg);
}

/* ====================================================================== */
/* === Responsive breakpoints === */
/* ====================================================================== */

/* At <=1180px we start to compress: hide the long label on user buttons. */
@media (max-width: 1180px) {
	.hm-v2 .hm-nav-main a { font-size: 13px; padding: 7px 8px; }
	.hm-v2 .hm-user-btn .hm-user-btn__label { display: none; }
	.hm-v2 .hm-user-btn { padding: 8px 10px; }
	.hm-v2 .hm-user-status__name { max-width: 100px; font-size: 11px; }
}

/* At <=900px the nav itself collapses into the burger drawer. */
@media (max-width: 900px) {
	.hm-v2 .hm-burger { display: inline-flex; }
	.hm-v2 .hm-nav-main {
		position: absolute;
		top: 100%;
		inset-inline-start: 0;
		inset-inline-end: 0;
		background: var(--hm-white, #fff);
		border-block-start: 1px solid var(--hm-border, #e5e7eb);
		box-shadow: 0 16px 40px rgba(20, 40, 30, 0.14);
		max-height: 0;
		overflow: hidden;
		transition: max-height 240ms ease;
		z-index: 1000;
	}
	.hm-v2 .hm-nav-main.is-open {
		max-height: 80vh;
		overflow-y: auto;
	}
	.hm-v2 .hm-nav-main ul,
	.hm-v2 .hm-nav-main__list,
	.hm-v2 #hm-primary-menu {
		flex-direction: column;
		align-items: stretch;
		padding: 8px;
		gap: 2px;
	}
	.hm-v2 .hm-nav-main li { width: 100%; }
	.hm-v2 .hm-nav-main a {
		width: 100%;
		justify-content: flex-start;
		padding: 12px 14px;
		font-size: 15px;
	}
	.hm-v2 .hm-nav-main .sub-menu {
		position: static;
		opacity: 1;
		visibility: visible;
		transform: none;
		box-shadow: none;
		border: none;
		background: var(--hm-sand-light, #f4efe5);
		padding: 4px 8px;
		margin-inline-start: 16px;
		max-width: none;
	}
	.hm-v2 .hm-nav-main .menu-item-has-children > a::after { display: none; }
	.hm-v2 .hm-top-bar-inner { position: relative; }
}

/* At <=640px hide non-essential user buttons text + tighten cart icon. */
@media (max-width: 640px) {
	.hm-v2 .hm-user-toolbar { gap: 4px; }
	.hm-v2 .hm-user-btn { padding: 7px 9px; min-height: 36px; }
	.hm-v2 .hm-user-status { display: none; }
	.hm-v2 .hm-cart-icon { width: 38px; height: 38px; }
}
