/* ==========================================================================
   Search overlay
   ========================================================================== */

.search-overlay__empty[hidden],
.search-overlay__loading[hidden],
.search-overlay__count[hidden] {
	display: none;
}

/* Overlay root — hidden by default; shown via is-open/is-closing classes */
.search-overlay {
	display: none;
}

/* Desktop: show as flex column when open or closing */
@media (min-width: 64.0625rem) {
	.search-overlay.is-open,
	.search-overlay.is-closing {
		display: flex;
		flex-direction: column;
		position: fixed;
		top: var(--search-overlay-top, 0);
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 500;
		pointer-events: auto;
	}
}

/* Backdrop — desktop: dims area below header; mobile: full-screen dim */
.search-overlay__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(21, 46, 74, 0.25);
	pointer-events: none;
	cursor: pointer;
}

.search-overlay.is-open .search-overlay__backdrop {
	pointer-events: auto;
}

/* White panel — desktop: drops below header */
.search-overlay__panel {
	position: relative;
	z-index: 1;
	background: #fff;
	border-top: 1px solid rgba(212, 217, 219, 0.4);
	box-shadow: 0 28px 60px -24px rgba(21, 46, 74, 0.4);
	width: 100%;
	max-width: 100%;
	overflow-x: hidden;
	flex-shrink: 0;
}

.search-overlay__drawer-top {
	display: none;
}

.search-overlay__header {
	max-width: 1270px;
	margin-inline: auto;
	width: 100%;
	padding: 20px 24px 0;
}

.search-overlay__body {
	max-width: 1270px;
	margin-inline: auto;
	width: 100%;
	padding: 0 24px 20px;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

/* ---------------------------------------------------------------------------
   Search bar row
   --------------------------------------------------------------------------- */

.search-overlay__bar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding-bottom: 9px;
	border-bottom: 1px solid #4c4d4f;
}

.search-overlay__bar-icon {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	width: 20px;
	height: 20px;
}

.search-overlay__input {
	flex: 1 0 0;
	min-width: 0;
	border: none;
	outline: none;
	background: transparent;
	font-family: var(--font-base);
	font-size: 1.125rem; /* 18px */
	line-height: 1.556; /* 28px */
	color: #4c4d4f;
	-webkit-appearance: none;
	appearance: none;
}

.search-overlay__input::placeholder {
	color: #d4d9db;
}

/* Hide browser-native clear button inside search inputs */
.search-overlay__input::-webkit-search-cancel-button,
.search-overlay__input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
}

.search-overlay__close {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border: none;
	border-radius: 9999px;
	background: transparent;
	cursor: pointer;
	padding: 0;
	color: #626b74;
	transition: background 0.15s ease;
}

@media (hover: hover) {
	.search-overlay__close:hover {
		background: rgba(76, 77, 79, 0.08);
	}
}

