/* ============================================================
 * Command palette (assets/js/palette.js) — a flat gray-900 operator
 * panel: one field, Lilex group labels, a copper-300 bar on the
 * selected row. No texture, no glow.
 * ========================================================= */
.upton-palette {
	background: var(--kdl-gray-900);
	border: 1px solid var(--kdl-gray-600);
	border-radius: var(--kdl-radius-sm);
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
	color: var(--kdl-gray-50);
	margin: 12vh auto auto;
	max-height: min(36rem, calc(100vh - 12vh - 24px));
	max-height: min(36rem, calc(100dvh - 12vh - 24px));
	overflow: hidden;
	padding: 0;
	width: min(40rem, calc(100vw - 32px));
}

.upton-palette[open] {
	display: flex;
	flex-direction: column;
}

.upton-palette::backdrop {
	background: rgba(10, 13, 17, 0.62);
}

.upton-palette__form {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-height: 0;
}

.upton-palette__field {
	align-items: center;
	border-bottom: 1px solid var(--kdl-gray-600);
	display: flex;
	flex: none;
	gap: 12px;
	padding: 0 12px 0 16px;
}

/* The field always holds focus while the palette is open: the copper
 * rule under it is its focus indicator. */
.upton-palette__field:focus-within {
	box-shadow: inset 0 -2px 0 var(--kdl-copper-300);
}

.upton-palette__icon {
	color: var(--kdl-gray-300);
	flex: none;
}

.upton-palette__input {
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	border: 0;
	border-radius: 0;
	color: #fff;
	flex: 1 1 auto;
	font: 400 1.125rem / 1.3 var(--kdl-font-sans);
	height: 58px;
	min-width: 0;
	padding: 0;
}

.upton-palette__input:is(:focus, :focus-visible) {
	outline: none;
}

.upton-palette__input::placeholder {
	color: var(--kdl-gray-300);
	opacity: 1;
}

.upton-palette__input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.upton-palette__close {
	background: transparent;
	border: 1px solid var(--kdl-gray-600);
	border-radius: var(--kdl-radius-xs);
	color: var(--kdl-gray-300);
	cursor: pointer;
	flex: none;
	font: 500 11px / 1 var(--kdl-font-mono);
	letter-spacing: 0.08em;
	min-height: 28px;
	padding: 0 8px;
	text-transform: uppercase;
}

.upton-palette__close:hover {
	border-color: var(--kdl-gray-400);
	color: #fff;
}

.upton-palette :focus-visible:not(.upton-palette__input) {
	outline: 2px solid var(--kdl-copper-300);
	outline-offset: 2px;
}

/* ─── Suggestions ───────────────────────────────────────────── */
.upton-palette__list {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 4px 0 8px;
}

.upton-palette__list:empty {
	padding: 0;
}

.upton-palette__group + .upton-palette__group {
	border-top: 1px solid var(--kdl-gray-700);
	margin-top: 4px;
}

.upton-palette__group-label {
	color: var(--kdl-gray-300);
	font: 500 11px / 1.3 var(--kdl-font-mono);
	letter-spacing: 0.14em;
	padding: 12px 16px 6px;
	text-transform: uppercase;
}

.upton-palette__option {
	align-items: baseline;
	color: var(--kdl-gray-50);
	cursor: pointer;
	display: flex;
	gap: 16px;
	min-height: 40px;
	padding: 10px 16px 10px 19px;
	position: relative;
}

.upton-palette__option-title {
	flex: 1 1 auto;
	font: 500 0.9375rem / 1.35 var(--kdl-font-sans);
	min-width: 0;
}

.upton-palette__option-meta {
	color: var(--kdl-gray-300);
	flex: 0 1 auto;
	font: 500 11px / 1.3 var(--kdl-font-mono);
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.08em;
	max-width: 55%;
	overflow: hidden;
	text-align: right;
	text-overflow: ellipsis;
	text-transform: uppercase;
	white-space: nowrap;
}

.upton-palette__option[aria-selected="true"] {
	background: var(--kdl-gray-700);
}

.upton-palette__option[aria-selected="true"]::before {
	background: var(--kdl-copper-300);
	bottom: 6px;
	content: "";
	left: 0;
	position: absolute;
	top: 6px;
	width: 3px;
}

.upton-palette__option[aria-selected="true"] .upton-palette__option-meta {
	color: var(--kdl-gray-100);
}

.upton-palette__option--every {
	border-top: 1px solid var(--kdl-gray-700);
	margin-top: 4px;
}

.upton-palette__option--every .upton-palette__option-title {
	color: var(--kdl-copper-300);
}

.upton-palette__note {
	color: var(--kdl-gray-300);
	font: 400 0.875rem / 1.4 var(--kdl-font-sans);
	margin: 0;
	padding: 14px 16px;
}

.upton-palette__keys {
	border-top: 1px solid var(--kdl-gray-700);
	color: var(--kdl-gray-300);
	display: flex;
	flex: none;
	flex-wrap: wrap;
	font: 500 11px / 1.3 var(--kdl-font-mono);
	gap: 6px 18px;
	letter-spacing: 0.06em;
	margin: 0;
	padding: 10px 16px;
	text-transform: uppercase;
}

.upton-palette__keys kbd {
	border: 1px solid var(--kdl-gray-600);
	border-radius: var(--kdl-radius-xs);
	color: var(--kdl-gray-50);
	font: inherit;
	margin-right: 3px;
	padding: 1px 5px;
}

@media (max-width: 599px) {
	.upton-palette {
		margin-top: 8px;
		max-height: calc(100vh - 16px);
		max-height: calc(100dvh - 16px);
		width: calc(100vw - 16px);
	}

	.upton-palette__option {
		flex-direction: column;
		gap: 2px;
	}

	.upton-palette__option-meta {
		max-width: 100%;
		text-align: left;
	}
}

@media (pointer: coarse) {
	.upton-palette__option,
	.upton-palette__close {
		min-height: 44px;
	}

	.upton-palette__close {
		min-width: 44px;
	}

	/* No keyboard, no key hints. */
	.upton-palette__keys {
		display: none;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.upton-palette[open] {
		animation: upton-palette-in 160ms var(--kdl-ease-decel);
	}

	.upton-palette[open]::backdrop {
		animation: upton-palette-fade 160ms linear;
	}

	@keyframes upton-palette-in {
		from {
			opacity: 0;
			transform: translateY(-6px);
		}
	}

	@keyframes upton-palette-fade {
		from {
			opacity: 0;
		}
	}
}

@media (forced-colors: active) {
	.upton-palette {
		border-color: CanvasText;
	}

	.upton-palette__option[aria-selected="true"] {
		outline: 2px solid Highlight;
		outline-offset: -2px;
	}

	.upton-palette__option[aria-selected="true"]::before {
		background: Highlight;
	}
}

@media print {
	.upton-palette {
		display: none !important;
	}
}
