/**
 * Search: typeahead suggestions, results list and empty states.
 *
 * The suggestion list is positioned against the search form, which is why
 * .cp-search needs position: relative (set in the theme). Everything here is
 * namespaced so it cannot leak into a theme's own search styling.
 */

/* Suggestions ------------------------------------------------------------- */

.cp-suggest {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	z-index: 60;
	max-height: min(60vh, 420px);
	margin: 0;
	padding: var(--cp-space-2);
	overflow-y: auto;
	list-style: none;
	border: 1px solid var(--cp-border);
	border-radius: var(--cp-radius-lg);
	background: var(--cp-bg);
	box-shadow: var(--cp-shadow-lg);
	text-align: left;
}

.cp-suggest[hidden] {
	display: none;
}

.cp-suggest__item {
	border-radius: var(--cp-radius-sm);
}

.cp-suggest__link {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--cp-space-3);
	padding: var(--cp-space-3);
	border-radius: var(--cp-radius-sm);
	color: var(--cp-text);
	text-decoration: none;
}

.cp-suggest__item.is-active,
.cp-suggest__item:hover {
	background: var(--cp-blue-light);
}

.cp-suggest__item.is-active .cp-suggest__name,
.cp-suggest__item:hover .cp-suggest__name {
	color: var(--cp-blue);
}

.cp-suggest__name {
	font-size: var(--cp-text-base);
	font-weight: var(--cp-weight-medium);
	color: var(--cp-navy);
	line-height: var(--cp-leading-snug);
}

/* The matched substring, so it is obvious why a result appeared. */
.cp-suggest__name mark {
	padding: 0;
	background: none;
	color: inherit;
	font-weight: var(--cp-weight-bold);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.cp-suggest__meta {
	flex: 0 0 auto;
	font-size: var(--cp-text-xs);
	color: var(--cp-text-muted);
	white-space: nowrap;
}

.cp-suggest__empty {
	padding: var(--cp-space-4) var(--cp-space-3);
	font-size: var(--cp-text-sm);
	color: var(--cp-text-muted);
	text-align: center;
}

/* Results page ------------------------------------------------------------ */

.cp-search--page {
	margin-bottom: var(--cp-space-6);
}

.cp-result-list {
	display: grid;
	gap: var(--cp-space-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.cp-result-item {
	padding: var(--cp-space-4) 0;
	border-bottom: 1px solid var(--cp-border);
}

.cp-result-item:last-child {
	border-bottom: 0;
}

.cp-result-item__title {
	margin: 0 0 var(--cp-space-1);
	font-size: var(--cp-text-lg);
	font-weight: var(--cp-weight-semibold);
	line-height: var(--cp-leading-snug);
}

.cp-result-item__title a {
	color: var(--cp-navy);
	text-decoration: none;
}

.cp-result-item__title a:hover {
	color: var(--cp-blue);
	text-decoration: underline;
}

.cp-result-item__text {
	margin: 0 0 var(--cp-space-2);
	font-size: var(--cp-text-sm);
	line-height: var(--cp-leading-snug);
	color: var(--cp-text-muted);
}

.cp-result-item__meta {
	margin: 0;
}

/* Tags -------------------------------------------------------------------- */

.cp-tag {
	display: inline-flex;
	align-items: center;
	min-height: 30px;
	padding: 0 var(--cp-space-3);
	border: 1px solid var(--cp-border);
	border-radius: var(--cp-radius-pill);
	background: var(--cp-bg-soft);
	font-size: var(--cp-text-xs);
	font-weight: var(--cp-weight-medium);
	color: var(--cp-text-muted);
	text-decoration: none;
	transition: border-color var(--cp-transition), color var(--cp-transition);
}

.cp-tag:hover {
	border-color: var(--cp-blue);
	color: var(--cp-blue);
}

.cp-tag-list {
	display: flex;
	flex-wrap: wrap;
	gap: var(--cp-space-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Empty states ------------------------------------------------------------ */

.cp-empty {
	margin-bottom: var(--cp-space-6);
	padding: var(--cp-space-6) var(--cp-space-5);
	border: 1px solid var(--cp-border);
	border-radius: var(--cp-radius-lg);
	background: var(--cp-bg-soft);
	text-align: center;
}

.cp-empty__title {
	margin: 0 0 var(--cp-space-2);
	font-size: var(--cp-text-xl);
	font-weight: var(--cp-weight-bold);
	color: var(--cp-navy);
}

.cp-empty__text {
	max-width: 52ch;
	margin: 0 auto var(--cp-space-4);
	color: var(--cp-text-muted);
	line-height: var(--cp-leading-normal);
}

.cp-empty p:last-child {
	margin-bottom: 0;
}

/* Category page ----------------------------------------------------------- */

.cp-page-meta {
	margin: var(--cp-space-3) 0 0;
	font-size: var(--cp-text-sm);
	color: var(--cp-text-muted);
}

.cp-card-grid--wide {
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

@media (max-width: 600px) {

	.cp-suggest {
		max-height: 50vh;
	}

	.cp-suggest__link {
		flex-direction: column;
		gap: var(--cp-space-1);
	}
}
