/* Item picker + modal (ADR-019). Co-located with picker.js: a terminal-styled
   replacement for native <select>. The wrapper holds the trigger button plus
   the now-hidden native control; the option list lives in one shared centred
   modal. The selected row borrows the module rail's amber-on-black "active"
   look. Depends on terminal.css for the shared :root tokens. */

.lk-picker {
	position: relative;
	display: flex;
	align-items: stretch;
	width: 100%;
}

.lk-picker--inline {
	display: inline-flex;
	width: auto;
}

/* The ‹ / › steppers flanking the trigger: borderless, no button chrome, a fixed
   32×37 hit area (37 = the single-line control height). They cycle the option in
   place; the trigger between them still opens the full list. */
.lk-picker-step {
	flex: 0 0 32px;
	width: 32px;
	height: 37px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--transparent);
	border: 0;
	padding: 0;
	color: var(--amber-dim);
	font-family: var(--font-mono);
	font-size: 1.15rem;
	line-height: 1;
	cursor: pointer;
	transition: color .12s;
}

.lk-picker-step:hover {
	color: var(--amber);
}

.lk-picker-step:focus-visible {
	outline: 1px solid var(--amber);
	outline-offset: -2px;
}

/* Keep the native control in the DOM for form submission, but out of sight and
   out of the tab order (picker.js also sets tabindex/aria-hidden). */
.lk-picker > select {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	clip: rect(0 0 0 0);
	overflow: hidden;
}

/* The trigger inherits the source select's classes, so .lk-form select and
   .lk-starmap-select styling already apply; this just adds the layout and a
   default form-input look for plain selects. */
.lk-picker-trigger {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	background: var(--bg-control);
	border: 1px solid var(--border);
	color: var(--text);
	font-family: var(--font-mono);
	font-size: 0.95rem;
	text-align: left;
	padding: 8px 10px;
	cursor: pointer;
}

.lk-picker--inline .lk-picker-trigger {
	flex: 0 1 auto;
	width: auto;
}

.lk-picker-trigger:hover {
	border-color: var(--amber-dim);
}

.lk-picker-trigger:focus-visible {
	outline: none;
	border-color: var(--amber);
	box-shadow: 0 0 6px var(--amber-alpha-35);
}

.lk-picker-value {
	flex: 1 1 auto;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.lk-picker-caret {
	flex: 0 0 auto;
	color: var(--amber-dim);
	font-size: 0.7em;
}

/* ── Modal ── */
.lk-picker-modal {
	position: fixed;
	inset: 0;
	z-index: 10001; /* above the fallback-fullscreen Star Map (10000) */
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.lk-picker-modal[hidden] {
	display: none;
}

.lk-picker-backdrop {
	position: absolute;
	inset: 0;
	background: var(--black-alpha-72);
}

.lk-picker-window {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(440px, 100%);
	max-height: min(70vh, 560px);
	background: var(--bg-panel);
	border: 1px solid var(--amber-dim);
	box-shadow: 0 0 0 1px var(--black-alpha-60), 0 0 28px var(--amber-alpha-18);
	padding: 14px;
}

.lk-picker-head {
	color: var(--amber-dim);
	font-size: 0.62rem;
	letter-spacing: 2px;
	margin: 0 0 10px;
}

.lk-picker-filter {
	width: 100%;
	background: var(--bg-control);
	border: 1px solid var(--border);
	color: var(--text);
	font-family: var(--font-mono);
	font-size: 0.9rem;
	padding: 7px 10px;
	margin-bottom: 8px;
}

.lk-picker-filter:focus {
	outline: none;
	border-color: var(--amber);
	box-shadow: 0 0 6px var(--amber-alpha-35);
}

.lk-picker-list {
	list-style: none;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	min-height: 0;
}

.lk-picker-group {
	color: var(--amber-dim);
	font-size: 0.62rem;
	letter-spacing: 2px;
	text-transform: uppercase;
	padding: 8px 12px 3px;
}

.lk-picker-opt {
	padding: 4px 12px;
	color: var(--text);
	font-size: 0.85rem;
	letter-spacing: 1px;
	white-space: pre; /* preserve the box-drawing tree spacing */
	cursor: pointer;
}

/* Keyboard / hover cursor — faint amber, like the rail's :hover. */
.lk-picker-opt.is-active {
	background: var(--amber-alpha-12);
	color: var(--text-bright);
}

/* The committed value — amber-on-black with a marker, like rail .active. */
.lk-picker-opt[aria-selected="true"] {
	background: var(--amber);
	color: var(--text-inverse);
}

.lk-picker-opt[aria-selected="true"]::before {
	content: "▸ ";
	margin-left: -10px;
}

.lk-picker-opt[aria-selected="true"].is-active {
	box-shadow: inset 0 0 0 1px var(--text-inverse);
}

.lk-picker-opt.is-disabled {
	color: var(--muted);
	cursor: default;
}

.lk-picker-empty {
	padding: 10px 12px;
	color: var(--muted);
	font-size: 0.82rem;
}
