/*
 * Brightway Consultancy — nav.css
 * Fluid Island navigation — header pill + mobile button-driven overlay.
 * Depends on tokens.css. MASTER.md §10 (Section patterns: Nav).
 *
 * Mobile pattern: <button class="bwc-nav-toggle" aria-expanded aria-controls>
 * + sibling <div id="bwc-nav-overlay" hidden>. JS in main.js flips
 * aria-expanded, toggles the [hidden] attribute on the overlay, and adds
 * .bwc-no-scroll to <body>. CSS keys all state off [aria-expanded] +
 * [hidden] — no <details>/<summary> dependency, no [open] state read or
 * written. Robust across Safari, Brave, Firefox.
 *
 * Universal contract:
 *   - Hover gated @media (hover: hover) and (pointer: fine)
 *   - :focus-visible custom — 2px gold + 4px offset (matches components.css)
 *   - Exact transition properties only — NEVER transition: all
 *   - UI durations ≤200ms (tooltip 160). NO motion on the keyboard-init
 *     toggle (Emil §6.3 rule 1) — icons swap via [aria-expanded] state
 *     without transition. GSAP enhances open/close in Phase 7.
 *   - prefers-reduced-motion handled globally in utilities.css.
 *   - Logical properties everywhere (inset-block-*, inline-size, etc.).
 */

/* ===========================================================================
 * 1. Header outer — fixed overlay pattern. Sits above the hero video
 *    without consuming layout height (no document flow contribution).
 *    The wrapper spans inset-inline: 0 to enable centred-container
 *    positioning of the pill. pointer-events: none on the wrapper +
 *    pointer-events: auto on .bwc-nav-pill (bloc 2) ensures only the
 *    pill itself catches clicks — clicks on the empty band around the
 *    pill pass through to the hero CTAs below. Pattern: Apple, Stripe,
 *    wattlecorp.com/ae.
 * ========================================================================= */

.bwc-header {
	position: fixed;
	inset-block-start: 1rem;
	inset-inline: 0;
	z-index: var(--bwc-z-sticky);
	pointer-events: none;
}

/* ===========================================================================
 * 2. Nav pill — Fluid Island translucent container
 * ========================================================================= */

.bwc-nav-pill {
	display: flex;
	inline-size: 100%; /* fill .bwc-container content area — without this, the flex container auto-sizes to its content and collapses on mobile when desktop items are display:none */
	align-items: center;
	justify-content: space-between;
	gap: clamp(1rem, 2vw, 2rem);
	padding-block: 0.5rem;
	padding-inline: 1.5rem 0.5rem; /* tighter right inline for flush CTA / toggle */
	background-color: color-mix(in srgb, var(--bwc-bg) 85%, transparent); /* warm-black 85% — frosted-glass surface so scrolled page content never bleeds through and renders the pill illegible */
	border: 1px solid rgba(245, 241, 232, 0.08);
	border-radius: 999px;
	backdrop-filter: blur(12px) saturate(140%);
	-webkit-backdrop-filter: blur(12px) saturate(140%); /* Safari */
	pointer-events: auto; /* counter to .bwc-header pointer-events: none — the pill itself catches clicks */
}

/* ===========================================================================
 * 3. Brand wordmark — Fraunces SOFT 10, premium editorial anchor
 * ========================================================================= */

.bwc-nav-brand {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem; /* picto → wordmark rhythm */
	font-family: var(--bwc-font-display);
	font-size: var(--bwc-fs-base);
	font-weight: 520;
	font-optical-sizing: auto;
	font-variation-settings: 'SOFT' 10;
	letter-spacing: -0.01em;
	color: var(--bwc-text);
	text-decoration: none;
	white-space: nowrap;
}

/* Brand mark — square padlock picto left of the Fraunces wordmark. Sized
 * in rem off the pill rhythm; 30px desktop / 26px ≤767px so it stays
 * recognisable without crowding the wordmark or inflating pill height.
 * Square asset (96×96 source) → height drives width via the img attrs. */
