/*
 * header.css - site header component.
 *
 * LAYER 5. Owns the three approved header bands and their mobile counterparts.
 *
 * PROVENANCE: values extracted from the approved screens
 *   desktop - screens/01-home-desktop.html (AR_Header), active nav state from
 *             screens/03-products-desktop-default.html, signed-in state from
 *             screens/29-account-dashboard-desktop.html
 *   mobile  - screens/02-home-mobile.html (AR_Header)
 *
 * Mobile-first: the mobile header is the default, the desktop header takes over at the
 * provisional 1024px breakpoint. Logical properties throughout.
 */

/* ===========================================================================
 * Shared
 * ======================================================================== */

.zahra-site-header {
	background: var(--zahra-color-surface);
	color: var(--zahra-color-ink);
}

/* ===========================================================================
 * Band 1 - utility topbar
 * ======================================================================== */

.zahra-topbar {
	background: var(--zahra-color-ink);
	color: var(--zahra-color-line-2);
}

.zahra-topbar__inner {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	block-size: 26px;
	font-size: 10px;
	font-weight: 500;
	color: var(--zahra-color-on-dark);
}

.zahra-topbar__tagline {
	color: var(--zahra-color-on-dark);
}

.zahra-topbar__tagline--full {
	display: none;
}

/*
 * Mobile: the contact group dissolves so the phone sits inline in the centred topbar;
 * everything else in the group is hidden.
 */
.zahra-topbar__contact {
	display: contents;
}

.zahra-topbar__link--email,
.zahra-topbar__sep,
.zahra-topbar__contact .zahra-lang {
	display: none;
}

.zahra-topbar__link {
	color: var(--zahra-color-line-2);
	text-decoration: none;
}

.zahra-topbar__sep {
	color: var(--zahra-color-ink-2);
}

/* Language switcher - structural only, no multilingual behaviour (Q-005 / Q-018). */
.zahra-lang {
	display: flex;
	gap: 2px;
	border: 1px solid var(--zahra-color-line-dark);
	padding: 2px;
	margin-inline-start: 4px;
}

.zahra-lang__item {
	padding: 2px 7px;
	font-size: 10.5px;
	font-weight: 600;
	color: var(--zahra-color-muted);
}

.zahra-lang__item--current {
	background: var(--zahra-color-line-2);
	color: var(--zahra-color-ink);
}

/* ===========================================================================
 * Band 2 - masthead
 * ======================================================================== */

.zahra-masthead {
	border-block-end: 1px solid var(--zahra-color-line);
}

/*
 * Grid, not flex. The approved mobile header puts search on its own row beneath the
 * toggle/logo/actions row, while the desktop header puts it inline between logo and
 * actions. Grid areas express both from one set of markup - flex cannot move a box to a new
 * row without wrapping hacks, and it was squeezing the search box into the 52px row.
 */
.zahra-masthead__inner {
	display: grid;
	grid-template-columns: auto 1fr auto;
	grid-template-rows: 52px auto;
	grid-template-areas:
		"toggle logo   actions"
		"search search search";
	align-items: center;
	column-gap: 10px;
}

.zahra-menu-toggle {
	grid-area: toggle;
}

.zahra-logo {
	grid-area: logo;
	display: flex;
	min-inline-size: 0;
}

/*
 * The parent-qualified selector deliberately outranks WooCommerce's contextual
 * `.woocommerce img` / `.woocommerce-page img { height: auto; }` rule. Keep physical and
 * logical dimensions paired: the plugin uses a physical property, while this component is
 * otherwise logical-property-first.
 */
.zahra-logo .zahra-logo__img {
	height: 26px;
	block-size: 26px;
	width: auto;
	inline-size: auto;
}

/* Hamburger - mobile only. 44px target per ACCESSIBILITY.md section 4. */
.zahra-menu-toggle {
	inline-size: 44px;
	block-size: 44px;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	margin-inline-start: -10px;
}

.zahra-menu-toggle__bar {
	block-size: 2px;
	background: var(--zahra-color-ink);
}

.zahra-header-actions {
	grid-area: actions;
	display: flex;
	align-items: center;
}

.zahra-header-action {
	inline-size: 40px;
	block-size: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 11px;
	font-weight: 600;
	color: var(--zahra-color-ink);
	text-decoration: none;
}

