/* Insightflow search results — scoped to avoid theme button/link overrides */
.insightflow-search-results {
	display: block;
	--if-result-border: #e5e7eb;
	--if-result-bg: #fff;
	--if-text-muted: #6b7280;
	--if-text-body: #374151;
	--if-title-color: #111827;
	--if-more-color: #1d4ed8;
	--if-excerpt-size: 0.875rem;
}

.insightflow-search-results__group {
	margin-bottom: 1.75rem;
}

.insightflow-search-results__group:last-child {
	margin-bottom: 0;
}

.insightflow-search-results__heading {
	margin: 0 0 1rem;
	font-size: 1.125rem;
	font-weight: 600;
	line-height: 1.3;
}

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

.insightflow-search-results__item {
	background: var(--if-result-bg);
	border: 1px solid var(--if-result-border);
	border-radius: 10px;
	overflow: hidden;
}

.insightflow-search-results__item + .insightflow-search-results__item {
	margin-top: 0.625rem;
}

/* —— Listing layout —— */
.insightflow-search-results__item--listing {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 1rem 1.25rem;
}

.insightflow-search-results__media--listing {
	flex: 0 0 140px;
	width: 140px;
	max-width: 36%;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: 8px;
	background: #f3f4f6;
	align-self: center;
}

.insightflow-search-results__item--listing .insightflow-search-results__image {
	width: 100%;
	height: 100%;
	max-height: none;
	object-fit: cover;
	border-radius: 8px;
	vertical-align: middle;
}

.insightflow-search-results__item--listing .insightflow-search-results__content {
	padding: 0;
	gap: 0.375rem;
}

.insightflow-search-results__item--listing .insightflow-search-results__title {
	font-size: 1.0625rem;
	margin: 0;
}

/* —— Card layout —— */
.insightflow-search-results__item--cards {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.insightflow-search-results__list--cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 1rem;
	align-items: stretch;
}

.insightflow-search-results__list--cards .insightflow-search-results__item {
	margin-top: 0;
}

.insightflow-search-results__media--cards {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: #f3f4f6;
	flex: none;
}

.insightflow-search-results__item--cards .insightflow-search-results__image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-height: none;
	object-fit: cover;
	border-radius: 0;
}

.insightflow-search-results__item--cards .insightflow-search-results__content {
	padding: 1rem;
	flex: 1;
	gap: 0.5rem;
}

.insightflow-search-results__item--cards .insightflow-search-results__title {
	margin: 0;
	padding: 0;
}

.insightflow-search-results__item--cards .insightflow-search-results__excerpt-wrap {
	margin: 0;
	padding: 0;
}

