/**
 * Mobile/tablet search sheet, on the same navy and neutral tokens as navigation.
 * The fixed outer clip contains the offscreen animation in Safari too.
 *
 * The box reaches the bottom edge rather than being given a measured height.
 * It used to take `--myc-search-height`, computed from `visualViewport`, and on
 * iOS Safari that left the sheet ending part-way down the screen with the page
 * showing through the gap above the keyboard: `getBoundingClientRect()` and
 * `visualViewport.offsetTop` do not answer in the same coordinate space there,
 * so the subtraction was wrong by however far the keyboard had shifted the
 * visual viewport. Anchoring top and bottom asks the browser the question
 * instead of computing it, and the keyboard simply overlaps a surface that
 * already extends behind it. What the keyboard covers is still measured — as
 * `--myc-search-keyboard` — but it only pads the scrolling list, where being
 * wrong costs a few pixels of scroll rather than a hole in the page.
 */
.myc-search-sheet[hidden],
.myc-search-sheet [hidden] {
	display: none !important;
}

.myc-search-sheet {
	position: fixed;
	top: var(--myc-search-top, var(--myc-header-height));
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 1000;
	clip-path: inset(0);
	pointer-events: none;
	color: var(--ps-color-text);
	font-family: var(--ps-font-sans);
}

.myc-search-sheet-inner {
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 0;
	padding: var(--ps-space-5) max(var(--ps-space-4), env(safe-area-inset-right, 0px)) 0 max(var(--ps-space-4), env(safe-area-inset-left, 0px));
	/* No border of its own: the sheet opens flush against the header, whose
	   own bottom border already draws the line. Both were painting it, which
	   read as one 2px rule. */
	background: var(--ps-color-page);
	transform: translateY(100%);
	transition: transform 280ms cubic-bezier(.22, .61, .36, 1);
}

.myc-search-sheet.is-open {
	pointer-events: auto;
}

/* Background portals (for example the floating contact button) are inert
 * while searching; they must not paint above the sheet either. */
body.myc-search-is-open > [aria-hidden="true"] {
	visibility: hidden;
}

.myc-search-sheet.is-open .myc-search-sheet-inner {
	transform: translateY(0);
}

.myc-search-sheet-heading,
.myc-search-form,
.myc-search-content {
	width: 100%;
	max-width: 880px;
	margin-right: auto;
	margin-left: auto;
	box-sizing: border-box;
}

.myc-search-sheet-heading {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: space-between;
	gap: var(--ps-space-3);
	margin-bottom: var(--ps-space-5);
}

.myc-search-sheet-heading .myc-kicker {
	display: block;
	margin: 0 0 var(--ps-space-2);
	color: var(--ps-color-brand-600);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .09em;
}

.myc-search-sheet-heading h2 {
	margin: 0;
	font-size: clamp(23px, 3vw, 32px);
	font-weight: 650;
	letter-spacing: -.04em;
	line-height: 1.2;
}

.myc-search-close,
.myc-search-form button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 44px;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid transparent;
	border-radius: var(--ps-radius-sm);
	background: transparent;
	color: var(--ps-color-text);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.myc-search-sheet svg,
.myc-search-toggle svg {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.myc-search-close {
	border-color: var(--ps-color-border);
	background: var(--ps-color-surface);
}

.myc-search-form {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	padding: 4px;
	border: 1px solid var(--ps-color-border);
	border-radius: var(--ps-radius-md);
	background: var(--ps-color-surface);
	transition: border-color var(--ps-transition-fast);
}

.myc-search-form:focus-within {
	border-color: var(--ps-color-brand-600);
}

.myc-search-form input {
	min-width: 0;
	width: 100%;
	height: 44px;
	padding: 0 var(--ps-space-3);
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--ps-color-text);
	font: inherit;
	font-size: 16px;
	-webkit-appearance: none;
	appearance: none;
}

.myc-search-form input::-webkit-search-cancel-button {
	display: none;
	-webkit-appearance: none;
}

.myc-search-form input::placeholder {
	color: var(--ps-color-text-muted);
	opacity: 1;
	font-size: 14px;
}

.myc-search-form .myc-search-submit {
	background: var(--ps-color-brand-600);
	color: var(--ps-color-surface);
}

/* A single group border for the input, and a visible key focus on each action. */
.myc-app-body .myc-search-form input:focus,
.myc-app-body .myc-search-form input:focus-visible {
	outline: none;
	box-shadow: none;
}

.myc-app-body .myc-search-sheet button:focus-visible,
.myc-app-body .myc-search-sheet a:focus-visible {
	outline: 1px solid var(--ps-color-brand-600);
	outline-offset: 3px;
	box-shadow: none;
}

