/*!
 * TAC Ultra Search — styles
 * TACUS_BUILD 0.2.0
 *
 * Scoped under .tacus / .tacus-overlay so it cannot leak into the theme, and
 * built on custom properties so the theme can retune it without editing this
 * file. Colours are the TAC palette.
 */

.tacus {
	--tacus-blue: #1870ff;
	--tacus-gold: #feab40;
	--tacus-ink: #131313;
	--tacus-muted: #5c5c5c;
	--tacus-line: #dfe3e8;
	--tacus-surface: #ffffff;
	--tacus-hover: #f2f6ff;
	--tacus-foot-bg: #fafbfc;
	--tacus-thumb-bg: #eeeeee;
	--tacus-lock-ink: #9e6a00;
	--tacus-radius: 8px;
	--tacus-font: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	position: relative;
	font-family: var(--tacus-font);
	color: var(--tacus-ink);
	max-width: 100%;
}

.tacus *,
.tacus *::before,
.tacus *::after {
	box-sizing: border-box;
}

/* ------------------------------------------------------------------- field */

.tacus-field {
	position: relative;
	display: flex;
	align-items: center;
}

.tacus-icon {
	position: absolute;
	left: 12px;
	width: 18px;
	height: 18px;
	color: var(--tacus-muted);
	pointer-events: none;
}

.tacus-input {
	width: 100%;
	padding: 12px 40px 12px 40px;
	font: 400 16px/1.3 var(--tacus-font);
	color: var(--tacus-ink);
	background: var(--tacus-surface);
	border: 1px solid var(--tacus-line);
	border-radius: var(--tacus-radius);
	outline: none;
	-webkit-appearance: none;
	appearance: none;
	transition: border-color .12s ease, box-shadow .12s ease;
}

.tacus-input:focus {
	border-color: var(--tacus-blue);
	box-shadow: 0 0 0 3px rgba(24, 112, 255, .16);
}

.tacus-input::-webkit-search-cancel-button {
	display: none;
}

.tacus-clear {
	position: absolute;
	right: 8px;
	width: 26px;
	height: 26px;
	padding: 0;
	font-size: 20px;
	line-height: 1;
	color: var(--tacus-muted);
	background: none;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

.tacus-clear:hover {
	background: var(--tacus-hover);
	color: var(--tacus-ink);
}

/* A single hairline that sweeps while a request is in flight. Deliberately not
   a spinner — at these latencies a spinner would flash and read as jank. */
.tacus.is-loading .tacus-field::after {
	content: "";
	position: absolute;
	left: 1px;
	right: 1px;
	bottom: 0;
	height: 2px;
	background: linear-gradient(90deg, transparent, var(--tacus-blue), transparent);
	border-radius: 2px;
	animation: tacus-sweep .9s linear infinite;
}

@keyframes tacus-sweep {
	0%   { transform: translateX(-100%); }
	100% { transform: translateX(100%); }
}

/* ------------------------------------------------------------------ panel */

.tacus-panel {
	position: absolute;
	z-index: 9999;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	max-height: 70vh;
	overflow-y: auto;
	background: var(--tacus-surface);
	border: 1px solid var(--tacus-line);
	border-radius: var(--tacus-radius);
	box-shadow: 0 12px 32px rgba(19, 19, 19, .13);
	overscroll-behavior: contain;
}

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

.tacus-item {
	margin: 0;
	padding: 0;
	border-bottom: 1px solid var(--tacus-line);
}

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

.tacus-link {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	padding: 11px 14px;
	color: inherit;
	text-decoration: none;
}

.tacus-item.is-active .tacus-link,
.tacus-link:hover {
	background: var(--tacus-hover);
}

.tacus-item.is-active {
	box-shadow: inset 3px 0 0 var(--tacus-blue);
}

.tacus-thumb {
	flex: 0 0 48px;
}

.tacus-thumb img {
	display: block;
	width: 48px;
	height: 48px;
	object-fit: cover;
	border-radius: 4px;
	background: var(--tacus-thumb-bg);
}

.tacus-body {
	flex: 1 1 auto;
	min-width: 0;
}

.tacus-title {
	display: block;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--tacus-ink);
}

