/**
 * IS Simple Search.
 *
 * Two rules carry the whole thing.
 *
 * .issb__thumb is a fixed square that the image covers. A results list must not
 * let the photograph decide the row height — letting it is exactly what turns a
 * search page into a column of full-width banners.
 *
 * .issb__input states its own colours rather than inheriting them. A search box
 * that inherits its background has no defence against a theme repainting the
 * template area it sits in, which is why the original went black after a search.
 * These use the theme's own tokens where they exist, with real fallbacks, so the
 * field still looks native.
 */

.issb {
	--issb-thumb: 72px;
	--issb-gap: 0.8rem;
	--issb-radius: 4px;
	--issb-line: color-mix( in srgb, currentColor 22%, transparent );
	--issb-muted: color-mix( in srgb, currentColor 65%, transparent );
}

/* ---- the box ---- */

.issb__form {
	margin: 0;
}

.issb__label {
	display: block;
	margin-bottom: 0.3rem;
	font-size: 0.8125em;
	font-weight: 600;
}

.issb__field {
	display: flex;
	gap: 0.4rem;
	align-items: stretch;
}

.issb__input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 0.5em 0.7em;
	font: inherit;
	/* Stated, not inherited. See the file comment. */
	color: var( --wp--preset--color--contrast, #1a1a1a );
	background-color: var( --wp--preset--color--base, #fff );
	border: 1px solid var( --issb-line, #949494 );
	border-radius: var( --issb-radius );
	-webkit-appearance: none;
	appearance: none;
}

.issb__input::placeholder {
	color: var( --issb-muted );
	opacity: 1;
}

.issb__input:focus-visible,
.issb__submit:focus-visible,
.issb__link:focus-visible,
.issb__page:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.issb__submit {
	flex: 0 0 auto;
	padding: 0.5em 0.9em;
	font: inherit;
	font-size: 0.9375em;
	color: var( --wp--preset--color--base, #fff );
	cursor: pointer;
	background-color: var( --wp--preset--color--contrast, #1a1a1a );
	border: 1px solid transparent;
	border-radius: var( --issb-radius );
}

.issb__submit:hover {
	opacity: 0.85;
}

/* ---- results ---- */

.issb--results .issb__form {
	margin-bottom: 1.4rem;
}

.issb__count,
.issb__note {
	margin: 0 0 1rem;
	font-size: 0.9375em;
	color: var( --issb-muted );
}

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

.issb__item + .issb__item {
	border-top: 1px solid var( --issb-line );
}

.issb__link {
	display: flex;
	gap: var( --issb-gap );
	align-items: flex-start;
	padding: 0.9rem 0;
	color: inherit;
	text-decoration: none;
}

.issb__link:hover .issb__title,
.issb__link:focus-visible .issb__title {
	text-decoration: underline;
}

/*
 * The row decides the picture's size, never the other way round. Fixed square,
 * image covers it, and the space is reserved before it loads so the list does
 * not reflow line by line as thumbnails arrive.
 */
.issb__thumb {
	flex: 0 0 var( --issb-thumb );
	width: var( --issb-thumb );
	height: var( --issb-thumb );
	overflow: hidden;
	background: var( --issb-line );
	border-radius: var( --issb-radius );
}

.issb__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/*
 * A result with no picture. It keeps its place in the row — collapsing it would
 * pull the text out of alignment with every row above — and it says what the
 * result is instead of looking like an image that failed to load, which is what
 * an empty dashed square reads as.
 */
.issb__thumb--stub {
	display: flex;
	align-items: center;
	justify-content: center;
	background: color-mix( in srgb, currentColor 7%, transparent );
	border: 1px solid var( --issb-line );
}

.issb__stub {
	width: 72%;
	height: 72%;
	/* The glyph inherits the theme's text colour. */
	color: currentColor;
}

/* The letters are punched out of the filled badge in the theme's background
   colour, so both stay legible whichever way round the palette runs. */
.issb__stub-letter {
	fill: var( --wp--preset--color--base, #fff );
}

.issb__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 0.2rem;
	min-width: 0;
}

.issb__title {
	font-size: 1.0625em;
	font-weight: 600;
	line-height: 1.25;
}

.issb__meta {
	font-size: 0.75em;
	color: var( --issb-muted );
}

.issb__excerpt {
	font-size: 0.875em;
	line-height: 1.45;
	color: var( --issb-muted );
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ---- pager ---- */

.issb__pager {
	display: flex;
	gap: 0.8rem;
	align-items: center;
	justify-content: center;
	margin-top: 1.6rem;
}

.issb__page {
	padding: 0.35em 0.8em;
	font-size: 0.875em;
	color: inherit;
	text-decoration: none;
	border: 1px solid var( --issb-line );
	border-radius: var( --issb-radius );
}

.issb__page:hover {
	border-color: currentColor;
}

.issb__page-of {
	font-size: 0.8125em;
	color: var( --issb-muted );
}

@media ( max-width: 480px ) {
	.issb--results {
		--issb-thumb: 56px;
	}
}

/* ---- editor preview ---- */

.issb__editor-note {
	margin-top: 0.6rem;
	padding: 0.8rem;
	font-size: 0.8125em;
	text-align: center;
	border: 1px dashed var( --issb-line );
	border-radius: var( --issb-radius );
	opacity: 0.7;
}
