/* ===========================================================
   Voyamore Core — Search ([voyamore_search])
   Four panel styles: modal, inline, drawer, spotlight.
   All share the same .vym-search markup; positioning + entry
   animation differ per .vym-search--{style} variant.
   =========================================================== */

.vym-search {
	font-family: var(--vym-font-ui);
	color: var(--vym-text);
	display: inline-flex;
	position: relative;
}

/* ====================================================================
   TRIGGER (the icon button)
   ==================================================================== */
.vym-search__trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px;
	background: transparent;
	border: 1px solid transparent;
	border-radius: 999px;
	color: var(--vym-text);
	cursor: pointer;
	font: inherit;
	transition: background 0.25s var(--vym-ease), border-color 0.25s var(--vym-ease), transform 0.25s var(--vym-ease), color 0.25s var(--vym-ease);
}
.vym-search__trigger:hover {
	background: var(--vym-glass);
	border-color: var(--vym-border);
}
.vym-search__trigger:focus-visible {
	outline: 2px solid var(--vym-accent);
	outline-offset: 2px;
}
.vym-search__trigger-icon {
	display: block;
	transition: transform 0.25s var(--vym-ease);
}
.vym-search__trigger:hover .vym-search__trigger-icon {
	transform: scale(1.08);
}
.vym-search__trigger-label {
	font-size: 14px;
	letter-spacing: 0.01em;
}
.vym-search__trigger-hotkey {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.05em;
	color: var(--vym-muted);
	background: var(--vym-glass);
	border: 1px solid var(--vym-border);
	padding: 2px 7px;
	border-radius: 6px;
	margin-left: 6px;
}

/* When the trigger has only the icon, tighten the padding slightly. */
.vym-search__trigger:not(:has(.vym-search__trigger-label)):not(:has(.vym-search__trigger-hotkey)) {
	padding: 10px;
}

/* ====================================================================
   PANEL — base
   ==================================================================== */
.vym-search__panel {
	z-index: 99990;
}
/* Force the `hidden` attribute to win against every style variant
   (.vym-search--modal / spotlight / drawer set display:flex on the
   panel, which would otherwise tie this rule on specificity and beat
   it on source order). Without !important the panel stays visible
   and blocks page clicks. */
.vym-search__panel[hidden],
.vym-search__backdrop[hidden] { display: none !important; }

.vym-search__backdrop {
	position: fixed;
	inset: 0;
	background: rgba(11, 15, 26, 0.55);
	backdrop-filter: blur(8px) saturate(140%);
	-webkit-backdrop-filter: blur(8px) saturate(140%);
	opacity: 0;
	transition: opacity 0.25s var(--vym-ease);
	z-index: 1;
}
.vym-search.is-open .vym-search__backdrop {
	opacity: 1;
}

.vym-search__surface {
	background: var(--vym-surface);
	color: var(--vym-text);
	border: 1px solid var(--vym-border);
	box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
	border-radius: 16px;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	position: relative;
	z-index: 2;
	opacity: 0;
	transform: translateY(8px) scale(0.985);
	transition: opacity 0.28s var(--vym-ease), transform 0.28s var(--vym-ease);
}
.vym-search.is-open .vym-search__surface {
	opacity: 1;
	transform: none;
}

/* ====================================================================
   HEAD (input row)
   ==================================================================== */
.vym-search__head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 18px 20px;
	border-bottom: 1px solid var(--vym-border);
	background: var(--vym-surface);
}
.vym-search__head-icon {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	color: var(--vym-muted);
}
.vym-search__input {
	flex: 1;
	min-width: 0;
	background: transparent;
	border: 0;
	outline: 0;
	color: var(--vym-text);
	font: inherit;
	font-size: 16px;
	padding: 4px 0;
}
.vym-search__input::placeholder { color: var(--vym-muted); }

.vym-search__clear,
.vym-search__close {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 6px;
	background: transparent;
	border: 0;
	color: var(--vym-muted);
	cursor: pointer;
	border-radius: 8px;
	transition: background 0.2s var(--vym-ease), color 0.2s var(--vym-ease);
}
.vym-search__clear:hover,
.vym-search__close:hover {
	background: var(--vym-glass);
	color: var(--vym-text);
}
.vym-search__clear svg,
.vym-search__close-x { width: 16px; height: 16px; }
.vym-search__close-kbd {
	font-size: 10px;
	font-weight: 600;
	border: 1px solid var(--vym-border);
	padding: 2px 6px;
	border-radius: 5px;
}

/* ====================================================================
   BODY (results / states)
   ==================================================================== */
.vym-search__body {
	flex: 1;
	min-height: 240px;
	max-height: 60vh;
	overflow-y: auto;
	padding: 14px 12px;
	scrollbar-width: thin;
	scrollbar-color: var(--vym-border) transparent;
}
.vym-search__body::-webkit-scrollbar { width: 8px; }
.vym-search__body::-webkit-scrollbar-thumb {
	background: var(--vym-border);
	border-radius: 4px;
}

