/**
 * Search panel: template-parts/header/search.php (not designed, built as the
 * mobile menu 2304:1268 and from the input and pill components). White panel
 * under the header, rounded bottom corners, page dimmed below; fixed, so the
 * page does not scroll while it is open (search.js sets --xat-search-top).
 * Field: a 56px cream pill with the search icon and a close button. Before
 * typing the categories as pills; results as rows with a 64px photo, name,
 * category and price, two columns from 1024; "See all results" under them.
 */

.search-panel {
	position: fixed;
	z-index: 3;
	top: var(--xat-search-top, 95px);
	right: 0;
	left: 0;
	box-sizing: border-box;
	max-height: calc(100dvh - var(--xat-search-top, 95px));
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: var(--space-md) 0 var(--space-lg);
	border-radius: 0 0 var(--radius-xl) var(--radius-xl);
	background: var(--color-white);
	box-shadow: var(--shadow-panel);
}

.search-panel[hidden],
.search-dim[hidden],
.search-panel__start[hidden],
.search-panel__empty[hidden] {
	display: none;
}

/* The page behind the open panel does not scroll. On <html> only, so the
 * sticky header stays (see mobile-menu.css). */
.is-search-open {
	overflow: hidden;
}

.search-dim {
	position: fixed;
	z-index: 2;
	top: var(--xat-search-top, 95px);
	right: 0;
	bottom: 0;
	left: 0;
	background: var(--color-dim);
}

.search-panel__inner {
	display: flex;
	flex-direction: column;
	gap: var(--space-md);
}

/* Field */

.search-panel__form {
	position: relative;
	display: flex;
	align-items: center;
	margin: 0;
}

.search-panel__icon {
	position: absolute;
	left: 20px;
	color: var(--color-ink);
	pointer-events: none;
}

.search-panel__input {
	box-sizing: border-box;
	width: 100%;
	height: 56px;
	margin: 0;
	padding: 0 60px 0 52px;
	border: 1px solid var(--color-line);
	border-radius: var(--radius-pill);
	background: var(--color-cream);
	color: var(--color-ink);
	font-family: var(--font-body);
	font-size: var(--text-field);
	line-height: var(--leading-body-m);
	appearance: none;
}

.search-panel__input::placeholder {
	color: var(--color-placeholder);
	opacity: 1;
}

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

.search-panel__close {
	position: absolute;
	right: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--radius-pill);
	background: var(--color-white);
	color: var(--color-ink);
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.search-panel__close:hover {
	background: var(--color-line);
}

/* Before typing: the categories. */

.search-panel__start {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.search-panel__eyebrow {
	margin: 0;
	color: var(--color-muted);
	font-size: var(--text-label-s);
	font-weight: var(--weight-semibold);
	letter-spacing: var(--tracking-label-s);
	line-height: var(--leading-label-s);
	text-transform: uppercase;
}

.search-panel__pills {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-xs);
	margin: 0;
	padding: 0;
	list-style: none;
}

.search-panel__pill {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	box-sizing: border-box;
	padding: 0 20px;
	border: 1px solid var(--color-line);
	border-radius: var(--radius-pill);
	color: var(--color-ink);
	font-size: var(--text-label-m);
	font-weight: var(--weight-semibold);
	line-height: var(--leading-label-m);
	text-decoration: none;
}

.search-panel__pill:hover {
	border-color: var(--color-ink);
}

/* Results */

.search-panel__results {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 4px var(--space-md);
	margin: 0;
	padding: 0;
	list-style: none;
}

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

.search-result {
	display: grid;
	grid-template-columns: 64px minmax(0, 1fr) auto;
	gap: var(--space-sm);
	align-items: center;
	padding: 8px;
	border-radius: var(--radius-md);
	color: var(--color-ink);
	text-decoration: none;
}

.search-result:hover,
.search-result:focus-visible {
	background: var(--color-cream);
}

