/* ============================================================
   Instroi — header (Figma 86:459).
   Three rows: top bar 28px (#1f3346) → main row 80px (#334659)
   → nav row 44px (white). Mobile-first.
   ============================================================ */

/* The sticky header condenses ~90px on scroll (top bar + nav row collapse).
   Browser scroll-anchoring would compensate by shifting scrollTop back across
   the condense threshold, oscillating the condensed<->expanded state — the
   visible header "flicker". Opting the document out of scroll-anchoring makes
   the height change a clean one-off instead of a feedback loop. Paired with a
   hysteresis dead-band in the JS scroll handler (assets/js/main.js). */
body { overflow-anchor: none; }

.site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	transition: box-shadow var(--transition);
}
/* Keep the sticky header below the WP admin bar for logged-in users. */
body.admin-bar .site-header { top: 32px; }
@media screen and (max-width: 782px) {
	body.admin-bar .site-header { top: 46px; }
}

/* Scrolled state — condense to a single translucent bar (Figma-adjacent to
   the original site): hide the thin top bar (and the nav row on desktop),
   give the main row a semi-transparent, blurred dark background. */
.site-header.is-scrolled { box-shadow: 0 8px 28px rgba(31, 51, 70, 0.28); }
.site-header.is-scrolled .site-header__top { display: none; }
.site-header.is-scrolled .site-header__main {
	background: rgba(31, 51, 70, 0.82);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
}
.site-header.is-scrolled .site-header__main-inner { min-height: 60px; }
@media (min-width: 960px) {
	.site-header.is-scrolled .site-header__nav { display: none; }
}
/* A burger-opened mobile menu must stay visible even when scrolled. */
.site-header.is-scrolled .site-header__nav.is-open { display: block; }

/* --- Top thin bar (28px) ------------------------------------ */
.site-header__top {
	background: var(--c-dark-deep);
	color: var(--c-on-dark-muted);
	font-size: 13px;
	line-height: 1;
}
.site-header__top-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--gap);
	min-height: 28px;
}
.nav-top ul {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 24px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.nav-top a {
	color: var(--c-on-dark-muted);
	text-decoration: none;
	padding-block: 7px;
	display: inline-block;
}
.nav-top a:hover { color: var(--c-white); }
/* The copy of «headtop» that folds into the burger — hidden by default,
   revealed only inside the mobile nav panel (see the ≤959px block). */
.nav-top--in-menu { display: none; }
/* Language switcher UA / RU */
.site-header__lang {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
	font-weight: 700;
}
.site-header__lang-item {
	color: var(--c-on-dark-muted);
	text-decoration: none;
}
.site-header__lang-item.is-active { color: var(--c-white); }
a.site-header__lang-item:hover { color: var(--c-white); }
.site-header__lang-sep { color: var(--c-on-dark-muted); }

/* --- Main row (80px, dark) ---------------------------------- */
.site-header__main { background: var(--c-dark); transition: background var(--transition); }
.site-header__main-inner {
	display: flex;
	align-items: center;
	gap: var(--gap);
	min-height: 64px;
	padding-block: 8px;
}
@media (min-width: 960px) {
	.site-header__main-inner { min-height: 80px; gap: 32px; }
}

.site-header__brand {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
}
.site-header__brand .custom-logo-link { display: inline-flex; }
.site-header__brand img { max-height: 48px; width: auto; }
.site-title {
	font-size: 28px;
	font-weight: 700;
	font-style: italic;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--c-white);
	text-decoration: none;
}
.site-title:hover { color: var(--c-primary-light); }

/* Thin vertical divider between logo and tagline (Figma 86:459). */
.site-header__divider {
	flex: 0 0 auto;
	align-self: stretch;
	width: 1px;
	min-height: 44px;
	margin: 0;
	background: rgba(255, 255, 255, 0.18);
}
.site-header__tagline {
	max-width: 320px;
	margin: 0;
	font-size: 14px;
	line-height: 1.4;
	color: var(--c-on-dark-muted);
}
@media (max-width: 1149px) {
	.site-header__divider { display: none; }
}
/* Hide the tagline while brand + CTA + phone need the room
   (at 1024–1149 the full row is ~1020px vs a ~990px container). */
@media (max-width: 1149px) {
	.site-header__tagline { display: none; }
}

.site-header__actions {
	display: flex;
	align-items: center;
	gap: 24px;
	margin-left: auto;
}
/* Figma header CTA sits on the dark row as a deeper-slate button */
.site-header__cta {
	flex: 0 0 auto;
	background: var(--c-dark-deep);
	font-size: 15px;
	min-height: 48px;
}
.site-header__cta:hover { background: var(--c-primary); }
@media (max-width: 767px) {
	.site-header__cta { display: none; }
}

/* Phone (markup comes from instroi_phone_link) */
.site-header__phone { display: inline-flex; align-items: center; gap: 10px; color: var(--c-white); }
.site-header__phone .phone,
.site-header__phone a {
	color: var(--c-white);
	font-size: 20px;
	font-weight: 700;
	text-decoration: none;
	white-space: nowrap;
}
.site-header__phone a:hover { color: var(--c-primary-light); }
.site-header__phone-icon { color: var(--c-on-dark-muted); flex: 0 0 auto; }

/* Phones: logo + phone + burger must fit one row without overflow. */
@media (max-width: 767px) {
	.site-header__main-inner { gap: 12px; }
	.site-header__actions { gap: 12px; }
}
@media (max-width: 479px) {
	.site-header__phone .phone, .site-header__phone a { font-size: 17px; }
	.site-header__phone { gap: 6px; }
	.site-header__phone-icon { display: none; }
	.site-header__brand img { max-height: 36px; }
}

