/* KODA docs — search palette.

   Shared by the generated manual pages and the /docs index, so it carries its
   own palette rather than leaning on either page's tokens. The values mirror
   the site's dark design system (src/app.css .theme-dark; docs-chrome.css):
   slate surfaces, gold accent, mono fact-labels. Every ink clears 4.5:1 on the
   surface it sits on. Everything is namespaced `kds-`. */

:root {
	--kds-bg: #1e2124;
	--kds-bg-deep: #16171a;
	--kds-line: rgba(255, 255, 255, 0.08);
	--kds-line-strong: rgba(255, 255, 255, 0.14);
	--kds-text: #e9eef5;
	--kds-body: #98a3b3;
	--kds-muted: #8b95a3;
	--kds-gold: #ccaa66;
	--kds-gold-soft: rgba(204, 170, 102, 0.1);
	--kds-gold-mark: #e2c58c;
	--kds-sans: 'Inter Variable', system-ui, sans-serif;
	--kds-mono: 'Chivo Mono Variable', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* Page state while the palette is up */
html.kds-open {
	overflow: hidden;
}

/* The <dialog> itself is an invisible full-viewport layer, so a click on the
   dimmed page (target === dialog) can close it. The panel is the visible box. */
dialog.kds {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--kds-text);
	font-family: var(--kds-sans);
	overflow: visible;
}

dialog.kds[open] {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: max(10vh, env(safe-area-inset-top, 0px)) 0 env(safe-area-inset-bottom, 0px);
}

dialog.kds::backdrop {
	background: rgba(8, 9, 11, 0.62);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
}

.kds-panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(680px, 100% - 2rem);
	max-height: min(72vh, 640px);
	background: var(--kds-bg);
	border: 1px solid var(--kds-line-strong);
	border-radius: 10px;
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.04),
		0 40px 80px -24px rgba(0, 0, 0, 0.85),
		0 0 0 1px rgba(0, 0, 0, 0.45);
	overflow: hidden;
	animation: kds-in 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* The gold hairline every KODA panel carries — a strip of tape on a spec plate. */
.kds-panel::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 2px;
	background: linear-gradient(90deg, var(--kds-gold), rgba(204, 170, 102, 0) 70%);
	pointer-events: none;
}

