/**
 * Team Moon — search popup: a sheet from the bottom on phones, a window in the middle on computers.
 */

.tm-mnb-search .tm-mnb__svg {
	display: block;
	width: 24px;
	height: 24px;
}

.tm-mnb-search {
	--ink: #09122d;
	--gold: var(--tm-mnb-accent, #c8a45c);
	--soft: #f5f1ea;
	--line: rgba(9, 18, 45, 0.08);
	--muted: #7c7a73;
	position: fixed;
	inset: 0;
	z-index: 100000;
	font-family: inherit;
}

.tm-mnb-search[hidden] {
	display: none;
}

html.tm-mnb-search-open,
html.tm-mnb-search-open body {
	overflow: hidden;
}

.tm-mnb-search__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(9, 18, 45, 0.45);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
	opacity: 0;
	transition: opacity 0.3s;
}

.tm-mnb-search__sheet {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	height: min(88vh, 760px);
	height: min(88dvh, 760px);
	padding-bottom: env(safe-area-inset-bottom, 0px);
	background: #fff;
	border-radius: 26px 26px 0 0;
	box-shadow: 0 -12px 40px rgba(9, 18, 45, 0.18);
	transform: translateY(100%);
	transition: transform 0.38s cubic-bezier(0.25, 0.9, 0.3, 1);
	color: var(--ink);
}

.tm-mnb-search.is-open .tm-mnb-search__backdrop {
	opacity: 1;
}

.tm-mnb-search.is-open .tm-mnb-search__sheet {
	transform: translateY(0);
}

.tm-mnb-search__grab {
	display: block;
	width: 42px;
	height: 5px;
	margin: 10px auto 4px;
	border-radius: 3px;
	background: rgba(9, 18, 45, 0.15);
}

.tm-mnb-search__form {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 8px 16px 12px;
	border-bottom: 1px solid var(--line);
}

.tm-mnb-search__box {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 8px;
	height: 50px;
	margin: 0;
	padding: 0 14px;
	border-radius: 16px;
	background: var(--soft);
	border: 1.5px solid transparent;
	color: var(--muted);
	transition: border-color 0.2s, background-color 0.2s;
}

.tm-mnb-search__box:focus-within {
	border-color: var(--gold);
	background: #fff;
	color: var(--ink);
}

.tm-mnb-search__box .tm-mnb__svg {
	flex: none;
	width: 20px;
	height: 20px;
}

.tm-mnb-search .tm-mnb-search__input {
	flex: 1;
	min-width: 0;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0 !important;
	outline: 0;
	box-shadow: none !important;
	background: transparent !important;
	color: var(--ink);
	font: inherit;
	font-size: 16px; /* 16px stops iPhone zooming in */
	-webkit-appearance: none;
	appearance: none;
}

.tm-mnb-search__input::-webkit-search-cancel-button,
.tm-mnb-search__input::-webkit-search-decoration {
	-webkit-appearance: none;
}

.tm-mnb-search .tm-mnb-search__clear {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #ef4444;
	box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
	color: #fff;
	cursor: pointer;
	transition: background-color 0.2s, transform 0.25s;
	animation: tm-mnb-pop 0.22s ease-out;
}

.tm-mnb-search .tm-mnb-search__clear:hover,
.tm-mnb-search .tm-mnb-search__clear:focus-visible {
	background: #dc2626;
	transform: rotate(90deg);
	outline: none;
}

.tm-mnb-search .tm-mnb-search__clear:active {
	transform: rotate(90deg) scale(0.9);
}

.tm-mnb-search__clear svg {
	display: block;
	width: 14px;
	height: 14px;
	stroke: #fff;
}

.tm-mnb-search__clear[hidden] {
	display: none !important;
}

@keyframes tm-mnb-pop {
	from { transform: scale(0.4); opacity: 0; }
	to { transform: scale(1); opacity: 1; }
}

.tm-mnb-search .tm-mnb-search__cancel {
	flex: none;
	min-height: 0;
	height: auto;
	padding: 8px 2px;
	border: 0;
	background: none;
	box-shadow: none;
	color: var(--ink);
	font: inherit;
	font-size: 15px;
	font-weight: 500;
	text-transform: none;
	cursor: pointer;
}

.tm-mnb-search__body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 16px 16px 24px;
}

.tm-mnb-search__title {
	margin: 0 0 12px;
	color: var(--muted);
	font-size: 13px;
	font-weight: 500;
}

