/**
 * Viora Header widget.
 *
 * `.viora-site-header` is the widget; `.viora-header` is the theme's builder
 * location wrapper around it.
 */

.viora-site-header {
	--viora-header-color: #ffffff;
	--viora-header-bg: transparent;
	--viora-header-stuck-bg: #ffffff;
	--viora-header-stuck-color: #111111;
	--viora-header-breakpoint: 1024px;
	--viora-header-pad-y: clamp(1.25rem, 2.84vw, 2.5625rem);

	position: relative;
	z-index: var(--viora-z-header);
	width: 100%;
	background-color: var(--viora-header-bg);
	color: var(--viora-header-color);
	transition:
		background-color var(--viora-motion-base) var(--viora-motion-easing),
		color var(--viora-motion-base) var(--viora-motion-easing),
		transform var(--viora-motion-base) var(--viora-motion-easing);
}

.viora-site-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--viora-space-md);
	width: 100%;
	margin-inline: auto;
	padding: var(--viora-header-pad-y) var(--viora-layout-container-pad);
}

/*
 * Overlay: the header floats above the first section, so the hero image runs
 * underneath it. The theme's location wrapper has to come out of the flow too.
 */
.viora-header:has(.viora-site-header--overlay),
.viora-site-header--overlay.is-detached {
	position: absolute;
	inset-inline: 0;
	top: 0;
}

/*
 * Static: nothing dark sits behind the bar, so the transparent-on-white
 * palette of overlay mode would be invisible. The variables carry the change,
 * so every child — menu, CTA, toggle — follows without its own override.
 */
.viora-site-header--static {
	--viora-header-color: var(--viora-color-heading);
	--viora-header-bg: var(--viora-color-surface);

	border-bottom: 1px solid rgba(17, 17, 17, 0.1);
}

.viora-site-header.is-sticky {
	position: fixed;
	top: 0;
	inset-inline: 0;
	transform: translateY(-100%);
}

.viora-site-header.is-sticky.is-stuck {
	transform: none;
	background-color: var(--viora-header-stuck-bg);
	color: var(--viora-header-stuck-color);
	box-shadow: var(--viora-shadow-sm);
	--viora-header-pad-y: clamp(0.75rem, 1.6vw, 1.25rem);
}

/* -------------------------------------------------- *
 * Brand
 * -------------------------------------------------- */

.viora-site-header__logo {
	display: inline-flex;
	align-items: center;
	color: inherit;
	font-family: var(--viora-font-display);
	font-size: clamp(1.5rem, 2.22vw, 2rem);
	font-weight: 500;
	line-height: 1;
	letter-spacing: -0.05em;
	text-decoration: none;
	text-transform: uppercase;
}

.viora-site-header__logo:hover {
	color: inherit;
	opacity: 0.75;
}

.viora-site-header__logo img {
	display: block;
	width: auto;
	height: 38px;
	object-fit: contain;
}

/* -------------------------------------------------- *
 * Menu
 * -------------------------------------------------- */

.viora-site-header__menu {
	display: flex;
	align-items: center;
	gap: clamp(1.25rem, 2.9vw, 2.625rem);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* The drop-down is absolute, so its item has to be the positioned ancestor —
   otherwise it lands against the header bar and sits at the far left. */
.viora-site-header__menu > li {
	position: relative;
}

.viora-site-header__menu a {
	position: relative;
	display: inline-block;
	color: inherit;
	font-family: var(--viora-font-body);
	font-size: clamp(0.8125rem, 1.04vw, 0.9375rem);
	font-weight: var(--viora-weight-semibold);
	line-height: 1.2;
	letter-spacing: -0.01em;
	text-decoration: none;
	text-transform: uppercase;
	white-space: nowrap;
}

/* Understated underline on hover / current page. */
.viora-site-header__menu a::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -0.35em;
	height: 1px;
	background-color: currentColor;
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform var(--viora-motion-base) var(--viora-motion-easing);
}

.viora-site-header__menu a:hover::after,
.viora-site-header__menu .current-menu-item > a::after,
.viora-site-header__menu .current_page_item > a::after {
	transform: scaleX(1);
}

/* -------------------------------------------------- *
 * Drop-down
 *
 * Shared by both menu sources — the Elementor repeater and wp_nav_menu both
 * emit `.menu-item-has-children` + `.sub-menu`.
 *
 * The panel carries `.viora-scheme--cream`, so every colour below reads from
 * `--viora-surface` / `--viora-ink` / `--viora-hairline` rather than naming a
 * value — the one way a widget is allowed to change scheme. That resolves to
 * the #f2efe8 surface with ink text. Squared off, because the panel reads as a
 * cut edge of the bar rather than as a floating card.
 * -------------------------------------------------- */

