/**
 * I1 — Sticky Anchor Sub-navigation (anchor-nav)
 *
 * PORTED + restyled from kd-fse-starter's assets/css/patterns/anchor-nav.css
 * (decision-log #11). Structural mechanism kept (mobile disclosure toggle,
 * dropdown panels, sticky bar); visual entirely restyled to the retreat comp
 * (Figma 90:149): navy #1C2161 full-width bar, script lockup left, white
 * Rubik 600 15px uppercase links, green outlined "TOP" pill right.
 *
 * PORT ADAPTATIONS — see inc/hero-subnav.php header comment for the full
 * rationale. In short: no floating/docked bar state (this comp's bar is a
 * plain full-width strip at every scroll position); sticky `top` is a CSS
 * var written live by anchor-nav.js from the header's rendered height
 * (this theme's header has no published height token to calc() against).
 *
 * Tokens used for color/type/spacing/radius:
 *   --color-retreat-navy  (#1C2161, Figma 90:150 bar fill)
 *   --color-success       (#02BC7F — Figma TOP pill ~#02c17f, token is the
 *                          canonical value; contrast already flagged to
 *                          design, decision-log blockers table)
 *   --shadow-nav           0 4px 4px rgba(0,0,0,.25) — EXACT match to
 *                          Figma 90:150's shadow, no override needed
 *   --font-heading         Rubik (nav links + TOP; comp specifies
 *                          Rubik:SemiBold, this theme's heading family)
 *   --font-sm              15px — EXACT match to Figma's 15px link size
 *   --max-width             1200px — same content column the header uses,
 *                          so the bar's items line up with the logo/menu
 *                          above it
 *   --space-*, --radius-pill, --radius-sm
 *
 * Two values have no existing token (both are I1-scoped geometry, not scale
 * drift, so — per decision #12's pattern for the retreat page — they are
 * declared here as local custom properties rather than raw literals sprinkled
 * through the rules below):
 *   --kd-subnav-bar-height  57px   (Figma 90:150, exact)
 *   --kd-subnav-sticky-top  0px    (default; anchor-nav.js overwrites this
 *                                  on scroll/resize with the header's live
 *                                  rendered bottom edge — see JS)
 *
 * Honest disclosure (I1 kickback round 1, blocker-10 — the "no hardcoded
 * values" claim above was false; this file DOES carry a handful of literal,
 * non-token values, listed here instead of pretending otherwise):
 *   - rgb(255 255 255 / 12%), rgb(255 255 255 / 10%), rgb(255 255 255 / 82%),
 *     rgb(0 0 0 / 15%), rgb(2 188 127 / 12%) — translucent hover/active-state
 *     overlay tints. No semantic token exists for an arbitrary-alpha overlay
 *     of an existing color; these are computed from the on-brand base color
 *     they overlay (white on navy, success-green on transparent), not
 *     invented hex.
 *   - SVG viewBox/width/height (10x6, 12x12, etc.) — icon geometry, not on
 *     the type/space scale.
 *   - 44px min-height on mobile targets — WCAG 2.5.8 minimum touch target,
 *     a spec constant, not a design token.
 *   - 200px dropdown min-width, 0.9375rem dropdown font-size — component-
 *     specific geometry with no equivalent preset.
 */

:root {
	--kd-subnav-bar-height: 57px;
	--kd-subnav-sticky-top: 0px;
}

/* ── Bar ──────────────────────────────────────────────────────────────────── */

.kd-subnav-bar {
	position: sticky;
	top: var(--kd-subnav-sticky-top);
	/* Sits just below the site header (z-index:100, header.css) — bars don't
	   overlap once sticky-top tracks the header correctly, this is only a
	   safety margin against transition frames. */
	z-index: 90;
	width: 100%;
	background-color: var(--color-retreat-navy);
	box-shadow: var(--shadow-nav);
}

.kd-subnav-inner {
	max-width: var(--max-width);
	margin-inline: auto;
	height: var(--kd-subnav-bar-height);
	display: flex;
	align-items: center;
	gap: var(--space-lg);
	padding-inline: var(--space-sm);
}

/* ── Logo lockup ──────────────────────────────────────────────────────────── */

.kd-subnav-logo {
	display: flex;
	align-items: center;
	flex-shrink: 0;
}

.kd-subnav-logo img {
	display: block;
	height: 28px;
	width: auto;
}

/* ── Nav + menu ───────────────────────────────────────────────────────────── */

.kd-subnav-wrap {
	display: flex;
	align-items: stretch;
	flex: 1;
	min-width: 0;
}

.kd-subnav-menu {
	display: flex;
	align-items: center;
	flex-wrap: nowrap;
	gap: var(--space-sm);
	margin: 0;
	padding: 0;
	list-style: none;
	min-height: var(--kd-subnav-bar-height);
}

.kd-subnav-menu > li {
	position: relative;
	display: flex;
	align-items: stretch;
}