.search-overlay__close:focus-visible {
	outline: 2px solid #4c4d4f;
	outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   Results count label
   --------------------------------------------------------------------------- */

.search-overlay__count {
	margin: 0;
	padding-block: 12px;
	font-family: var(--font-base);
	font-size: 0.6875rem; /* 11px */
	line-height: 1.5;
	letter-spacing: 0.24em;
	text-transform: uppercase;
	color: #80919a;
}

/* ---------------------------------------------------------------------------
   Loading state
   --------------------------------------------------------------------------- */

.search-overlay__loading {
	margin: 0;
	padding-block: 12px;
	font-family: var(--font-base);
	font-size: 0.875rem;
	color: #80919a;
}

/* ---------------------------------------------------------------------------
   Results list wrapper — scrollable
   --------------------------------------------------------------------------- */

.search-overlay__results-wrap {
	max-height: 480px;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.search-overlay__results {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* Divider between result rows */
.search-overlay__results li + li {
	border-top: 1px solid rgba(212, 217, 219, 0.5);
}

/* ---------------------------------------------------------------------------
   Single result row — rendered by JS as <li><a>…</a></li>
   --------------------------------------------------------------------------- */

.search-overlay__result-link {
	display: flex;
	align-items: center;
	gap: 16px;
	min-width: 0;
	max-width: 100%;
	padding-block: 16px;
	text-decoration: none;
	color: inherit;
}

.search-overlay__result-link:focus-visible {
	outline: 2px solid #4c4d4f;
	outline-offset: -2px;
}

/* Thumbnail */
.search-overlay__result-image {
	flex-shrink: 0;
	width: 88px;
	height: 88px;
	border-radius: 2px;
	background: #f4f4f4;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

.search-overlay__result-image img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}

/* Image placeholder when no image is available */
.search-overlay__result-image-placeholder {
	width: 100%;
	height: 100%;
	background: #f4f4f4;
}

/* Text content column */
.search-overlay__result-body {
	flex: 1 0 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding-left: 4px;
}

.search-overlay__result-line {
	font-family: var(--font-base);
	font-size: 0.625rem; /* 10px */
	line-height: 1.5;
	letter-spacing: 0.24em;
	text-transform: uppercase;
	color: var(--product-line-color, #4c4d4f);
	overflow-wrap: break-word;
}

.search-overlay__result-title {
	font-family: var(--font-base);
	font-size: 1rem; /* 16px */
	line-height: 1.375; /* 22px */
	color: #4c4d4f;
	overflow-wrap: break-word;
}

.search-overlay__result-benefit {
	font-family: var(--font-base);
	font-size: 0.75rem; /* 12px */
	line-height: 1.25; /* 15px */
	color: #626b74;
	overflow-wrap: break-word;
}

/* Stars row — mirrors product-card star widget */
.search-overlay__stars-row {
	display: flex;
	align-items: center;
	gap: 6px;
	padding-top: 4px;
}

.search-overlay__stars {
	position: relative;
	display: inline-flex;
	line-height: 1;
}

.search-overlay__stars-empty,
.search-overlay__stars-filled {
	display: flex;
	flex-direction: row;
	align-items: center;
	line-height: 1;
}

.search-overlay__stars svg {
	width: 11px;
	height: 10px;
	display: block;
	flex-shrink: 0;
}

.search-overlay__stars-empty {
	color: #d4d9db;
}

.search-overlay__stars-filled {
	position: absolute;
	top: 0;
	left: 0;
	overflow: hidden;
	color: #f59e0b;
}

.search-overlay__score {
	font-family: var(--font-base);
	font-size: 0.6875rem; /* 11px */
	line-height: 1.5;
	color: #4c4d4f;
}

.search-overlay__result-price {
	flex-shrink: 0;
	align-self: flex-start;
	padding-top: 4px;
	padding-left: 4px;
	font-family: var(--font-base);
	font-size: 1rem;
	line-height: 1.5;
	color: #4c4d4f;
	text-align: right;
	white-space: nowrap;
}

/* Arrow that appears on hover */
.search-overlay__result-arrow {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	color: #1a2340;
	font-size: 1rem;
	opacity: 0;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

@media (hover: hover) {
	.search-overlay__result-link:hover .search-overlay__result-arrow {
		opacity: 1;
		transform: translateX(3px);
	}
}

.search-overlay__result-link:focus-visible .search-overlay__result-arrow {
	opacity: 1;
	transform: translateX(3px);
}

/* ---------------------------------------------------------------------------
   Empty state
   --------------------------------------------------------------------------- */

.search-overlay__empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding-block: 48px;
	margin: 0;
	text-align: center;
}

.search-overlay__empty-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	border: 1px solid #d4d9db;
	border-radius: 9999px;
}

.search-overlay__empty-title {
	display: block;
	font-family: var(--font-base);
	font-size: 1.125rem; /* 18px */
	line-height: 1.556; /* 28px */
	color: #4c4d4f;
	margin-top: 8px;
}

.search-overlay__empty-hint {
	display: block;
	font-family: var(--font-base);
	font-size: 0.875rem; /* 14px */
	line-height: 1.214; /* 17px */
	color: #80919a;
	max-width: 320px;
}

.search-overlay__empty-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-top: 4px;
	padding: 0.75rem 1.5rem;
	border: 1px solid #1a2340;
	border-radius: 0.5rem;
	background: #1a2340;
	color: #fff;
	font: inherit;
	font-size: 0.875rem;
	line-height: 1;
	text-decoration: none;
}

@media (hover: hover) {
	.search-overlay__empty-button:hover {
		opacity: 0.85;
	}
}

.search-overlay__empty-button:focus-visible {
	opacity: 0.85;
}

/* ==========================================================================
   Mobile drawer — below 1024px (matches mobile menu breakpoint)
   ========================================================================== */

@keyframes searchOverlayFadeIn {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes searchOverlayFadeOut {
	from { opacity: 1; }
	to   { opacity: 0; }
}

@keyframes searchDrawerSlideIn {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}

@keyframes searchDrawerSlideOut {
	from { transform: translateY(0); }
	to   { transform: translateY(100%); }
}

@media (max-width: 64rem) {
	.search-overlay {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 500;
		pointer-events: none;
	}

	.search-overlay.is-open,
	.search-overlay.is-closing {
		pointer-events: auto;
	}

	.search-overlay__backdrop {
		background: rgb(0 0 0 / 50%);
		opacity: 0;
		pointer-events: none;
	}

	.search-overlay.is-open .search-overlay__backdrop {
		animation: searchOverlayFadeIn 0.3s ease forwards;
		pointer-events: auto;
	}

	.search-overlay.is-closing .search-overlay__backdrop {
		animation: searchOverlayFadeOut 0.3s ease forwards;
		pointer-events: none;
	}

	.search-overlay__panel {
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		display: flex;
		flex-direction: column;
		height: calc(100% - 24px);
		max-height: calc(100% - 24px);
		border-top: 1px solid #e5e7eb;
		border-radius: 10px 10px 0 0;
		box-shadow: none;
		transform: translateY(100%);
		overflow: hidden;
	}

	.search-overlay.is-open .search-overlay__panel {
		animation: searchDrawerSlideIn 0.3s ease forwards;
	}

	.search-overlay.is-closing .search-overlay__panel {
		animation: searchDrawerSlideOut 0.3s ease forwards;
	}

	.search-overlay__drawer-top {
		display: block;
		flex-shrink: 0;
		height: 24px;
		background: #fff;
	}

	.search-overlay__header {
		flex-shrink: 0;
		max-width: none;
		padding: 0;
		background: #1a2340;
	}

	.search-overlay__bar {
		gap: 12px;
		padding: 12px 16px;
		border-bottom: none;
		position: relative;
	}

	.search-overlay__bar-icon {
		position: absolute;
		left: 28px;
		top: 50%;
		transform: translateY(-50%);
		width: 20px;
		height: 20px;
		color: #80919a;
		pointer-events: none;
		z-index: 1;
	}

	.search-overlay__input {
		flex: 1 0 0;
		font-size: 0.875rem;
		line-height: normal;
		color: #4c4d4f;
		background: #fff;
		border: 1px solid #1a2340;
		border-radius: 9999px;
		padding: 12px 16px 11px 41px;
	}

	.search-overlay__input::placeholder {
		color: #80919a;
	}

	.search-overlay__close {
		width: 44px;
		height: 44px;
		color: #fff;
		flex-shrink: 0;
	}

	@media (hover: hover) {
		.search-overlay__close:hover {
			background: rgb(255 255 255 / 12%);
		}
	}

	.search-overlay__body {
		flex: 1 1 auto;
		max-width: none;
		padding: 0;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		min-height: 0;
	}

	.search-overlay__count {
		padding: 12px 16px;
		flex-shrink: 0;
	}

	.search-overlay__loading {
		padding: 12px 16px;
		flex-shrink: 0;
	}

	.search-overlay__results-wrap {
		position: relative;
		flex: 1 1 auto;
		display: flex;
		flex-direction: column;
		max-height: none;
		min-height: 0;
		overflow-y: auto;
	}

	.search-overlay__results:empty {
		display: none;
	}

	.search-overlay__result-link {
		padding-inline: 16px;
	}

	.search-overlay__result-price {
		align-self: center;
	}

	.search-overlay__result-arrow {
		display: none;
	}

	.search-overlay__empty {
		position: absolute;
		inset: 0;
		justify-content: center;
		padding-block: 0;
		padding-inline: 24px;
	}
}

