/*
 * Custom Header — Elementor Widget
 * ─────────────────────────────────────────────────────────────────────────────
 *
 * All rules are scoped under .custom-header to prevent leakage into Elementor
 * or theme styles. No !important except where absolutely required to beat
 * Elementor container resets.
 *
 * CSS custom properties (variables)
 * ──────────────────────────────────
 * Defaults live here. To change them globally, edit this block.
 * To override per widget instance, use the Elementor Style panel controls —
 * they inject a scoped <style> block that targets only that instance.
 *
 *   --ch-font            Typography inherits from the theme by default.
 *   --ch-bg-scrolled     Background colour applied after scroll threshold.
 *   --ch-text            Link and logo text colour.
 *   --ch-accent          Hover underline colour.
 *   --ch-border          1px bottom border colour shown when scrolled.
 *   --ch-height-default  Header height before scrolling.
 *   --ch-height-scrolled Header height after scrolling.
 *   --ch-transition      Transition timing for all animated properties.
 *   --ch-side-padding    Horizontal padding on the inner container.
 *   --ch-link-gap        Gap between desktop nav links.
 *   --ch-z               z-index stacking value.
 */

.custom-header {
	--ch-font:            inherit;
	--ch-bg-scrolled:     #ffffff;
	--ch-text:            #0D0D0D;
	--ch-accent:          #000000;
	--ch-border:          #e5e5e5;
	--ch-height-default:  90px;
	--ch-height-scrolled: 60px;
	--ch-transition:      200ms ease;
	--ch-side-padding:    clamp(1.5rem, 5vw, 4rem);
	--ch-link-gap:        2rem;
	--ch-z:               9999;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Base — fixed bar
   ───────────────────────────────────────────────────────────────────────────── */

.custom-header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	width: 100%;
	z-index: var(--ch-z);
	font-family: var(--ch-font);
	background: transparent;
	border-bottom: 1px solid transparent;
	transition:
		background var(--ch-transition),
		border-color var(--ch-transition),
		height var(--ch-transition);
	/* Reset any Elementor container margins/paddings on the widget wrapper */
	box-sizing: border-box;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Inner layout — logo left, nav right
   ───────────────────────────────────────────────────────────────────────────── */

.custom-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: var(--ch-height-default);
	padding: 0 var(--ch-side-padding);
	transition: height var(--ch-transition);
	box-sizing: border-box;
}

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

.custom-header__logo {
	display: flex;
	align-items: center;
	flex-shrink: 0;
}