.tm-mnb-search__cats {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.tm-mnb-search__cat {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 40px;
	padding: 0 14px 0 6px;
	border: 1px solid var(--line);
	border-radius: 20px;
	background: #fff;
	color: var(--ink) !important;
	font-size: 14px;
	font-weight: 500;
	text-decoration: none !important;
	transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}

.tm-mnb-search__cat:active {
	transform: scale(0.96);
	background: var(--soft);
}

.tm-mnb-search__cat img {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	background: var(--soft);
}

.tm-mnb-search__cat:not(:has(img)) {
	padding-inline-start: 14px;
}

.tm-mnb-search__sec + .tm-mnb-search__sec {
	margin-top: 22px;
}

.tm-mnb-search__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 6px;
}

.tm-mnb-search__head .tm-mnb-search__title {
	margin: 0;
}

.tm-mnb-search .tm-mnb-search__clear-all {
	min-height: 0;
	height: auto;
	padding: 4px 0;
	border: 0;
	background: none;
	box-shadow: none;
	color: #ef4444;
	font: inherit;
	font-size: 13px;
	font-weight: 500;
	text-transform: none;
	cursor: pointer;
}

.tm-mnb-search__recent-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tm-mnb-search__recent-list li {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	border-bottom: 1px solid var(--line);
	animation: tm-mnb-in 0.3s ease-out both;
	transition: opacity 0.2s, transform 0.2s;
}

.tm-mnb-search__recent-list li.is-gone {
	opacity: 0;
	transform: translateX(var(--tm-mnb-out, -24px));
}

.tm-mnb-search .tm-mnb-search__recent-q {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 0;
	justify-content: flex-start;
	height: 46px;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
	color: var(--ink);
	font: inherit;
	font-size: 15px;
	font-weight: 400;
	text-align: start;
	text-transform: none;
	cursor: pointer;
}

.tm-mnb-search__recent-q span {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.tm-mnb-search__recent-q .tm-mnb__svg {
	flex: none;
	width: 18px;
	height: 18px;
	color: var(--muted);
}

.tm-mnb-search .tm-mnb-search__recent-x {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	min-height: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	box-shadow: none;
	color: var(--muted);
	cursor: pointer;
	transition: background-color 0.2s, color 0.2s;
}

.tm-mnb-search .tm-mnb-search__recent-x:hover,
.tm-mnb-search .tm-mnb-search__recent-x:active {
	background: rgba(239, 68, 68, 0.1);
	color: #ef4444;
}

.tm-mnb-search__recent-x svg {
	width: 14px;
	height: 14px;
}

.tm-mnb-search__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.tm-mnb-search .tm-mnb-search__chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 0;
	height: 36px;
	padding: 0 14px;
	border: 1px solid var(--line);
	border-radius: 18px;
	background: #fff;
	box-shadow: none;
	color: var(--ink);
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	text-transform: none;
	cursor: pointer;
	transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}

.tm-mnb-search .tm-mnb-search__chip:hover {
	border-color: var(--gold);
}

.tm-mnb-search .tm-mnb-search__chip:active {
	transform: scale(0.96);
	background: var(--soft);
}

.tm-mnb-search__chip .tm-mnb__svg {
	width: 15px;
	height: 15px;
	color: var(--gold);
}

.tm-mnb-search__chip mark {
	padding: 0;
	background: none;
	color: inherit;
	font-weight: 700;
}

.tm-mnb-search__suggest {
	margin-bottom: 14px;
}

.tm-mnb-search__suggest[hidden] {
	display: none;
}

.tm-mnb-search__suggest .tm-mnb-search__chips {
	flex-wrap: nowrap;
	overflow-x: auto;
	margin: 0 -16px;
	padding: 0 16px 2px;
	scrollbar-width: none;
}

.tm-mnb-search__suggest .tm-mnb-search__chips::-webkit-scrollbar {
	display: none;
}

.tm-mnb-search__suggest .tm-mnb-search__chip {
	flex: none;
	background: var(--soft);
	border-color: transparent;
}

.tm-mnb-search.has-query .tm-mnb-search__start {
	display: none;
}

.tm-mnb-search__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tm-mnb-search__list li {
	margin: 0;
	padding: 0;
	animation: tm-mnb-in 0.35s both;
	animation-delay: calc(var(--i, 0) * 40ms);
}

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

.tm-mnb-search__item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 0;
	border-bottom: 1px solid var(--line);
	color: var(--ink) !important;
	text-decoration: none !important;
}

