/*
 * ElasticPress Archive Search
 * Sizes and colours are custom properties, so you can match your site's other
 * search bars from your theme without editing this file, e.g.
 *
 *   .ep-archive-search { --epas-icon-size: 20px; --epas-icon-color: #1a1a1a; }
 */

.ep-archive-search {
	--epas-icon-size: 18px;
	--epas-icon-color: currentColor;
	--epas-button-width: 2.5em;
	margin: 0 0 1.5em;
}

.ep-archive-search__field {
	position: relative;
	display: flex;
	align-items: center;
}

.ep-archive-search .ep-archive-search__input {
	width: 100%;
	min-width: 0;
	margin: 0;
	padding-inline-end: calc(var(--epas-button-width) * 2);
}

.ep-archive-search__actions {
	position: absolute;
	inset-block: 0;
	inset-inline-end: 0;
	display: flex;
	align-items: stretch;
}

/* Reset theme button/link styles so only the icon shows. */
.ep-archive-search .ep-archive-search__clear,
.ep-archive-search .ep-archive-search__submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--epas-button-width);
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: var(--epas-icon-color);
	font: inherit; /* Buttons don't inherit font-size, which would shrink em-sized icons. */
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
}

.ep-archive-search .ep-archive-search__clear[hidden] {
	display: none;
}

.ep-archive-search .ep-archive-search__clear:hover,
.ep-archive-search .ep-archive-search__submit:hover {
	background: transparent;
	color: var(--epas-icon-color);
	opacity: 0.7;
}

.ep-archive-search .ep-archive-search__clear:focus-visible,
.ep-archive-search .ep-archive-search__submit:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -4px;
}

.ep-archive-search__icon {
	display: inline-flex;
	pointer-events: none;
}

.ep-archive-search__icon svg {
	display: block;
	width: var(--epas-icon-size);
	height: var(--epas-icon-size);
}

/*
 * The wrapper generates no box of its own, so theme layout rules for
 * ul.products and pagination behave exactly as if it weren't there.
 */
.ep-archive-results {
	display: contents;
}

/* Results area while loading. A display: contents element can't fade itself, so fade its children. */
.ep-archive-results > *,
[data-epas-loading]:not(.ep-archive-results) {
	transition: opacity 0.15s ease;
}

.ep-archive-results[data-epas-loading] > *,
[data-epas-loading]:not(.ep-archive-results) {
	opacity: 0.5;
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	.ep-archive-results > *,
	[data-epas-loading]:not(.ep-archive-results) {
		transition: none;
	}
}
