/*
 * Search: the autosuggest panel, the matched concept row, the dead end.
 *
 * Every value here is measured from mockups 08, 09 and 10. Colours come from
 * tokens.css and nowhere else, which is acceptance criterion 3.
 *
 * The panel is the only place in the build that uses the third of the three
 * permitted shadows, 0 8px 28px rgba(35,37,32,0.14). It also carries the 4px
 * brass top rule the mockups put on a panel that has arrived rather than one
 * that was always there.
 */

/* ------------------------------------------------------------------ the field */

.fms-search {
	position: relative;
}

.fms-search__clear {
	position: absolute;
	top: 50%;
	right: 56px;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--fms-tap-min);
	height: var(--fms-tap-min);
	padding: 0;
	background: none;
	border: 0;
	border-radius: 50%;
	color: var(--fms-muted);
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
}

/*
 * Room for the clear button, but only while it is there. The resting field keeps
 * the 60px the submit button needs, so the placeholder, which is a whole
 * sentence in this design, is not truncated for a control that is not showing.
 * Without :has() the padding simply stays at 60 and long text slides under the
 * clear button, which is a smaller loss than a clipped placeholder.
 */
.fms-search:has(.fms-search__clear:not([hidden])) input {
	padding-right: 104px;
}

.fms-search__clear:hover {
	color: var(--fms-ink);
}

/* The magnifier was the one control on every page of the site with no hover
 * state at all. */
.fms-search__submit {
	transition: color 0.18s;
}

.fms-search__submit:hover {
	color: var(--fms-brass);
}

/* The field is drawn with a forest rule while its panel is open, which is how
 * mockup 08 shows it: 1.5px forest rather than the resting hairline. */
.fms-search.is-open .fms-search__input {
	border-color: var(--fms-forest);
	border-width: 1.5px;
}

/* --------------------------------------------------------------- the panel */

.fms-suggest {
	position: absolute;
	z-index: 60;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	overflow: hidden;
	max-height: min(76vh, 640px);
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--fms-white);
	border: 1px solid var(--fms-border);
	border-top: 4px solid var(--fms-brass);
	border-radius: 14px;
	box-shadow: var(--fms-shadow-panel, 0 8px 28px rgba(35, 37, 32, 0.14));
	text-align: left;
}

.fms-suggest__empty {
	padding: 26px 26px 28px;
}

.fms-suggest__eyebrow {
	margin: 0 0 14px;
	color: var(--fms-brass);
	font-size: 10.5px;
}

.fms-suggest__prompt {
	margin: 0 0 18px;
	color: var(--fms-muted);
	font-size: 14.5px;
	line-height: 1.55;
}

.fms-suggest__pills {
	display: flex;
	flex-wrap: wrap;
	gap: 9px;
}

.fms-suggest__rule {
	height: 1px;
	margin: 24px 0 20px;
	background: var(--fms-border);
}

.fms-suggest__recent-list {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.fms-search-pill {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 10px 16px 9px;
	background: var(--fms-cream);
	border: 1px solid var(--fms-border);
	border-radius: 32px;
	color: var(--fms-ink);
	font-weight: 500;
	font-size: 13.5px;
	line-height: 1.2;
	text-decoration: none;
}

.fms-search-pill svg {
	flex: none;
	color: var(--fms-muted);
}

.fms-search-pill--brass {
	background: var(--fms-white);
	padding: 12px 20px 11px;
}

.fms-search-pill--brass svg {
	color: var(--fms-brass);
}

.fms-search-pill:hover {
	border-color: var(--fms-forest);
	color: var(--fms-ink);
}

/* ------------------------------------------------------- the grouped results */

.fms-suggest__line {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 14px 24px;
	background: var(--fms-sage);
}

.fms-suggest__line svg {
	flex: none;
	margin-top: 1px;
	color: var(--fms-brass);
}

.fms-suggest__line p {
	margin: 0;
	color: var(--fms-ink);
	font-size: 13.5px;
	line-height: 1.5;
}

.fms-suggest__line strong {
	font-weight: 500;
}

.fms-suggest__group {
	border-bottom: 1px solid var(--fms-border);
}

.fms-suggest__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px 24px 8px;
}

