/*
 * Hubka Theme
 *
 * Phase: Mobile Header Refinement
 * Purpose: Site Header container, brand (logo/title), search, and header
 * actions (account, cart). Deliberately no sticky positioning, no
 * transparency, no shadows — a restrained editorial header.
 *
 * Revision note: `hubka-header__search-row` was extracted out of
 * `hubka-header__actions` (which now holds only account/cart) so mobile
 * layout can push search onto its own full-width row via `order` +
 * `flex-basis`, independent of account/cart. On desktop, the new DOM
 * order (brand → nav → search-row → actions) already matches the
 * existing visual sequence, so no explicit `order` is needed there —
 * desktop appearance is unchanged. Verified via round-trip/render before
 * this file was written, and via live desktop + mobile screenshots after.
 *
 * Second revision note: live mobile DOM measurement showed row 1's three
 * items (brand, nav toggle, actions) spread by the parent's
 * `justify-content: space-between` into three evenly-spaced, orphaned
 * clusters. Attempted fix with `.hubka-header__nav { margin-inline-end:
 * auto }` at the mobile breakpoint — verified via live measurement that
 * it had NO effect, then root-caused precisely by enumerating matching
 * stylesheet rules directly: WordPress core's own layout CSS
 * (`.is-layout-flex > :is(*, div) { margin: 0px; }`, specificity 0,1,1)
 * was beating the single-class selector (specificity 0,1,0) regardless
 * of source order. Fixed with `.hubka-header > .hubka-header__nav`
 * (specificity 0,2,0), which cleanly and legitimately outweighs core's
 * rule without `!important`. Verified working via live measurement after.
 *
 * Third revision note: the mobile-nav toggle button was showing on
 * DESKTOP too (reported with a screenshot). Root-caused by reading
 * WordPress core's own navigation/style.css directly: core hides
 * `.wp-block-navigation__responsive-container-open` above 600px via
 * `.wp-block-navigation__responsive-container-open:not(.always-shown) {
 * display: none; }` (specificity 0,2,0) — our own unconditional sizing
 * rule (`.hubka-header__nav .wp-block-navigation__responsive-container-
 * open { display: flex; ... }`, also 0,2,0) loaded after core's in the
 * cascade and won by source order, permanently re-showing the button.
 * Fixed by scoping our rule to `@media (max-width: 599px)`, matching
 * core's own real breakpoint exactly (600px — not this project's usual
 * 782px convention, which governs a different, unrelated layout
 * decision) rather than fighting core's own responsive logic.
 *
 * Fourth revision note: desktop search field changed from a fixed
 * 12rem width to a narrow default (3rem, icon-forward) that expands to
 * 14rem on `:focus-within`. A fully-hidden icon that only reveals an
 * input on click would require JavaScript (clicking a submit button
 * cannot move focus into a sibling input via CSS alone) — not
 * implemented, since this project has a standing no-JS constraint;
 * documented here rather than silently only doing the smaller part of
 * what was asked.
 *
 * Rules:
 * - Reuse theme.json tokens.
 * - Use logical properties.
 * - Keep selectors shallow.
 * - Do not duplicate component styling.
 */

.hubka-header {
	padding-block: var(--wp--preset--spacing--40);
	padding-inline: var(--wp--preset--spacing--50);
	border-block-end: 1px solid var(--wp--preset--color--border);
	gap: var(--wp--preset--spacing--50);
}

.hubka-header__brand {
	gap: var(--wp--preset--spacing--20);
	align-items: center;
}

.hubka-header__title {
	font-weight: 600;
}

.hubka-header__title a {
	color: var(--wp--preset--color--text);
}

.hubka-header__actions {
	gap: var(--wp--preset--spacing--30);
	align-items: center;
}

/* Search: base/forms.css styles generic <input> elements sitewide, but
 * the header search is a self-contained pill (border/radius/background
 * live on the wrapper, not the input) for a more integrated, editorial
 * feel — this intentionally overrides the generic input border for this
 * specific context via selector specificity, not by fighting !important. */
.hubka-header__search-row {
	align-items: center;
}

.hubka-header__search {
	display: flex;
	align-items: center;
}

.hubka-header__search .wc-block-product-search__fields {
	display: flex;
	align-items: center;
	gap: 0;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 999px;
	background-color: var(--wp--preset--color--background);
	transition: border-color 0.2s ease;
}

.hubka-header__search .wc-block-product-search__fields:focus-within {
	border-color: var(--wp--preset--color--primary);
}

/* The "Search" label is redundant once the placeholder already reads
 * "Search products…"; visually hidden but kept for screen readers
 * rather than removed — functionality and accessibility unchanged. */
