/* VELYON Theme — Search popup + live search (v1.7.0)
 * Markup: inc/search-popup.php   Behaviour: assets/js/search-popup.js
 * z-index 400: above the mobile drawer (300/301). Tokens only, so dark/light
 * and the Brand Color follow automatically.
 */

.velyon-search-modal {
	--vsm-top: min(12vh, 110px);
	position: fixed;
	inset: 0;
	z-index: 400;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding: var(--vsm-top) 16px 16px;
	opacity: 0;
	transition: opacity .2s ease;
}
/* `display:flex` above would otherwise beat the [hidden] attribute. */
.velyon-search-modal[hidden] {
	display: none;
}
.velyon-search-modal.is-open {
	opacity: 1;
}

/* Dark, blurred backdrop. */
.vsm-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(4, 7, 6, .8);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
	.vsm-backdrop {
		background: rgba(4, 7, 6, .58);
		-webkit-backdrop-filter: blur(10px) saturate(120%);
		backdrop-filter: blur(10px) saturate(120%);
	}
}

.vsm-dialog {
	position: relative;
	width: 100%;
	max-width: 640px;
	max-height: calc(100vh - var(--vsm-top) - 16px);
	max-height: calc(100dvh - var(--vsm-top) - 16px);
	display: flex;
	flex-direction: column;
	background: var(--velyon-surface);
	border: 1px solid var(--velyon-border);
	border-radius: var(--velyon-radius-l);
	box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
	overflow: hidden;
	transform: translateY(-10px) scale(.985);
	transition: transform .2s ease;
}
.velyon-search-modal.is-open .vsm-dialog {
	transform: none;
}

/* ---------- Input row ---------- */
.vsm-form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px;
	border-bottom: 1px solid var(--velyon-border);
	margin: 0;
}
.vsm-icon {
	display: flex;
	flex-shrink: 0;
	color: var(--velyon-text-muted);
}
.vsm-icon svg {
	width: 20px;
	height: 20px;
}
.vsm-input {
	flex: 1;
	min-width: 0;
	border: 0;
	outline: 0;
	background: transparent;
	color: var(--velyon-text);
	font-family: var(--velyon-font-body);
	/* 16px on purpose: iOS Safari zooms the whole page in when a smaller
	   field gets focus. */
	font-size: 16px;
	padding: 8px 0;
	-webkit-appearance: none;
	appearance: none;
}
.vsm-input::placeholder {
	color: var(--velyon-text-muted);
}
.vsm-input::-webkit-search-cancel-button,
.vsm-input::-webkit-search-decoration {
	-webkit-appearance: none;
	display: none;
}
.vsm-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: 1px solid transparent;
	background: transparent;
	color: var(--velyon-text-muted);
	padding: 0;
}
.vsm-btn[hidden] {
	display: none;
}
.vsm-btn svg {
	width: 18px;
	height: 18px;
}
.vsm-btn:hover,
.vsm-btn:focus-visible {
	background: var(--velyon-surface-alt);
	color: var(--velyon-text);
	border-color: var(--velyon-border);
	outline: none;
}
.vsm-close {
	border-color: var(--velyon-border);
}

/* ---------- Body ---------- */
.vsm-body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 6px;
}
.vsm-hint,
.vsm-state {
	margin: 0;
	padding: 18px 12px;
	color: var(--velyon-text-muted);
	font-size: 13.5px;
	line-height: 1.5;
}
.vsm-hint[hidden],
.vsm-state[hidden],
.vsm-results[hidden],
.vsm-all[hidden] {
	display: none;
}

/* Loading skeleton */
.vsm-state.is-loading {
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.vsm-skel {
	height: 48px;
	border-radius: var(--velyon-radius-m);
	background: linear-gradient(90deg, var(--velyon-surface-alt) 25%, var(--velyon-border) 50%, var(--velyon-surface-alt) 75%);
	background-size: 200% 100%;
	animation: vsm-shimmer 1.2s linear infinite;
}
@keyframes vsm-shimmer {
	from { background-position: 200% 0; }
	to   { background-position: -200% 0; }
}

/* Must come after .is-loading above: equal specificity, later rule wins. */
.vsm-state.is-loading[hidden] {
	display: none;
}

/* Results */
.vsm-results {
	list-style: none;
	margin: 0;
	padding: 0;
}
.vsm-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 9px 10px;
	border-radius: var(--velyon-radius-m);
	color: var(--velyon-text);
}
.vsm-item:hover,
.vsm-item.is-active {
	background: var(--velyon-surface-alt);
}
.vsm-item.is-active {
	box-shadow: inset 0 0 0 1.5px var(--velyon-accent);
}
.vsm-thumb {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	border-radius: 10px;
	overflow: hidden;
	background: var(--velyon-surface-alt);
	display: flex;
	align-items: center;
	justify-content: center;
}
.vsm-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.vsm-thumb.is-letter {
	font-family: var(--velyon-font-heading);
	font-weight: 800;
	font-size: 16px;
	color: var(--velyon-accent-deep);
	background: color-mix(in srgb, var(--velyon-accent) 14%, var(--velyon-surface-alt));
}
.vsm-main {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	flex: 1;
}
.vsm-title {
	font-family: var(--velyon-font-heading);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.35;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.vsm-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	font-size: 12px;
	color: var(--velyon-text-muted);
}
.vsm-type {
	flex-shrink: 0;
	padding: 1px 8px;
	border: 1px solid var(--velyon-border);
	border-radius: 999px;
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: .03em;
	text-transform: uppercase;
}
.vsm-excerpt {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
}
.vsm-results mark {
	background: color-mix(in srgb, var(--velyon-accent) 28%, transparent);
	color: inherit;
	border-radius: 3px;
	padding: 0 1px;
}

.vsm-all {
	display: block;
	margin: 6px 4px 2px;
	padding: 11px 12px;
	border-top: 1px solid var(--velyon-border);
	text-align: center;
	font-family: var(--velyon-font-heading);
	font-size: 13px;
	font-weight: 700;
	color: var(--velyon-accent-deep);
	word-break: break-word;
}
.vsm-all:hover,
.vsm-all:focus-visible {
	text-decoration: underline;
	outline: none;
}

/* Keyboard hint strip (desktop only) */
.vsm-foot {
	display: flex;
	gap: 16px;
	padding: 9px 16px;
	border-top: 1px solid var(--velyon-border);
	background: var(--velyon-surface-alt);
	color: var(--velyon-text-muted);
	font-size: 11.5px;
}
.vsm-foot kbd {
	display: inline-block;
	min-width: 18px;
	margin-right: 2px;
	padding: 0 5px;
	border: 1px solid var(--velyon-border);
	border-bottom-width: 2px;
	border-radius: 5px;
	background: var(--velyon-surface);
	font-family: var(--velyon-font-body);
	font-size: 11px;
	text-align: center;
}

/* Page behind the popup must not scroll (shared with the old overlay). */
body.has-search-open {
	overflow: hidden;
}

/* ---------- Phones / touch ---------- */
@media (max-width: 782px) {
	.velyon-search-modal {
		--vsm-top: calc(10px + env(safe-area-inset-top, 0px));
		padding: var(--vsm-top) 10px 10px;
	}
	.vsm-dialog {
		border-radius: var(--velyon-radius-m);
	}
	.vsm-foot {
		display: none;
	}
}
@media (hover: none) {
	.vsm-foot {
		display: none;
	}
}
