/**
 * DevQ Search.
 *
 * Everything is driven by the custom properties in .dq-s, so a theme can
 * retheme the widget by overriding those instead of fighting selectors.
 * Defaults here are Distillata's redesign palette (navy / water-cyan).
 */

.dq-s {
	--dqs-accent: #01aeef;
	--dqs-ink: #0a2540;
	--dqs-muted: #5b6b7c;
	--dqs-line: #dfe6ed;
	--dqs-bg: #ffffff;
	--dqs-hover: #f2f8fc;
	--dqs-radius: 4px;
	--dqs-shadow: 0 18px 40px rgba(10, 37, 64, 0.16);

	position: relative;
	display: block;
	width: 100%;
	max-width: 420px;
	margin: 0;
}

/* ---------- field ---------- */

.dq-s__field {
	position: relative;
	display: flex;
	align-items: center;
	background: var(--dqs-bg);
	border: 1px solid var(--dqs-line);
	border-radius: var(--dqs-radius);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dq-s__field:focus-within {
	border-color: var(--dqs-accent);
	box-shadow: 0 0 0 3px rgba(1, 174, 239, 0.16);
}

.dq-s__input.dq-s__input {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	padding: 11px 14px;
	border: 0;
	background: transparent;
	font-size: 15px;
	line-height: 1.3;
	color: var(--dqs-ink);
	box-shadow: none;
	border-radius: var(--dqs-radius);
}

.dq-s__input:focus {
	outline: none;
	box-shadow: none;
}

/* Kill the native clear/decoration so ours is the only one. */
.dq-s__input::-webkit-search-decoration,
.dq-s__input::-webkit-search-cancel-button,
.dq-s__input::-webkit-search-results-button {
	-webkit-appearance: none;
	appearance: none;
}

.dq-s__input::placeholder {
	color: var(--dqs-muted);
	opacity: 1;
}

.dq-s__submit,
.dq-s__clear {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	min-width: 0;
	height: 40px;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--dqs-ink);
	cursor: pointer;
	border-radius: var(--dqs-radius);
}

.dq-s__submit:hover,
.dq-s__clear:hover {
	color: var(--dqs-accent);
	background: transparent;
}

.dq-s__clear {
	order: -1;
	font-size: 20px;
	line-height: 1;
	color: var(--dqs-muted);
}

/*
 * The shared rule above sets display, which beats the UA stylesheet's
 * [hidden]{display:none} on specificity - so without this the clear button
 * stays visible on an empty field.
 */
.dq-s__clear[hidden] {
	display: none;
}

/* Spinner sits over the submit icon while a request is open. */
.dq-s.is-loading .dq-s__submit svg {
	opacity: 0;
}

.dq-s.is-loading .dq-s__submit::after {
	content: "";
	position: absolute;
	width: 16px;
	height: 16px;
	border: 2px solid var(--dqs-line);
	border-top-color: var(--dqs-accent);
	border-radius: 50%;
	animation: dqs-spin 0.7s linear infinite;
}

.dq-s__submit {
	position: relative;
}

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

@media (prefers-reduced-motion: reduce) {
	.dq-s.is-loading .dq-s__submit::after {
		animation-duration: 2s;
	}
}

/* ---------- dropdown ---------- */

.dq-s__panel {
	position: absolute;
	z-index: 9999;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	max-height: 70vh;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: var(--dqs-bg);
	border: 1px solid var(--dqs-line);
	border-radius: var(--dqs-radius);
	box-shadow: var(--dqs-shadow);
	text-align: left;
}

.dq-s__panel[hidden] {
	display: none;
}

.dq-s__note,
.dq-s__empty {
	margin: 0;
	padding: 12px 14px;
	font-size: 13px;
	line-height: 1.45;
	color: var(--dqs-muted);
	border-bottom: 1px solid var(--dqs-line);
}

.dq-s__empty {
	border-bottom: 0;
}

.dq-s__empty a {
	color: var(--dqs-accent);
	text-decoration: underline;
}

.dq-s__group + .dq-s__group {
	border-top: 1px solid var(--dqs-line);
}

.dq-s__grouplabel {
	margin: 0;
	padding: 9px 14px 5px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--dqs-muted);
}

.dq-s__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.dq-s__item {
	margin: 0;
	padding: 0;
	list-style: none;
}

.dq-s__link {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 9px 14px;
	text-decoration: none;
	color: var(--dqs-ink);
}

.dq-s__item.is-active .dq-s__link,
.dq-s__link:hover,
.dq-s__link:focus {
	background: var(--dqs-hover);
	text-decoration: none;
	color: var(--dqs-ink);
}

.dq-s__thumb {
	flex: 0 0 44px;
	width: 44px;
	height: 44px;
	border-radius: 3px;
	overflow: hidden;
	background: var(--dqs-hover);
}

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

.dq-s__body {
	flex: 1 1 auto;
	min-width: 0;
}

.dq-s__title {
	display: block;
	font-size: 14px;
	line-height: 1.35;
	font-weight: 600;
}

.dq-s__title mark {
	background: rgba(1, 174, 239, 0.18);
	color: inherit;
	padding: 0 1px;
}

.dq-s__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-top: 2px;
	font-size: 12.5px;
	color: var(--dqs-muted);
}

/* Woo's price_html ships its own markup; normalise it down to the meta size. */
.dq-s__price,
.dq-s__price .amount,
.dq-s__price del,
.dq-s__price ins {
	font-size: 12.5px;
	color: var(--dqs-muted);
	background: none;
	text-decoration: none;
}

.dq-s__price ins {
	font-weight: 700;
	color: var(--dqs-ink);
}

.dq-s__price del {
	opacity: 0.65;
	text-decoration: line-through;
	margin-right: 4px;
}

.dq-s__oos {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #c8102e;
}

.dq-s__more {
	display: block;
	padding: 11px 14px;
	border-top: 1px solid var(--dqs-line);
	font-size: 13px;
	font-weight: 700;
	text-align: center;
	text-decoration: none;
	color: var(--dqs-accent);
}

.dq-s__more:hover {
	background: var(--dqs-hover);
	text-decoration: none;
}

/* On small screens the panel goes full width of the form and taller. */
@media (max-width: 767px) {
	.dq-s {
		max-width: none;
	}

	.dq-s__panel {
		max-height: 60vh;
	}

	.dq-s__title {
		font-size: 13.5px;
	}
}

/* Screen-reader-only label, in case the theme doesn't define one. */
.dq-s .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