.custom-header__logo img {
	display: block;
	max-height: 36px;
	width: auto;
	transition: transform var(--ch-transition), opacity var(--ch-transition);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Desktop nav
   ───────────────────────────────────────────────────────────────────────────── */

.custom-header__nav {
	display: flex;
	align-items: center;
	gap: var(--ch-link-gap);
}

.custom-header__nav a {
	position: relative;
	display: inline-block;
	color: var(--ch-text);
	text-decoration: none;
	font-family: var(--ch-font);
	font-size: 0.875rem;
	letter-spacing: 0.04em;
	line-height: 1;
	padding-bottom: 2px;
	transition: color var(--ch-transition);
}

/*
 * Hover underline: a pseudo-element that scales from 0 to 1 on hover,
 * anchored at the left edge (transform-origin: left).
 * Colour uses --ch-accent so it can be overridden per instance.
 */
.custom-header__nav a::after {
	content: '';
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 1px;
	background: var(--ch-accent);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform var(--ch-transition);
}

.custom-header__nav a:hover::after,
.custom-header__nav a:focus-visible::after {
	transform: scaleX(1);
}

.custom-header__nav a:focus-visible {
	outline: 2px solid var(--ch-accent);
	outline-offset: 4px;
	border-radius: 2px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Hamburger toggle — hidden on desktop
   ───────────────────────────────────────────────────────────────────────────── */

.custom-header__toggle {
	display: none;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	width: 36px;
	height: 36px;
	padding: 0;
	background: none;
	border: none;
	cursor: pointer;
	gap: 5px;
	position: relative;
	z-index: 1;
	flex-shrink: 0;
}

.custom-header__toggle span {
	display: block;
	width: 22px;
	height: 1.5px;
	background: var(--ch-text);
	border-radius: 1px;
	transition:
		transform var(--ch-transition),
		opacity var(--ch-transition);
	transform-origin: center;
}

/*
 * Hamburger → × morphing via pure CSS.
 * When .is-open is on .custom-header:
 *   - middle span fades out
 *   - top span rotates +45°
 *   - bottom span rotates -45°
 */
.custom-header.is-open .custom-header__toggle span:nth-child(1) {
	transform: translateY(6.5px) rotate(45deg);
}

.custom-header.is-open .custom-header__toggle span:nth-child(2) {
	opacity: 0;
	transform: scaleX(0);
}

.custom-header.is-open .custom-header__toggle span:nth-child(3) {
	transform: translateY(-6.5px) rotate(-45deg);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Scrolled state — JS adds .is-scrolled when scroll exceeds threshold.
   To adjust the threshold: Elementor panel → Behavior → Scroll Trigger Threshold.
   To adjust the visual changes: edit the values below.
   ───────────────────────────────────────────────────────────────────────────── */

.custom-header.is-scrolled {
	background: var(--ch-bg-scrolled);
	border-bottom-color: var(--ch-border);
}

.custom-header.is-scrolled .custom-header__inner {
	height: var(--ch-height-scrolled);
}

.custom-header.is-scrolled .custom-header__logo img {
	transform: scale(0.88);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Mobile menu overlay
   Hidden by default; shown by .is-open on .custom-header.
   ───────────────────────────────────────────────────────────────────────────── */

.custom-header__mobile {
	position: fixed;
	inset: 0;
	background: var(--ch-bg-scrolled);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	z-index: calc(var(--ch-z) - 1);

	/* Hidden state */
	opacity: 0;
	pointer-events: none;
	transform: translateY(-10px);
	transition:
		opacity 250ms ease,
		transform 250ms ease;
}

/*
 * Open state: opacity + translateY entrance animation.
 * Duration: 250ms as specified.
 */
.custom-header.is-open .custom-header__mobile {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Mobile nav links — large type, centred, generous spacing
   ───────────────────────────────────────────────────────────────────────────── */

.custom-header__mobile-nav {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2.5rem;
}

.custom-header__mobile-nav a {
	color: var(--ch-text);
	text-decoration: none;
	font-family: var(--ch-font);
	font-size: clamp(2rem, 8vw, 4rem);
	font-weight: 400;
	letter-spacing: -0.02em;
	line-height: 1;
	transition: opacity var(--ch-transition);
}

.custom-header__mobile-nav a:hover,
.custom-header__mobile-nav a:focus-visible {
	opacity: 0.5;
}

.custom-header__mobile-nav a:focus-visible {
	outline: 2px solid var(--ch-accent);
	outline-offset: 6px;
	border-radius: 2px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Responsive — switch to hamburger below the configured breakpoint.
   The breakpoint is also read by JS from data-mobile-breakpoint.
   To change it: Elementor panel → Behavior → Mobile Breakpoint.
   The CSS media query below uses the CSS variable fallback of 768px.
   If you change the breakpoint in Elementor, update this query to match.
   ───────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
	.custom-header__nav {
		display: none;
	}

	.custom-header__toggle {
		display: flex;
	}
}

/* ─────────────────────────────────────────────────────────────────────────────
   Body scroll lock — applied by JS when mobile menu is open.
   Class added to <body>, not .custom-header, so it can be scoped separately.
   ───────────────────────────────────────────────────────────────────────────── */

body.custom-header-no-scroll {
	overflow: hidden;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Elementor editor — ensure the widget is visible in the preview iframe.
   In the editor, the header is inside an Elementor section/container so
   `position: fixed` would escape the canvas; override to `relative` for
   the editor preview only.
   ───────────────────────────────────────────────────────────────────────────── */

.elementor-editor-active .custom-header {
	position: relative;
	z-index: 1;
}

.elementor-editor-active .custom-header__mobile {
	position: relative;
	inset: auto;
}
