/* ka-search frontend styles.
 *
 * Sticky input + dropdown with shadow, image/title/category/price rows,
 * keyboard-nav active state, ARIA-compliant. Mobile (<768px) goes full-
 * screen drawer for thumb-friendly results.
 *
 * Every selector is scoped to .ka_search* so we don't collide with other
 * plugins or theme styles. Every visual default can be overridden via the
 * Divi 5 Design tab — these are sensible baselines, not opinionated.
 *
 * (c) 2026 K&A Innovations LLC. Internal use only.
 */

/* ------- Module wrapper (the Divi block's own .ka_search.ka_blurb-like
 * class lives on the parent .et_pb_module element). The inner wrapper
 * (.ka_search__inner) owns the relative positioning so the dropdown can
 * anchor to it. */
.ka_search__inner {
	position: relative;
	display: block;
	width: 100%;
	max-width: 720px;
	margin: 0 auto;
	font-family: inherit;
}

/* ------- Input */
.ka_search__input {
	display: block;
	width: 100%;
	box-sizing: border-box;
	padding: 12px 16px;
	font: inherit;
	font-size: 16px;
	line-height: 1.4;
	color: #1c1d23;
	background: #fff;
	border: 1px solid #cfcfcf;
	border-radius: 8px;
	transition: border-color 120ms ease, box-shadow 120ms ease;
	-webkit-appearance: none;
	appearance: none;
}
.ka_search__input:focus {
	outline: none;
	border-color: #1c1d23;
	box-shadow: 0 0 0 3px rgba(28, 29, 35, 0.12);
}
.ka_search__input::placeholder {
	color: #888;
}

/* ------- Dropdown */
.ka_search__dropdown {
	position: absolute;
	left: 0;
	right: 0;
	z-index: 9999;
	margin-top: 8px;
	max-height: 65vh;
	overflow-y: auto;
	background: #fff;
	border: 1px solid #e2e2e2;
	border-radius: 8px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}
.ka_search__dropdown[hidden] {
	display: none !important;
}

/* Position: above vs below the input. */
.ka_search__inner--below .ka_search__dropdown {
	top: 100%;
}
.ka_search__inner--above .ka_search__dropdown {
	bottom: 100%;
	margin-top: 0;
	margin-bottom: 8px;
}

/* ------- Result rows */
.ka_search__resultlist {
	display: flex;
	flex-direction: column;
}

.ka_search__result {
	display: flex;
	gap: 14px;
	align-items: center;
	padding: 12px 14px;
	color: inherit;
	text-decoration: none;
	border-bottom: 1px solid #f0f0f0;
	transition: background 100ms ease;
}
.ka_search__result:last-child {
	border-bottom: 0;
}
.ka_search__result:hover,
.ka_search__result.is-active,
.ka_search__result:focus-visible {
	background: #f6f6f6;
	outline: none;
}

/* ------- Result image / placeholder */
.ka_search__image {
	flex: 0 0 48px;
	width: 48px;
	height: 48px;
	object-fit: cover;
	border-radius: 4px;
	background: #eee;
	display: block;
}
.ka_search__image--placeholder {
	background: linear-gradient(135deg, #f4f4f4 25%, #eaeaea 25%, #eaeaea 50%, #f4f4f4 50%, #f4f4f4 75%, #eaeaea 75%, #eaeaea);
	background-size: 12px 12px;
}

/* ------- Result body */
.ka_search__body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	flex: 1 1 auto;
	min-width: 0;
}
.ka_search__title {
	font-weight: 600;
	font-size: 14px;
	line-height: 1.35;
	color: #1c1d23;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
.ka_search__meta {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
	font-size: 12px;
	color: #555;
}

/* ------- Category chip */
.ka_search__chip {
	display: inline-block;
	padding: 2px 8px;
	background: #f0f0f0;
	border-radius: 999px;
	color: #444;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.02em;
}

/* ------- Brand */
.ka_search__brand {
	font-style: italic;
	color: #777;
}

/* ------- Price tag */
.ka_search__price {
	font-weight: 700;
	color: #1c1d23;
}
.ka_search__price ins {
	text-decoration: none;
}
.ka_search__price del {
	color: #888;
	margin-right: 4px;
}

/* ------- Highlighted match */
.ka_search__hit {
	background: #fff5d6;
	color: inherit;
	font-weight: 700;
	padding: 0 2px;
	border-radius: 2px;
}

/* ------- Empty state */
.ka_search__empty {
	padding: 24px 16px;
	text-align: center;
	color: #888;
	font-size: 14px;
}

/* ------- View-all footer */
.ka_search__viewall {
	display: block;
	padding: 12px 14px;
	text-align: center;
	font-weight: 700;
	font-size: 13px;
	letter-spacing: 0.02em;
	background: #fafafa;
	color: #1c1d23;
	text-decoration: none;
	border-top: 1px solid #f0f0f0;
}
.ka_search__viewall:hover {
	background: #f0f0f0;
}

/* ------- Mobile drawer behavior (<768px).
 * Full-screen overlay so the dropdown is thumb-reachable; the input
 * sticks to the top of the drawer.
 */
@media (max-width: 767px) {
	.ka_search__inner {
		max-width: 100%;
	}
	.ka_search__dropdown {
		position: fixed;
		top: 60px;
		left: 0;
		right: 0;
		bottom: 0;
		max-height: calc(100vh - 60px);
		margin: 0;
		border-radius: 0;
		border-left: 0;
		border-right: 0;
		box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
	}
	.ka_search__inner--above .ka_search__dropdown,
	.ka_search__inner--below .ka_search__dropdown {
		top: 60px;
		bottom: 0;
	}
	.ka_search__result {
		padding: 14px 16px;
	}
	.ka_search__image {
		flex: 0 0 56px;
		width: 56px;
		height: 56px;
	}
	.ka_search__title {
		font-size: 15px;
	}
}

/* Reduced-motion respect */
@media (prefers-reduced-motion: reduce) {
	.ka_search__input,
	.ka_search__result {
		transition: none;
	}
}
