/*
 * Mobile header + navigation drawer (Phase 3B — docs/MOBILE-NAVIGATION.md).
 * Visible below 1024px only; components/mega-menu.css takes over above that.
 */

.bholats-mobile-header { display: block; border-bottom: var(--border-default); background: var(--color-surface); }
@media (min-width: 1024px) {
	.bholats-mobile-header { display: none; }
}

.bholats-mobile-header__row {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	padding-block: var(--space-2);
}

.bholats-mobile-header__logo { display: flex; align-items: center; flex-shrink: 0; }
/* 48px (not the old 40px): same legibility reasoning as the desktop main
 * row -- see components/header.css and docs/BRAND-IDENTITY-IMPLEMENTATION.md. */
.bholats-mobile-header__logo img,
.bholats-mobile-header__logo :is(img, svg) { height: 48px; width: auto; object-fit: contain; }

.bholats-mobile-header__search-btn {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: var(--space-2);
	height: 44px;
	padding-inline: var(--space-3);
	background: var(--color-surface-sunken);
	border: var(--border-default);
	border-radius: var(--radius-md);
	color: var(--color-text-secondary);
	font-size: var(--text-sm);
	cursor: pointer;
}
.bholats-mobile-header__search-btn svg { width: var(--icon-md); height: var(--icon-md); flex-shrink: 0; }
.bholats-mobile-header__search-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bholats-mobile-header__icon-btn,
.bholats-mobile-header__menu-btn {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	flex-shrink: 0;
	background: none;
	border: none;
	color: var(--color-text-primary);
	border-radius: var(--radius-sm);
}
.bholats-mobile-header__icon-btn:hover,
.bholats-mobile-header__menu-btn:hover { background: var(--color-surface-sunken); }
.bholats-mobile-header__icon-btn svg,
.bholats-mobile-header__menu-btn svg { width: var(--icon-md); height: var(--icon-md); }

/* Sale-colour badge, deliberately not a brand colour, so it never reads as a
   generic UI accent — docs/DESIGN-SYSTEM.md §1 header spec. */
.bholats-mobile-header__cart-count {
	position: absolute;
	top: 2px;
	right: 2px;
	min-width: 16px;
	height: 16px;
	padding: 0 3px;
	border-radius: var(--radius-full);
	background: var(--color-sale);
	color: var(--color-text-on-brand);
	font-size: 10px;
	font-weight: var(--font-weight-bold);
	line-height: 16px;
	text-align: center;
}
.bholats-mobile-header__cart-count[hidden] { display: none; }

.bholats-mobile-search-panel {
	padding-block: var(--space-2) var(--space-3);
	border-top: var(--border-default);
}
.bholats-mobile-search-panel[hidden] { display: none; }

/* --- Drawer --- */

.bholats-drawer-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(11, 31, 43, 0.5);
	z-index: var(--z-overlay);
}
.bholats-drawer-backdrop[hidden] { display: none; }

.bholats-drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(85vw, 380px);
	background: var(--color-surface);
	box-shadow: var(--shadow-lg);
	z-index: var(--z-modal);
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform var(--duration-slow) var(--ease-standard);
}
.bholats-drawer[hidden] { display: none; }
.bholats-drawer.bholats-drawer--open { transform: translateX(0); }

.bholats-drawer__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--space-4);
	border-bottom: var(--border-default);
	flex-shrink: 0;
}
.bholats-drawer__heading { font-family: var(--font-display); font-weight: var(--font-weight-semibold); font-size: var(--text-h4); color: var(--color-text-primary); }
.bholats-drawer__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	background: none;
	border: none;
	color: var(--color-text-primary);
}
.bholats-drawer__close:hover { background: var(--color-surface-sunken); }
.bholats-drawer__close svg { width: var(--icon-md); height: var(--icon-md); }

.bholats-drawer__panels { position: relative; flex: 1; overflow: hidden; }

