/**
 * PI - Header Search
 *
 * Global event + location search bar shown in the site header, left of the
 * primary navigation. Colors track the Pique Interests brand-red scheme used
 * on topic pages so it reads as part of the existing site design.
 */

.pi-header-search {
	--pihs-primary: #7e3c3b;
	--pihs-primary-hover: #9a5a59;
	--pihs-border: #d7c9c8;
	--pihs-surface: #ffffff;
	--pihs-muted: #6f6461;
	display: flex;
	align-items: center;
	margin-right: 1.25rem;
	min-width: 0;
}

/* While the script is relocating the bar into the header, keep it out of view. */
.pi-header-search[hidden] {
	display: none;
}

.pi-header-search__form {
	display: flex;
	align-items: center;
	gap: 0;
	width: 100%;
	max-width: 480px;
	min-width: 0;
	background: var(--pihs-surface);
	border: 1px solid var(--pihs-border);
	border-radius: 999px;
	padding: 0.25rem 0.25rem 0.25rem 0.75rem;
	box-shadow: 0 1px 2px rgba(31, 36, 48, 0.06);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/*
 * Mobile magnifier toggle. Hidden on desktop, where the full bar is always
 * shown; below the mobile-header breakpoint it becomes the collapsed control
 * that expands the search over the logo.
 */
.pi-header-search__toggle {
	display: none;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--pihs-primary);
	cursor: pointer;
	border-radius: 50%;
	transition: color 0.15s ease, background-color 0.15s ease;
}

.pi-header-search__toggle:hover,
.pi-header-search__toggle:focus-visible {
	color: var(--pihs-primary-hover);
	background: rgba(126, 60, 59, 0.08);
}

.pi-header-search__toggle-icon {
	width: 24px;
	height: 24px;
}

.pi-header-search__form:focus-within {
	border-color: var(--pihs-primary);
	box-shadow: 0 0 0 3px rgba(126, 60, 59, 0.12);
}

.pi-header-search__field {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	min-width: 0;
	flex: 1 1 auto;
}

.pi-header-search__field--events {
	flex: 1 1 45%;
	padding-right: 0.6rem;
}

.pi-header-search__field--location {
	flex: 1 1 55%;
	padding-left: 0.6rem;
	position: relative;
}

/*
 * Reset the text inputs to sit flush inside the pill. The parent theme
 * styles bare `input[type="text"]` with a border/background/shadow whose
 * selector outweighs a single class, so scope these to the form to win on
 * specificity and keep the fields borderless.
 */
.pi-header-search__form .pi-header-search__input {
	flex: 1 1 auto;
	min-width: 0;
	border: 0;
	outline: 0;
	box-shadow: none;
	border-radius: 0;
	background: transparent;
	font-size: 0.95rem;
	line-height: 1.4;
	color: #1f2430;
	padding: 0.35rem 0;
}

.pi-header-search__form .pi-header-search__input:focus {
	border: 0;
	outline: 0;
	box-shadow: none;
	background: transparent;
}

.pi-header-search__input::placeholder {
	color: var(--pihs-muted);
	opacity: 1;
}

.pi-header-search__input--location {
	padding-right: 1.75rem;
}

.pi-header-search__divider {
	flex: 0 0 auto;
	width: 1px;
	align-self: stretch;
	margin: 0.35rem 0;
	background: var(--pihs-border);
}

/* Brand crosshairs "use my location" control inside the location field. */
.pi-header-search__locate {
	position: absolute;
	right: 0.15rem;
	top: 50%;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--pihs-primary);
	cursor: pointer;
	border-radius: 50%;
	transition: color 0.15s ease, background-color 0.15s ease;
}

.pi-header-search__locate:hover,
.pi-header-search__locate:focus-visible {
	color: var(--pihs-primary-hover);
	background: rgba(126, 60, 59, 0.08);
}

.pi-header-search__locate:disabled {
	cursor: default;
	opacity: 0.6;
}

.pi-header-search__locate-icon {
	width: 18px;
	height: 18px;
}

.pi-header-search__locate.is-loading .pi-header-search__locate-icon {
	animation: pihs-spin 0.9s linear infinite;
}

.pi-header-search__locate.is-error {
	color: #b3261e;
}

@keyframes pihs-spin {
	to {
		transform: rotate(360deg);
	}
}

/* "Save as my default location" star, shown to logged-in users. */
.pi-header-search__save-default {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	margin-left: 0.15rem;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--pihs-muted);
	cursor: pointer;
	border-radius: 50%;
	transition: color 0.15s ease, background-color 0.15s ease;
}

.pi-header-search__save-default svg {
	width: 18px;
	height: 18px;
}

.pi-header-search__save-default:hover,
.pi-header-search__save-default:focus-visible {
	color: var(--pihs-primary);
	background: rgba(126, 60, 59, 0.08);
}

.pi-header-search__save-default.is-saved {
	color: #b8892e;
}

.pi-header-search__submit {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	margin-left: 0.3rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--pihs-primary);
	color: #fff;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.pi-header-search__submit:hover,
.pi-header-search__submit:focus-visible {
	background: var(--pihs-primary-hover);
}

.pi-header-search__submit svg {
	width: 20px;
	height: 20px;
}

/* Google Places autocomplete dropdown, nudged above the sticky header. */
.pac-container {
	z-index: 100000;
}

/*
 * Below the Kadence mobile-header breakpoint the hamburger takes over. Rather
 * than hide the search entirely, collapse it to a brand-red magnifier that sits
 * to the left of the menu icon. Tapping it expands the full search experience
 * (same fields as desktop) as an overlay anchored to the icon and growing left
 * over the logo — no other header elements are displaced.
 */
@media (max-width: 1024px) {
	/*
	 * The magnifier is inserted as a sibling before the menu toggle inside
	 * Kadence's mobile right-section. When that section lays its children out
	 * as blocks they stack, putting the icon above the hamburger. Force a
	 * horizontal row so the search sits to the left of the menu toggle. The
	 * host class is added by the script only when it places the bar here.
	 */
	.pi-header-search-host {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.pi-header-search {
		position: relative;
		margin-right: 0.5rem;
	}

	/* Show the magnifier toggle; keep it as the bar's only in-flow content so
	   the overlay stays anchored to a stable position beside the menu icon. */
	.pi-header-search__toggle {
		display: inline-flex;
	}

	/* Collapsed: the full form is hidden until the toggle expands it. */
	.pi-header-search__form {
		display: none;
	}

	.pi-header-search.is-expanded .pi-header-search__form {
		display: flex;
		position: absolute;
		top: 50%;
		right: 0;
		transform: translateY(-50%);
		width: min(20rem, calc(100vw - 5rem));
		max-width: none;
		z-index: 1001;
		box-shadow: 0 6px 24px rgba(31, 36, 48, 0.22);
	}

	/* Keep the toggle in place beneath the open overlay so the anchor point
	   (and the header layout) doesn't shift when the search opens. */
	.pi-header-search.is-expanded .pi-header-search__toggle {
		visibility: hidden;
	}
}