.zahra-header-action__label {
	display: none;
}

.zahra-header-action--cart {
	font-size: 12px;
	color: var(--zahra-color-surface);
	background: var(--zahra-color-ink);
}

/*
 * TASK-065 follow-up (owner UX correction) - basket icon + badge, added inside the existing
 * .zahra-header-action--cart link above. No other .zahra-header-action rule is touched: the
 * account link keeps its pre-existing label/value layout untouched.
 */
.zahra-header-action__icon-wrap {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
}

.zahra-header-action__icon {
	display: flex;
}

/*
 * A numeric badge, not a button - the "no new button radius" rule (TASK-065 original, §17)
 * governs CTAs, not a small count indicator. aria-hidden in the markup: the accessible name
 * comes from the link's own aria-label, never from this text (see site-header.php).
 */
.zahra-header-action__badge {
	position: absolute;
	inset-block-start: -6px;
	inset-inline-end: -8px;
	min-inline-size: 16px;
	block-size: 16px;
	padding-inline: 4px;
	border-radius: 999px;
	background: var(--zahra-color-brand);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 16px;
	text-align: center;
}

/* ===========================================================================
 * Search
 * ======================================================================== */

/*
 * Mobile: its own full-width row. The negative inline margin lets the hairline span the
 * full viewport as the design shows, while the content stays on the gutter.
 * The block's closing hairline is .zahra-masthead's own border-block-end.
 */
.zahra-header-search {
	grid-area: search;
	margin-inline: calc(-1 * var(--zahra-gutter-mobile--provisional));
	padding-inline: var(--zahra-gutter-mobile--provisional);
	padding-block: 8px;
	border-block-start: 1px solid var(--zahra-color-line);
}

.zahra-search__box {
	display: flex;
	block-size: 44px;
	border: 1.5px solid var(--zahra-color-ink);
	background: var(--zahra-color-surface);
}

.zahra-search__icon {
	display: flex;
	align-items: center;
	padding-inline-start: 12px;
	color: var(--zahra-color-muted);
}

.zahra-search__scope {
	display: none;
}

.zahra-search__input {
	flex: 1 1 0%;
	min-inline-size: 0;
	border: 0;
	outline: none;
	padding-inline: 10px;
	font-size: 14px;
	background: transparent;
}

.zahra-search__submit {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 7px;
	background: var(--zahra-color-brand);
	color: var(--zahra-color-surface);
	font-size: 13px;
	font-weight: 600;
	padding-inline: 14px;
}

.zahra-search__submit:hover {
	background: var(--zahra-color-brand-dark);
}

.zahra-search__submit-icon {
	display: none;
}

/* ===========================================================================
 * Band 3 - navigation
 *
 * Mobile: a horizontally scrollable chip strip. The approved design uses
 * overflow:hidden; scrolling is used instead so items past the fold stay reachable -
 * hiding them would make them unreachable, which the design cannot have intended.
 * ======================================================================== */

.zahra-primary-nav {
	border-block-end: 1px solid var(--zahra-color-line);
	background: var(--zahra-color-surface);
}

.zahra-primary-nav__inner {
	display: flex;
	align-items: center;
	gap: 8px;
	padding-block: 8px;
	overflow-x: auto;
	scrollbar-width: none;
}

.zahra-primary-nav__inner::-webkit-scrollbar {
	display: none;
}

/* Account-auth mobile screens omit this strip. The complete drawer remains available. */
@media (max-width: 1023.98px) {
	body.zahra-account-login-page .zahra-primary-nav,
	body.zahra-account-lost-password-page .zahra-primary-nav,
	body.zahra-account-details-page .zahra-primary-nav,
	body.zahra-account-dashboard-page .zahra-primary-nav,
	body.zahra-account-address-page .zahra-primary-nav {
		display: none;
	}
}

.zahra-primary-nav__list {
	display: flex;
	align-items: center;
	gap: 8px;
	list-style: none;
	margin: 0;
	padding: 0;
}

/*
 * Both selectors in each pair below cover the two sources of navigation markup: the
 * fallback's own classes, and the classes WordPress generates for an assigned menu. They
 * must render identically.
 */
