/*
 * TN Search: structural styles only. Fonts and text colour come from the
 * site; themes tune the rest with these variables, e.g.
 *   :root { --tn-search-accent: #0a6b4f; --tn-search-radius: 0; }
 * Same file is used by the Ghost news theme.
 */
:root {
	--tn-search-accent: currentColor;
	--tn-search-bg: #fff;
	--tn-search-fg: inherit;
	--tn-search-muted: color-mix(in srgb, currentColor 62%, transparent);
	--tn-search-border: color-mix(in srgb, currentColor 18%, transparent);
	--tn-search-hover: color-mix(in srgb, currentColor 7%, transparent);
	--tn-search-mark: color-mix(in srgb, #ffd54a 55%, transparent);
	--tn-search-radius: 6px;
	--tn-search-shadow: 0 10px 30px rgb(0 0 0 / 0.14), 0 2px 6px rgb(0 0 0 / 0.08);
}

/* ---------- form ---------- */

.tn-search {
	position: relative;
	display: flex;
	align-items: center;
	min-width: 0;
}

.tn-search__label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.tn-search__input {
	width: 100%;
	min-width: 0;
	padding: 0.5em 2.4em 0.5em 0.85em;
	border: 1px solid var(--tn-search-border);
	border-radius: var(--tn-search-radius);
	background: var(--tn-search-bg);
	color: inherit;
	font: inherit;
	line-height: 1.4;
	-webkit-appearance: none;
	appearance: none;
}

.tn-search__input:focus-visible {
	outline: 2px solid var(--tn-search-accent);
	outline-offset: 1px;
}

.tn-search__input::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

.tn-search__submit {
	position: absolute;
	right: 0.35em;
	display: grid;
	place-items: center;
	width: 2em;
	height: 2em;
	padding: 0;
	border: 0;
	border-radius: var(--tn-search-radius);
	background: transparent;
	color: inherit;
	cursor: pointer;
	opacity: 0.7;
}

.tn-search__submit:hover,
.tn-search__submit:focus-visible {
	opacity: 1;
}

/* ---------- dropdown ---------- */

.tn-search-panel {
	position: absolute;
	z-index: 100000;
	max-height: min(70vh, 34rem);
	overflow-y: auto;
	padding: 0.35rem 0;
	border: 1px solid var(--tn-search-border);
	border-radius: var(--tn-search-radius);
	background: var(--tn-search-bg);
	color: var(--tn-search-fg, inherit);
	box-shadow: var(--tn-search-shadow);
	font-size: 0.95rem;
	line-height: 1.35;
	text-align: left;
}

.tn-search-panel[hidden] {
	display: none;
}

.tn-search-panel__group + .tn-search-panel__group {
	margin-top: 0.25rem;
	padding-top: 0.25rem;
	border-top: 1px solid var(--tn-search-border);
}

.tn-search-panel__heading {
	padding: 0.45rem 0.9rem 0.2rem;
	color: var(--tn-search-muted);
	font-size: 0.75em;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.tn-search-panel__option,
.tn-search-panel__all {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.45rem 0.9rem;
	color: inherit;
	text-decoration: none;
}

.tn-search-panel__option:hover,
.tn-search-panel__option[aria-selected="true"],
.tn-search-panel__all:hover,
.tn-search-panel__all[aria-selected="true"] {
	background: var(--tn-search-hover);
}

.tn-search-panel__title {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tn-search-panel__type {
	flex: none;
	color: var(--tn-search-muted);
	font-size: 0.8em;
}

.tn-search-panel__all {
	margin-top: 0.25rem;
	border-top: 1px solid var(--tn-search-border);
	padding-top: 0.6rem;
	font-weight: 600;
}

.tn-search-panel__status {
	padding: 0.7rem 0.9rem;
	color: var(--tn-search-muted);
}

.tn-search-panel mark,
.tn-search-results mark {
	background: var(--tn-search-mark);
	color: inherit;
	border-radius: 2px;
}

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

.tn-search-page {
	padding-top: 2rem;
	padding-bottom: 4rem;
}

.tn-search--page {
	max-width: 40rem;
	margin: 1rem 0 2rem;
	font-size: 1.1rem;
}

.tn-search-results__status {
	color: var(--tn-search-muted);
}

.tn-search-group {
	margin: 0 0 2.5rem;
}

.tn-search-group__heading {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 0.6rem;
	margin: 0 0 0.75rem;
	padding-bottom: 0.4rem;
	border-bottom: 1px solid var(--tn-search-border);
}

.tn-search-group__count {
	color: var(--tn-search-muted);
	font-size: 0.6em;
	font-weight: 400;
}

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

.tn-search-item + .tn-search-item {
	border-top: 1px solid var(--tn-search-border);
}

.tn-search-item__link {
	display: flex;
	gap: 1rem;
	padding: 0.9rem 0;
	color: inherit;
	text-decoration: none;
}

.tn-search-item__link:hover .tn-search-item__title,
.tn-search-item__link:focus-visible .tn-search-item__title {
	text-decoration: underline;
}

.tn-search-item__image {
	flex: none;
	width: 7rem;
	height: 4.7rem;
	border-radius: var(--tn-search-radius);
	object-fit: cover;
	background: var(--tn-search-hover);
}

.tn-search-item__body {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	min-width: 0;
}

.tn-search-item__meta {
	color: var(--tn-search-muted);
	font-size: 0.8em;
}

.tn-search-item__title {
	font-size: 1.1em;
	font-weight: 600;
	line-height: 1.3;
}

.tn-search-item__snippet {
	color: var(--tn-search-muted);
	font-size: 0.92em;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.tn-search-group__more {
	margin-top: 0.5rem;
	padding: 0.5em 1.1em;
	border: 1px solid var(--tn-search-border);
	border-radius: var(--tn-search-radius);
	background: transparent;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.tn-search-group__more:hover {
	background: var(--tn-search-hover);
}

.tn-search-group__more:disabled {
	opacity: 0.5;
	cursor: progress;
}

@media (max-width: 600px) {
	.tn-search-item__image {
		width: 4.5rem;
		height: 4.5rem;
	}
}
