/*
 * Header — Block: ds-header
 * Fixed bar over the hero. A flat glass plate fades in on scroll.
 * Layout uses logical properties so FA / AR / EN share one grid.
 *
 * @package Dreamy_Signal
 */

.ds-header {
	--dshd-fg: #fff;
	--dshd-muted: rgba(255, 255, 255, 0.62);
	--dshd-line: rgba(255, 255, 255, 0.14);
	--dshd-accent: #ff4a1a;
	--dshd-pad-x: clamp(0.7rem, 2.4vw, 1.25rem);
	--dshd-gap: clamp(0.45rem, 1.4vw, 1.15rem);
	--dshd-control: 2.35rem;

	inset-inline: 0;
	pointer-events: none;
	position: fixed;
	top: 0;
	z-index: 50;
}

.ds-header *,
.ds-header *::before,
.ds-header *::after {
	box-sizing: border-box;
}

.ds-header[lang="en"] {
	font-family: var(--ds-font-en);
}

.ds-header[lang="fa"],
.ds-header[lang="ar"] {
	font-family: var(--ds-font-fa), var(--ds-font-en);
}

.ds-header__shell {
	align-items: center;
	border: 1px solid transparent;
	border-radius: 1.15rem;
	display: grid;
	gap: var(--dshd-gap);
	grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
	isolation: isolate;
	margin-block-start: max(0.7rem, env(safe-area-inset-top, 0px));
	margin-inline: auto;
	max-width: min(96rem, calc(100% - 1.2rem));
	padding-block: 0.45rem;
	padding-left: max(var(--dshd-pad-x), env(safe-area-inset-left, 0px));
	padding-right: max(var(--dshd-pad-x), env(safe-area-inset-right, 0px));
	pointer-events: auto;
	position: relative;
	width: calc(100% - 1.2rem);
}

/* Flat glass plate — no live blur (it lags over the map canvas). */
.ds-header__shell::before {
	background: rgba(10, 10, 12, 0.84);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: inherit;
	content: "";
	inset: -1px;
	opacity: 0;
	pointer-events: none;
	position: absolute;
	transition: opacity 280ms ease;
	z-index: 0;
}

.ds-header.is-glass .ds-header__shell::before,
.ds-header.is-open .ds-header__shell::before {
	opacity: 1;
}

.ds-header__nav,
.ds-header__logo,
.ds-header__actions,
.ds-header__toggle {
	min-width: 0;
	position: relative;
	z-index: 1;
}

.ds-header__nav {
	align-items: center;
	display: flex;
	flex-wrap: nowrap;
	gap: 0.15rem var(--dshd-gap);
	grid-column: 1;
	justify-content: flex-start;
	justify-self: start;
	pointer-events: auto;
}

.ds-header__toggle {
	align-items: center;
	background: rgba(255, 255, 255, 0.04);
	border: 1px solid var(--dshd-line);
	border-radius: 999px;
	color: var(--dshd-fg);
	cursor: pointer;
	display: none;
	flex: 0 0 auto;
	gap: 0.45rem;
	grid-column: 1;
	justify-content: center;
	justify-self: start;
	min-height: var(--dshd-control);
	padding: 0;
	width: var(--dshd-control);
	z-index: 3;
}

.ds-header__link {
	color: var(--dshd-muted);
	flex: 0 0 auto;
	font-size: 0.84rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.2;
	max-width: 100%;
	overflow: hidden;
	padding-block: 0.35rem;
	text-decoration: none;
	text-overflow: ellipsis;
	transition: color 360ms ease;
	white-space: nowrap;
	-webkit-tap-highlight-color: transparent;
}

.ds-header[dir="rtl"] .ds-header__link {
	letter-spacing: 0;
	line-height: 1.45;
}