/*
 * Signals that the item opens a panel. Without it the only way to find a
 * sub-menu was to hover the right word by accident.
 */
/* Sized in em so the same rule serves the bar and the far larger mobile menu. */
.viora-site-header__menu > .menu-item-has-children > a {
	padding-right: 0.9em;
}

.viora-site-header__menu > .menu-item-has-children > a::before {
	content: "";
	position: absolute;
	top: 50%;
	right: 0;
	width: 0.3em;
	height: 0.3em;
	margin-top: -0.22em;
	border-right: 1px solid currentColor;
	border-bottom: 1px solid currentColor;
	transform: rotate(45deg);
	transition: transform var(--viora-motion-base) var(--viora-motion-easing);
}

/* Hover only opens the panel on the bar — compact keys off `.is-open` instead,
   because a tapped item on a touch screen keeps :hover long after the tap. */
.viora-site-header:not(.is-compact) .viora-site-header__menu > .menu-item-has-children:hover > a::before,
.viora-site-header:not(.is-compact) .viora-site-header__menu > .menu-item-has-children:focus-within > a::before {
	margin-top: -0.06em;
	transform: rotate(-135deg);
}

/* The underline stops short of the chevron instead of running under it. */
.viora-site-header__menu > .menu-item-has-children > a::after {
	right: 0.9em;
}

.viora-site-header__menu .sub-menu {
	position: absolute;
	/* Stands off the bar rather than butting against it; the bridge below keeps
	   the gap hoverable. */
	top: calc(100% + 0.625rem);
	/* Pulled back by the row padding so the first label sits on the same optical
	   line as its parent instead of stepping in from it. */
	left: calc(var(--viora-space-sm) * -1);
	z-index: 2;
	min-width: 13rem;
	margin: 0;
	padding: var(--viora-space-2xs) 0;
	list-style: none;
	background-color: var(--viora-surface);
	border: 1px solid var(--viora-hairline);
	border-radius: 0;
	box-shadow: var(--viora-shadow-lg);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-0.375rem);
	transition:
		opacity var(--viora-motion-fast) var(--viora-motion-easing),
		transform var(--viora-motion-fast) var(--viora-motion-easing),
		visibility var(--viora-motion-fast);
}

/*
 * Covers the stand-off gap. It is inside the panel, so hovering it still counts
 * as hovering the parent item — without it the panel closes the moment the
 * pointer leaves the link on its way down.
 */
.viora-site-header__menu .sub-menu::before {
	content: "";
	position: absolute;
	right: 0;
	bottom: 100%;
	left: 0;
	height: calc(0.625rem + 1px);
}

.viora-site-header__menu li {
	position: relative;
}

.viora-site-header__menu li:hover > .sub-menu,
.viora-site-header__menu li:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: none;
}

/*
 * Reset rather than inherit: the top level is uppercase semibold with tight
 * tracking, which is far too loud for a stacked list of eleven links.
 */
.viora-site-header__menu .sub-menu a {
	display: block;
	padding: var(--viora-space-2xs) var(--viora-space-sm);
	color: var(--viora-ink);
	font-family: var(--viora-font-ui);
	font-size: 0.875rem;
	font-weight: var(--viora-weight-medium);
	line-height: 1.5;
	letter-spacing: 0.01em;
	text-transform: none;
	transition:
		color var(--viora-motion-fast) var(--viora-motion-easing),
		background-color var(--viora-motion-fast) var(--viora-motion-easing);
}

/* The top level marks itself with an underline; a stacked list reads better
   with a rule down its leading edge. */
.viora-site-header__menu .sub-menu a::after {
	top: var(--viora-space-3xs);
	right: auto;
	bottom: var(--viora-space-3xs);
	left: 0;
	width: 2px;
	height: auto;
	background-color: var(--viora-color-accent);
	transform: scaleY(0);
	transform-origin: center top;
	transition: transform var(--viora-motion-fast) var(--viora-motion-easing);
}

/*
 * The label is already at full strength, so the row itself has to carry the
 * hover: a lift off the panel plus the accent rule. Inverting to a light row
 * would fight the panel it sits in.
 */