.insightflow-search-results__item--cards .insightflow-search-results__excerpt-wrap,
.insightflow-search-results__item--cards .insightflow-search-results__excerpt {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.insightflow-search-results__item--cards .insightflow-search-results__excerpt {
	margin: 0;
	padding: 0;
}

/* —— Shared content —— */
.insightflow-search-results__content {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1;
}

.insightflow-search-results__title {
	display: block;
	font-weight: 600;
	line-height: 1.35;
	color: var(--if-title-color);
}

/* Whole card/listing row is clickable when a destination URL exists */
.insightflow-search-results__item--linked {
	position: relative;
	cursor: pointer;
}

.insightflow-search-results__item-link {
	position: absolute;
	inset: 0;
	z-index: 1;
	text-decoration: none;
	color: inherit;
}

.insightflow-search-results__item-link .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.insightflow-search-results__item--linked .insightflow-search-results__media,
.insightflow-search-results__item--linked .insightflow-search-results__content {
	position: relative;
	z-index: 2;
	pointer-events: none;
}

.insightflow-search-results__item--linked:hover {
	border-color: #cbd5e1;
}

.insightflow-search-results__item--linked:focus-within {
	outline: 2px solid var(--if-more-color);
	outline-offset: 2px;
}

/* Clamped excerpt; "More" overlays the end of the last line (no side padding on text) */
.insightflow-search-results__excerpt-wrap {
	position: relative;
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 0;
	font-size: var(--if-excerpt-size);
	line-height: var(--insightflow-excerpt-line-height, 1.5);
}

/* Override theme rules e.g. .list-cards p { padding: 12px !important } */
.list-cards .insightflow-search-results .insightflow-search-results__excerpt-wrap,
.list-cards .insightflow-search-results .insightflow-search-results__excerpt,
.insightflow-search-results .insightflow-search-results__excerpt-wrap,
.insightflow-search-results .insightflow-search-results__excerpt {
	margin: 0 !important;
	padding: 0 !important;
	text-indent: 0 !important;
	border: none !important;
}

.insightflow-search-results__excerpt {
	width: 100%;
	max-width: 100%;
	color: var(--if-text-body);
	font-size: inherit;
	line-height: inherit;
	overflow: hidden;
	display: -webkit-box !important;
	-webkit-box-orient: vertical !important;
	-webkit-line-clamp: var(--insightflow-excerpt-lines, 3);
	line-clamp: var(--insightflow-excerpt-lines, 3);
	word-break: break-word;
}

.insightflow-search-results__excerpt-wrap.is-expanded .insightflow-search-results__excerpt {
	display: block;
	width: auto;
	max-width: none;
	-webkit-line-clamp: unset;
	overflow: visible;
}

/* Inline text-style button — resets theme .button rules */
.insightflow-search-results button.insightflow-search-results__more {
	appearance: none;
	-webkit-appearance: none;
	position: absolute;
	right: 0;
	bottom: 0;
	margin: 0;
	padding: 0 0 0 0.35em;
	border: none;
	border-radius: 0;
	background: var(--if-result-bg);
	box-shadow: -1.25em 0 0.75em var(--if-result-bg);
	font-family: inherit;
	font-size: inherit;
	font-weight: 600;
	line-height: inherit;
	color: var(--if-more-color);
	text-decoration: underline;
	text-underline-offset: 2px;
	white-space: nowrap;
	cursor: pointer;
	z-index: 3;
	pointer-events: auto;
}

.insightflow-search-results__excerpt-wrap.is-expanded button.insightflow-search-results__more {
	position: static;
	display: inline;
	margin: 0 0 0 0.25em;
	padding: 0;
	box-shadow: none;
	background: transparent;
	vertical-align: baseline;
}

.insightflow-search-results button.insightflow-search-results__more:hover,
.insightflow-search-results button.insightflow-search-results__more:focus {
	color: var(--if-more-color);
	background: transparent;
	text-decoration: underline;
	outline: none;
	box-shadow: none;
}

.insightflow-search-results button.insightflow-search-results__more:focus-visible {
	outline: 2px solid var(--if-more-color);
	outline-offset: 2px;
}

.insightflow-search-results button.insightflow-search-results__more[hidden] {
	display: none !important;
}

.insightflow-search-results--empty,
.insightflow-search-results--empty-query,
.insightflow-search-results--error {
	padding: 0.75rem 1rem;
	border-radius: 8px;
	border: 1px solid var(--if-result-border);
	background: var(--if-result-bg);
}

.insightflow-search-results--error {
	border-color: #fecaca;
	background: #fef2f2;
	color: #b91c1c;
}

.insightflow-search-form-wrap {
	width: 100%;
}

.insightflow-search-form {
	display: flex;
	gap: 0.5rem;
	margin: 0;
}

.insightflow-search-form--inline {
	flex-direction: row;
	align-items: stretch;
	flex-wrap: nowrap;
}

.insightflow-search-form--stacked {
	flex-direction: column;
	align-items: stretch;
}

.insightflow-search-form__input {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	margin: 0;
	padding: 0.5rem 0.75rem;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	font-size: 1rem;
	line-height: 1.4;
	box-sizing: border-box;
}

.insightflow-search-form--stacked .insightflow-search-form__input {
	flex: none;
	width: 100%;
}

.insightflow-search-form__submit {
	flex: 0 0 auto;
	margin: 0;
	padding: 0.5rem 1rem;
	border: 1px solid #1d4ed8;
	border-radius: 6px;
	background: #2563eb;
	color: #fff;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.4;
	cursor: pointer;
}

.insightflow-search-form--stacked .insightflow-search-form__submit {
	align-self: flex-start;
}

.insightflow-search-form__submit:hover,
.insightflow-search-form__submit:focus {
	background: #1d4ed8;
}

.insightflow-search-form__submit:disabled {
	opacity: 0.65;
	cursor: not-allowed;
}

.insightflow-search-form__loading {
	display: none;
	font-size: 0.9rem;
	color: var(--if-text-muted, #6b7280);
}

.insightflow-search-form--stacked .insightflow-search-form__loading {
	align-self: flex-start;
}

@media (max-width: 480px) {
	.insightflow-search-results__item--listing {
		flex-direction: column;
		align-items: stretch;
	}

	.insightflow-search-results__media--listing {
		flex: none;
		width: 100%;
		max-width: none;
	}
}