.zahra-primary-nav__item,
.zahra-primary-nav__list > li {
	flex: 0 0 auto;
}

.zahra-primary-nav__list > li > a,
.zahra-primary-nav__link {
	display: flex;
	align-items: center;
	position: relative;
	font-size: 12px;
	font-weight: 600;
	color: var(--zahra-color-ink);
	background: transparent;
	border: 1px solid var(--zahra-color-line);
	padding: 6px 11px;
	text-decoration: none;
}

/*
 * Active state. Never colour alone - the chip inverts background AND border, so the cue
 * survives without colour perception (ACCESSIBILITY.md section 2).
 */
.zahra-primary-nav__item--current > .zahra-primary-nav__link,
.zahra-primary-nav__link[aria-current="page"],
.zahra-primary-nav__list > li.current-menu-item > a,
.zahra-primary-nav__list > li.current-menu-ancestor > a {
	color: var(--zahra-color-surface);
	background: var(--zahra-color-ink);
	border-color: var(--zahra-color-ink);
}

.zahra-nav-cta,
.zahra-account-status {
	display: none;
}

/* ===========================================================================
 * Mobile drawer
 *
 * NOTE: no approved design exists for the OPEN state - every approved mobile screen shows
 * the hamburger closed. This uses only approved tokens and header values; it is a
 * deliberately minimal, un-approved surface. See docs/tasks/TASK-004-global-header-footer.md.
 * ======================================================================== */

.zahra-drawer {
	display: none;
	border-block-end: 1px solid var(--zahra-color-line);
	background: var(--zahra-color-surface);
}

.zahra-drawer.is-open {
	display: block;
}

.zahra-drawer__lang {
	padding-block: 12px;
	border-block-end: 1px solid var(--zahra-color-line-3);
}

/* .zahra-lang is designed for the dark topbar surface (border/text tuned for --ink); the
 * drawer is a light surface, so its border and item colors are overridden here rather than
 * introducing a second component. */
.zahra-drawer__lang .zahra-lang {
	border-color: var(--zahra-color-line-3);
}

.zahra-drawer__lang .zahra-lang__item {
	color: var(--zahra-color-muted);
}

.zahra-drawer__lang .zahra-lang__item--current {
	background: var(--zahra-color-line-2);
	color: var(--zahra-color-ink);
}

.zahra-drawer__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.zahra-drawer__item {
	border-block-end: 1px solid var(--zahra-color-line-3);
}

.zahra-drawer__item:last-child {
	border-block-end: 0;
}

.zahra-drawer__link {
	display: flex;
	align-items: center;
	min-block-size: 44px;
	padding-block: 10px;
	font-size: 13px;
	font-weight: 600;
	color: var(--zahra-color-ink);
	text-decoration: none;
}

/* ===========================================================================
 * Desktop - IMPLEMENTATION PROVISIONAL breakpoint (Q-013)
 * ======================================================================== */

