/*
 * Header search
 */

/* SEARCH FORM */

.site-header-search {
	position: absolute;
	z-index: 8;

	box-sizing: border-box;
	
	left: 1.6em;
	right: 1.6em;
	width: auto;
	top: 74px;
}


/* SEARCH CONTROL */

.site-header-search__control {
	box-sizing: border-box;

	position: relative;

	width: 100%;
	height: 44px;

	background: var(--input-bg);
	border: 1px solid var(--hover-medium);
	border-radius: 50px;

	transition:
		border-color 0.3s ease,
		box-shadow 0.3s ease;
}


/* INPUT */

.site-header-search__input {
	-webkit-appearance: none;
	appearance: none;

	box-sizing: border-box;

	display: block;

	width: 100%;
	height: 100%;

	padding: 0 44px;

	border: none;
	outline: none;

	background: transparent;

	color: var(--text-primary);

	font-size: 15px;
	line-height: 44px;
}
.site-header-search__input:focus {
	box-shadow: none;
}
.site-header-search__input::placeholder {
	color: var(--text-muted);
	opacity: 1;
}


/* Remove browser search decorations */

.site-header-search__input::-webkit-search-decoration,
.site-header-search__input::-webkit-search-cancel-button,
.site-header-search__input::-webkit-search-results-button,
.site-header-search__input::-webkit-search-results-decoration {
	display: none;
}

/* SEARCH ICON */

.site-header-search__icon {
	position: absolute;
	top: 0;
	left: 0;

	display: flex;
	align-items: center;
	justify-content: center;

	width: 44px;
	height: 44px;

	color: var(--text-muted);

	pointer-events: none;
}

/* CLEAR BUTTON */

.site-header-search__clear {
	position: absolute;
	top: 0;
	right: 0;

	display: flex;
	align-items: center;
	justify-content: center;

	width: 44px;
	height: 44px;

	margin: 0;
	padding: 0;

	border: none;
	background: transparent;
	border-radius: 0 50px 50px 0;

	color: var(--text-muted);

	font-size: 22px;
	line-height: 1;

	cursor: pointer;

	transition:
		color 0.2s ease,
		background 0.2s ease;
}

.site-header-search__clear[hidden] {
	display: none;
}

.site-header-search__clear:hover,
.site-header-search__clear:focus-visible {
	color: var(--text-primary);
	background: var(--input-bg);
	outline: none;
}

/* FOCUS */

.site-header-search__control:focus-within {
	border-color: var(--primary);
	box-shadow: 0 0 0 3px var(--primary-soft);
}

/* SCOPE POPOVER */

.site-header-search__popover {
	box-sizing: border-box;

	position: absolute;

	top: calc(100% + 8px);
	left: 0;

	width: 100%;

	padding: 8px;

	background: var(--surface-3);
	
	backdrop-filter: var(--blur-glass);
	-webkit-backdrop-filter: var(--blur-glass);

	border: 1px solid var(--hover-medium);
	border-radius: 14px;

	box-shadow: var(--shadow-dropdown);
}

/* POPOVER TITLE */

.site-header-search__popover-title {
	padding: 7px 10px 6px;

	color: var(--text-muted);

	font-size: 10px;
	font-weight: 600;
	line-height: 1.3;

	text-transform: uppercase;
	letter-spacing: 0.04em;
}

/* OPTIONS */

.site-header-search__options {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

/* SCOPE OPTION */

button.site-header-search__option {
	box-sizing: border-box;

	display: flex;
	align-items: center;
	justify-content: space-between;

	width: 100%;
	min-height: 40px;

	margin: 0;
	padding: 8px 10px;

	border: none;
	border-radius: 8px;

	background: transparent;

	color: var(--surface-7);

	font: inherit;
	font-size: 14px;

	text-align: left;

	cursor: pointer;

	transition:
		background 0.2s ease,
		color 0.2s ease;
}

/* Hover */

.site-header-search__option:hover {
	background: var(--hover-medium);
}

/* Keyboard focus */

.site-header-search__option:focus-visible {
	background: var(--hover-medium);
	outline: 2px solid var(--primary);
	outline-offset: -2px;
}

/* Selected scope */

.site-header-search__option.is-active {
	color: var(--primary);
	font-weight: 600;
}

/* Selected scope hover */

.site-header-search__option.is-active:hover {
	background: var(--primary-soft);
}

/* CHECKMARK */

.site-header-search__option-check {
	display: none;

	color: var(--primary);

	font-size: 15px;
	font-weight: 700;
	line-height: 1;
}

.site-header-search__option.is-active
	.site-header-search__option-check {
	display: inline-flex;
	align-items: center;
}

/* DESKTOP */

@media screen and (min-width: 783px) {

	.site-header-search {
		float: left;
		position: inherit;
		top: auto;
		left: auto;
		right: auto;

		width: clamp(18%, 5vw + 18%, 40%);
		height: 64px;

		margin: 0 1.2em 0 0;

		display: flex;
		align-items: center;
	}

	.site-header-search__control {
		width: 100%;
	}

	/* The popover is attached to the 64px header search */
	.site-header-search__popover {
		top: calc(100% + 8px);
		left: 0;

		width: 100%;
	}
}


/* MOBILE */

@media screen and (max-width: 782px) {

	.site-header-search__control {
		height: 44px;
	}

	.site-header-search__input {
		font-size: 15px;
	}

	/* Mobile popover stays aligned with the search form */
	.site-header-search__popover {
		top: calc(100% + 6px);
		left: 0;

		width: 100%;

		border-radius: 12px;
	}

	/* Bigger touch targets on mobile */
	.site-header-search__option {
		min-height: 46px;

		padding: 10px 12px;

		font-size: 15px;
	}
}

/* REDUCED MOTION */

@media (prefers-reduced-motion: reduce) {
	.site-header-search__control,
	.site-header-search__clear,
	.site-header-search__option {
		transition: none;
	}
}