/* =========================================================
   Search fields – Intertronics
   ---------------------------------------------------------
   One look for every search box: a white field with the site
   border radius, a visible border, and a grey magnifier. Hover
   and focus use the brand orange. All values come from the
   theme's colour and radius variables.

   Applies to:
   1. Any markup wrapped in .itx-search-field (reusable class)
   2. WordPress core search forms (widget and block)
   3. Impreza's Search / List Search element (.w-search)
   4. Ajax Search Pro (.asp_m), including the header panel

   Change the look in one place: the --itx-search-* tokens.
   Override them on a wrapper for a variant, e.g.
   .my-hero { --itx-search-height: 3.75rem; }
   ========================================================= */

:root {
	--itx-search-height: 3.25rem;
	--itx-search-padding-x: 1.25rem;
	/* The radius used by tiles, panels and images. */
	--itx-search-radius: var(--site-border-radius, 1rem);
	--itx-search-font-size: 1rem;
	--itx-search-bg: var(--color-light, #fff);
	--itx-search-text: var(--color-content-text, #303030);
	/* Intertronics grey, 7:1 on white (placeholder text needs 4.5:1). */
	--itx-search-placeholder: var(--color-intertronics-grey, #58595b);
	/* The .itx-tile card border (style.css), so fields and cards match. */
	--itx-search-border: rgba(17, 17, 17, 0.07);
	/* Brand orange for hover and focus, as on tiles and Impreza's own fields. */
	--itx-search-border-hover: var(--color-content-primary, #f27a21);
	--itx-search-icon: var(--color-intertronics-grey, #58595b);
	--itx-search-icon-hover: var(--color-content-primary, #f27a21);
	--itx-search-focus: var(--color-content-primary, #f27a21);
}

/* ---------------------------------------------------------
   1. Reusable class
   Wrap an input (and optional submit button) in
   .itx-search-field for custom search markup:

   <form class="itx-search-field" role="search">
       <input type="search" aria-label="Search" placeholder="Search">
       <button type="submit" aria-label="Search">…icon…</button>
   </form>
   --------------------------------------------------------- */

.itx-search-field,
.search-form,
.wp-block-search__inside-wrapper {
	display: flex;
	align-items: center;
	box-sizing: border-box;
	min-height: var(--itx-search-height);
	padding: 0 0.4rem 0 var(--itx-search-padding-x);
	background: var(--itx-search-bg);
	border: 1px solid var(--itx-search-border);
	border-radius: var(--itx-search-radius);
	transition: border-color 0.2s ease;
}

.itx-search-field:hover,
.search-form:hover,
.wp-block-search__inside-wrapper:hover {
	border-color: var(--itx-search-border-hover);
}

.itx-search-field:focus-within,
.search-form:focus-within,
.wp-block-search__inside-wrapper:focus-within {
	border-color: var(--itx-search-focus);
	outline: 2px solid var(--itx-search-focus);
	outline-offset: 2px;
}

.itx-search-field input,
.search-form .search-field,
.wp-block-search__inside-wrapper .wp-block-search__input {
	flex: 1 1 auto;
	min-width: 0;
	height: auto;
	margin: 0;
	padding: 0;
	font: inherit;
	font-size: var(--itx-search-font-size);
	color: var(--itx-search-text);
	background: transparent;
	border: 0;
	box-shadow: none;
	outline: none; /* the wrapper shows the focus ring */
	-webkit-appearance: none;
	appearance: none;
}

.itx-search-field input::placeholder,
.search-form .search-field::placeholder,
.wp-block-search__input::placeholder {
	color: var(--itx-search-placeholder);
	opacity: 1;
}

.itx-search-field button,
.search-form .search-submit,
.wp-block-search__inside-wrapper .wp-block-search__button {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.5rem;
	height: 2.5rem;
	margin: 0;
	padding: 0 0.5rem;
	color: var(--itx-search-icon);
	background: transparent;
	border: 0;
	border-radius: var(--itx-search-radius);
	cursor: pointer;
	transition: color 0.2s ease;
}

.itx-search-field button:hover,
.search-form .search-submit:hover,
.wp-block-search__inside-wrapper .wp-block-search__button:hover {
	color: var(--itx-search-icon-hover);
}

/* ---------------------------------------------------------
   2. Impreza Search / List Search
   Impreza draws its fields from --inputs-* properties set on
   :root by the Field Style. Re-pointing them here keeps
   Impreza's own layout (icon position, reset button) intact.
   The header search keeps its own header styling.
   --------------------------------------------------------- */

.w-search.w-search:not(.elm_in_header) {
	--inputs-height: var(--itx-search-height);
	--inputs-padding: var(--itx-search-padding-x);
	--inputs-font-size: var(--itx-search-font-size);
	--inputs-border-width: 1px;
	--inputs-border-radius: var(--itx-search-radius);
	--inputs-background: var(--itx-search-bg);
	--inputs-border-color: var(--itx-search-border);
	--inputs-text-color: var(--itx-search-text);
	--inputs-box-shadow: none;
	--inputs-focus-background: var(--itx-search-bg);
	--inputs-focus-border-color: var(--itx-search-focus);
	--inputs-focus-text-color: var(--itx-search-text);
	--inputs-focus-box-shadow: 0 0 0 1px var(--itx-search-focus);
}

.w-search:not(.elm_in_header) input:hover {
	border-color: var(--itx-search-border-hover);
}

.w-search:not(.elm_in_header) input:focus {
	border-color: var(--itx-search-focus);
}

.w-search:not(.elm_in_header) input::placeholder {
	color: var(--itx-search-placeholder);
	opacity: 1;
}

.w-search:not(.elm_in_header) .w-search-form-btn {
	color: var(--itx-search-icon);
	background: transparent;
	transition: color 0.2s ease;
}

.w-search:not(.elm_in_header) .w-search-form-btn:hover,
.w-search:not(.elm_in_header) .w-search-form-btn:focus-visible {
	color: var(--itx-search-icon-hover);
}

/* ---------------------------------------------------------
   3. Ajax Search Pro
   Ajax Search Pro writes each instance's styles with ID
   selectors (#ajaxsearchpro1_1 .probox), so these rules need
   !important to win. The outer .asp_m only frames the box;
   .probox is the visible field.
   --------------------------------------------------------- */

.asp_w_container .asp_m.asp_main_container {
	--itx-search-input-height: 2rem;

	background: transparent !important;
	border: 0 !important;
	border-radius: var(--itx-search-radius) !important;
	box-shadow: none !important;
	/* Lets the focus ring draw outside the field. Results open in a separate element. */
	overflow: visible !important;
}

.asp_w_container .asp_m .probox {
	display: flex !important;
	align-items: center !important;
	box-sizing: border-box !important;
	height: var(--itx-search-height) !important;
	margin: 0 !important;
	padding: 0 0.4rem 0 calc(var(--itx-search-padding-x) - 0.5rem) !important;
	background: var(--itx-search-bg) !important;
	border: 1px solid var(--itx-search-border) !important;
	border-radius: var(--itx-search-radius) !important;
	box-shadow: none !important;
	transition: border-color 0.2s ease;
}

.asp_w_container .asp_m .probox:hover {
	border-color: var(--itx-search-border-hover) !important;
}

.asp_w_container .asp_m .probox:focus-within {
	border-color: var(--itx-search-focus) !important;
	outline: 2px solid var(--itx-search-focus);
	outline-offset: 2px;
}

/* Ajax Search Pro stretches this to the full box height and pins the input
   to its top. Matching the input's height lets .probox centre it. */
.asp_w_container .asp_m .probox .proinput {
	height: var(--itx-search-input-height) !important;
}

.asp_w_container .asp_m .probox .proinput input.orig,
.asp_w_container .asp_m .probox .proinput input.autocomplete {
	height: var(--itx-search-input-height) !important;
	font-size: var(--itx-search-font-size) !important;
	color: var(--itx-search-text) !important;
}

/* The autocomplete hint sits directly behind the real input. */
.asp_w_container .asp_m .probox .proinput input.autocomplete {
	margin-top: calc(-1 * var(--itx-search-input-height)) !important;
}

/* The wrapper shows the focus ring instead. */
.asp_w_container .asp_m .probox .proinput input.orig:focus {
	outline: none;
}

.asp_w_container .asp_m .probox .proinput input.orig::placeholder {
	color: var(--itx-search-placeholder) !important;
	opacity: 1 !important;
}

.asp_w_container .asp_m .probox .promagnifier {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 2.5rem !important;
	height: 2.5rem !important;
	flex: 0 0 2.5rem !important;
	background: transparent !important;
	border: 0 !important;
	border-radius: var(--itx-search-radius) !important;
	box-shadow: none !important;
}

.asp_w_container .asp_m .probox .promagnifier .innericon {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 1.25rem !important;
	height: 1.25rem !important;
	float: none !important;
}

.asp_w_container .asp_m .probox .promagnifier .innericon svg {
	width: 100%;
	height: 100%;
	fill: var(--itx-search-icon) !important;
	transition: fill 0.2s ease;
}

.asp_w_container .asp_m .probox .promagnifier:hover .innericon svg,
.asp_w_container .asp_m .probox .promagnifier:focus-visible .innericon svg {
	fill: var(--itx-search-icon-hover) !important;
}

.asp_w_container .asp_m .probox .promagnifier:focus-visible {
	outline: 2px solid var(--itx-search-focus);
	outline-offset: 0;
}

/* ---------------------------------------------------------
   4. Motion
   --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.itx-search-field,
	.search-form,
	.wp-block-search__inside-wrapper,
	.itx-search-field button,
	.w-search .w-search-form-btn,
	.asp_w_container .asp_m .probox,
	.asp_w_container .asp_m .probox .promagnifier .innericon svg {
		transition: none;
	}
}