@media (min-width: 1024px) {

	/* --- Band 1: 30px bar, tagline start / contact + language end --- */

	.zahra-topbar__inner {
		justify-content: space-between;
		gap: 24px;
		block-size: 30px;
		font-size: 11.5px;
	}

	.zahra-topbar__tagline--full {
		display: inline;
	}

	.zahra-topbar__tagline--short,
	.zahra-topbar__dot {
		display: none;
	}

	/*
	 * Desktop: the contact group re-forms, leaving the bar with exactly two flex children -
	 * tagline at the start, contact cluster at the end.
	 */
	.zahra-topbar__contact {
		display: flex;
		align-items: center;
		gap: 14px;
	}

	.zahra-topbar__link--email,
	.zahra-topbar__sep,
	.zahra-topbar__contact .zahra-lang {
		display: flex;
	}

	.zahra-topbar__sep {
		display: inline;
	}

	.zahra-topbar__lang {
		display: flex;
	}

	/* --- Band 2: 72px masthead --- */

	/* One row: logo, search, actions. The toggle and its drawer are gone entirely. */
	.zahra-masthead__inner {
		grid-template-columns: auto minmax(0, 660px) auto;
		grid-template-rows: 72px;
		grid-template-areas: "logo search actions";
		column-gap: 28px;
	}

	.zahra-menu-toggle,
	.zahra-drawer {
		display: none;
	}

	.zahra-logo .zahra-logo__img {
		height: 34px;
		block-size: 34px;
	}

	/* Search returns inline, losing the mobile row's bleed and hairline. */
	.zahra-header-search {
		margin-inline: 0;
		padding-inline: 0;
		padding-block: 0;
		border-block-start: 0;
	}

	.zahra-search__icon {
		display: none;
	}

	.zahra-search__scope {
		flex: 0 0 auto;
		display: flex;
		align-items: center;
		gap: 8px;
		padding-inline: 13px;
		background: var(--zahra-color-sand);
		border-inline-end: 1px solid var(--zahra-color-line);
		font-size: 12.5px;
		font-weight: 500;
	}

	/* Caret drawn with borders, as in the approved design. */
	.zahra-search__caret {
		inline-size: 6px;
		block-size: 6px;
		border-inline-end: 1.5px solid var(--zahra-color-muted);
		border-block-end: 1.5px solid var(--zahra-color-muted);
		transform: rotate(45deg);
		margin-block-start: -3px;
	}

	.zahra-search__input {
		padding-inline: 13px;
		font-size: 13.5px;
	}

	.zahra-search__submit {
		padding-inline: 20px;
		font-size: 13.5px;
	}

	.zahra-search__submit-icon {
		display: block;
	}

	/* --- Utilities: stacked label + value --- */

	.zahra-header-actions {
		gap: 20px;
	}

	.zahra-header-action {
		inline-size: auto;
		block-size: auto;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: 1px;
		font-size: 12.5px;
	}

	.zahra-header-action__label {
		display: block;
		font-size: 10.5px;
		font-weight: 400;
		color: var(--zahra-color-muted);
	}

	.zahra-header-action--cart {
		flex-direction: row;
		align-items: center;
		gap: 8px;
		color: var(--zahra-color-ink);
		background: transparent;
		border: 1px solid var(--zahra-color-line);
		padding: 6px 13px;
	}

	.zahra-header-action--cart .zahra-header-action__stack {
		display: flex;
		flex-direction: column;
		gap: 1px;
	}

	/* --- Band 3: 44px nav bar with underline active state --- */

	.zahra-primary-nav__inner {
		block-size: 44px;
		gap: 2px;
		padding-block: 0;
		align-items: stretch;
		overflow: visible;
	}

	.zahra-primary-nav__list {
		gap: 2px;
		align-items: stretch;
	}

	.zahra-primary-nav__list > li > a,
	.zahra-primary-nav__link {
		/*
		 * The <li> stretches to the row's full 44px (align-items: stretch above), but the
		 * link/span itself only sizes to its own text unless told to fill that height too -
		 * without this it sat at the top of the row with dead space below, instead of the
		 * text being vertically centred in the bar.
		 */
		block-size: 100%;
		padding-inline: 13px;
		padding-block: 0;
		font-size: 13px;
		border: 0;
		background: transparent;
	}

	.zahra-primary-nav__item--current > .zahra-primary-nav__link,
	.zahra-primary-nav__link[aria-current="page"],
	.zahra-primary-nav__list > li.current-menu-item > a,
	.zahra-primary-nav__list > li.current-menu-ancestor > a {
		color: var(--zahra-color-ink);
		background: transparent;
	}

	/* Underline replaces the inverted chip on desktop. */
	.zahra-primary-nav__item--current > .zahra-primary-nav__link::after,
	.zahra-primary-nav__link[aria-current="page"]::after,
	.zahra-primary-nav__list > li.current-menu-item > a::after,
	.zahra-primary-nav__list > li.current-menu-ancestor > a::after {
		content: "";
		position: absolute;
		inset-inline: 13px;
		inset-block-end: 0;
		block-size: 2.5px;
		background: var(--zahra-color-brand);
	}

	.zahra-nav-cta {
		display: flex;
		align-items: center;
		margin-inline-start: auto;
		background: var(--zahra-color-brand);
		color: var(--zahra-color-surface);
		font-size: 12.5px;
		font-weight: 600;
		padding: 7px 15px;
		text-decoration: none;
		flex: 0 0 auto;
	}

	.zahra-nav-cta:hover {
		background: var(--zahra-color-brand-dark);
	}
}