/* Top-level links */
.kd-subnav-menu > li > a {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	padding: 0 var(--space-3xs);
	height: var(--kd-subnav-bar-height);
	font-family: var(--font-heading);
	font-size: var(--font-sm);
	font-weight: 600;
	line-height: 18px;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--color-white);
	text-decoration: none;
	white-space: nowrap;
	transition: background-color 0.15s ease;
}

.kd-subnav-menu > li > a:hover,
.kd-subnav-menu > li > a:focus-visible {
	background-color: rgb(255 255 255 / 12%);
	color: var(--color-white);
	outline: none;
}

.kd-subnav-menu > li > a:focus-visible {
	outline: 2px solid var(--color-white);
	outline-offset: -3px;
}

/* Active underline — scroll-spy's .is-active ONLY. WP's own
   .current-menu-item is deliberately NOT honored here: for custom links
   WordPress strips the #fragment before matching item URL against the
   current page, so on /retreat/ every /retreat/#anchor item gets
   .current-menu-item and the whole menu underlines at once (latent since
   I1, first seen 2026-08-16 — masked earlier because ?nocache= gate URLs
   break WP's match). On an anchor subnav that class is always
   all-or-nothing, never a real location signal. */
.kd-subnav-menu > li.is-active > a {
	box-shadow: inset 0 -3px 0 var(--color-white);
}

/* ── Dropdown chevron (depth-2 items) ───────────────────────────────────────── */

.kd-subnav-menu > li.menu-item-has-children > a {
	padding-right: calc(var(--space-3xs) * 0.75);
}

.kd-subnav-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.75rem;
	height: var(--kd-subnav-bar-height);
	padding: 0 0.25rem;
	background: transparent;
	border: none;
	color: var(--color-white);
	cursor: pointer;
	flex-shrink: 0;
}

.kd-subnav-toggle:hover,
.kd-subnav-toggle:focus-visible {
	background-color: rgb(255 255 255 / 12%);
	outline: none;
}

.kd-subnav-toggle:focus-visible {
	outline: 2px solid var(--color-white);
	outline-offset: -3px;
}

.kd-subnav-toggle svg {
	display: block;
	width: 12px;
	height: 12px;
	transition: transform 0.15s ease;
}

.kd-subnav-toggle[aria-expanded="true"] svg {
	transform: rotate(180deg);
}

/* ── Dropdown panels ──────────────────────────────────────────────────────── */

.kd-subnav-menu .sub-menu {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	margin: 0;
	padding: 0.5rem 0;
	list-style: none;
	min-width: 200px;
	background: var(--color-white);
	border-radius: var(--radius-sm);
	box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
	z-index: 10;
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
	pointer-events: none;
}

.kd-subnav-menu > li.is-open > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

.kd-subnav-menu .sub-menu a {
	display: block;
	padding: 0.5rem 1.25rem;
	font-family: var(--font-heading);
	font-size: 0.9375rem;
	font-weight: 500;
	text-transform: none;
	color: var(--color-retreat-navy);
	text-decoration: none;
	white-space: nowrap;
}

.kd-subnav-menu .sub-menu a:hover,
.kd-subnav-menu .sub-menu a:focus-visible {
	color: var(--color-primary);
	background-color: var(--color-grey-100);
	outline: none;
}

/* ── TOP pill ─────────────────────────────────────────────────────────────── */