.viora-site-header__menu .sub-menu a:hover,
.viora-site-header__menu .sub-menu a:focus-visible,
.viora-site-header__menu .sub-menu .current-menu-item > a,
.viora-site-header__menu .sub-menu .current_page_item > a {
	background-color: var(--viora-hairline);
	color: var(--viora-ink);
}

.viora-site-header__menu .sub-menu a:hover::after,
.viora-site-header__menu .sub-menu a:focus-visible::after,
.viora-site-header__menu .sub-menu .current-menu-item > a::after,
.viora-site-header__menu .sub-menu .current_page_item > a::after {
	transform: scaleY(1);
}

/* -------------------------------------------------- *
 * Actions
 * -------------------------------------------------- */

.viora-site-header__actions {
	display: flex;
	align-items: center;
	gap: var(--viora-space-xs);
}

/*
 * Two classes throughout: `.viora-btn.viora-btn--primary` in the design system
 * carries the fill and a drop shadow, and a single class loses to it — which is
 * why the `box-shadow: none` here never took effect and the flat pill kept a
 * soft outline under it.
 */
.viora-btn.viora-site-header__cta {
	border: 0;
	padding: 0.8125rem 1.6875rem;
	font-family: var(--viora-font-ui);
	font-size: 0.9375rem;
	letter-spacing: -0.025em;
	text-transform: uppercase;
	box-shadow: none;
}

.viora-btn.viora-site-header__cta:hover {
	box-shadow: none;
}

/*
 * The button takes its cue from what sits behind the bar. Overlay mode floats
 * over the hero image, so the button is the light element; on the inner pages
 * the bar is already white and the button has to be the dark one.
 *
 * Two classes to match `.viora-btn.viora-btn--primary` from the design system,
 * which is what paints it otherwise — one class would lose to it.
 */
.viora-site-header--overlay .viora-site-header__cta {
	background-color: var(--viora-color-surface);
	color: var(--viora-color-heading);
}

.viora-site-header--static .viora-site-header__cta {
	background-color: var(--viora-color-secondary);
	color: var(--viora-color-on-invert);
}

/* Hover swaps to the other state — no new colour, and it reads on both bars. */
.viora-site-header--overlay .viora-site-header__cta:hover {
	background-color: var(--viora-color-secondary);
	color: var(--viora-color-on-invert);
}

.viora-site-header--static .viora-site-header__cta:hover {
	background-color: var(--viora-color-surface);
	color: var(--viora-color-heading);
}

/*
 * Stuck, the overlay bar turns white — a white button on it would disappear.
 * Sticky is off on this header, but the state exists and would be a silent
 * bug the moment it is switched on.
 */
.viora-site-header.is-stuck .viora-site-header__cta {
	background-color: var(--viora-color-secondary);
	color: var(--viora-color-on-invert);
}

.viora-site-header.is-stuck .viora-site-header__cta:hover {
	background-color: var(--viora-color-heading-soft);
	color: var(--viora-color-on-invert);
}

.viora-site-header__toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	margin-right: calc(var(--viora-space-2xs) * -1);
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
	appearance: none;
}

.viora-site-header__toggle svg {
	display: block;
	width: 1.5rem;
	height: 1.5rem;
}

.viora-site-header__toggle-icon--close {
	display: none;
}

.viora-site-header__logo:focus-visible,
.viora-site-header__menu a:focus-visible,
.viora-site-header__toggle:focus-visible,
.viora-site-header__cta:focus-visible {
	outline: 1px solid currentColor;
	outline-offset: 5px;
}

/* -------------------------------------------------- *
 * Compact / mobile panel
 *
 * Toggled by the script from --viora-header-breakpoint, with a plain media
 * query as the no-JS fallback.
 * -------------------------------------------------- */

.viora-site-header.is-compact .viora-site-header__toggle {
	display: inline-flex;
}

.viora-site-header.is-compact .viora-site-header__cta {
	display: none;
}

.viora-site-header.is-compact .viora-site-header__nav {
	position: fixed;
	inset: 0;
	z-index: var(--viora-z-overlay);
	display: flex;
	align-items: center;
	/*
	 * Sub-menus are expanded inline here, so a menu with a few of them outgrows
	 * a short phone. `safe` keeps centring while it fits and stops centring —
	 * rather than clipping the top out of reach — once it does not. The plain
	 * `center` above is the fallback for browsers that drop the keyword.
	 */
	align-items: safe center;
	justify-content: center;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: var(--viora-space-2xl) var(--viora-layout-container-pad);
	background-color: var(--viora-color-surface-invert);
	color: var(--viora-color-on-invert);
	opacity: 0;
	visibility: hidden;
	transition:
		opacity var(--viora-motion-base) var(--viora-motion-easing),
		visibility var(--viora-motion-base);
}

