/**
 * Product search (js/search-modal.js)
 * Phones: full-screen layer. 768px+: a panel centred just under the header.
 * px units on purpose: the site's root font-size is 62.5%, so rem would shrink everything.
 */

.ec-search {
	--ec-search-ink: #1a1a1a;
	--ec-search-muted: #5c5c5c;
	--ec-search-line: #ececec;
	--ec-search-accent: #bc05ff;
	--ec-search-tint: #faf5fe;
	--ec-search-pad: 16px;

	position: fixed;
	top: var(--ec-search-top, 0);
	left: 0;
	right: 0;
	height: var(--ec-search-h, 100vh);
	height: var(--ec-search-h, 100dvh);
	z-index: 100000;
	background: #fff;
	color: var(--ec-search-ink);
	font-family: "Urbanist", system-ui, sans-serif;
	font-size: 16px;
	line-height: 1.4;
	text-align: left;
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px);
	transition: opacity .2s ease, transform .25s ease, visibility 0s linear .25s;
}

.ec-search.is-open {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity .2s ease, transform .25s ease, visibility 0s;
}

.ec-search *,
.ec-search *::before,
.ec-search *::after {
	box-sizing: border-box;
}

.ec-search__form {
	display: flex;
	flex-direction: column;
	height: 100%;
	margin: 0;
	background: #fff;
}

/* Header: search field + close */

.ec-search__head {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 16px var(--ec-search-pad) 14px;
	padding-top: max(16px, env(safe-area-inset-top));
	border-bottom: 1px solid var(--ec-search-line);
}

.ec-search__field {
	position: relative;
	flex: 1;
	min-width: 0;
	margin: 0;
}

.ec-search__icon {
	position: absolute;
	top: 50%;
	left: 18px;
	width: 20px;
	height: 20px;
	transform: translateY(-50%);
	color: var(--ec-search-muted);
	pointer-events: none;
}

.ec-search__input {
	display: block;
	width: 100%;
	height: 52px;
	margin: 0;
	padding: 0 18px 0 48px;
	border: 1px solid #dcdcdc;
	border-radius: 100px;
	background: #fff;
	color: var(--ec-search-ink);
	font: 500 17px/1 "Urbanist", system-ui, sans-serif; /* 16px+ stops iOS zooming in on focus */
	-webkit-appearance: none;
	appearance: none;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.ec-search__input::placeholder {
	color: #8a8a8a;
	opacity: 1;
}

.ec-search__input:focus {
	outline: none;
	border-color: var(--ec-search-accent);
	box-shadow: 0 0 0 3px rgba(188, 5, 255, .15);
}

.ec-search__input::-webkit-search-cancel-button,
.ec-search__input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
}

.ec-search__close {
	flex: none;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	margin: 0 -6px 0 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--ec-search-ink);
	cursor: pointer;
	transition: background-color .15s ease;
}

.ec-search__close:hover {
	background: #f3f3f3;
}

.ec-search__close svg {
	width: 22px;
	height: 22px;
}

/* Loading bar along the bottom of the header */

.ec-search__progress {
	position: absolute;
	left: 0;
	right: 0;
	bottom: -1px;
	height: 2px;
	overflow: hidden;
	opacity: 0;
	transition: opacity .15s ease;
}

.ec-search__progress::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	width: 40%;
	background: var(--ec-search-accent);
	animation: ec-search-progress 1s ease-in-out infinite;
}

.ec-search.is-loading .ec-search__progress {
	opacity: 1;
}

@keyframes ec-search-progress {
	from { left: -40%; }
	to { left: 100%; }
}

/* Results */

.ec-search__body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.ec-search__status {
	margin: 0;
	padding: 14px var(--ec-search-pad) 6px;
	color: var(--ec-search-muted);
	font-size: 14px;
}

.ec-search__status:empty {
	display: none;
}

.ec-search__list {
	margin: 0;
	padding: 0 0 8px;
	list-style: none;
}

.ec-search__item {
	margin: 0;
	padding: 0;
}

.ec-search__item::before {
	content: none;
}

.ec-search__link {
	display: grid;
	grid-template-columns: 64px minmax(0, 1fr);
	align-items: center;
	gap: 14px;
	min-height: 84px;
	padding: 10px var(--ec-search-pad);
	color: inherit;
	text-decoration: none;
	transition: background-color .15s ease;
}