.bholats-drawer-panel {
	position: absolute;
	inset: 0;
	overflow-y: auto;
	padding: var(--space-2) var(--space-4) var(--space-4);
	background: var(--color-surface);
	transform: translateX(100%);
	transition: transform var(--duration-base) var(--ease-standard);
}
/* All panels (including root) rely solely on the --active class for
   visibility — an earlier #bholats-drawer-root ID-selector rule here had
   higher specificity than .bholats-drawer-panel--exit-left, so the root
   panel could never actually be slid away once JS tried to dismiss it
   (found via Puppeteer interaction testing, docs/MOBILE-NAVIGATION.md). The
   root panel gets its initial --active class server-side instead (see
   template-parts/header/mobile-drawer.php). */
.bholats-drawer-panel.bholats-drawer-panel--active { transform: translateX(0); }
.bholats-drawer-panel.bholats-drawer-panel--exit-left { transform: translateX(-100%); }
.bholats-drawer-panel.bholats-drawer-panel--exit-right { transform: translateX(100%); }

.bholats-drawer-panel__title {
	padding: var(--space-3) var(--space-2);
	font-family: var(--font-display);
	font-weight: var(--font-weight-semibold);
	font-size: var(--text-h5);
	color: var(--color-text-primary);
}

.bholats-drawer-panel__back {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	width: 100%;
	min-height: 44px;
	padding: var(--space-2);
	margin-bottom: var(--space-2);
	background: var(--color-surface-sunken);
	border: none;
	border-radius: var(--radius-sm);
	font-weight: var(--font-weight-semibold);
	font-size: var(--text-sm);
	color: var(--color-text-primary);
	text-align: left;
	cursor: pointer;
}
.bholats-drawer-panel__back svg { width: var(--icon-sm); height: var(--icon-sm); flex-shrink: 0; }

.bholats-drawer-panel__list { list-style: none; margin: 0; padding: 0; }
.bholats-drawer-panel__list--utility { margin-top: var(--space-4); padding-top: var(--space-2); border-top: var(--border-default); }

.bholats-drawer-panel__row {
	display: flex;
	align-items: stretch;
	border-bottom: var(--border-default);
}

.bholats-drawer-panel__link {
	flex: 1;
	display: flex;
	align-items: center;
	min-height: 44px;
	padding-block: var(--space-2);
	font-size: var(--text-sm);
	color: var(--color-text-primary);
	text-decoration: none;
}
.bholats-drawer-panel__link:hover { color: var(--color-brand-blue); }

.bholats-drawer-panel__drill {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	flex-shrink: 0;
	background: none;
	border: none;
	color: var(--color-text-secondary);
}
.bholats-drawer-panel__drill svg { width: var(--icon-sm); height: var(--icon-sm); }

body.bholats-scroll-locked { overflow: hidden; }

/* Stacking-context fix: .bholats-header has position:relative + its own
   z-index (header.css), which establishes a stacking context for its
   entire subtree — including .bholats-drawer (z-modal) and
   .bholats-drawer-backdrop (z-overlay), both nested inside <header> (see
   header.php). From outside <header>, that whole subtree only ever
   competes using the header's OWN z-index (z-sticky), regardless of the
   drawer's higher internal value. Any other page element also at z-sticky
   that comes later in the DOM than <header> — confirmed live on: the
   archive filter/sort toolbar (components/archive.css), the WhatsApp
   button (footer.php, via components/whatsapp-button.css), and the mobile
   sticky purchase bar (single-product.css) — then wins that tie by DOM
   order and paints over the open drawer, even though its own z-index
   (200) is numerically lower than the drawer's (400). Raising the
   header's own z-index to z-modal only while body.bholats-scroll-locked
   is set (the same flag mobile-drawer.js already toggles for scroll-lock,
   reused rather than adding a new one) matches the header's external
   stacking slot to its most-privileged internal content exactly when
   that content is open, without changing anything while the drawer is
   closed — so the toolbar's normal sticky behaviour, and every other
   z-sticky element, are unaffected outside this state. Scoped below
   1024px to match the drawer itself, which desktop's mega-menu (a
   completely separate mechanism, components/mega-menu.css) never uses. */
@media (max-width: 1023px) {
	body.bholats-scroll-locked .bholats-header {
		z-index: var(--z-modal);
	}
}

@media (prefers-reduced-motion: reduce) {
	.bholats-drawer,
	.bholats-drawer-panel { transition-duration: 1ms; }
}
