/* Quick Search — front-end styles */

/* ------------------------------------------------------------------ *
 *  TWEAK THE FIELD TRANSPARENCY HERE
 *
 *  Two custom properties drive the look:
 *    --qs-bg-idle   = background of the field when NOT focused
 *    --qs-bg-focus  = background of the field WHEN focused/typing
 *
 *  Current values:
 *    --qs-bg-idle:  rgba(255,255,255,0)  → fully see-through
 *                   (use the 4th value to set transparency:
 *                    0 = invisible, 0.5 = half, 1 = solid white)
 *    --qs-bg-focus: #ffffff              → solid white on focus
 *
 *  Override from Customizer → Additional CSS without editing the plugin:
 *    .quick-search { --qs-bg-idle: rgba(255,255,255,0.3); }
 * ------------------------------------------------------------------ */
.quick-search {
	--qs-bg-alpha: 0.5;
	--qs-bg-idle: rgba(255, 255, 255, 0);
	--qs-bg-focus: #ffffff;

	position: relative;
	display: block;
	width: 100%;
	max-width: 100%;
	margin: 0;
	font-family: inherit;
	box-sizing: border-box;
}

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

.quick-search__field-wrap {
	position: relative;
	display: flex;
	align-items: center;
	width: 100%;
	/* 0.5 alpha background by default (controlled by --qs-bg-alpha on .quick-search).
	   Using rgba on the wrap (not `opacity`) so the input text and placeholder stay
	   fully opaque. !important defeats theme rules that paint input wrappers white. */
	background: var(--qs-bg-idle) !important;
	border: solid 2px #527293a1 !important;
	border-radius: 25px;
	transition: background-color 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
	overflow: hidden;
}

/* When the user clicks/tabs into the field, restore a fully opaque white
   background so typed text reads against a solid surface. Border is
   re-asserted here so theme rules like input:focus { border-color: ... }
   cannot mutate it. */
.quick-search__field-wrap:focus-within {
	background: var(--qs-bg-focus) !important;
	border: solid 2px #527293a1 !important;
	box-shadow: 0 0 0 3px rgba(82, 114, 147, 0.18) !important;
}

.quick-search__input {
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	padding: 10px 48px 10px 18px;
	margin: 0;
	border: 0 !important;
	outline: none;
	/* Force transparent so the field-wrap's translucent background shows through.
	   Many themes (incl. GeneratePress variants) paint input[type="search"]
	   with a solid white via background-color — both shorthand and longhand
	   are overridden below with maximum-specificity rules. */
	background: transparent !important;
	background-color: transparent !important;
	font-size: 15px;
	line-height: 1.4;
	color: #1f2d3d;
	box-shadow: none !important;
	border-radius: 25px;
	-webkit-appearance: none;
	appearance: none;
}

/* Belt-and-suspenders override against theme rules that target the input
   by its [type=search] attribute or its ID with !important. */
input[type="search"].quick-search__input,
input#quick-search-input.quick-search__input,
.quick-search input.quick-search__input {
	background: transparent !important;
	background-color: transparent !important;
}

/* ------------------------------------------------------------------ *
 *  GHOST-BORDER KILLER
 *
 *  Symptom: a thin gray line (often #BFBFBF) appears *inside* the
 *  field the moment the user focuses/types — looks like a nested
 *  border or an inner outline. It is NOT painted by this plugin.
 *
 *  Sources we've seen in the wild:
 *    • GeneratePress: input:focus { border-color: #BFBFBF; ... }
 *    • BuddyPress forms: input:focus { box-shadow: inset 0 0 0 1px #ccc }
 *    • Browser UA: :focus-visible { outline: 2px solid Highlight }
 *    • WordPress core admin-bar leak on front-end (rare)
 *
 *  Why our earlier `border: 0 !important` wasn't enough: theme rules
 *  target the :focus pseudo-class, which has higher specificity than
 *  the base selector. We now repeat the kill across every focus
 *  state and bind to id + class + attribute for max specificity, so
 *  no theme rule (with or without !important) can paint over it.
 *
 *  Accessibility note: focus is still clearly indicated by the wrap's
 *  outer blue glow + the wrap turning solid white on focus.
 * ------------------------------------------------------------------ */
.quick-search input#quick-search-input.quick-search__input,
.quick-search input#quick-search-input.quick-search__input:focus,
.quick-search input#quick-search-input.quick-search__input:focus-visible,
.quick-search input#quick-search-input.quick-search__input:hover,
.quick-search input#quick-search-input.quick-search__input:active,
.quick-search input[type="search"].quick-search__input:focus,
.quick-search input[type="search"].quick-search__input:focus-visible,
.quick-search input[name="s"].quick-search__input:focus,
.quick-search input[name="s"].quick-search__input:focus-visible {
	border: 0 none transparent !important;
	border-width: 0 !important;
	border-color: transparent !important;
	outline: 0 none transparent !important;
	outline-width: 0 !important;
	outline-style: none !important;
	outline-offset: 0 !important;
	box-shadow: none !important;
	-webkit-box-shadow: none !important;
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	appearance: none !important;
	background: transparent !important;
	background-color: transparent !important;
}