.search-result__photo {
	width: 64px;
	height: 64px;
	border-radius: 12px;
	background: var(--color-photo);
	object-fit: cover;
}

.search-result__text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.search-result__name {
	overflow: hidden;
	font-size: var(--text-label-m);
	font-weight: var(--weight-semibold);
	line-height: var(--leading-label-m);
	text-overflow: ellipsis;
	white-space: nowrap;
}

.search-result__category {
	color: var(--color-muted);
	font-size: var(--text-body-s);
	line-height: var(--leading-body-s);
}

.search-result__price {
	font-size: var(--text-label-m);
	font-weight: var(--weight-semibold);
	line-height: var(--leading-label-m);
	white-space: nowrap;
}

.search-panel__empty {
	margin: 0;
	color: var(--color-muted);
}

.search-panel__all {
	display: inline-flex;
	gap: 6px;
	align-self: flex-start;
	align-items: center;
	min-height: 44px;
	color: var(--color-orange);
	font-size: var(--text-label-m);
	font-weight: var(--weight-semibold);
	line-height: var(--leading-label-m);
	text-decoration: none;
}

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

.search-panel__all:hover {
	color: var(--color-ink);
}

@media (min-width: 768px) {
	.search-panel {
		padding: var(--space-lg) 0 48px;
	}
}

@media (min-width: 1024px) {
	.search-panel__results {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* Opening: the panel slides down out of the header and fades in, the page
 * dims, then the field, the label and the category pills follow one after
 * the other. Results fade in the same way as they arrive. Closing (search.js
 * sets .is-closing, then hidden): the panel slides back up. Transform and
 * opacity only. */
.search-panel:not([hidden]) {
	animation: search-panel-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.search-dim:not([hidden]) {
	animation: search-fade-in 0.3s ease both;
}

.search-panel:not([hidden]) .search-panel__form,
.search-panel:not([hidden]) .search-panel__eyebrow,
.search-panel:not([hidden]) .search-panel__pills > li,
.search-panel__results > li,
.search-panel__empty:not([hidden]) {
	animation: search-item-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.search-panel:not([hidden]) .search-panel__form {
	animation-delay: 0.06s;
}

.search-panel:not([hidden]) .search-panel__eyebrow {
	animation-delay: 0.12s;
}

.search-panel:not([hidden]) .search-panel__pills > li:nth-child(1) {
	animation-delay: 0.16s;
}

.search-panel:not([hidden]) .search-panel__pills > li:nth-child(2) {
	animation-delay: 0.2s;
}

.search-panel:not([hidden]) .search-panel__pills > li:nth-child(3) {
	animation-delay: 0.24s;
}

.search-panel:not([hidden]) .search-panel__pills > li:nth-child(n+4) {
	animation-delay: 0.28s;
}

.search-panel__results > li {
	animation-duration: 0.3s;
}

.search-panel__results > li:nth-child(2) {
	animation-delay: 0.04s;
}

.search-panel__results > li:nth-child(3) {
	animation-delay: 0.08s;
}

.search-panel__results > li:nth-child(4) {
	animation-delay: 0.12s;
}

.search-panel__results > li:nth-child(5) {
	animation-delay: 0.16s;
}

.search-panel__results > li:nth-child(n+6) {
	animation-delay: 0.2s;
}

.search-panel.is-closing {
	animation: search-panel-out 0.2s ease both;
}

.search-dim.is-closing {
	animation: search-fade-out 0.2s ease both;
}

@keyframes search-panel-in {
	from {
		opacity: 0;
		transform: translateY(-16px);
	}
}

@keyframes search-panel-out {
	to {
		opacity: 0;
		transform: translateY(-12px);
	}
}

@keyframes search-item-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
}

@keyframes search-fade-in {
	from {
		opacity: 0;
	}
}

@keyframes search-fade-out {
	to {
		opacity: 0;
	}
}

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

	.search-panel,
	.search-dim,
	.search-panel *,
	.search-panel__results > li {
		animation: none !important;
	}
}