.vym-search__state[hidden] { display: none; }

/* idle */
.vym-search__idle-hint {
	color: var(--vym-muted);
	text-align: center;
	padding: 32px 20px;
	font-size: 14px;
}

/* recent searches */
.vym-search__section-label {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--vym-muted);
	padding: 12px 12px 8px;
}
.vym-search__recent-list {
	list-style: none;
	padding: 0 4px;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.vym-search__recent-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 12px;
	border-radius: 10px;
	color: var(--vym-text);
	cursor: pointer;
	transition: background 0.18s var(--vym-ease);
	font-size: 14px;
}
.vym-search__recent-item:hover,
.vym-search__recent-item.is-active {
	background: var(--vym-glass);
}
.vym-search__recent-item-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vym-search__recent-item-remove {
	background: transparent;
	border: 0;
	color: var(--vym-muted);
	cursor: pointer;
	padding: 4px;
	border-radius: 6px;
	opacity: 0;
	transition: opacity 0.2s, background 0.2s, color 0.2s;
}
.vym-search__recent-item:hover .vym-search__recent-item-remove { opacity: 1; }
.vym-search__recent-item-remove:hover { background: var(--vym-glass); color: var(--vym-text); }
.vym-search__recent-item-remove svg { width: 14px; height: 14px; }
.vym-search__recent-item-icon { color: var(--vym-muted); flex-shrink: 0; }
.vym-search__recent-item-icon svg { width: 14px; height: 14px; }

/* loading skeleton */
.vym-search__state--loading {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 4px;
}
.vym-search__skel {
	display: flex;
	gap: 14px;
	align-items: center;
	padding: 10px 12px;
	border-radius: 12px;
}
.vym-search__skel-thumb {
	width: 56px;
	height: 56px;
	border-radius: 10px;
	background: var(--vym-glass);
	flex-shrink: 0;
	animation: vym-search-shimmer 1.4s ease infinite;
}
.vym-search__skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.vym-search__skel-line {
	height: 12px;
	border-radius: 6px;
	background: var(--vym-glass);
	animation: vym-search-shimmer 1.4s ease infinite;
}
@keyframes vym-search-shimmer {
	0%   { opacity: 0.6; }
	50%  { opacity: 0.35; }
	100% { opacity: 0.6; }
}

/* results list */
.vym-search__results-list {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.vym-search__result {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px;
	border-radius: 12px;
	color: var(--vym-text);
	text-decoration: none;
	transition: background 0.18s var(--vym-ease), transform 0.18s var(--vym-ease);
	cursor: pointer;
	opacity: 0;
	transform: translateY(4px);
	animation: vym-search-fade-in 0.4s var(--vym-ease) forwards;
	animation-delay: calc(var(--vym-stagger, 0) * 40ms);
}
@keyframes vym-search-fade-in {
	to { opacity: 1; transform: none; }
}
.vym-search__result:hover,
.vym-search__result.is-active {
	background: var(--vym-glass);
	color: var(--vym-text);
}
.vym-search__result.is-active {
	box-shadow: inset 3px 0 0 var(--vym-accent);
}
.vym-search__result:focus-visible {
	outline: 2px solid var(--vym-accent);
	outline-offset: -2px;
}

.vym-search__result-thumb {
	width: 56px;
	height: 56px;
	border-radius: 10px;
	background-color: var(--vym-glass);
	background-size: cover;
	background-position: center;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--vym-muted);
}
.vym-search__result-thumb[data-empty="1"] svg { width: 22px; height: 22px; opacity: 0.6; }