/* Placeholder darkened from #8a9bae -> #4a5a6d so "Quick search…" stays
   legible while the wrap background is at 0.5 alpha. */
.quick-search__input::placeholder {
	color: #4a5a6d;
	opacity: 1;
}

/* Explicit padding override (high specificity to beat theme/plugin styles) */
input#quick-search-input.quick-search__input {
	padding: 9px 10px 15px 17px;
}

/* Hide native search clear-button in WebKit/IE for a clean look. */
.quick-search__input::-webkit-search-decoration,
.quick-search__input::-webkit-search-cancel-button,
.quick-search__input::-webkit-search-results-button,
.quick-search__input::-webkit-search-results-decoration {
	-webkit-appearance: none;
	display: none;
}
.quick-search__input::-ms-clear {
	display: none;
}

.quick-search__submit {
	position: absolute;
	top: 50%;
	right: 6px;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	margin: 0;
	background: transparent;
	border: 0;
	color: #527293;
	cursor: pointer;
	border-radius: 50%;
	transition: background-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.quick-search__submit:hover,
.quick-search__submit:focus {
	background-color: rgba(82, 114, 147, 0.12);
	color: #36506b;
	outline: none;
}

.quick-search__submit:active {
	transform: translateY(-50%) scale(0.94);
}

.quick-search__lens {
	display: block;
	width: 18px;
	height: 18px;
	pointer-events: none;
}

/* Slide-down results dropdown */
.quick-search__results {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	z-index: 9999;
	max-height: 0;
	overflow: hidden;
	background: #fff;
	border: 1px solid #d8e0e8;
	border-radius: 14px;
	box-shadow: 0 12px 28px rgba(20, 34, 54, 0.14);
	opacity: 0;
	transform: translateY(-6px);
	transition: opacity 0.22s ease, transform 0.22s ease, max-height 0.28s ease;
	pointer-events: none;
}

.quick-search__results[hidden] {
	display: none !important;
}

.quick-search.is-open .quick-search__results {
	max-height: 70vh;
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
	overflow-y: auto;
}

.quick-search__list {
	list-style: none;
	margin: 0;
	padding: 6px 0;
}

.quick-search__item {
	margin: 0;
	padding: 0;
	border-bottom: 1px solid #eef1f5;
}

.quick-search__item:last-child {
	border-bottom: 0;
}

.quick-search__link {
	display: block;
	padding: 10px 16px;
	text-decoration: none;
	color: #1f2d3d;
	transition: background-color 0.15s ease;
}

.quick-search__link:hover,
.quick-search__link:focus,
.quick-search__item.is-active .quick-search__link {
	background-color: #f3f7fb;
	outline: none;
}

.quick-search__title {
	display: block;
	font-weight: 700;
	font-size: 14.5px;
	line-height: 1.35;
	color: #2f6d12;
	margin: 0 0 2px;
}

.quick-search__excerpt {
	display: block;
	font-size: 13px;
	line-height: 1.45;
	color: #5b6b7d;
	margin: 0;
}

.quick-search__title mark,
.quick-search__excerpt mark {
	background: #fff3a8;
	color: inherit;
	padding: 0 1px;
	border-radius: 2px;
}

.quick-search__meta {
	display: none;
	font-size: 11.5px;
	color: #90a0b3;
	margin-top: 3px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.quick-search__status {
	padding: 14px 16px;
	font-size: 13.5px;
	color: #5b6b7d;
	text-align: center;
}

.quick-search__viewall {
	display: block;
	padding: 11px 16px;
	text-align: center;
	font-size: 13px;
	font-weight: 600;
	color: #527293;
	background: #f6f9fc;
	text-decoration: none;
	border-top: 1px solid #eef1f5;
}

.quick-search__viewall:hover,
.quick-search__viewall:focus {
	background: #eaf0f6;
	color: #36506b;
	outline: none;
}

/* Tiny spinner for the "searching" state */
.quick-search__spinner {
	display: inline-block;
	width: 14px;
	height: 14px;
	margin-right: 8px;
	vertical-align: -2px;
	border: 2px solid rgba(82, 114, 147, 0.25);
	border-top-color: #527293;
	border-radius: 50%;
	animation: quick-search-spin 0.7s linear infinite;
}

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

/* Small screens */
@media (max-width: 480px) {
	input#quick-search-input.quick-search__input {
		font-size: 16px; /* prevent iOS zoom */
		padding: 8px 8px 13px 15px;
	}
	.quick-search__submit {
		width: 32px;
		height: 32px;
		right: 4px;
	}
}