.hubka-header__search .wc-block-product-search__label {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.hubka-header__search .wc-block-product-search__field {
	font-size: var(--wp--preset--font-size--small);
	border: none;
	background: none;
	padding-inline-start: var(--wp--preset--spacing--30);
	padding-inline-end: var(--wp--preset--spacing--20);
	padding-block: var(--wp--preset--spacing--20);
	outline: none;
	min-block-size: auto;
}

/* Integrated submit icon — sits inside the same pill as the input,
 * rather than as a visually separate, disconnected control. */
.hubka-header__search .wc-block-product-search__button {
	background: none;
	border: none;
	color: var(--wp--preset--color--muted);
	padding-inline: var(--wp--preset--spacing--30);
	display: flex;
	align-items: center;
	border-radius: 999px;
}

.hubka-header__search .wc-block-product-search__button:hover,
.hubka-header__search .wc-block-product-search__button:focus-visible {
	color: var(--wp--preset--color--primary);
}

/* Account and cart action icons: consistent sizing, quiet by default,
 * brand color on interaction. */
.hubka-header__account .wc-block-customer-account__link,
.hubka-header__cart .wc-block-mini-cart__button {
	color: var(--wp--preset--color--text);
	display: flex;
	align-items: center;
	justify-content: center;
	min-inline-size: 2.75rem;
	min-block-size: 2.75rem;
}

.hubka-header__account .wc-block-customer-account__link:hover,
.hubka-header__account .wc-block-customer-account__link:focus-visible,
.hubka-header__cart .wc-block-mini-cart__button:hover,
.hubka-header__cart .wc-block-mini-cart__button:focus-visible {
	color: var(--wp--preset--color--primary);
}

.hubka-header__account svg,
.hubka-header__cart svg {
	inline-size: 1.25rem;
	block-size: 1.25rem;
}

/* Desktop search: narrow (icon-forward) by default, expands on focus.
 * See "Fourth revision note" above for why this isn't a fully-hidden
 * icon — that specific interaction needs JavaScript, which this
 * project deliberately doesn't use. Scoped above the 782px mobile
 * breakpoint, where search already correctly becomes full-width on its
 * own row (untouched, still handled below in the existing media query). */
@media (min-width: 783px) {
	.hubka-header__search .wc-block-product-search__field {
		inline-size: 3rem;
		transition: inline-size 0.2s ease;
	}

	.hubka-header__search .wc-block-product-search__fields:focus-within .wc-block-product-search__field {
		inline-size: 14rem;
	}
}

/* Hamburger toggle: match the account/cart icon group's size and touch
 * target so all three utility controls feel like one cohesive group.
 * Scoped to WordPress core's own real breakpoint for this button (600px
 * — confirmed directly from wp-includes/blocks/navigation/style.css),
 * not this project's usual 782px convention, so we style the button
 * only where core actually shows it, rather than fighting core's own
 * display:none above 600px. */
@media (max-width: 599px) {
	.hubka-header__nav .wp-block-navigation__responsive-container-open,
	.hubka-header__nav .wp-block-navigation__responsive-container-close {
		min-inline-size: 2.75rem;
		min-block-size: 2.75rem;
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 0;
	}

	.hubka-header__nav .wp-block-navigation__responsive-container-open svg,
	.hubka-header__nav .wp-block-navigation__responsive-container-close svg {
		inline-size: 1.25rem;
		block-size: 1.25rem;
	}
}

/* Mobile: two-row layout. Brand + nav toggle grouped tight on the left
 * (margin-inline-end:auto on nav pushes actions to the far right, rather
 * than letting the parent's space-between spread all three into evenly-
 * spaced orphaned clusters). Uses a parent-child selector
 * (`.hubka-header > .hubka-header__nav`) rather than the bare class,
 * since core's own `.is-layout-flex > :is(*, div) { margin: 0 }` rule
 * (specificity 0,1,1) otherwise beats a single-class selector (0,1,0) —
 * confirmed by directly enumerating matching stylesheet rules. Search
 * becomes its own full-width row 2, matching this project's established
 * mobile breakpoint (782px, per hero.css) — this is a separate, wider
 * breakpoint than the 600px one governing the nav-toggle button itself
 * above; between 600–782px core shows its full inline link list (not
 * the hamburger) while this two-row layout still applies, which is
 * expected, not a bug — core's own breakpoint choice, not ours. */
@media (max-width: 782px) {
	.hubka-header {
		flex-wrap: wrap;
		row-gap: var(--wp--preset--spacing--30);
		padding-block: var(--wp--preset--spacing--30);
		padding-inline: var(--wp--preset--spacing--30);
	}

	.hubka-header > .hubka-header__nav {
		margin-inline-end: auto;
	}

	.hubka-header__search-row {
		order: 99;
		flex-basis: 100%;
		inline-size: 100%;
	}

	.hubka-header__search {
		inline-size: 100%;
	}

	.hubka-header__search .wc-block-product-search__fields {
		inline-size: 100%;
	}

	.hubka-header__search .wc-block-product-search__field {
		flex: 1 1 auto;
		inline-size: auto;
	}

	.hubka-header__title {
		font-size: var(--wp--preset--font-size--large);
	}

	.hubka-header__actions {
		gap: var(--wp--preset--spacing--20);
	}
}