.vym-search__result-body { flex: 1; min-width: 0; }
.vym-search__result-type {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--vym-accent);
	margin-bottom: 4px;
}
.vym-search__result-title {
	font-size: 15px;
	font-weight: 500;
	line-height: 1.3;
	color: var(--vym-text);
	margin-bottom: 3px;
	letter-spacing: -0.005em;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
.vym-search__result-excerpt {
	font-size: 13px;
	line-height: 1.5;
	color: var(--vym-muted);
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

/* Highlight pill — wraps matching characters. */
.vym-search__result mark,
.vym-search__result-title mark,
.vym-search__result-excerpt mark {
	background: color-mix(in srgb, var(--vym-accent) 22%, transparent);
	color: var(--vym-accent);
	font-weight: 600;
	padding: 0 2px;
	border-radius: 3px;
}

.vym-search__result-arrow {
	width: 16px;
	height: 16px;
	color: var(--vym-muted);
	flex-shrink: 0;
	opacity: 0;
	transition: opacity 0.2s var(--vym-ease), transform 0.2s var(--vym-ease);
}
.vym-search__result:hover .vym-search__result-arrow,
.vym-search__result.is-active .vym-search__result-arrow {
	opacity: 1;
	transform: translateX(4px);
}

.vym-search__view-all {
	display: block;
	text-align: center;
	padding: 14px;
	margin-top: 8px;
	color: var(--vym-accent);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-decoration: none;
	border-top: 1px solid var(--vym-border);
	transition: gap 0.2s var(--vym-ease);
}
.vym-search__view-all:hover { color: var(--vym-accent); text-decoration: underline; }

/* empty / no-results */
.vym-search__state--empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	padding: 48px 20px;
	text-align: center;
}
.vym-search__empty-icon {
	color: var(--vym-muted);
	opacity: 0.5;
}
.vym-search__empty-icon svg { width: 32px; height: 32px; }
.vym-search__empty-text {
	color: var(--vym-muted);
	font-size: 14px;
}

/* ====================================================================
   FOOT (key hints + footnote)
   ==================================================================== */
.vym-search__foot {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	padding: 10px 18px;
	border-top: 1px solid var(--vym-border);
	background: var(--vym-bg-soft);
	font-size: 11px;
	color: var(--vym-muted);
}
.vym-search__keys {
	display: flex;
	gap: 16px;
	flex-wrap: wrap;
}
.vym-search__keys span {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}
.vym-search__keys kbd {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 4px;
	background: var(--vym-surface);
	border: 1px solid var(--vym-border);
	border-radius: 4px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 10px;
	color: var(--vym-text);
}
.vym-search__footnote { font-style: italic; }

/* ====================================================================
   STYLE VARIANT: modal — full viewport overlay, centered card
   ==================================================================== */
.vym-search--modal .vym-search__panel {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 80px 20px 20px;
}
.vym-search--modal .vym-search__surface {
	width: 100%;
	max-width: 680px;
	max-height: calc(100vh - 100px);
}

/* ====================================================================
   STYLE VARIANT: spotlight — center-screen floating, command-palette feel
   ==================================================================== */
.vym-search--spotlight .vym-search__panel {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}
.vym-search--spotlight .vym-search__surface {
	width: 100%;
	max-width: 640px;
	max-height: 70vh;
	box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.7);
}
.vym-search--spotlight .vym-search__head { padding: 22px 24px; }
.vym-search--spotlight .vym-search__input { font-size: 18px; }

/* ====================================================================
   STYLE VARIANT: drawer — slides down from top of viewport
   ==================================================================== */
.vym-search--drawer .vym-search__panel {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
}
.vym-search--drawer .vym-search__surface {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	border-radius: 0 0 16px 16px;
	border-top: 0;
	transform: translateY(-12px);
	max-height: 80vh;
}
.vym-search--drawer.is-open .vym-search__surface { transform: none; }
.vym-search--drawer .vym-search__head { padding: 22px 28px; }

/* ====================================================================
   STYLE VARIANT: inline — input slides out to the right of the trigger
   ==================================================================== */
.vym-search--inline {
	/* The component itself becomes the positioning context. */
	align-items: center;
}
.vym-search--inline .vym-search__panel {
	position: absolute;
	top: 50%;
	right: 100%;
	transform: translateY(-50%);
	margin-right: 6px;
	width: 360px;
	max-width: calc(100vw - 80px);
}
.vym-search--inline .vym-search__backdrop {
	display: none;
}
.vym-search--inline .vym-search__surface {
	transform: translateX(8px);
}
.vym-search--inline.is-open .vym-search__surface { transform: none; }
.vym-search--inline .vym-search__head { padding: 12px 16px; }
.vym-search--inline .vym-search__body { max-height: 50vh; min-height: 0; }
.vym-search--inline .vym-search__foot { display: none; }

/* When the inline panel can't fit to the left, fall back to dropping below. */
@media (max-width: 720px) {
	.vym-search--inline .vym-search__panel {
		position: fixed;
		inset: auto 12px auto 12px;
		top: 70px;
		right: 12px;
		left: 12px;
		transform: none;
		width: auto;
		max-width: none;
	}
}

/* ====================================================================
   RESPONSIVE — every panel collapses to near-fullscreen on small viewports.
   ==================================================================== */
@media (max-width: 540px) {
	.vym-search--modal .vym-search__panel,
	.vym-search--spotlight .vym-search__panel {
		padding: 12px;
		align-items: flex-start;
	}
	.vym-search--modal .vym-search__surface,
	.vym-search--spotlight .vym-search__surface {
		max-height: calc(100vh - 24px);
	}
	.vym-search__keys { gap: 10px; font-size: 10px; }
	.vym-search__foot { padding: 8px 14px; }
}

/* Lock page scroll when any search panel is open. JS toggles this class. */
html.vym-search-locked,
body.vym-search-locked { overflow: hidden; }