/* --- Burger (mobile only) ----------------------------------- */
.site-header__burger {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	width: 44px;
	height: 44px;
	padding: 10px;
	color: var(--c-white);
}
.site-header__burger span {
	display: block;
	height: 2px;
	width: 100%;
	background: currentColor;
	border-radius: 1px;
	transition: transform var(--transition), opacity var(--transition);
}
.site-header__burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-header__burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.site-header__burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* --- Nav row (44px, white) ----------------------------------- */
.site-header__nav { background: var(--c-white); border-bottom: 1px solid var(--c-gray-100); }
.site-header__nav-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--gap);
}

/* Search toggle + panel (Figma: icon at far right of the nav row) */
.site-header__search { position: relative; flex: 0 0 auto; }
.site-header__search-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	color: var(--c-text);
	transition: color var(--transition);
}
.site-header__search-toggle:hover,
.site-header__search-toggle[aria-expanded="true"] { color: var(--c-primary); }
/* Expands INLINE inside the white nav bar, sliding out to the LEFT of the
   icon — no floating card, just the field + button sitting in the strip. */
.site-header__search-panel {
	position: absolute;
	top: 50%;
	right: calc(100% + 6px);
	transform: translateY(-50%);
	z-index: 60;
	display: flex;
	align-items: center;
	width: min(320px, 52vw);
	max-width: 0;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	background: transparent;
	box-shadow: none;
	transition: max-width 0.3s ease, opacity 0.22s ease, visibility 0.3s;
}
.site-header__search-panel.is-open {
	max-width: min(320px, 52vw);
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}
.site-header__search-panel .search-form { display: flex; gap: 6px; width: 100%; padding: 0; }
.site-header__search-panel .search-field {
	flex: 1 1 auto;
	min-width: 0;
	height: 36px;
	padding: 0 12px;
	border: 1px solid var(--c-gray-100);
	border-radius: var(--radius-btn);
	background: var(--c-gray-50);
	font: inherit;
	font-size: 15px;
}
.site-header__search-panel .search-submit {
	flex: 0 0 auto;
	height: 36px;
	padding: 0 16px;
	background: var(--c-primary);
	color: var(--c-white);
	border: 0;
	border-radius: var(--radius-btn);
	font-weight: 700;
	white-space: nowrap;
	cursor: pointer;
}
.site-header__search-panel .search-submit:hover { background: var(--c-primary-light); }

.nav-main ul {
	margin: 0;
	padding: 0;
	list-style: none;
}
.nav-main > ul {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0 8px;
}
.nav-main a {
	display: block;
	padding: 12px 16px;
	color: var(--c-text);
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	text-decoration: none;
	transition: color var(--transition);
}
.nav-main a:hover { color: var(--c-primary); }
.nav-main .current-menu-item > a,
.nav-main .current-menu-ancestor > a { color: var(--c-primary); }

/* Dropdown (depth 2) */
.nav-main li { position: relative; }
.nav-main ul ul {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 50;
	min-width: 240px;
	padding: 8px 0;
	background: var(--c-white);
	border-radius: 0 0 var(--radius-card) var(--radius-card);
	box-shadow: 0 12px 32px rgba(31, 51, 70, 0.18);
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}
.nav-main li:hover > ul,
.nav-main li:focus-within > ul {
	opacity: 1;
	visibility: visible;
	transform: none;
}
.nav-main ul ul a {
	padding: 10px 20px;
	font-size: 14px;
	letter-spacing: 0.02em;
	text-transform: none;
}

/* --- Mobile navigation --------------------------------------- */
@media (max-width: 959px) {
	/* Comfortable tap targets on touch: top-bar links, UA/RU and the
	   phone number get taller hit areas (≈44px) without markup changes. */
	.nav-top a { padding-block: 12px; }
	.site-header__lang-item { padding: 12px 6px; }
	.site-header__phone .phone,
	.site-header__phone a { display: inline-block; padding-block: 10px; }

	.site-header__burger { display: flex; }

	/* Top bar: drop the cramped extra menu, keep just the language switch
	   (thin single line). The links move into the burger below. */
	.site-header__top .nav-top { display: none; }
	.site-header__top-inner { justify-content: flex-end; }

	.site-header__nav {
		display: none;
		border-bottom: 0;
	}
	.site-header__nav.is-open { display: block; }

	/* «headtop» folded into the burger — a secondary list under the main menu. */
	.site-header__nav .nav-top--in-menu { display: block; border-top: 1px solid var(--c-gray-100); }
	.nav-top--in-menu ul {
		display: flex;
		flex-direction: column;
		gap: 0;
		margin: 0;
		padding: 8px 0;
		list-style: none;
	}
	.nav-top--in-menu a {
		display: block;
		padding: 14px var(--gap);
		color: var(--c-text);
		font-size: 15px;
		font-weight: 700;
		text-decoration: none;
	}
	.nav-top--in-menu a:hover { color: var(--c-primary); }

	.site-header__nav-inner { flex-direction: column; align-items: stretch; gap: 0; }
	.site-header__search { align-self: stretch; padding: 4px var(--gap) 12px; }
	/* On mobile the panel is a plain in-flow dropdown, not the left slide-out. */
	.site-header__search-panel {
		position: static;
		right: auto;
		transform: none;
		width: 100%;
		max-width: none;
		overflow: visible;
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
		box-shadow: none;
		background: transparent;
		padding: 8px 0 0;
		transition: none;
		display: none;
	}
	.site-header__search-panel.is-open { display: block; }

	.nav-main > ul {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
		padding-block: 8px;
	}
	.nav-main a { padding: 14px var(--gap); }

	.nav-main ul ul {
		position: static;
		min-width: 0;
		padding: 0 0 0 16px;
		box-shadow: none;
		opacity: 1;
		visibility: visible;
		transform: none;
	}
}
