/**
 * BFPT Premium Command Palette Search - Mac Liquid Glass Styling.
 * Translucent surfaces, silky backdrop blur, specular top highlights,
 * responsive mobile sheet/overlay, and accessible high-contrast typography.
 *
 * @package Blocksy_Child
 */

/* ==========================================================================
   1. Root Overlay & Backdrop
   ========================================================================== */
.bfpt-palette-overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 0;
	opacity: 0;
	visibility: hidden;
	transition: opacity 180ms cubic-bezier(0.16, 1, 0.3, 1),
	            visibility 180ms ease;
	pointer-events: none;
}

.bfpt-palette-overlay.is-open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.bfpt-palette-overlay[hidden] {
	display: none !important;
}

.bfpt-palette-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(15, 17, 23, 0.45);
	backdrop-filter: blur(14px);
	-webkit-backdrop-filter: blur(14px);
	z-index: 1;
	cursor: default;
}

[data-theme="dark"] .bfpt-palette-backdrop {
	background: rgba(0, 0, 0, 0.68);
}

/* Graceful opaque fallback when backdrop-filter is unsupported */
@supports not (backdrop-filter: blur(1px)) {
	.bfpt-palette-backdrop {
		background: rgba(18, 20, 26, 0.88);
	}
}

/* ==========================================================================
   2. Liquid-Glass Command Palette Dialog Panel
   ========================================================================== */
.bfpt-palette-dialog {
	position: fixed;
	top: 10vh;
	left: 50%;
	transform: translate(-50%, -10px) scale(0.97);
	width: min(660px, calc(100vw - 32px));
	max-height: min(600px, calc(100dvh - 14vh));
	background: rgba(255, 255, 255, 0.82);
	backdrop-filter: saturate(190%) blur(28px);
	-webkit-backdrop-filter: saturate(190%) blur(28px);
	border: 1px solid rgba(255, 255, 255, 0.65);
	border-radius: 20px;
	box-shadow:
		0 0 0 1px rgba(0, 0, 0, 0.05) inset,
		0 1px 1px 0 rgba(255, 255, 255, 0.8) inset,
		0 20px 48px -10px rgba(15, 17, 23, 0.22),
		0 36px 72px -16px rgba(15, 17, 23, 0.32);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 2;
	transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1),
	            opacity 200ms ease;
	font-family: var(--font-family-body, inherit);
	color: var(--c-ink, #171717);
}

[data-theme="dark"] .bfpt-palette-dialog {
	background: rgba(30, 32, 40, 0.84);
	border: 1px solid rgba(255, 255, 255, 0.12);
	box-shadow:
		0 0 0 1px rgba(255, 255, 255, 0.08) inset,
		0 1px 1px 0 rgba(255, 255, 255, 0.18) inset,
		0 24px 54px -12px rgba(0, 0, 0, 0.65),
		0 40px 80px -16px rgba(0, 0, 0, 0.75);
}

