/* Ctrl/Cmd+K search palette and Home easter egg (assets/js/palette.js). */
.td-pal {
	width: min(620px, calc(100vw - 24px));
	max-width: none;
	max-height: none;
	margin: 12vh auto auto;
	padding: 0;
	border: 0;
	background: transparent;
	overflow: visible;
}

/* Permanent gutter: a gutter that only applied while open made Chromium shrink vw (Blocksy's 90vw container) and shift the page. */
html {
	scrollbar-gutter: stable;
}

/* Page behind: no scrolling. */
html:has(.td-pal[open]) {
	overflow: hidden;
}

.td-pal::backdrop {
	background: rgba(17, 17, 17, 0.45);
}

.td-pal__box {
	background: var(--td-ink, #111);
	color: #E9E9E4;
	border: 2px solid var(--td-ink, #111);
	border-radius: var(--td-radius-md, 18px);
	box-shadow: 6px 6px 0 var(--td-violet, #7B3DF0);
	font-family: var(--td-mono, ui-monospace, monospace);
	overflow: hidden;
}

.td-pal__in {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 16px;
	border-bottom: 1px solid #2E2E2E;
}

.td-pal__ps {
	color: var(--td-lime, #B5F23D);
	font-weight: 700;
}

body .td-pal__q {
	--has-height: 40px;
	flex: 1;
	min-width: 0;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: #fff;
	font: 500 16px var(--td-mono, ui-monospace, monospace);
	box-shadow: none;
	outline: none;
}

.td-pal__q::placeholder {
	color: #8A8A84;
}

.td-pal__q::-webkit-search-cancel-button {
	display: none;
}

.td-pal kbd {
	font: 700 11px var(--td-mono, ui-monospace, monospace);
	color: #ddd;
	background: #222;
	border: 1.5px solid #555;
	border-bottom-width: 3px;
	border-radius: 6px;
	padding: 0 5px;
}

.td-pal__list {
	list-style: none;
	margin: 0;
	padding: 6px;
	max-height: min(52vh, 420px);
	overflow-y: auto;
	overscroll-behavior: contain;
}

.td-pal__opt {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 8px 10px;
	border-radius: 10px;
	cursor: pointer;
}

.td-pal__opt.is-on,
.td-pal__opt:hover {
	background: #232323;
}

.td-pal__ar {
	flex: none;
	color: #555;
}

.td-pal__opt.is-on .td-pal__ar {
	color: var(--td-lime, #B5F23D);
}

.td-pal__t {
	min-width: 0;
	font: 600 15px/1.3 var(--td-body, Poppins, sans-serif);
	color: #fff;
}

.td-pal__opt.is-all .td-pal__t {
	font-weight: 500;
}

.td-pal__c {
	flex: none;
	margin-left: auto;
	font-size: 11.5px;
	color: var(--td-lime, #B5F23D);
}

.td-pal__c.is-note {
	color: var(--td-ink, #111);
	background: var(--td-lime, #B5F23D);
	border-radius: 4px;
	padding: 0 5px;
}

.td-pal__empty {
	padding: 10px;
	font-size: 13px;
	color: #8A8A84;
}

.td-pal__ft {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 14px;
	padding: 8px 16px;
	border-top: 1px solid #2E2E2E;
	font-size: 11px;
	color: #8A8A84;
}

.td-pal__n {
	margin-left: auto;
}

@media (max-width: 768px) {
	.td-pal {
		margin-top: 10px;
	}

	.td-pal__ft {
		display: none;
	}

	.td-pal__c {
		display: none;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.td-pal[open] .td-pal__box {
		animation: td-pal-in 0.16s ease-out;
	}

	@keyframes td-pal-in {
		from {
			transform: translateY(-8px);
			opacity: 0.6;
		}
	}
}


/* Live region for the "no title matches" hint: read aloud, not shown (the visible copy is aria-hidden). */
.td-pal__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Header search button (Blocksy search element, desktop header): ghost pill like the menu links,
   with the shortcut as a keycap. The kbd is printed by inc/search-palette.php; palette.js sets its
   text ("Ctrl K" / "⌘K") and adds .is-on. Before that it is invisible but keeps its width, so the
   menu doesn't shift. Hidden on touch devices and phones (no keyboard shortcut there). */
body.td-theme .ct-header .ct-header-search {
	--theme-icon-color: var(--td-ink);
	--theme-icon-hover-color: var(--td-ink);
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	min-width: 44px;
	padding: 0 12px;
	border-radius: 999px;
	color: var(--td-ink);
}

@media (hover: hover) {
	body.td-theme .ct-header .ct-header-search:hover {
		background: rgba(17, 17, 17, 0.08);
	}
}

body.td-theme .ct-header .ct-header-search:focus-visible {
	background: rgba(17, 17, 17, 0.08);
	outline: 2px solid var(--td-violet);
	outline-offset: 2px;
}

.ct-header .td-hint {
	visibility: hidden;
	min-width: 3.9em;
	text-align: center;
	font: 700 11px/1.7 var(--td-mono, ui-monospace, monospace);
	color: var(--td-ink, #111);
	background: #fff;
	border: 1.5px solid var(--td-ink, #111);
	border-bottom-width: 3px;
	border-radius: 6px;
	padding: 0 6px;
	white-space: nowrap;
}

.ct-header .td-hint.is-on {
	visibility: visible;
}

@media (hover: none), (pointer: coarse), (max-width: 768px) {
	.ct-header .td-hint {
		display: none;
	}
}

/* 1000-1099px (Blocksy desktop header, narrow): without the hint all five menu items fit. With it the menu
   overlapped the search item by 0.2px at 1024, so Blocksy's "More" collapse flipped between page loads. */
@media (max-width: 1099.98px) {
	.ct-header .td-hint {
		display: none;
	}
}

/* Easter egg: sparkle burst from the logo hat, and the "sudo make coffee" toast. */
.ct-header .site-logo-container {
	position: relative;
}

.td-burst i {
	position: absolute;
	left: 10%;
	top: 30%;
	width: 9px;
	height: 9px;
	background: var(--td-lime, #B5F23D);
	border: 1.5px solid var(--td-ink, #111);
	clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
	pointer-events: none;
	animation: td-burst 0.8s ease-out forwards;
}

@keyframes td-burst {
	to {
		transform: translate(var(--x), var(--y)) scale(0.4) rotate(180deg);
		opacity: 0;
	}
}

.td-toast {
	position: fixed;
	left: 50%;
	bottom: calc(24px + env(safe-area-inset-bottom));
	z-index: 1000;
	width: max-content;
	max-width: calc(100vw - 32px);
	padding: 10px 14px;
	background: var(--td-ink, #111);
	color: var(--td-lime, #B5F23D);
	border: 2px solid var(--td-ink, #111);
	border-radius: 12px;
	box-shadow: 4px 4px 0 var(--td-violet, #7B3DF0);
	font: 600 13px var(--td-mono, ui-monospace, monospace);
	transform: translate(-50%, 20px);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s, transform 0.2s;
}

.td-toast.is-on {
	transform: translate(-50%, 0);
	opacity: 1;
}

@media (max-width: 768px) {
	/* Above the phone tab bar. */
	.td-toast {
		bottom: calc(96px + env(safe-area-inset-bottom));
	}
}

@media (prefers-reduced-motion: reduce) {
	.td-toast {
		transition: none;
	}
}