.kd-subnav-top {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.35em;
	flex-shrink: 0;
	margin-left: auto;
	height: 32px;
	padding: 0 var(--space-3xs);
	background: transparent;
	border: 2px solid var(--color-success);
	border-radius: var(--radius-pill);
	color: var(--color-success);
	font-family: var(--font-heading);
	font-size: var(--font-sm);
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.kd-subnav-top:hover,
.kd-subnav-top:focus-visible {
	background-color: rgb(2 188 127 / 12%);
	outline: none;
}

.kd-subnav-top:focus-visible {
	outline: 2px solid var(--color-success);
	outline-offset: 2px;
}

.kd-subnav-top svg {
	display: block;
	width: 12px;
	height: 12px;
}

/* ── Disclosure button — hidden at ≥1280px (desktop only) ───────────────────── */

.kd-subnav-mobile-toggle {
	display: none;
}

/* ── Collapsed nav — disclosure button + dropdown panel (<1199.98px) ────────
 * No mobile/tablet frame exists in the comp for this bar — behaviour derived
 * from the desktop design + the starter's own collapsed pattern (ported
 * near-verbatim). FLAG: responsive pass needs designer review.
 *
 * BREAKPOINT NOTE — corrected 2026-08-15, I1 kickback round 1 (was
 * 1279.98px, ~100px too conservative):
 *
 * Live-measured on retreat-test-i1 (post 519) at 1440px viewport, all
 * children at natural/unshrunk size:
 *   .kd-subnav-inner padding-inline  24px + 24px = 48px  (--space-sm each side)
 *   .kd-subnav-logo  width                       = 61.48px
 *   inner gap (--space-lg)                       = 40px
 *   .kd-subnav-menu  width (7 links, natural)     = 926.73px
 *   inner gap (--space-lg)                       = 40px
 *   .kd-subnav-top   width                       = 67.21px
 *                                          TOTAL  = 1183.42px  (border-box)
 *
 * .kd-subnav-inner's own box is min(1200px, viewport) — so the row's true
 * fit boundary is viewport ≈ 1183.42px, NOT 1280px. Confirmed live: 0px gap
 * between the last link and the TOP pill at both 1190px and 1183px (forced
 * off the media query for the test), no overlap; comfortable ~56.6px gap at
 * 1440px. The row already fits at 1440px per the comp (90:149, 7 links +
 * logo + TOP) — no spacing/font tightening was needed.
 *
 * 1199.98px is set here — not the bare 1183.42px minimum — to land exactly
 * at the point .kd-subnav-inner's own max-width:1200px cap starts applying,
 * giving ~16.6px of safety margin (covers sub-pixel/font-rendering variance
 * and typical scrollbar-gutter width) without needlessly widening the
 * collapse range the way 1279.98px did.
 *
 * SOURCE OF TRUTH: this literal must match TWO other places that cannot
 * share a CSS custom property with this file (media queries don't accept
 * var()) — kept in sync by hand, cross-referenced:
 *   1. assets/js/anchor-nav.js `KD_SUBNAV_COLLAPSE_BP` constant (~:141)
 *   2. inc/hero-subnav.php noscript fallback media query (~:280)
 */

@media (max-width: 1199.98px) {
	.kd-subnav-inner {
		height: auto;
		min-height: var(--kd-subnav-bar-height);
		flex-wrap: wrap;
		padding-inline: 0;
		gap: 0;
	}

	.kd-subnav-logo {
		padding-inline-start: var(--space-sm);
	}

	.kd-subnav-wrap {
		order: 3;
		flex-basis: 100%;
	}

	.kd-subnav-top {
		margin-left: 0;
		margin-inline-end: var(--space-sm);
	}

	.kd-subnav-mobile-toggle {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: var(--space-3xs);
		flex: 1;
		min-width: 0; /* let the label ellipsize instead of wrapping/growing the bar */
		min-height: 44px; /* WCAG 2.5.8 minimum touch target */
		padding: 0 var(--space-sm);
		background: transparent;
		border: none;
		color: var(--color-white);
		font-family: var(--font-heading);
		font-size: var(--font-sm);
		font-weight: 600;
		text-transform: uppercase;
		cursor: pointer;
		text-align: left;
	}

	.kd-subnav-mobile-toggle__label {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		min-width: 0;
	}

	.kd-subnav-mobile-toggle:focus-visible {
		outline: 2px solid var(--color-white);
		outline-offset: -3px;
	}

	.kd-subnav-mobile-toggle svg {
		display: block;
		width: 12px;
		height: 12px;
		flex-shrink: 0;
		transition: transform 0.15s ease;
	}

	.kd-subnav-mobile-toggle[aria-expanded="true"] svg {
		transform: rotate(180deg);
	}

	.kd-subnav-menu {
		display: none;
		position: static;
		flex-direction: column;
		flex-wrap: nowrap;
		gap: 0;
		padding: var(--space-4xs) 0;
		min-height: unset;
		width: 100%;
		background: rgb(0 0 0 / 15%);
	}

	.kd-subnav-menu.is-open {
		display: flex;
	}

	.kd-subnav-menu > li {
		flex-direction: column;
		align-items: stretch;
		width: 100%;
	}

	.kd-subnav-menu > li > a {
		height: auto;
		min-height: 44px; /* WCAG 2.5.8 */
		padding: var(--space-3xs) var(--space-sm);
		white-space: normal;
	}

	.kd-subnav-toggle {
		display: none;
	}

	.kd-subnav-menu .sub-menu {
		position: static;
		opacity: 1;
		visibility: visible;
		transform: none;
		pointer-events: auto;
		box-shadow: none;
		background: transparent;
		border-radius: 0;
		padding: 0;
		min-width: unset;
		display: block;
	}

	.kd-subnav-menu .sub-menu a {
		padding-left: calc(var(--space-sm) + 1rem);
		color: rgb(255 255 255 / 82%);
		font-size: 0.9375rem;
		min-height: 44px; /* WCAG 2.5.8 */
		display: flex;
		align-items: center;
	}

	.kd-subnav-menu .sub-menu a:hover,
	.kd-subnav-menu .sub-menu a:focus-visible {
		color: var(--color-white);
		background-color: rgb(255 255 255 / 10%);
	}

	/* .current-menu-item dropped here too — same all-or-nothing WP
	   fragment-stripping issue as the desktop underline rule (see its
	   comment); a tinted background on every mobile row is the same bug
	   in different clothes. */
	.kd-subnav-menu > li.is-active > a {
		box-shadow: none;
		background-color: rgb(255 255 255 / 12%);
	}
}

@media (max-width: 480px) {
	.kd-subnav-logo {
		display: none;
	}
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
	.kd-subnav-menu .sub-menu,
	.kd-subnav-toggle svg,
	.kd-subnav-mobile-toggle svg {
		transition: none;
	}
}
