/* ──────────────────────────────────────────────────────────
 *  Crochetts Product Search — Overlay styles
 * ────────────────────────────────────────────────────────── */

/* ── Overlay backdrop ──────────────────────────────────── */

.cps-overlay {
	position: fixed;
	inset: 0;
	z-index: 999900;
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity .3s ease, visibility .3s ease;
}

.cps-overlay.is-open {
	pointer-events: auto;
	opacity: 1;
	visibility: visible;
}

.cps-overlay__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .45);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
}

/* ── Panel ─────────────────────────────────────────────── */

.cps-overlay__panel {
	position: relative;
	max-width: 720px;
	width: 92%;
	margin: 0 auto;
	background: #fff;
	border-radius: 0 0 16px 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
	transform: translateY(-30px);
	transition: transform .3s ease;
	overflow: hidden;
}

.cps-overlay.is-open .cps-overlay__panel {
	transform: translateY(0);
}

/* ── Header (input row) ────────────────────────────────── */

.cps-overlay__header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 14px 16px;
	border-bottom: 1px solid #eee;
}

.cps-overlay__input-wrap {
	flex: 1;
	display: flex;
	align-items: center;
	background: #f5f3f0;
	border-radius: 10px;
	padding: 0 12px;
	gap: 8px;
	transition: box-shadow .2s;
}

.cps-overlay__input-wrap:focus-within {
	box-shadow: 0 0 0 2px #c8a6d0;
	background: #fff;
}

.cps-overlay__icon {
	flex-shrink: 0;
	color: #999;
}

.cps-overlay__input {
	flex: 1;
	border: none;
	background: transparent;
	font-size: 16px;
	padding: 12px 0;
	outline: none;
	color: #333;
	font-family: inherit;
}

.cps-overlay__input::placeholder {
	color: #aaa;
}

.cps-overlay__clear {
	display: none;
	background: none;
	border: none;
	font-size: 22px;
	color: #999;
	cursor: pointer;
	padding: 4px 6px;
	line-height: 1;
	border-radius: 50%;
	transition: background .2s;
}

.cps-overlay__clear:hover {
	background: #e8e4e0;
	color: #555;
}

.cps-overlay__input:not(:placeholder-shown) ~ .cps-overlay__clear {
	display: block;
}

.cps-overlay__close {
	flex-shrink: 0;
	background: none;
	border: none;
	cursor: pointer;
	padding: 6px;
	color: #666;
	border-radius: 8px;
	transition: background .2s, color .2s;
}

.cps-overlay__close:hover {
	background: #f0ece8;
	color: #333;
}

/* ── Results area ───────────────────────────────────────── */

.cps-overlay__results {
	max-height: 60vh;
	overflow-y: auto;
	padding: 8px 0;
	scrollbar-width: thin;
	scrollbar-color: #d0c8c0 transparent;
}

.cps-overlay__results::-webkit-scrollbar {
	width: 6px;
}

.cps-overlay__results::-webkit-scrollbar-thumb {
	background: #d0c8c0;
	border-radius: 3px;
}

/* ── Heading ───────────────────────────────────────────── */

.cps-results-heading {
	padding: 8px 20px 6px;
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .08em;
	color: #999;
}

/* ── Result card ────────────────────────────────────────── */

.cps-result {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 10px 20px;
	text-decoration: none;
	color: inherit;
	transition: background .15s;
	cursor: pointer;
}

.cps-result:hover,
.cps-result:focus {
	background: #f9f5f2;
}

.cps-result__image {
	flex-shrink: 0;
	width: 52px;
	height: 52px;
	border-radius: 8px;
	object-fit: cover;
	background: #f5f3f0;
}

.cps-result__info {
	flex: 1;
	min-width: 0;
}

.cps-result__title {
	font-size: 15px;
	font-weight: 500;
	color: #333;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cps-result__meta {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 2px;
	font-size: 13px;
	color: #888;
}

.cps-result__sku {
	font-variant-numeric: tabular-nums;
}

.cps-result__price {
	font-weight: 600;
	color: #6b4f6b;
}

/* ── No results / Loading ──────────────────────────────── */

.cps-overlay__empty,
.cps-overlay__loading {
	padding: 40px 20px;
	text-align: center;
	color: #999;
	font-size: 15px;
}

.cps-overlay__loading::after {
	content: '';
	display: inline-block;
	width: 18px;
	height: 18px;
	border: 2px solid #d0c8c0;
	border-top-color: #6b4f6b;
	border-radius: 50%;
	animation: cps-spin .6s linear infinite;
	margin-left: 8px;
	vertical-align: middle;
}

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

/* ── View all ──────────────────────────────────────────── */

.cps-view-all {
	display: block;
	padding: 14px 20px;
	text-align: center;
	font-size: 14px;
	font-weight: 600;
	color: #6b4f6b;
	text-decoration: none;
	border-top: 1px solid #eee;
	transition: background .15s;
}

.cps-view-all:hover {
	background: #f9f5f2;
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 600px) {
	.cps-overlay__panel {
		width: 100%;
		border-radius: 0;
		max-height: 100vh;
	}

	.cps-overlay__results {
		max-height: calc(100vh - 68px);
	}

	.cps-overlay__input {
		font-size: 16px; /* prevent iOS zoom */
	}
}