.tm-mnb-search__img {
	flex: none;
	width: 60px;
	height: 60px;
	border-radius: 14px;
	object-fit: cover;
	background: var(--soft);
}

.tm-mnb-search__txt {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.tm-mnb-search__name {
	display: -webkit-box;
	overflow: hidden;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.45;
}

.tm-mnb-search__price {
	font-size: 14px;
	font-weight: 700;
	color: var(--ink);
}

.tm-mnb-search__price del {
	margin-inline-end: 6px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 400;
	opacity: 1;
}

.tm-mnb-search__price ins {
	text-decoration: none;
}

.tm-mnb-search__price svg,
.tm-mnb-search__price img {
	height: 0.9em;
	width: auto;
	vertical-align: -0.05em;
}

.tm-mnb-search__out {
	align-self: flex-start;
	padding: 1px 8px;
	border-radius: 8px;
	background: #fdecec;
	color: #b42318;
	font-size: 11px;
	font-weight: 500;
}

.tm-mnb-search__item.is-skel .tm-mnb-search__img,
.tm-mnb-search__item.is-skel i {
	background: linear-gradient(90deg, #f2eee6 25%, #faf8f3 50%, #f2eee6 75%);
	background-size: 200% 100%;
	animation: tm-mnb-shine 1.1s linear infinite;
}

.tm-mnb-search__item.is-skel i {
	display: block;
	height: 12px;
	width: 80%;
	border-radius: 6px;
}

.tm-mnb-search__item.is-skel i + i {
	width: 40%;
}

@keyframes tm-mnb-shine {
	to { background-position: -200% 0; }
}

.tm-mnb-search__all {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 50px;
	margin-top: 16px;
	border-radius: 16px;
	background: var(--ink);
	color: #fff !important;
	font-size: 15px;
	font-weight: 500;
	text-decoration: none !important;
}

.tm-mnb-search__close {
	margin: 0 0 12px;
	padding: 10px 14px;
	border-radius: 12px;
	background: var(--soft);
	color: var(--ink);
	font-size: 13px;
	line-height: 1.6;
}

.tm-mnb-search__empty {
	margin: 40px 0;
	color: var(--muted);
	font-size: 14px;
	text-align: center;
}

.tm-mnb-search__empty.is-short {
	margin: 8px 0 22px;
}

@media (prefers-reduced-motion: reduce) {
	.tm-mnb-search *,
	.tm-mnb-search__sheet {
		transition: none !important;
		animation: none !important;
	}
}

/* ---------- Computer: a window in the middle of the screen ---------- */
@media (min-width: 769px) {
	.tm-mnb-search {
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 32px;
	}

	.tm-mnb-search__sheet {
		position: relative;
		inset: auto;
		width: min(760px, 100%);
		/* Fixed height: the window doesn't jump while results load. */
		height: min(620px, calc(100vh - 64px));
		height: min(620px, calc(100dvh - 64px));
		max-height: none;
		padding-bottom: 0;
		border-radius: 24px;
		box-shadow: 0 32px 90px rgba(9, 18, 45, 0.3), 0 0 0 1px rgba(9, 18, 45, 0.04);
		overflow: hidden;
		opacity: 0;
		transform: translateY(16px) scale(0.97);
		transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.22s;
	}

	.tm-mnb-search.is-open .tm-mnb-search__sheet {
		opacity: 1;
		transform: none;
	}

	.tm-mnb-search__grab {
		display: none;
	}

	.tm-mnb-search__form {
		gap: 12px;
		padding: 22px 24px 18px;
	}

	.tm-mnb-search__box {
		height: 56px;
		padding: 0 18px;
		border-radius: 16px;
	}

	.tm-mnb-search .tm-mnb-search__input {
		font-size: 17px;
	}

	.tm-mnb-search .tm-mnb-search__cancel {
		height: 56px;
		padding: 0 18px;
		border-radius: 16px;
		background: var(--soft);
		font-size: 15px;
		transition: background-color 0.2s, color 0.2s;
	}

	.tm-mnb-search .tm-mnb-search__cancel:hover {
		background: rgba(239, 68, 68, 0.1);
		color: #ef4444;
	}

	.tm-mnb-search__body {
		padding: 22px 24px 28px;
	}

	.tm-mnb-search__list {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: 18px;
	}
}

/* The header search opens the popup: hide the theme's own dropdown. */
body.tm-search-popup-header .wd-header-search .wd-dropdown-search,
body.tm-search-popup-header .wd-header-search .wd-search-dropdown {
	display: none !important;
}