.viora-site-header.is-compact.is-open .viora-site-header__nav {
	opacity: 1;
	visibility: visible;
}

.viora-site-header.is-compact.is-open .viora-site-header__toggle-icon--open {
	display: none;
}

.viora-site-header.is-compact.is-open .viora-site-header__toggle-icon--close {
	display: block;
}

.viora-site-header.is-compact.is-open .viora-site-header__toggle {
	position: relative;
	z-index: calc(var(--viora-z-overlay) + 1);
	color: var(--viora-color-on-invert);
}

.viora-site-header.is-compact .viora-site-header__menu {
	flex-direction: column;
	gap: var(--viora-space-sm);
	text-align: center;
}

.viora-site-header.is-compact .viora-site-header__menu a {
	font-family: var(--viora-font-display);
	font-size: clamp(1.75rem, 9vw, 2.75rem);
	font-weight: 400;
	letter-spacing: -0.03em;
}

/* The panel becomes a plain nested list inside the full-screen menu, so every
   piece of its floating chrome has to come off — not just the background. */
.viora-site-header.is-compact .viora-site-header__menu .sub-menu {
	position: static;
	min-width: 0;
	padding: var(--viora-space-2xs) 0 0;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	/* The scheme class also sets a colour, and the panel behind it is dark —
	   left alone the links inherit the cream scheme's ink and vanish. */
	color: inherit;
	opacity: 1;
	visibility: visible;
	transform: none;
}

.viora-site-header.is-compact .viora-site-header__menu .sub-menu::before,
.viora-site-header.is-compact .viora-site-header__menu .sub-menu a::after {
	display: none;
}

/* Padded both sides so the label stays centred with the chevron beside it. */
.viora-site-header.is-compact .viora-site-header__menu > .menu-item-has-children > a {
	padding-inline: 0.9em;
}

/*
 * A tap leaves :hover applied on a touch screen, so the bar's underline stayed
 * drawn under whichever item was last tapped. The current-page mark below is
 * reasserted afterwards, so it still shows.
 */
.viora-site-header.is-compact .viora-site-header__menu a:hover::after {
	transform: scaleX(0);
}

.viora-site-header.is-compact .viora-site-header__menu .current-menu-item > a::after,
.viora-site-header.is-compact .viora-site-header__menu .current_page_item > a::after {
	transform: scaleX(1);
}

/*
 * Accordion.
 *
 * Only once the script is running: `is-accordion` is set from JS, so with
 * scripts off the sub-menus stay expanded and every link is still reachable.
 * Otherwise a phone would show a menu with no way to open anything.
 */
.viora-site-header.is-compact.is-accordion .viora-site-header__menu .sub-menu {
	display: none;
}

.viora-site-header.is-compact.is-accordion .viora-site-header__menu .is-open > .sub-menu {
	display: block;
	animation: viora-header-submenu var(--viora-motion-base) var(--viora-motion-easing) both;
}

.viora-site-header.is-compact.is-accordion .viora-site-header__menu .is-open > a::before {
	margin-top: -0.06em;
	transform: rotate(-135deg);
}

@keyframes viora-header-submenu {
	from {
		opacity: 0;
		transform: translateY(-0.375rem);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

.viora-site-header.is-compact .viora-site-header__menu .sub-menu a {
	padding: var(--viora-space-3xs) 0;
	color: inherit;
	font-size: 1rem;
	letter-spacing: 0;
	opacity: 0.72;
}

.viora-site-header.is-compact .viora-site-header__menu .sub-menu a:hover,
.viora-site-header.is-compact .viora-site-header__menu .sub-menu a:focus-visible {
	background: none;
	color: inherit;
	opacity: 1;
}

@media (max-width: 1024px) {
	.viora-site-header:not(.is-ready) .viora-site-header__nav {
		display: none;
	}

	.viora-site-header:not(.is-ready) .viora-site-header__toggle {
		display: inline-flex;
	}

	.viora-site-header:not(.is-ready) .viora-site-header__cta {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.viora-site-header,
	.viora-site-header__menu a,
	.viora-site-header__menu a::after,
	.viora-site-header__menu a::before,
	.viora-site-header__menu .sub-menu,
	.viora-site-header.is-compact .viora-site-header__nav {
		transition: none;
	}

	.viora-site-header__menu .sub-menu {
		transform: none;
	}
}