.bwc-nav-brand__mark {
	display: block;
	inline-size: 1.625rem; /* 26px — mobile base */
	block-size: 1.625rem;
}

@media (min-width: 768px) {
	.bwc-nav-brand__mark {
		inline-size: 1.875rem; /* 30px — desktop */
		block-size: 1.875rem;
	}
}

.bwc-nav-brand:focus-visible {
	outline: 2px solid var(--bwc-accent-gold);
	outline-offset: 4px;
	border-radius: 2px;
}

/* ===========================================================================
 * 4. Desktop / Mobile mutually-exclusive containers
 *    Below md: mobile <details> visible, desktop hidden.
 *    md+ (768px): desktop visible (flex), mobile hidden.
 * ========================================================================= */

.bwc-nav-desktop {
	display: none;
}

.bwc-nav-mobile {
	display: block;
}

@media (min-width: 768px) {
	.bwc-nav-desktop {
		display: flex;
		align-items: center;
		gap: clamp(1.5rem, 3vw, 2.5rem);
	}

	.bwc-nav-mobile {
		display: none;
	}
}

/* ===========================================================================
 * 5. Items list — horizontal in the pill, vertical (overridden) in overlay
 * ========================================================================= */

.bwc-nav-items {
	display: flex;
	align-items: center;
	gap: clamp(1rem, 2vw, 1.5rem);
	list-style: none;
	margin: 0;
	padding: 0;
}

/* ===========================================================================
 * 6. Nav link — color + traced gold hairline on hover / aria-current
 * ========================================================================= */

.bwc-nav-link {
	position: relative;
	display: inline-block;
	color: var(--bwc-text);
	font-family: var(--bwc-font-body);
	font-size: var(--bwc-fs-sm);
	font-weight: 500;
	text-decoration: none;
	padding-block: 0.25rem;
	transition: color var(--bwc-dur-tooltip) var(--bwc-ease-out);
}

.bwc-nav-link::after {
	content: '';
	position: absolute;
	inset-inline: 0;
	inset-block-end: -2px;
	block-size: 1px;
	background-color: var(--bwc-accent-gold);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform var(--bwc-dur-tooltip) var(--bwc-ease-out);
}

@media (hover: hover) and (pointer: fine) {
	.bwc-nav-link:hover {
		color: var(--bwc-accent-gold);
	}

	.bwc-nav-link:hover::after {
		transform: scaleX(1);
	}
}

.bwc-nav-link:focus-visible {
	outline: 2px solid var(--bwc-accent-gold);
	outline-offset: 4px;
	border-radius: 2px;
}

/* Active page — sticky gold treatment (hairline always visible) */
.bwc-nav-link[aria-current="page"] {
	color: var(--bwc-accent-gold);
}

.bwc-nav-link[aria-current="page"]::after {
	transform: scaleX(1);
}

/* ===========================================================================
 * 7. Nav CTA — compact pill, override .bwc-btn-primary padding for header rhythm
 * ========================================================================= */

.bwc-nav-cta {
	padding-block: 0.5rem;
	padding-inline: 1.25rem;
	font-size: var(--bwc-fs-sm);
}

/* ===========================================================================
 * 8. Mobile toggle — circular hamburger <button>, always rendered on
 *    mobile. Native button reset (background-color, border, padding,
 *    cursor) so no UA chrome leaks through.
 * ========================================================================= */

.bwc-nav-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	inline-size: 2.5rem;
	block-size: 2.5rem;
	padding: 0;
	cursor: pointer;
	background-color: transparent;
	color: var(--bwc-text);
	border: 1px solid rgba(245, 241, 232, 0.12);
	border-radius: 999px;
	font: inherit; /* defeat UA button font-family quirks (Safari) */
	transition: border-color var(--bwc-dur-tooltip) var(--bwc-ease-out);
}