.tacus-snippet {
	display: block;
	margin-top: 3px;
	font-size: 13px;
	line-height: 1.45;
	color: var(--tacus-muted);
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.tacus-meta {
	display: block;
	margin-top: 5px;
	font-size: 11.5px;
	letter-spacing: .01em;
	color: var(--tacus-muted);
}

.tacus-sep {
	margin: 0 6px;
	opacity: .55;
}

.tacus-type {
	text-transform: uppercase;
	letter-spacing: .06em;
}

.tacus-lock {
	color: var(--tacus-lock-ink);
	font-weight: 600;
}

.tacus mark {
	padding: 0 1px;
	color: inherit;
	background: rgba(254, 171, 64, .42);
	border-radius: 2px;
}

.tacus-note {
	padding: 16px 14px;
	font-size: 14px;
	color: var(--tacus-muted);
}

.tacus-foot {
	padding: 8px 14px;
	font-size: 11.5px;
	color: var(--tacus-muted);
	background: var(--tacus-foot-bg);
	border-top: 1px solid var(--tacus-line);
}

/* Visually hidden, but read by assistive tech. */
.tacus-live {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ---------------------------------------------------------------- overlay */

.tacus-overlay[hidden] {
	display: none;
}

.tacus-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: flex-start;
	justify-content: center;
}

.tacus-overlay-scrim {
	position: absolute;
	inset: 0;
	background: rgba(13, 17, 23, .55);
	backdrop-filter: blur(2px);
}

.tacus-overlay-box {
	position: relative;
	width: min(640px, calc(100vw - 32px));
	margin-top: min(14vh, 120px);
}

.tacus-overlay .tacus-panel {
	position: static;
	margin-top: 8px;
	max-height: min(60vh, 520px);
}

.tacus-overlay .tacus-input {
	padding-top: 15px;
	padding-bottom: 15px;
	font-size: 17px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
}

html.tacus-locked,
html.tacus-locked body {
	overflow: hidden;
}

/* ------------------------------------------------------------------ mobile */

@media (max-width: 600px) {
	.tacus-overlay-box {
		width: 100vw;
		margin-top: 0;
	}

	.tacus-overlay .tacus-input {
		border-radius: 0;
		/* 16px minimum or iOS Safari zooms the viewport on focus. */
		font-size: 16px;
	}

	.tacus-overlay .tacus-panel {
		border-radius: 0;
		border-left: 0;
		border-right: 0;
		max-height: calc(100vh - 60px);
	}

	.tacus-snippet {
		-webkit-line-clamp: 3;
	}
}

/* -------------------------------------------------------------------- dark
 *
 * Dark is OPT-IN, not automatic. Keying it to prefers-color-scheme alone means
 * a visitor whose OS is in dark mode gets a black search box embedded in a
 * light WordPress theme, which reads as a rendering bug rather than a feature.
 * The theme setting picks:
 *
 *   .tacus-theme-light  (default) — always light, matches a light site
 *   .tacus-theme-auto             — follows the visitor's OS preference
 *   .tacus-theme-dark             — always dark, for a dark site
 *
 * Everything that changes between the two palettes is a custom property, so
 * the dark values are declared once per selector and nothing else duplicates.
 */

.tacus.tacus-theme-dark {
	--tacus-ink: #e9edf2;
	--tacus-muted: #9aa4b0;
	--tacus-line: #263040;
	--tacus-surface: #0d1117;
	--tacus-hover: #161d29;
	--tacus-foot-bg: #11161f;
	--tacus-thumb-bg: #1b222c;
	--tacus-lock-ink: #feab40;
}

@media (prefers-color-scheme: dark) {
	.tacus.tacus-theme-auto {
		--tacus-ink: #e9edf2;
		--tacus-muted: #9aa4b0;
		--tacus-line: #263040;
		--tacus-surface: #0d1117;
		--tacus-hover: #161d29;
		--tacus-foot-bg: #11161f;
		--tacus-thumb-bg: #1b222c;
		--tacus-lock-ink: #feab40;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tacus.is-loading .tacus-field::after {
		animation: none;
		opacity: .5;
	}

	.tacus-input {
		transition: none;
	}
}

/* ------------------------------------------------------------------- chips
 *
 * Tags and categories present in the matched set, shown concurrently with the
 * results so refinement is one click rather than a new query. Counts come from
 * the whole matched set and respect gating — see TACUS_Query::facets().
 */

.tacus-facet-host[hidden] {
	display: none;
}

.tacus-facets {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 10px 14px;
	background: var(--tacus-foot-bg);
	border-bottom: 1px solid var(--tacus-line);
}

.tacus-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	max-width: 100%;
	padding: 4px 9px;
	font: 500 12px/1.2 var(--tacus-font);
	color: var(--tacus-ink);
	background: var(--tacus-surface);
	border: 1px solid var(--tacus-line);
	border-radius: 999px;
	cursor: pointer;
	transition: border-color .12s ease, background .12s ease;
}

.tacus-chip:hover {
	background: var(--tacus-hover);
	border-color: var(--tacus-blue);
}

.tacus-chip:focus-visible {
	outline: 2px solid var(--tacus-blue);
	outline-offset: 1px;
}

/* Gold is "segment / scope" in the TAC system, which is exactly what an
   applied refinement is. */
.tacus-chip.is-active {
	color: #131313;
	background: var(--tacus-gold);
	border-color: var(--tacus-gold);
}

.tacus-chip.is-active:hover {
	background: #ffbe66;
	border-color: var(--tacus-gold);
}

.tacus-chip-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 190px;
}

.tacus-chip-count {
	font-size: 11px;
	font-variant-numeric: tabular-nums;
	color: var(--tacus-muted);
}

.tacus-chip.is-active .tacus-chip-count,
.tacus-chip.is-active .tacus-chip-x {
	color: #131313;
}

.tacus-chip-x {
	font-size: 14px;
	line-height: 1;
	opacity: .75;
}

.tacus-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* Placeholder keeps the text column aligned when a post has no featured image. */
.tacus-thumb-empty {
	display: block;
	width: 48px;
	height: 48px;
	border-radius: 4px;
	background: var(--tacus-thumb-bg);
}