.ec-search__link:hover,
.ec-search__link:focus-visible {
	background: var(--ec-search-tint);
	outline: none;
}

.ec-search__thumb {
	display: block;
	width: 64px;
	height: 64px;
	overflow: hidden;
	border-radius: 10px;
	background: #f4f4f4;
}

.ec-search__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.ec-search__text {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

.ec-search__cat {
	color: var(--ec-search-muted);
	font-size: 12px;
	letter-spacing: .06em;
	text-transform: uppercase;
}

.ec-search__name {
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	color: var(--ec-search-ink);
	font: 500 16px/1.3 "Raleway", system-ui, sans-serif;
}

.ec-search__name mark {
	background: none;
	color: inherit;
	font-weight: 800;
}

.ec-search__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.ec-search__price {
	color: #404040;
	font-size: 15px;
}

.ec-search__price del {
	margin-right: 4px;
	color: #8a8a8a;
}

.ec-search__price ins {
	text-decoration: none;
}

.ec-search__tag {
	padding: 2px 8px;
	border-radius: 100px;
	background: #f1f1f1;
	color: var(--ec-search-muted);
	font-size: 12px;
}

/* Footer: View all results */

.ec-search__foot {
	padding: 12px var(--ec-search-pad);
	padding-bottom: max(12px, env(safe-area-inset-bottom));
	border-top: 1px solid var(--ec-search-line);
	background: #fff;
}

.ec-search__all {
	display: block;
	width: 100%;
	height: 52px;
	margin: 0;
	padding: 0 20px;
	border: 0;
	border-radius: 100px;
	background: #000;
	color: #fff;
	font: 500 16px/1 "Urbanist", system-ui, sans-serif;
	cursor: pointer;
	transition: background-color .15s ease, opacity .15s ease;
}

.ec-search__all:hover:not(:disabled) {
	background: #333;
}

.ec-search__all:focus-visible,
.ec-search__close:focus-visible {
	outline: 3px solid var(--ec-search-accent);
	outline-offset: 2px;
}

.ec-search__all:disabled {
	opacity: .3;
	cursor: default;
}

.ec-search__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* Phones: the page behind stays put while search is open */
html.ec-search-lock,
html.ec-search-lock body {
	overflow: hidden;
}

/* Desktop and tablet: panel under the header, page below it dimmed */

@media (min-width: 768px) {
	.ec-search {
		--ec-search-pad: 20px;

		top: var(--ec-search-offset, 0);
		bottom: 0;
		height: auto;
		padding: 12px 24px 24px;
		background: rgba(26, 26, 26, .28);
		transform: none;
	}

	.ec-search__form {
		width: 100%;
		max-width: 640px;
		height: auto;
		max-height: min(100%, 600px);
		margin: 0 auto;
		overflow: hidden;
		border-radius: 18px;
		box-shadow: 0 24px 60px rgba(0, 0, 0, .18), 0 2px 8px rgba(0, 0, 0, .06);
		transform: translateY(-8px);
		transition: transform .25s ease;
	}

	.ec-search.is-open .ec-search__form {
		transform: none;
	}

	.ec-search__head {
		padding: 14px 14px 14px var(--ec-search-pad);
	}

	.ec-search__close {
		margin: 0;
	}

	.ec-search__input {
		height: 48px;
		font-size: 16px;
	}

	.ec-search__link {
		grid-template-columns: 52px minmax(0, 1fr);
		min-height: 68px;
		padding-top: 8px;
		padding-bottom: 8px;
	}

	.ec-search__thumb {
		width: 52px;
		height: 52px;
		border-radius: 8px;
	}

	.ec-search__name {
		font-size: 15px;
	}

	.ec-search__all {
		height: 46px;
		font-size: 15px;
	}

	/* Just the search box until something is typed */
	.ec-search:not(.has-query) .ec-search__head {
		border-bottom: 0;
	}

	.ec-search:not(.has-query) .ec-search__body,
	.ec-search:not(.has-query) .ec-search__foot {
		display: none;
	}

	.ec-search__foot {
		padding-bottom: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ec-search,
	.ec-search.is-open,
	.ec-search__form,
	.ec-search.is-open .ec-search__form {
		transform: none;
		transition: none;
	}

	.ec-search__progress::before {
		left: 0;
		width: 100%;
		animation: none;
	}
}