@keyframes kds-in {
	from {
		opacity: 0;
		transform: translateY(-8px) scale(0.985);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* Search bar ------------------------------------------------------------- */

.kds-bar {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	height: 58px;
	padding: 0 0.9rem 0 1.05rem;
	margin: 0;
	border-bottom: 1px solid var(--kds-line);
	flex-shrink: 0;
}

.kds-icon {
	display: inline-flex;
	color: var(--kds-muted);
	transition: color 160ms ease;
	flex-shrink: 0;
}

.kds-icon svg {
	width: 18px;
	height: 18px;
}

.kds-bar:focus-within .kds-icon {
	color: var(--kds-gold);
}

.kds-input {
	flex: 1;
	min-width: 0;
	height: 100%;
	margin: 0;
	padding: 0;
	background: transparent;
	border: 0;
	outline: 0;
	color: var(--kds-text);
	font-family: var(--kds-sans);
	font-size: 17px;
	font-weight: 500;
	line-height: 1.3;
	letter-spacing: -0.005em;
	-webkit-appearance: none;
	appearance: none;
}

.kds-input::placeholder {
	color: var(--kds-muted);
	opacity: 1;
}

.kds-input::-webkit-search-decoration,
.kds-input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.kds-count {
	font-family: var(--kds-mono);
	font-size: 10px;
	font-weight: 500;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--kds-gold);
	white-space: nowrap;
}

.kds-count:empty {
	display: none;
}

.kds-close {
	display: inline-flex;
	align-items: center;
	margin: 0;
	padding: 0;
	background: transparent;
	border: 0;
	color: var(--kds-muted);
	cursor: pointer;
	font-family: var(--kds-sans);
	font-size: 13px;
}

.kds-close:hover {
	color: var(--kds-text);
}

.kds-close-key {
	font-family: var(--kds-mono);
	font-size: 10px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	padding: 3px 6px;
	border: 1px solid var(--kds-line-strong);
	border-radius: 4px;
	line-height: 1.2;
}

.kds-close-word {
	display: none;
}

/* Results ---------------------------------------------------------------- */

.kds-results {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 0.35rem 0 0.6rem;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.kds-doc {
	display: flex;
	align-items: baseline;
	gap: 0.55rem;
	padding: 0.95rem 1.1rem 0.4rem;
	font-family: var(--kds-mono);
	font-size: 10px;
	font-weight: 500;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--kds-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.kds-eyebrow {
	color: var(--kds-gold);
}

.kds-sep {
	opacity: 0.5;
}

.kds-item {
	position: relative;
	display: block;
	padding: 0.55rem 1.1rem 0.6rem 1.35rem;
	color: inherit;
	text-decoration: none;
	outline: 0;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

/* Gold rule that grows from the left edge — the same motif as the /docs
   index rows, so a result reads as "one of those, up close". */
.kds-item::before {
	content: '';
	position: absolute;
	left: 0;
	top: 4px;
	bottom: 4px;
	width: 2px;
	background: var(--kds-gold);
	transform: scaleY(0);
	transform-origin: top;
	transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.kds-item.is-active {
	background: linear-gradient(90deg, var(--kds-gold-soft), transparent 70%);
}

.kds-item.is-active::before {
	transform: scaleY(1);
}

.kds-title {
	display: block;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.35;
	color: var(--kds-text);
}

.kds-crumb {
	display: block;
	margin-top: 3px;
	font-family: var(--kds-mono);
	font-size: 10.5px;
	letter-spacing: 0.04em;
	line-height: 1.5;
	color: var(--kds-muted);
}

/* One quiet marker on the current manual's group header */
.kds-here {
	margin-left: 0.35rem;
	padding: 1px 5px;
	color: var(--kds-gold);
	font-size: 9px;
	letter-spacing: 0.14em;
	border: 1px solid rgba(204, 170, 102, 0.35);
	border-radius: 3px;
	line-height: 1.4;
}

.kds-snip {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	margin-top: 4px;
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--kds-body);
	overflow-wrap: anywhere;
}

.kds-item mark {
	background: rgba(204, 170, 102, 0.16);
	color: var(--kds-gold-mark);
	border-radius: 2px;
	padding: 0 1px;
}

.kds-title mark {
	background: transparent;
	color: var(--kds-gold-mark);
	text-decoration: underline;
	text-decoration-color: rgba(204, 170, 102, 0.55);
	text-underline-offset: 3px;
	padding: 0;
}

.kds-item-doc .kds-title {
	font-size: 15px;
}

/* Empty / status --------------------------------------------------------- */

.kds-none {
	padding: 1.6rem 1.35rem 1.4rem;
	color: var(--kds-body);
	font-size: 13.5px;
	line-height: 1.6;
}

.kds-none p {
	margin: 0;
}

.kds-none b {
	color: var(--kds-text);
	font-weight: 600;
	overflow-wrap: anywhere;
}

.kds-none a {
	color: var(--kds-gold);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.kds-none .kds-hint {
	margin-top: 0.4rem;
	font-size: 12.5px;
	color: var(--kds-muted);
}

.kds-hint code {
	font-family: var(--kds-mono);
	font-size: 11.5px;
	color: var(--kds-body);
	background: var(--kds-bg-deep);
	border: 1px solid var(--kds-line);
	border-radius: 4px;
	padding: 1px 5px;
}

/* Footer ----------------------------------------------------------------- */

.kds-foot {
	display: flex;
	align-items: center;
	gap: 1.1rem;
	padding: 0.55rem 1.1rem;
	border-top: 1px solid var(--kds-line);
	font-size: 11px;
	color: var(--kds-muted);
	flex-shrink: 0;
	white-space: nowrap;
}

.kds-foot kbd {
	display: inline-block;
	font-family: var(--kds-mono);
	font-size: 10px;
	font-weight: 500;
	line-height: 1.4;
	padding: 1px 5px;
	margin-right: 4px;
	background: var(--kds-bg-deep);
	color: var(--kds-body);
	border: 1px solid var(--kds-line-strong);
	border-bottom-width: 2px;
	border-radius: 4px;
	white-space: nowrap;
	box-shadow: none;
}

.kds-foot kbd + kbd {
	margin-left: -2px;
}

.kds-ref {
	margin-left: auto;
	font-family: var(--kds-mono);
	font-size: 10px;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--kds-gold);
}

/* Phones ----------------------------------------------------------------- */

@media (max-width: 640px) {
	dialog.kds[open] {
		padding: 0;
	}

	.kds-panel {
		width: 100%;
		height: 100%;
		max-height: none;
		border: 0;
		border-radius: 0;
		box-shadow: none;
		padding-top: env(safe-area-inset-top, 0px);
		animation-name: kds-in-mobile;
	}

	@keyframes kds-in-mobile {
		from {
			opacity: 0;
		}
		to {
			opacity: 1;
		}
	}

	.kds-bar {
		height: 56px;
		padding: 0 0.9rem 0 1rem;
	}

	.kds-count,
	.kds-close-key,
	.kds-foot {
		display: none;
	}

	.kds-close-word {
		display: inline;
	}

	.kds-results {
		padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
	}
}

@media (prefers-reduced-motion: reduce) {
	.kds-panel {
		animation: none;
	}

	.kds-item::before {
		transition: none;
	}
}