@media (hover: hover) and (pointer: fine) {
	.bwc-nav-toggle:hover {
		border-color: var(--bwc-accent-gold);
	}
}

.bwc-nav-toggle:focus-visible {
	outline: 2px solid var(--bwc-accent-gold);
	outline-offset: 4px;
}

/* ===========================================================================
 * 9. Toggle icons — hamburger / X swap keyed off body.bwc-nav-open. State
 *    lives in one place (body class) so the icon, the overlay visibility,
 *    and the body-scroll lock all move together. NO animation — Emil §6.3
 *    rule 1: keyboard-initiated state change is instant; GSAP enhances in
 *    Phase 7. aria-expanded on the button itself is the ARIA state for AT.
 * ========================================================================= */

.bwc-nav-toggle-icon {
	display: flex;
	align-items: center;
	justify-content: center;
}

.bwc-nav-toggle-icon > svg {
	inline-size: 1.25rem;
	block-size: 1.25rem;
}

.bwc-nav-toggle-icon--close {
	display: none;
}

body.bwc-nav-open .bwc-nav-toggle-icon--open {
	display: none;
}

body.bwc-nav-open .bwc-nav-toggle-icon--close {
	display: flex;
}

/* ===========================================================================
 * 10. Mobile overlay — full-viewport panel, vertical items + CTA.
 *
 *     POSITION: the overlay markup is emitted at <body> root (header.php),
 *     NOT inside .bwc-nav-pill. The pill's backdrop-filter creates a new
 *     containing block for position:fixed descendants (CSS Filter Effects
 *     Module L1 §2) — if the overlay were a descendant, inset:0 would
 *     map to the pill box, not the viewport, producing a ~50–300px black
 *     strip aligned with the pill. Hoisting the overlay to <body> root
 *     restores the viewport as its containing block.
 *
 *     STATE: a single source of truth — the .bwc-nav-open class on <body>,
 *     written by main.js. Default is display:none (closed); body.bwc-nav-
 *     open promotes to display:flex. The HTML `hidden` attribute is kept
 *     in sync as a redundant a11y signal but is NOT load-bearing for
 *     visual state — even if some external script strips it, the overlay
 *     stays hidden.
 *
 *     STACKING: z-index = --bwc-z-sticky − 1 sits just below the fixed
 *     header pill, so the close-toggle stays clickable. overscroll-
 *     behavior:contain prevents touch-momentum from bubbling to <body>;
 *     full body-scroll lock is applied via .bwc-nav-open's overflow
 *     rule in utilities.css.
 * ========================================================================= */

.bwc-nav-overlay {
	/* Always in the layout (display:flex) so opacity + transform can
	 * animate the open/close. Visual state is gated by opacity +
	 * transform + pointer-events; a11y by [inert]; semantic closure by
	 * [hidden] (overridden below so it doesn't trigger display:none). */
	position: fixed;
	inset: 0;
	display: flex;
	flex-direction: column;
	background-color: var(--bwc-bg);
	padding-block: 6rem var(--bwc-space-4);
	padding-inline: clamp(1.5rem, 6vw, 4rem);
	overflow-y: auto;
	overscroll-behavior: contain;
	z-index: calc(var(--bwc-z-sticky) - 1);

	/* Closed state. Documented modal/drawer exception to the ≤300ms UI
	 * ceiling (--bwc-dur-modal = 320ms) per the motion contract. */
	opacity: 0;
	transform: translateY(-0.75rem);
	pointer-events: none;
	transition:
		opacity var(--bwc-dur-modal) var(--bwc-ease-drawer),
		transform var(--bwc-dur-modal) var(--bwc-ease-drawer);
}

/* Defeat the UA stylesheet's [hidden] { display:none } — the [hidden]
 * attribute is kept on the closed overlay as a redundant a11y signal,
 * but it must NOT remove the element from layout or the open/close
 * animation cannot run. */