.fms-suggest__label {
	margin: 0;
	color: var(--fms-brass);
	font-weight: 700;
	font-size: 10.5px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.fms-suggest__count {
	color: var(--fms-muted);
	font-size: 12px;
}

.fms-suggest__row {
	display: flex;
	align-items: center;
	gap: 14px;
	min-height: 56px;
	padding: 11px 24px;
	color: var(--fms-ink);
	text-decoration: none;
}

.fms-suggest__row:hover,
.fms-suggest__row:focus-visible,
.fms-suggest__row.is-active {
	background: var(--fms-cream);
	color: var(--fms-ink);
}

.fms-suggest__thumb {
	flex: none;
	display: block;
	width: 44px;
	height: 44px;
	background-color: var(--fms-white);
	background-position: center;
	background-repeat: no-repeat;
	background-size: 72%;
	border: 1px solid var(--fms-border);
	border-radius: 8px;
}

.fms-suggest__mark {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	background: var(--fms-sage);
	border-radius: 50%;
}

.fms-suggest__mark svg {
	color: var(--fms-forest);
}

.fms-suggest__mark--ingredient svg {
	color: var(--fms-brass);
}

.fms-suggest__mark--brand svg {
	color: var(--fms-muted);
}

.fms-suggest__text {
	flex: 1;
	min-width: 0;
}

.fms-suggest__title {
	display: block;
	overflow: hidden;
	color: var(--fms-ink);
	font-weight: 500;
	font-size: 15px;
	line-height: 1.35;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.fms-suggest__meta {
	display: block;
	margin-top: 2px;
	overflow: hidden;
	color: var(--fms-muted);
	font-size: 13px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.fms-suggest__price {
	flex: none;
	color: var(--fms-brass);
	font-weight: 500;
	font-size: 14.5px;
}

.fms-suggest__chip {
	flex: none;
	padding: 5px 11px 4px;
	background: var(--fms-sage);
	border-radius: 32px;
	color: var(--fms-forest);
	font-weight: 700;
	font-size: 9.5px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.fms-suggest__all {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-height: 56px;
	padding: 18px 24px;
	background: var(--fms-forest);
	color: var(--fms-white);
	font-weight: 500;
	font-size: 14.5px;
	text-decoration: none;
}

.fms-suggest__all span:last-child {
	color: var(--fms-brass);
}

.fms-suggest__all:hover {
	color: var(--fms-white);
}

.fms-suggest__none {
	padding: 24px 24px 26px;
}

.fms-suggest__none p {
	margin: 0 0 14px;
	color: var(--fms-ink);
	font-size: 14.5px;
	line-height: 1.55;
}

.fms-suggest__none p:last-child {
	margin-bottom: 0;
}

/* ------------------------------------------------- the matched concept row */

.fms-matched {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

.fms-matched__label {
	color: var(--fms-muted);
	font-weight: 700;
	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.fms-matched__chip {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	min-height: 44px;
	padding: 9px 15px 8px;
	background: var(--fms-white);
	border: 1px solid var(--fms-border);
	border-radius: 32px;
	text-decoration: none;
}

.fms-matched__chip:hover {
	border-color: var(--fms-forest);
}

.fms-matched__kind {
	color: var(--fms-brass);
	font-weight: 700;
	font-size: 9.5px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.fms-matched__name {
	color: var(--fms-ink);
	font-weight: 500;
	font-size: 13.5px;
}

.fms-matched__x {
	color: var(--fms-muted);
	font-size: 13px;
	line-height: 1;
}

/* The card's matched line, which only the search results use. */
.fms-pcard__note {
	display: block;
	margin: 0 0 12px;
	color: var(--fms-muted);
	font-size: 13.5px;
	line-height: 1.5;
}

/* ------------------------------------------------------------ the dead end */

.fms-dead .fms-container {
	padding-top: 72px;
	padding-bottom: 88px;
}

.fms-dead__head {
	max-width: 770px;
}

.fms-dead__head h1 {
	margin: 0 0 18px;
}

.fms-dead__head .fms-lead {
	margin: 0 0 22px;
}

.fms-dead__spellings {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.fms-dead__spelling {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 48px;
	padding: 14px 24px 12px;
	background: var(--fms-white);
	border: 1px solid var(--fms-border);
	border-radius: 32px;
	text-decoration: none;
}

.fms-dead__spelling--first {
	background: var(--fms-forest);
	border-color: var(--fms-forest);
}

.fms-dead__spelling-lead {
	color: var(--fms-muted);
	font-size: 14.5px;
}

.fms-dead__spelling--first .fms-dead__spelling-lead {
	color: rgba(247, 244, 237, 0.8);
}

.fms-dead__spelling-word {
	color: var(--fms-ink);
	font-weight: 500;
	font-size: 15px;
}

.fms-dead__spelling--first .fms-dead__spelling-word {
	color: var(--fms-brass);
}

.fms-dead__routes {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 24px;
	margin-top: 52px;
}

.fms-dead__route {
	display: flex;
	flex-direction: column;
	padding: 32px 30px;
	border-top: 4px solid var(--fms-brass);
}

.fms-dead__icon {
	display: block;
	margin-bottom: 18px;
	color: var(--fms-brass);
}

.fms-dead__route h2 {
	margin: 0 0 10px;
	font-size: 21px;
	line-height: 1.25;
}

.fms-dead__route p {
	margin: 0 0 20px;
	color: var(--fms-muted);
	font-size: 15.5px;
	line-height: 1.55;
}

.fms-dead__route a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: var(--fms-tap-min);
	margin-top: auto;
	color: var(--fms-brass);
	font-weight: 500;
	font-size: 14.5px;
	text-decoration: none;
}

.fms-dead__route a:hover {
	color: var(--fms-brass);
	text-decoration: underline;
}

.fms-dead__popular {
	margin-top: 40px;
	padding: 40px 42px;
	background: var(--fms-sage);
	border: 1px solid var(--fms-border);
	border-radius: 14px;
}

.fms-dead__popular h2 {
	margin: 0 0 8px;
	font-size: 26px;
	line-height: 1.2;
}

.fms-dead__popular p {
	margin: 0 0 24px;
	max-width: 770px;
	color: var(--fms-ink);
	font-size: 16px;
	line-height: 1.55;
}

.fms-dead__pills {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

/* ---------------------------------------------------------------- mobile */

@media (max-width: 900px) {
	.fms-dead__routes {
		grid-template-columns: minmax(0, 1fr);
		margin-top: 40px;
	}
}

@media (max-width: 600px) {
	.fms-dead .fms-container {
		padding-top: 52px;
		padding-bottom: 52px;
	}

	.fms-dead__spellings {
		flex-direction: column;
		align-items: stretch;
	}

	.fms-dead__spelling {
		justify-content: flex-start;
		min-height: 50px;
		padding: 15px 22px 13px;
	}

	.fms-dead__spelling-lead {
		font-size: 14px;
	}

	.fms-dead__spelling-word {
		font-size: 14.5px;
	}

	.fms-dead__route {
		padding: 28px 24px;
	}

	.fms-dead__popular {
		padding: 28px 24px;
	}

	.fms-dead__popular h2 {
		font-size: 22px;
	}

	/*
	 * The panel is the width of the viewport on mobile, not the width of the
	 * field, because the field sits inside a 24px gutter and a 342px panel
	 * cannot hold a 56px thumbnail, a title, a price and a chip.
	 */
	.fms-suggest {
		top: calc(100% + 6px);
		max-height: min(70vh, 520px);
	}

	.fms-suggest__empty {
		padding: 22px 20px 24px;
	}

	.fms-suggest__row {
		gap: 12px;
		padding: 12px 20px;
	}

	.fms-suggest__head {
		padding: 16px 20px 6px;
	}

	.fms-suggest__label {
		font-size: 10px;
	}

	.fms-suggest__count {
		font-size: 11.5px;
	}

	.fms-suggest__title {
		font-size: 14.5px;
	}

	.fms-suggest__meta {
		font-size: 12.5px;
	}

	.fms-suggest__price {
		font-size: 14px;
	}

	.fms-suggest__line {
		padding: 14px 20px;
	}

	.fms-suggest__all {
		padding: 18px 20px;
		font-size: 14px;
	}

	/*
	 * The chip is the first thing to go when the row is 342px wide: the title,
	 * the meta line and the price all carry more information than a repeat of
	 * the group heading immediately above it. Mockup 08's own mobile artboard
	 * drops it too.
	 */
	.fms-suggest__chip {
		display: none;
	}

	.fms-matched {
		gap: 8px;
	}

	.fms-matched__label {
		width: 100%;
	}
}