@supports not (backdrop-filter: blur(1px)) {
	.bfpt-palette-dialog {
		background: var(--c-surf, #ffffff);
	}
	[data-theme="dark"] .bfpt-palette-dialog {
		background: var(--c-surf, #27272c);
	}
}

.bfpt-palette-overlay.is-open .bfpt-palette-dialog {
	transform: translate(-50%, 0) scale(1);
}

/* ==========================================================================
   3. Palette Header & Search Input
   ========================================================================== */
.bfpt-palette-header {
	padding: 16px 20px 12px 20px;
	border-bottom: 1px solid var(--c-bdr, #E1E5EA);
	background: rgba(255, 255, 255, 0.25);
}

[data-theme="dark"] .bfpt-palette-header {
	background: rgba(0, 0, 0, 0.15);
	border-bottom-color: var(--c-bdr, #3F3F48);
}

.bfpt-palette-input-wrap {
	display: flex;
	align-items: center;
	gap: 12px;
	position: relative;
}

.bfpt-palette-search-icon {
	flex-shrink: 0;
	color: var(--c-pri, #C92722);
}

.bfpt-palette-input {
	flex: 1;
	background: transparent !important;
	border: none !important;
	box-shadow: none !important;
	outline: none !important;
	font-size: 1.125rem !important; /* 18px avoids iOS zoom */
	font-weight: 500 !important;
	line-height: 1.4 !important;
	color: var(--c-ink, #171717) !important;
	padding: 4px 0 !important;
	margin: 0 !important;
}

.bfpt-palette-input::placeholder {
	color: var(--c-muted, #5F636B);
	opacity: 0.85;
	font-weight: 400;
}

.bfpt-palette-clear-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	border: none;
	background: rgba(0, 0, 0, 0.08);
	color: var(--c-muted, #5F636B);
	cursor: pointer;
	padding: 0;
	transition: background-color 140ms ease, color 140ms ease;
}

[data-theme="dark"] .bfpt-palette-clear-btn {
	background: rgba(255, 255, 255, 0.12);
	color: #D4D4D8;
}

.bfpt-palette-clear-btn:hover {
	background: var(--c-pri, #C92722);
	color: #ffffff;
}

.bfpt-palette-kbd-chip {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 3px 6px;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.04em;
	color: var(--c-muted, #5F636B);
	background: rgba(0, 0, 0, 0.05);
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 6px;
	user-select: none;
}

[data-theme="dark"] .bfpt-palette-kbd-chip {
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(255, 255, 255, 0.12);
	color: #A8A8B0;
}

.bfpt-palette-close-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 8px;
	border: none;
	background: transparent;
	color: var(--c-muted, #5F636B);
	cursor: pointer;
	padding: 0;
	transition: background-color 140ms ease, color 140ms ease;
}

.bfpt-palette-close-btn:hover {
	background: rgba(0, 0, 0, 0.06);
	color: var(--c-ink, #171717);
}

[data-theme="dark"] .bfpt-palette-close-btn:hover {
	background: rgba(255, 255, 255, 0.10);
	color: #ffffff;
}

.bfpt-palette-close-btn:focus-visible {
	outline: 2px solid var(--c-focus, #C92722);
	outline-offset: 2px;
}

/* ==========================================================================
   4. Quick Filter Pills
   ========================================================================== */
.bfpt-palette-filters {
	display: flex;
	gap: 6px;
	overflow-x: auto;
	padding: 10px 0 2px 0;
	margin-top: 4px;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.bfpt-palette-filters::-webkit-scrollbar {
	display: none;
}

.bfpt-palette-pill {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	font-size: 12px;
	font-weight: 500;
	border-radius: 9999px;
	border: 1px solid rgba(0, 0, 0, 0.08);
	background: rgba(0, 0, 0, 0.03);
	color: var(--c-muted, #5F636B);
	cursor: pointer;
	white-space: nowrap;
	transition: all 140ms ease;
	flex-shrink: 0;
}

[data-theme="dark"] .bfpt-palette-pill {
	border-color: rgba(255, 255, 255, 0.12);
	background: rgba(255, 255, 255, 0.04);
	color: #A8A8B0;
}

.bfpt-palette-pill:hover {
	background: rgba(201, 39, 34, 0.08);
	border-color: var(--c-pri, #C92722);
	color: var(--c-pri, #C92722);
}

.bfpt-palette-pill.is-active {
	background: var(--c-pri, #C92722);
	border-color: var(--c-pri, #C92722);
	color: #ffffff !important;
	font-weight: 600;
}

.bfpt-palette-pill--other.is-active {
	background: #356FA8;
	border-color: #356FA8;
}

/* ==========================================================================
   5. Section Bar
   ========================================================================== */
.bfpt-palette-section-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 20px 6px 20px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--c-muted, #5F636B);
}

/* ==========================================================================
   6. Results Listbox
   ========================================================================== */
.bfpt-palette-results {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 4px 12px 12px 12px;
	max-height: 380px;
}

.bfpt-palette-results::-webkit-scrollbar {
	width: 6px;
}

.bfpt-palette-results::-webkit-scrollbar-track {
	background: transparent;
}

.bfpt-palette-results::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.15);
	border-radius: 9999px;
}

[data-theme="dark"] .bfpt-palette-results::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.20);
}

/* Result item */
.bfpt-palette-item {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 10px 12px;
	border-radius: 12px;
	text-decoration: none !important;
	color: inherit !important;
	cursor: pointer;
	position: relative;
	transition: background-color 120ms ease;
	border: 1px solid transparent;
}

.bfpt-palette-item:hover,
.bfpt-palette-item.is-selected {
	background: rgba(201, 39, 34, 0.07);
	border-color: rgba(201, 39, 34, 0.18);
}

[data-theme="dark"] .bfpt-palette-item:hover,
[data-theme="dark"] .bfpt-palette-item.is-selected {
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(255, 255, 255, 0.14);
}

.bfpt-palette-item.is-selected::before {
	content: '';
	position: absolute;
	left: 3px;
	top: 10px;
	bottom: 10px;
	width: 3px;
	border-radius: 2px;
	background: var(--c-pri, #C92722);
}

/* Icon Squircle */
.bfpt-palette-icon-tile {
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	border-radius: 10px;
	background: var(--c-tile-bg, #DCEBFA);
	color: var(--c-tile-glyph, #235284);
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--c-tile-bdr, #C5DCF4);
}

[data-theme="dark"] .bfpt-palette-icon-tile {
	background: var(--c-tile-bg, #33333B);
	color: var(--c-tile-glyph, #FFFFFF);
	border-color: var(--c-tile-bdr, #3F3F48);
}

.bfpt-palette-icon-tile--other {
	background: #FFE8E6;
	color: #C92722;
	border-color: #F8C8C6;
}

[data-theme="dark"] .bfpt-palette-icon-tile--other {
	background: #49302F;
	color: #FFB4A9;
	border-color: #5C3D3B;
}

/* Content */
.bfpt-palette-item-content {
	flex: 1;
	min-width: 0;
}

.bfpt-palette-item-title {
	font-size: 14px;
	font-weight: 600;
	color: var(--c-ink, #171717);
	line-height: 1.3;
	margin: 0 0 2px 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bfpt-palette-item-desc {
	font-size: 12px;
	color: var(--c-muted, #5F636B);
	line-height: 1.4;
	margin: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bfpt-palette-match-highlight {
	color: var(--c-pri, #C92722);
	font-weight: 700;
	background: rgba(201, 39, 34, 0.10);
	border-radius: 2px;
	padding: 0 2px;
}

/* Badges & Meta */
.bfpt-palette-item-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

.bfpt-palette-badge {
	font-size: 11px;
	font-weight: 500;
	padding: 2px 7px;
	border-radius: 9999px;
	background: rgba(0, 0, 0, 0.05);
	color: var(--c-muted, #5F636B);
	border: 1px solid rgba(0, 0, 0, 0.06);
	white-space: nowrap;
}

[data-theme="dark"] .bfpt-palette-badge {
	background: rgba(255, 255, 255, 0.08);
	color: #D4D4D8;
	border-color: rgba(255, 255, 255, 0.10);
}

.bfpt-palette-badge--other {
	background: #FFE8E6;
	color: #8C211C;
	border-color: #F8C8C6;
	font-weight: 600;
}

[data-theme="dark"] .bfpt-palette-badge--other {
	background: #49302F;
	color: #FFB4A9;
	border-color: #5C3D3B;
}

.bfpt-palette-enter-hint {
	font-size: 12px;
	color: var(--c-muted, #5F636B);
	opacity: 0;
	transition: opacity 120ms ease;
}

.bfpt-palette-item:hover .bfpt-palette-enter-hint,
.bfpt-palette-item.is-selected .bfpt-palette-enter-hint {
	opacity: 1;
}

/* ==========================================================================
   7. Empty State
   ========================================================================== */
.bfpt-palette-empty {
	padding: 40px 20px;
	text-align: center;
}

.bfpt-palette-empty-icon {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.04);
	color: var(--c-muted, #5F636B);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 12px;
}

[data-theme="dark"] .bfpt-palette-empty-icon {
	background: rgba(255, 255, 255, 0.08);
	color: #D4D4D8;
}

.bfpt-palette-empty-title {
	font-size: 15px;
	font-weight: 600;
	color: var(--c-ink, #171717);
	margin: 0 0 6px 0;
}

.bfpt-palette-empty-hint {
	font-size: 13px;
	color: var(--c-muted, #5F636B);
	margin: 0;
}

.bfpt-palette-empty-suggestions {
	display: flex;
	justify-content: center;
	gap: 6px;
	flex-wrap: wrap;
	margin-top: 14px;
}

.bfpt-palette-suggestion-chip {
	padding: 4px 10px;
	font-size: 12px;
	border-radius: 9999px;
	background: rgba(0, 0, 0, 0.04);
	border: 1px solid rgba(0, 0, 0, 0.08);
	color: var(--c-pri, #C92722);
	cursor: pointer;
	text-decoration: none;
	transition: all 120ms ease;
}

[data-theme="dark"] .bfpt-palette-suggestion-chip {
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(255, 255, 255, 0.12);
	color: #FF8B7D;
}

.bfpt-palette-suggestion-chip:hover {
	background: var(--c-pri, #C92722);
	color: #ffffff;
}

/* ==========================================================================
   8. Footer Bar
   ========================================================================== */
.bfpt-palette-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 20px;
	border-top: 1px solid var(--c-bdr, #E1E5EA);
	background: rgba(255, 255, 255, 0.35);
	font-size: 12px;
	color: var(--c-muted, #5F636B);
}

[data-theme="dark"] .bfpt-palette-footer {
	background: rgba(0, 0, 0, 0.20);
	border-top-color: var(--c-bdr, #3F3F48);
}

.bfpt-palette-shortcuts {
	display: flex;
	align-items: center;
	gap: 14px;
}

.bfpt-palette-shortcut-item {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.bfpt-kbd {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	padding: 2px 5px;
	font-size: 10px;
	font-weight: 600;
	font-family: inherit;
	background: rgba(0, 0, 0, 0.06);
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 4px;
	box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
	color: var(--c-ink, #171717);
}

[data-theme="dark"] .bfpt-kbd {
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(255, 255, 255, 0.15);
	box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
	color: #FFFFFF;
}

.bfpt-palette-footer-meta {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-weight: 500;
}

/* ==========================================================================
   9. Mobile Responsive Layout (320px - 640px)
   ========================================================================== */
@media (max-width: 640px) {
	.bfpt-palette-dialog {
		top: 0;
		left: 0;
		transform: none !important;
		width: 100vw;
		height: 100dvh;
		max-height: 100dvh;
		border-radius: 0;
		border: none;
		box-shadow: none;
		padding-top: env(safe-area-inset-top, 0);
		padding-bottom: env(safe-area-inset-bottom, 0);
	}

	.bfpt-palette-header {
		padding: 12px 14px 10px 14px;
	}

	.bfpt-palette-kbd-chip {
		display: none; /* Hide Esc badge on touch */
	}

	.bfpt-palette-close-btn {
		width: 36px;
		height: 36px;
	}

	.bfpt-palette-results {
		padding: 6px 8px 12px 8px;
		max-height: none;
	}

	.bfpt-palette-item {
		padding: 12px 10px;
		min-height: 52px; /* Touch-friendly tap target */
	}

	.bfpt-palette-shortcuts {
		display: none; /* Hide keyboard legend on mobile */
	}

	.bfpt-palette-footer {
		padding: 10px 14px;
		justify-content: center;
	}
}

/* Screen reader utility */
.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
