/**
 * Header live search — command palette (⌘K-style modal).
 *
 * Re-skins the theme's full-width search overlay (.tp-search-area, geometry in
 * SCSS-compiled main.css) into a centered modal: a pinned input header above a
 * single scrolling results body. main.css is not edited — these rules load after
 * it and are scoped to the .tp-cmdk marker class added in header.php.
 *
 * Why a modal: the old full-width overlay couldn't pin the input (it lived in a
 * box only as tall as itself) and overflowed the viewport. Here the header is a
 * flex sibling of the scroll body, so it pins for free (incl. mobile) and the
 * body's overflow-y bounds the scroll.
 *
 * Colors follow theme cues: --tp-theme-primary (#488ecc) at rest,
 * --tp-theme-secondary (#1A73E8) on hover/active — same as .tp-btn.
 *
 * Hand-authored (not SCSS-compiled), enqueued sitewide in functions.php.
 */

/* ── Overlay → full-screen flex centering layer (dim comes from .body-overlay) */
.tp-search-area.tp-cmdk {
	height: 100%;
	background: transparent;
	overflow: hidden;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	animation: none;
	transform: none;
}

/* ── The modal card ──────────────────────────────────────────────────────── */
.tp-cmdk .tp-cmdk-panel {
	width: min(640px, 92vw);
	margin-top: 10vh;
	max-height: 78vh;
	display: flex;
	flex-direction: column;
	background: var(--tp-common-white);
	border-radius: 14px;
	box-shadow: 0 24px 60px rgba(22, 22, 19, 0.22);
	overflow: hidden;
	transform: translateY(-10px) scale(0.98);
	opacity: 0;
	transition: transform 0.25s ease, opacity 0.25s ease;
}

.tp-search-area.tp-cmdk.opened .tp-cmdk-panel {
	transform: translateY(0) scale(1);
	opacity: 1;
}

/* ── Pinned input header ─────────────────────────────────────────────────── */
.tp-cmdk-head {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	border-bottom: 1px solid #e6e8f0;
	margin: 0;
}

.tp-cmdk-icon {
	flex: 0 0 auto;
	font-size: 17px;
	color: var(--tp-theme-primary);
}

.tp-cmdk-input {
	flex: 1 1 auto;
	min-width: 0;
	height: 44px;
	border: 0;
	outline: 0;
	background: transparent;
	font-size: 19px;
	color: var(--tp-heading-primary);
	box-shadow: none;
	padding: 0;
}

.tp-cmdk-input::placeholder {
	color: #a8aaad;
}

/* Esc pill (reuses .tp-search-close-btn for main.js close wiring; restyled). */
.tp-cmdk .tp-cmdk-esc {
	flex: 0 0 auto;
	width: auto;
	height: auto;
	border-radius: 6px;
	border: 1px solid #e6e8f0;
	background: #f6f7f9;
	color: var(--tp-text-body);
	font-size: 12px;
	font-weight: 600;
	line-height: 1;
	padding: 6px 9px;
}

.tp-cmdk .tp-cmdk-esc:hover {
	border-color: var(--tp-theme-secondary);
	color: var(--tp-theme-secondary);
}

/* ── Scrolling results body ──────────────────────────────────────────────── */
.tp-cmdk-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 10px 12px 16px;
}

.tp-search-results {
	display: none;
}

.tp-search-results.is-visible {
	display: block;
}

.tp-search-loading,
.tp-search-noresults {
	padding: 22px 8px;
	color: var(--tp-text-body);
	font-size: 15px;
	text-align: center;
}

.tp-search-group {
	margin-top: 14px;
}

.tp-search-group:first-child {
	margin-top: 4px;
}

.tp-search-group-title {
	display: flex;
	align-items: center;
	gap: 9px;
	margin: 0 8px 6px;
	padding-bottom: 6px;
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--tp-theme-secondary);
}

.tp-search-group-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tp-search-result a {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 9px 8px;
	border-radius: 8px;
	color: var(--tp-heading-primary);
	text-decoration: none;
	transition: background-color .15s ease, color .15s ease;
}

.tp-search-result a:hover,
.tp-search-result a.is-active {
	background-color: rgba(72, 142, 204, 0.1);
	color: var(--tp-theme-secondary);
}

.tp-search-result-icon {
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(72, 142, 204, 0.12);
	color: var(--tp-theme-primary);
	font-size: 15px;
}

.tp-search-result a:hover .tp-search-result-icon,
.tp-search-result a.is-active .tp-search-result-icon {
	background: var(--tp-theme-secondary);
	color: var(--tp-common-white);
}

.tp-search-result-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.tp-search-result-title {
	font-size: 15px;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tp-search-result-sub {
	font-size: 13px;
	color: var(--tp-text-body);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ── Mobile: full-screen sheet, input pinned at top ──────────────────────── */
@media (max-width: 767px) {
	/* width:100% (not 100vw) fills the already-full-width fixed layer without
	   the scrollbar overflow that 100vw causes. The flex column + flex:1 body
	   keeps the .tp-cmdk-head pinned while only the body scrolls. */
	.tp-cmdk .tp-cmdk-panel {
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100%;
		margin-top: 0;
		border-radius: 0;
	}

	.tp-cmdk-input {
		font-size: 17px;
	}
}