.myc-search-content {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior-y: contain;
	-webkit-overflow-scrolling: touch;
	/* The list is short and the sheet's own edges already say where it ends, so
	   the bar is one more thing over the results rather than a bearing. Same
	   pair as the filter chips and the category rows. */
	scrollbar-width: none;
	padding: 0 4px calc(var(--myc-search-keyboard, 0px) + max(var(--ps-space-5), env(safe-area-inset-bottom, 0px)));
}

.myc-search-content::-webkit-scrollbar {
	display: none;
}

.myc-search-status {
	margin: var(--ps-space-5) 0 var(--ps-space-4);
	color: var(--ps-color-text-muted);
	font-size: 13px;
	line-height: 1.6;
}

.myc-search-results {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--ps-space-3);
	margin: 0;
	padding: 0;
	list-style: none;
}

.myc-search-result a {
	display: flex;
	align-items: center;
	gap: var(--ps-space-3);
	min-height: 98px;
	height: 100%;
	padding: var(--ps-space-3);
	border: 1px solid var(--ps-color-border);
	border-radius: var(--ps-radius-md);
	background: var(--ps-color-surface);
	color: var(--ps-color-text);
	text-decoration: none;
	box-sizing: border-box;
	transition: border-color var(--ps-transition-fast);
}

.myc-search-result img {
	flex: 0 0 72px;
	width: 72px;
	height: 72px;
	border-radius: var(--ps-radius-sm);
	object-fit: contain;
	background: var(--ps-color-surface-subtle);
}

.myc-search-result-copy {
	display: grid;
	min-width: 0;
	flex: 1;
	gap: var(--ps-space-2);
}

.myc-search-result-name {
	font-size: 13px;
	font-weight: 600;
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.myc-search-result-price {
	color: var(--ps-color-brand-600);
	font-size: 13px;
	font-weight: 700;
}

.myc-search-result-price del {
	color: var(--ps-color-text-muted);
	font-weight: 400;
}

.myc-search-result-price ins {
	background: none;
	text-decoration: none;
}

.myc-search-result svg {
	width: 16px;
	height: 16px;
	flex: 0 0 16px;
	color: var(--ps-color-text-muted);
}

.myc-search-all {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--ps-space-4);
	min-height: 48px;
	margin-top: var(--ps-space-5);
	padding: var(--ps-space-3) var(--ps-space-4);
	border-radius: var(--ps-radius-sm);
	background: var(--ps-color-brand-600);
	color: var(--ps-color-surface);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	box-sizing: border-box;
}

@media (hover: hover) {
	.myc-search-result a:hover,
	.myc-search-close:hover {
		border-color: var(--ps-color-brand-600);
	}

	.myc-search-all:hover,
	.myc-search-form .myc-search-submit:hover {
		background: var(--ps-color-brand-700);
		color: var(--ps-color-surface);
	}
}

@media (min-width: 768px) and (max-width: 1080px) {
	.myc-search-sheet-inner {
		padding-top: var(--ps-space-6);
	}

	.myc-search-results {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 1080px) {
	.myc-header-mobile-tools {
		display: flex;
		grid-column: 1;
		grid-row: 1;
		align-items: center;
		width: 88px;
	}

	.myc-header-mobile-tools .myc-menu-toggle {
		flex: 0 0 44px;
	}

	.myc-search-toggle {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		flex: 0 0 44px;
		width: 44px;
		height: 44px;
		border: 1px solid transparent;
		border-radius: var(--ps-radius-sm);
		color: var(--ps-color-text);
		box-sizing: border-box;
		-webkit-tap-highlight-color: transparent;
	}

	/* The open state is carried by the colour alone. A tinted background reads
	   as a stray shadow behind the icon rather than as a state, and the sheet
	   below it is already unmistakable. */
	.myc-search-toggle[aria-expanded="true"] {
		color: var(--ps-color-brand-600);
	}

	.myc-app-body .myc-search-toggle:focus-visible {
		outline: 1px solid var(--ps-color-brand-600);
		outline-offset: -1px;
		box-shadow: none;
	}

	.myc-topbar .myc-brand {
		max-width: calc(100% - 224px);
	}

	body.myc-search-is-open .myc-topbar {
		position: fixed;
		top: var(--myc-search-header-top, 0px);
		right: 0;
		left: 0;
	}
}

@media (min-width: 1081px) {
	.myc-search-sheet {
		display: none;
	}
}

@media (max-height: 480px) {
	.myc-search-sheet-inner {
		padding-top: var(--ps-space-3);
	}

	.myc-search-sheet-heading {
		margin-bottom: var(--ps-space-3);
	}

	.myc-search-sheet-heading .myc-kicker {
		display: none;
	}
}

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