.bwc-nav-overlay[hidden] {
	display: flex;
}

body.bwc-nav-open .bwc-nav-overlay {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

/* Items list — vertical column, comfortable rhythm, hairline gold
 * separator beneath that anchors the CTA below. */
.bwc-nav-overlay .bwc-nav-items {
	flex-direction: column;
	gap: var(--bwc-space-3);
	align-items: flex-start;
	margin-block: 0;
	padding-block-end: var(--bwc-space-4);
	border-block-end: 1px solid var(--bwc-accent-gold-hairline);
}

/* Item link — Fraunces at fs-lg (20–24px), comfortable touch target
 * (line-height + padding clears 44px). Sized for a mobile menu, not
 * a hero display scale. */
.bwc-nav-overlay .bwc-nav-link {
	font-family: var(--bwc-font-display);
	font-size: var(--bwc-fs-lg);
	font-weight: 480;
	line-height: 1.2;
	padding-block: 0.625rem;
}

/* CTA — full-width pill at the bottom of the overlay, centered text. */
.bwc-nav-overlay .bwc-nav-cta {
	align-self: stretch;
	justify-content: center;
	margin-block-start: var(--bwc-space-4);
	padding-block: 1rem;
	padding-inline: 1.5rem;
	font-size: var(--bwc-fs-base);
}

/*
 * AUDIT — Phase 6, nav.css (2026-05-22)
 *
 * emil-design-eng — Before/After review (greenfield):
 *
 *   | Concern (rule)                                  | Resolution                                                                                      |
 *   |-------------------------------------------------|-------------------------------------------------------------------------------------------------|
 *   | Rule 1 — no animation on keyboard-init actions  | ✅ <details> toggle has NO transition; icons swap via [open] state (no animation property).     |
 *   | Rule 2 — exact transition properties            | ✅ color / border-color / transform. 0 use of "all".                                            |
 *   | Rule 3 — asymmetric enter/exit                  | UI durations ≤160ms — within Emil's symmetric band. Larger overlay-open motion is Phase 7 GSAP. |
 *   | Rule 5 — hover gated behind (hover:hover) media | ✅ Every :hover wrapped — .bwc-nav-link, .bwc-nav-toggle.                                       |
 *   | Rule 6 — prefers-reduced-motion respected       | Delegated to utilities.css universal override. End-states still apply when motion is reduced.   |
 *   | Rule 7 — no scale(0) entries                    | ✅ No scale anywhere (transform: scaleX(0) is a 1D underline reveal, not a scale-from-zero      |
 *   |                                                 | entry — width-equivalent, not an opacity-bypass anti-pattern).                                  |
 *   | Rule 8 — button :active scale(0.97)             | N/A — nav links are not buttons (Emil rule 1 forbids action animation on keyboard activation).  |
 *   |                                                 | .bwc-nav-cta inherits .bwc-btn-primary's :active rule from components.css.                      |
 *   | Rule 9 — animate transform/opacity (paint OK)   | ✅ transform + color + border-color only. No layout-thrashing properties animated.              |
 *   | Rule 10 — CSS transitions over keyframes        | ✅ No @keyframes. Pure CSS transitions.                                                         |
 *
 *   Duration audit: only --bwc-dur-tooltip (160ms) used. Well under 200ms UI ceiling.
 *   Easing audit: --bwc-ease-out only. --bwc-ease-in not referenced (banned).
 *
 * high-end-visual-design — Absolute Zero:
 *
 *   | Anti-pattern                                    | Status                                                                                          |
 *   |-------------------------------------------------|-------------------------------------------------------------------------------------------------|
 *   | Inter/Roboto/etc. fonts                         | ✅ Fraunces (brand, overlay links) + Barlow (pill links, CTA) via --bwc-font-* tokens.          |
 *   | Pure #000 / pure #FFF                           | ✅ Surfaces use --bwc-bg / --bwc-text. White rgba alphas (sand 4% / 8% / 12%) over warm bg —    |
 *   |                                                 | translucent washes, not pure #FFF fills.                                                        |
 *   | 1px solid gray                                  | ✅ Borders are sand-alpha (pill, toggle) or gold (hover/active/focus). Never neutral gray.      |
 *   | shadow-md / shadow-lg / harsh drop shadow       | ✅ No drop shadows. Pill uses border + backdrop-filter blur for elevation cue.                  |
 *   | Default focus ring                              | ✅ Every :focus-visible custom — 2px gold + 4px offset on brand, link, toggle.                  |
 *   | transition: all                                 | ✅ Zero occurrences. Every transition enumerates exact properties.                              |
 *   | Built-in CSS ease-in / ease-in-out / linear     | ✅ Zero. Only --bwc-ease-out (custom cubic-bezier).                                             |
 *   | Edge-to-edge sticky navbar                      | ✅ Pill is contained inside .bwc-container (max 1440 + clamped gutters) — Fluid Island pattern, |
 *   |                                                 | NOT edge-to-edge.                                                                               |
 *   | Tailwind utility class                          | ✅ All .bwc-*-prefixed BEM-style. No utility-framework patterns.                                |
 *   | Thick-stroke / emoji icons                      | ✅ Hamburger + X SVG strokes = 1.5px (ultra-thin Phosphor Light style). No emoji.               |
 *   | Animation on keyboard-init action               | ✅ Button toggle has NO CSS transition — icons swap instantly via [aria-expanded]. GSAP later. |
 *
 * Accessibility verification (BRIEF §9 / WCAG 2.1 AA):
 *
 *   | Requirement                                     | Status                                                                                          |
 *   |-------------------------------------------------|-------------------------------------------------------------------------------------------------|
 *   | <nav> landmark with distinguishing label        | ✅ <nav aria-label="Primary"> in header.php.                                                    |
 *   | Current-page indication                         | ✅ aria-current="page" injected by REQUEST_URI path matching (works pre-content).               |
 *   | Skip-to-content first focusable                 | ✅ Existing .bwc-skip-link kept, reaches #bwc-main.                                             |
 *   | Disclosure-button ARIA contract                 | ✅ <button aria-expanded aria-controls="bwc-nav-overlay"> — canonical disclosure pattern        |
 *   |                                                 | (W3C APG). JS flips aria-expanded in sync with the [hidden] toggle on the overlay.              |
 *   | Icon-only toggle has accessible name            | ✅ <button aria-label="Open navigation"> announces the control to AT.                          |
 *   | Visible focus on every interactive element      | ✅ Brand, links, toggle — custom gold outline.                                                  |
 *   | Decorative SVG hidden from AT                   | ✅ aria-hidden="true" on .bwc-nav-toggle-icon spans.                                            |
 *   | Keyboard parity for mobile toggle               | ✅ Native <button> — keyboard-focusable + Enter/Space activates; Esc closes via main.js.       |
 *
 * Tokens consumed: --bwc-z-sticky, --bwc-bg, --bwc-text, --bwc-accent-gold,
 * --bwc-font-body, --bwc-font-display, --bwc-fs-base, --bwc-fs-sm,
 * --bwc-fs-2xl, --bwc-space-4, --bwc-space-6,
 * --bwc-dur-tooltip, --bwc-ease-out.
 *
 * Inline alpha values (intentional, no token has these exact alphas):
 * sand 8% (pill border), sand 12% (toggle border). Pill bg is warm-black 85%
 * (color-mix of --bwc-bg) — frosted surface that keeps the pill legible when
 * page content scrolls beneath the fixed header.
 *
 * Result: 0 blocking violation. Body-scroll lock owned by main.js via
 * the .bwc-no-scroll utility on <body>.
 */