.ds-header[lang="en"] .ds-header__link {
	font-size: 0.78rem;
	font-weight: 500;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.ds-header[lang="ar"] .ds-header__link {
	font-size: 0.82rem;
}

.ds-header__link:hover,
.ds-header__link:focus-visible {
	color: var(--dshd-fg);
}

.ds-header__logo {
	align-items: center;
	color: var(--dshd-fg);
	display: inline-flex;
	grid-column: 2;
	justify-content: center;
	justify-self: center;
	max-width: min(14rem, 42vw);
	text-decoration: none;
	z-index: 3;
	-webkit-tap-highlight-color: transparent;
}

.ds-header__word {
	direction: ltr;
	display: block;
	font-family: var(--ds-font-mono);
	font-size: clamp(0.52rem, 1.15vw, 0.62rem);
	font-weight: 500;
	letter-spacing: 0.28em;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	text-transform: uppercase;
	unicode-bidi: isolate;
	white-space: nowrap;
}

.ds-header__mark {
	display: block;
	height: 1.55rem;
	max-width: min(9.5rem, 38vw);
	object-fit: contain;
	width: auto;
}

.ds-header__actions {
	align-items: center;
	display: flex;
	flex: 0 0 auto;
	gap: 0.45rem;
	grid-column: 3;
	justify-content: flex-end;
	justify-self: end;
	z-index: 3;
}

.ds-header__cta {
	align-items: center;
	background: var(--dshd-fg);
	border: 1px solid var(--dshd-fg);
	border-radius: 999px;
	color: #000;
	display: inline-flex;
	flex: 0 0 auto;
	font-size: 0.82rem;
	font-weight: 700;
	line-height: 1.2;
	max-width: 100%;
	min-height: var(--dshd-control);
	overflow: hidden;
	padding-inline: 1.05rem;
	text-decoration: none;
	text-overflow: ellipsis;
	transition:
		transform 360ms var(--ds-transition-ease, ease),
		background-color 360ms ease;
	white-space: nowrap;
	-webkit-tap-highlight-color: transparent;
}

.ds-header[dir="rtl"] .ds-header__cta {
	letter-spacing: 0;
	line-height: 1.45;
}

.ds-header[lang="en"] .ds-header__cta {
	letter-spacing: -0.02em;
}

.ds-header[lang="ar"] .ds-header__cta {
	font-size: 0.8rem;
	padding-inline: 0.95rem;
}

.ds-header__cta:hover {
	transform: translateY(-1px);
}

.ds-header__cta:focus-visible,
.ds-header__link:focus-visible,
.ds-header__logo:focus-visible,
.ds-header__toggle:focus-visible {
	outline: 2px solid var(--dshd-accent);
	outline-offset: 3px;
}

.ds-header__toggle-label {
	display: none;
	font-size: 0.72rem;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
}

.ds-header[dir="rtl"] .ds-header__toggle-label {
	line-height: 1.45;
}

.ds-header[lang="en"] .ds-header__toggle-label {
	font-size: 0.62rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.ds-header[lang="ar"] .ds-header__toggle-label {
	font-size: 0.7rem;
}

.ds-header__toggle-bars {
	display: flex;
	flex-direction: column;
	gap: 5px;
	width: 14px;
}

.ds-header__toggle-bars span {
	background: currentColor;
	display: block;
	height: 1px;
	transition: transform 360ms ease, opacity 360ms ease;
	width: 100%;
}

.ds-header.is-open .ds-header__toggle-bars span:first-child {
	transform: translateY(3px) rotate(45deg);
}

.ds-header.is-open .ds-header__toggle-bars span:last-child {
	transform: translateY(-3px) rotate(-45deg);
}

html.ds-has-header .ds-hero {
	padding-top: calc(var(--dsh-pad-y) + 3.4rem + env(safe-area-inset-top, 0px));
}

html.ds-has-header .ds-hero__top {
	display: none;
}

html.ds-header-open {
	overflow: hidden;
}

.ds-header.is-open {
	z-index: 80;
}

@media (hover: hover) and (pointer: fine) {
	.ds-header__cta:hover {
		background: #f4f4f5;
	}
}

@media (max-width: 1280px) {
	.ds-header {
		--dshd-gap: 0.85rem;
		--dshd-pad-x: 1rem;
	}

	.ds-header__link {
		font-size: 0.8rem;
	}

	.ds-header[lang="en"] .ds-header__link {
		font-size: 0.72rem;
		letter-spacing: 0.06em;
	}
}

@media (max-width: 1100px) {
	.ds-header {
		--dshd-control: 2.25rem;
		--dshd-gap: 0.65rem;
		--dshd-pad-x: 0.85rem;
	}

	.ds-header__shell {
		margin-block-start: max(0.55rem, env(safe-area-inset-top, 0px));
		max-width: calc(100% - 0.9rem);
		padding-block: 0.4rem;
		width: calc(100% - 0.9rem);
	}

	.ds-header__toggle {
		display: inline-flex;
	}

	.ds-header__nav {
		align-items: center;
		background: #0a0a0c;
		border: 0;
		border-radius: 0;
		display: none;
		flex-direction: column;
		flex-wrap: nowrap;
		gap: 0.15rem;
		inset: 0;
		justify-content: center;
		justify-self: stretch;
		max-height: none;
		overflow: auto;
		padding:
			max(6.5rem, calc(env(safe-area-inset-top, 0px) + 5.6rem))
			1.4rem
			max(2rem, env(safe-area-inset-bottom, 0px));
		pointer-events: auto;
		position: fixed;
		width: 100%;
		height: 100%;
		height: 100dvh;
		z-index: 1;
	}

	.ds-header.is-open .ds-header__nav {
		display: flex;
	}

	.ds-header__link {
		border-radius: 0.9rem;
		font-size: clamp(1.45rem, 7vw, 2.1rem);
		font-weight: 700;
		letter-spacing: -0.03em;
		line-height: 1.2;
		max-width: none;
		padding: 0.7rem 1rem;
		text-align: center;
		width: min(22rem, 100%);
	}

	.ds-header[lang="en"] .ds-header__link {
		font-size: clamp(1.2rem, 6vw, 1.85rem);
		font-weight: 500;
		letter-spacing: 0.12em;
	}

	.ds-header[dir="rtl"] .ds-header__link {
		font-size: clamp(1.5rem, 7.2vw, 2.15rem);
		letter-spacing: 0;
		line-height: 1.45;
	}

	.ds-header__logo {
		max-width: min(12rem, 46vw);
	}

	.ds-header__word {
		letter-spacing: 0.2em;
	}

	.ds-header__cta {
		padding-inline: 0.9rem;
	}

	html.ds-has-header .ds-hero {
		padding-top: calc(var(--dsh-pad-y) + 3.8rem + env(safe-area-inset-top, 0px));
	}
}

@media (max-width: 980px) {
	.ds-header__shell {
		max-width: calc(100% - 0.9rem);
		width: calc(100% - 0.9rem);
	}
}

@media (max-width: 720px) {
	.ds-header {
		--dshd-pad-x: 0.7rem;
	}

	.ds-header__word {
		font-size: 0.56rem;
		letter-spacing: 0.18em;
	}

	.ds-header__mark {
		height: 1.4rem;
		max-width: 8.2rem;
	}
}

@media (max-width: 480px) {
	.ds-header {
		--dshd-control: 2.2rem;
		--dshd-gap: 0.4rem;
	}

	.ds-header__toggle-label {
		display: none;
	}

	.ds-header__word {
		font-size: 0.5rem;
		letter-spacing: 0.14em;
	}

	.ds-header__mark {
		height: 1.3rem;
		max-width: 7.2rem;
	}

	.ds-header__cta {
		font-size: 0.76rem;
		padding-inline: 0.72rem;
	}

	.ds-header[lang="ar"] .ds-header__cta {
		font-size: 0.74rem;
		padding-inline: 0.68rem;
	}

	html.ds-has-header .ds-hero {
		padding-top: calc(var(--dsh-pad-y) + 4rem + env(safe-area-inset-top, 0px));
	}
}

@media (max-width: 360px) {
	.ds-header__shell {
		gap: 0.3rem;
		max-width: calc(100% - 0.6rem);
		padding-inline: 0.45rem;
		width: calc(100% - 0.6rem);
	}

	.ds-header__logo {
		max-width: min(9.5rem, 40vw);
	}

	.ds-header__word {
		letter-spacing: 0.1em;
	}

	.ds-header__cta {
		font-size: 0.72rem;
		min-width: 0;
		padding-inline: 0.58rem;
	}
}

@media (max-height: 760px) and (min-width: 981px) {
	.ds-header__shell {
		margin-block-start: max(0.45rem, env(safe-area-inset-top, 0px));
		padding-block: 0.32rem;
	}

	html.ds-has-header .ds-hero {
		padding-top: calc(var(--dsh-pad-y) + 3.1rem + env(safe-area-inset-top, 0px));
	}
}

@media (orientation: landscape) and (max-height: 540px) {
	.ds-header {
		--dshd-control: 2.05rem;
	}

	.ds-header__shell {
		margin-block-start: max(0.28rem, env(safe-area-inset-top, 0px));
		padding-block: 0.22rem;
	}

	.ds-header__nav {
		max-height: none;
		padding-top: max(5.4rem, calc(env(safe-area-inset-top, 0px) + 4.6rem));
	}

	.ds-header__link {
		padding-block: 0.5rem;
	}

	.ds-header__word {
		font-size: 0.5rem;
		letter-spacing: 0.16em;
	}

	html.ds-has-header .ds-hero {
		padding-top: calc(var(--dsh-pad-y) + 2.8rem + env(safe-area-inset-top, 0px));
	}
}

@media (pointer: coarse) {
	.ds-header__link {
		padding-block: 0.42rem;
	}

	.ds-header__cta,
	.ds-header__toggle {
		min-height: 2.4rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ds-header__shell::before,
	.ds-header__cta,
	.ds-header__link,
	.ds-header__toggle-bars span {
		transition: none;
	}

	.ds-header__cta:hover {
		transform: none;
	}
}
