/**
 * Desktop header search icon + popup.
 * Driven by assets/js/header-search.js
 *
 * The icon is the Divi Menu module search button (or an injected twin); the
 * popup replaces Divi's inline search field, which stays hidden.
 */

/* Social Follow column — row layout so the icon sits beside the socials. */
.et-l--header .primary-global-header .et_pb_column.iti-search-host {
	flex-direction: row;
	align-items: center;
	justify-content: flex-end;
}

/* Sits after the Social Follow module, divided by a hairline rule. */
.iti-search-slot {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
	margin-left: 12px;
	padding-left: 12px;
	border-left: 1px solid var(--iti-rule, rgba(10, 31, 61, 0.1));
}

/* Match the header social icons: 32px box, 8px radius, navy glyph. */
.iti-search-toggle {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: none;
	border-radius: 8px;
	background: transparent;
	color: var(--iti-navy, #0a1f3d);
	cursor: pointer;
	transition: color 0.2s ease, background 0.2s ease;
}

.iti-search-toggle:hover {
	background: rgba(255, 107, 74, 0.08);
	color: var(--iti-coral, #ff6b4a);
}

/* Divi renders its icon through the ETmodules font on :before */
.et-l--header .primary-global-header .et_pb_menu__search-button:before {
	font-size: 16px;
	line-height: 1;
	color: inherit;
}

.iti-search-toggle--custom svg {
	width: 17px;
	height: 17px;
}

/* Divi's inline search field — replaced by the popup */
.et-l--header .primary-global-header .et_pb_menu__search-container {
	display: none !important;
}

/* Full-viewport overlay — the page is replaced by the search surface. */
.iti-search-modal {
	position: fixed;
	inset: 0;
	z-index: 100012;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.26s ease;
}

.iti-search-modal.is-open {
	opacity: 1;
	pointer-events: auto;
}

.iti-search-backdrop {
	position: absolute;
	inset: 0;
	background: var(--iti-paper, #fff);
}

.iti-search-panel {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	padding: 24px;
}

/* Tinted wash so the white surface is not flat */
.iti-search-panel:before {
	content: "";
	position: absolute;
	inset: 0;
	background: radial-gradient(120% 80% at 50% 0%, var(--iti-mist-2, #f6f9fd) 0%, transparent 70%);
	pointer-events: none;
}

body.admin-bar .iti-search-panel {
	padding-top: 56px;
}

.iti-search-close {
	position: absolute;
	top: 28px;
	right: 34px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	padding: 0;
	border: 1px solid var(--iti-rule, rgba(10, 31, 61, 0.1));
	border-radius: 50%;
	background: transparent;
	color: var(--iti-navy, #0a1f3d);
	cursor: pointer;
	transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.iti-search-close:hover {
	border-color: var(--iti-coral, #ff6b4a);
	background: rgba(255, 107, 74, 0.08);
	color: var(--iti-coral, #ff6b4a);
	transform: rotate(90deg);
}

.iti-search-close svg {
	width: 22px;
	height: 22px;
}

body.admin-bar .iti-search-close {
	top: 60px;
}

.iti-search-body {
	position: relative;
	width: min(880px, 100%);
	margin-bottom: 6vh;
	transform: translateY(18px);
	transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.iti-search-modal.is-open .iti-search-body {
	transform: translateY(0);
}

/* Single underline, no box — the field is the page */
.iti-search-form {
	display: flex;
	align-items: center;
	gap: 20px;
	padding-bottom: 14px;
	border-bottom: 2px solid var(--iti-rule, rgba(10, 31, 61, 0.1));
	transition: border-color 0.2s ease;
}

.iti-search-form:focus-within {
	border-bottom-color: var(--iti-coral, #ff6b4a);
}

.iti-search-input {
	flex: 1;
	min-width: 0;
	height: 64px;
	padding: 0;
	border: none;
	background: none;
	font-family: inherit;
	font-size: clamp(20px, 2.4vw, 30px);
	font-weight: 600;
	letter-spacing: -0.02em;
	color: var(--iti-navy, #0a1f3d);
}

.iti-search-input::placeholder {
	font-weight: 500;
	color: var(--iti-muted, #6b7793);
}

.iti-search-input:focus {
	outline: none;
}

.iti-search-input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.iti-search-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	flex: none;
	padding: 0;
	border: none;
	background: none;
	color: var(--iti-navy, #0a1f3d);
	cursor: pointer;
	transition: color 0.2s ease;
}

.iti-search-submit:hover {
	color: var(--iti-coral, #ff6b4a);
}

.iti-search-submit svg {
	width: 26px;
	height: 26px;
}

.iti-search-form.has-error {
	border-bottom-color: var(--iti-coral, #ff6b4a);
}

.iti-search-error {
	margin: 14px 0 0;
	font-size: 14px;
	font-weight: 600;
	color: var(--iti-coral-3, #e9472b);
}

.iti-search-error:empty {
	display: none;
}

@media (max-width: 600px) {
	.iti-search-close {
		top: 16px;
		right: 16px;
		width: 44px;
		height: 44px;
	}

	.iti-search-submit {
		width: 38px;
		height: 38px;
	}

	.iti-search-submit svg {
		width: 22px;
		height: 22px;
	}
}

body.iti-search-lock {
	overflow: hidden;
}

/* Drawer owns search below the responsive breakpoint */
@media (max-width: 1024px) {
	.iti-search-slot,
	.iti-search-toggle {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.iti-search-modal,
	.iti-search-body,
	.iti-search-close,
	.iti-search-submit {
		transition: none;
	}
}
