/* ==========================================================================
   SEARCH MODE
   --------------------------------------------------------------------------
   The UX frame "Otsing" is a page — header, one large field on a rule given the
   middle of the screen, a short row of ways in, footer — and search is now that
   page. The header's search control swaps this section in for <main> and back
   (assets/js/header.js); nothing here floats over the page or covers the
   footer, and the section grows downward with its results like any page does.

   The frame is a wireframe, so it sets the structure and the proportions; the
   colours, faces and surfaces are the site's own. Where the frame's grey is
   mapped to a token, the comment beside it says which.
   ========================================================================== */

.search-mode {
	background-color: var(--color-cream);
}

/*
 * Fills the screen below the header, less a strip that lets the footer's top
 * edge show: the frame, at 1280 x 1024, gives the empty search its own ~685px
 * and then the footer. A field and five chips alone would otherwise leave the
 * footer hanging a few hundred pixels under a small cluster, which reads as a
 * page that failed to load rather than as a page about searching.
 *
 * --search-mode-top is where the section starts in the viewport, measured by
 * header.js as it opens — under the full header from the top of a page, under
 * the sticky bar alone from further down, and shifted by the admin bar when it
 * is present. The fallback is the full desktop header's height.
 */
.search-mode__inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	min-height: max(420px, calc(100svh - var(--search-mode-top, 122px) - var(--space-3xl)));
	/*
	 * The frame sets the field's first line 214px under an 1024px-tall
	 * header's foot — about a fifth of the screen. Tied to the viewport height
	 * so a short laptop does not push the field half-way down, and capped so a
	 * tall screen does not either.
	 */
	padding-block: clamp(var(--space-lg), 20vh, 216px) var(--space-3xl);
}

/* Arrives rather than appears. `hidden` itself cannot be animated, so the
   contents fade in from the frame the section is first displayed. */
@starting-style {

	.search-mode:not([hidden]) .search-mode__inner {
		opacity: 0;
		transform: translateY(8px);
	}
}

.search-mode__inner {
	transition:
		opacity 220ms linear,
		transform 260ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {

	.search-mode__inner {
		transition: none;
	}
}

/* --------------------------------------------------------------------------
   FIELD

   A rule, not a box. Measured off the frame at 138%: the rule is 770px of a
   1280 frame — 60% — the magnifier stands 12px in from where the rule starts
   with 31px before the first letter, and the words sit 25px above the rule.

   The previous field was a bordered, rounded input with its placeholder at 70%
   opacity: a form control, where the frame draws the page's headline.
   -------------------------------------------------------------------------- */

.search-mode__form {
	position: relative;
	display: flex;
	align-items: center;
	gap: 30px;
	width: 100%;
	max-width: 768px;
	padding-inline-start: 12px;
	padding-block-end: var(--space-md);
	/* The frame's #C4C7C7 hairline, in the site's own line colour — the same
	   rose the footer's social rings and the chips' neighbours are drawn in. */
	border-block-end: 1px solid var(--color-rose);
	transition: border-color var(--transition-base);
}

/* The rule is the field's focus state: primary, as every focused control on
   the site is. The input itself draws no outline or box of its own. */
.search-mode__form:focus-within {
	border-block-end-color: var(--color-primary);
}

.search-mode__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	color: var(--color-text);
}

/*
 * The frame's placeholder: cap height 26px at the 1280 frame, which is 40px
 * type, medium weight, in the frame's darkest text grey — mapped to the body
 * brown, the colour every piece of running text on the site is set in. The
 * previous 28px at 70% opacity was a hint; this is the line the page is about.
 *
 * The base form layer sets every text input by attribute, which outranks a
 * single class — qualified rather than made important.
 */
input[type='search'].search-mode__field {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background-color: transparent;
	font-family: var(--font-ui);
	font-weight: 500;
	font-size: clamp(24px, 1.6vw + 16px, 40px);
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: var(--color-ink);
	/* A placeholder longer than a phone's field ends in an ellipsis rather
	   than being cut through a letter. */
	text-overflow: ellipsis;
}

/* Full strength. Browsers dim placeholders by default (Firefox to 54%), which
   is exactly the washed-out grey the field used to have. */
input[type='search'].search-mode__field::placeholder {
	color: var(--color-text);
	opacity: 1;
}

/*
 * No box on focus. The form layer draws every focused field as a bordered box
 * with a tinted ring — which, on this field, is the rounded bubble the design
 * does not have. Its selector weighs (0,4,1); the form ancestor brings this one
 * level, and this sheet loads after the form layer, so it wins without
 * !important. The rule under the field turning primary is the focus state. The
 * outline stays transparent rather than none, so Windows High Contrast still
 * paints one.
 */
.search-mode__form input[type='search'].search-mode__field:focus,
.search-mode__form input[type='search'].search-mode__field:focus-visible {
	border: 0;
	box-shadow: none;
	outline: 2px solid transparent;
	outline-offset: 0;
	background-color: transparent;
}

input[type='search'].search-mode__field::-webkit-search-decoration,
input[type='search'].search-mode__field::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

/* Enter submits; the control is here for the keyboard and for a browser that
   needs one, and shows itself when it is focused. */
.search-mode__submit {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	border: 0;
	white-space: nowrap;
}

.search-mode__submit:focus-visible {
	position: static;
	width: auto;
	height: auto;
	margin: 0;
	padding: 8px 20px;
	overflow: visible;
	clip-path: none;
	border: 1px solid var(--color-primary);
	border-radius: var(--radius-pill);
	background-color: transparent;
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: 14px;
	line-height: 20px;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--color-primary);
	cursor: pointer;
}

/* --------------------------------------------------------------------------
   STATUS

   The count, or that nothing matched, said once in a sentence under the rule.
   Empty, it takes no room — collapsed rather than display:none, because a live
   region that is not rendered when its text arrives is not reliably announced.
   -------------------------------------------------------------------------- */

.search-mode__status {
	width: 100%;
	max-width: 768px;
	margin: var(--space-md) 0 0;
	font-family: var(--font-ui);
	font-weight: 400;
	font-size: 15px;
	line-height: 22px;
	color: var(--color-text);
	text-align: center;
}

.search-mode__status:empty {
	margin: 0;
}

/* --------------------------------------------------------------------------
   BODY — suggestions and results
   -------------------------------------------------------------------------- */

/* The frame puts the suggestions' label 100px under the rule. */
.search-mode__body {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-lg);
	width: 100%;
	max-width: 768px;
	margin-block-start: calc(var(--space-2xl) + var(--space-sm));
	transition: opacity 120ms linear;
}

/* A count or a no-match sentence already sits under the rule, so the body
   closes up beneath it. */
.search-mode__status:not(:empty) + .search-mode__body {
	margin-block-start: var(--space-lg);
}

/* The list dims while a request is in flight, rather than being torn down and
   rebuilt under the reader. */
.search-mode.is-loading .search-mode__body {
	opacity: 0.55;
}

.search-mode__suggestions {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-md);
	width: 100%;
}

/* A display declaration outranks the UA's [hidden], so the attribute is honoured
   explicitly on every part of the body that carries one. */
.search-mode__suggestions[hidden],
.search-mode__results[hidden],
.search-mode__all[hidden] {
	display: none;
}

.search-mode__suggestions-title {
	margin: 0;
	font-family: var(--font-ui);
	font-style: normal;
	font-weight: 600;
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--color-text);
}

.search-mode__chips {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 12px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.search-mode__chip {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 47px;
	padding: 12px 24px;
	border: 1px solid color-mix(in srgb, var(--color-text) 70%, transparent);
	border-radius: var(--radius-pill);
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: 14px;
	line-height: 21px;
	color: var(--color-ink);
	text-decoration: none;
	transition:
		border-color var(--transition-base),
		color var(--transition-base);
}

.search-mode__chip:hover,
.search-mode__chip:focus-visible {
	border-color: var(--color-primary);
	color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   RESULTS

   A list under the field, on the field's own measure, that runs as long as it
   needs to: the page grows and the footer moves down beneath it. No internal
   scroll box — that was the dropdown's constraint, and search is not a
   dropdown any more.
   -------------------------------------------------------------------------- */

.search-mode__results {
	width: 100%;
}

.search-mode__results-list {
	display: flex;
	flex-direction: column;
	width: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
	border-block-start: 1px solid var(--color-border);
}

.search-mode__result {
	display: flex;
	align-items: center;
	gap: var(--space-md);
	padding-block: var(--space-md);
	border-block-end: 1px solid var(--color-border);
	color: inherit;
	text-decoration: none;
}

/* A result without an image: the plate keeps its place and carries a type icon. */
.search-mode__result-media--icon {
	color: color-mix(in srgb, var(--color-text) 55%, transparent);
}

/* Portrait, as a bottle is: the catalogue's plate at list size. */
.search-mode__result-media {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 72px;
	aspect-ratio: 3 / 4;
	padding: 6px;
	overflow: hidden;
	border-radius: var(--radius-button);
	background-color: var(--color-surface-light);
	transition: transform var(--transition-base);
}

.search-mode__result-image {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.search-mode__result-body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
	flex: 1 1 auto;
}

.search-mode__result-label {
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: 11px;
	line-height: 16px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--color-text);
}

.search-mode__result-title {
	font-family: var(--font-heading);
	font-weight: 400;
	font-size: 20px;
	line-height: 1.3;
	color: var(--color-ink);
	transition: color var(--transition-base);
}

.search-mode__result-meta {
	font-family: var(--font-ui);
	font-weight: 400;
	font-size: 14px;
	line-height: 20px;
	color: var(--color-text);
}

/* The card's price: Inter 18/700 in ink, red only when actually reduced. */
.search-mode__result-price {
	flex-shrink: 0;
	font-family: var(--font-meta);
	font-weight: 700;
	font-size: 18px;
	line-height: 26px;
	color: var(--color-ink);
	white-space: nowrap;
}

/* WooCommerce wraps a reduced price in <del>/<ins>; the row shows what the
   product page shows rather than restyling it. */
.search-mode__result-price del {
	margin-inline-end: 6px;
	font-size: 13px;
	font-weight: 500;
	color: var(--color-text);
}

.search-mode__result-price ins {
	color: var(--color-primary-dark);
	text-decoration: none;
}

/*
 * A row's price may now carry three things — the sale mark, an alcohol-free
 * product's struck and sale price, the EEVA deposit note — and held on one
 * nowrap line they squeezed the name to a sliver and ran over it on phones.
 * Each amount stays whole; the deposit note takes its own line under them.
 */
.search-mode__result-price {
	max-width: 50%;
	white-space: normal;
	text-align: end;
}

.search-mode__result-price del,
.search-mode__result-price ins,
.search-mode__result-price .woocommerce-Price-amount {
	white-space: nowrap;
}

.search-mode__result-price .eeva-pant-note {
	display: block;
	font-family: var(--font-meta);
	font-weight: 500;
	font-size: 11px;
	line-height: 16px;
	color: var(--color-text-secondary);
}

/* The product cards' hover, on a row: the name reddens under the pointer and
   the plate lifts. Pointer devices only, as on the cards. */
@media (hover: hover) and (pointer: fine) {

	.search-mode__result:hover .search-mode__result-title {
		color: var(--color-primary);
	}

	.search-mode__result:hover .search-mode__result-media {
		transform: translateY(-2px);
	}
}

.search-mode__result:focus-visible .search-mode__result-title {
	color: var(--color-primary);
}

@media (prefers-reduced-motion: reduce) {

	.search-mode__result:hover .search-mode__result-media {
		transform: none;
	}
}

/* The one place search mode hands over to the results page, and only when there
   is more there than is shown here. */
.search-mode__all {
	padding-block-end: 5px;
	border-block-end: 1px solid var(--color-rose);
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: 14px;
	line-height: 20px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--color-ink);
	text-decoration: none;
	transition:
		color var(--transition-base),
		border-color var(--transition-base);
}

.search-mode__all:hover,
.search-mode__all:focus-visible {
	color: var(--color-primary);
	border-block-end-color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   THE CONTROL

   The header already says "this one" in primary red on hover. Open says it the
   same way and keeps saying it, so the icon reads as active for as long as the
   page is in search mode.
   -------------------------------------------------------------------------- */

.site-header__action--search[aria-expanded='true'] {
	color: var(--color-primary);
}

/* ==========================================================================
   <= 767px
   ========================================================================== */

@media (max-width: 767px) {

	/* A phone opens its keyboard over the lower half of the screen, so the
	   field sits near the top rather than a fifth of the way down. */
	.search-mode__inner {
		min-height: max(360px, calc(100svh - var(--search-mode-top, 122px) - var(--space-2xl)));
		padding-block: var(--space-xl) var(--space-2xl);
	}

	.search-mode__form {
		gap: 12px;
		padding-inline-start: 0;
		padding-block-end: var(--space-sm);
	}

	/*
	 * Sized so the whole placeholder fits the field. A focused field never
	 * shows a placeholder ellipsis in Chrome, and search mode focuses the field
	 * as it opens, so at 24px a 375 screen cut the sentence through a word
	 * ("…tootjaid" at "toot"). Measured, the sentence needs 353px at 24px and
	 * the field has 289 at 375 and 328 at 414: 5.2vw sets it at 19.5 and 21.5,
	 * still the largest type on the screen.
	 */
	input[type='search'].search-mode__field {
		font-size: clamp(19px, 5.2vw, 24px);
	}

	.search-mode__body {
		margin-block-start: var(--space-xl);
	}

	.search-mode__chip {
		min-height: 44px;
		padding: 10px 18px;
	}

	.search-mode__result {
		align-items: flex-start;
		gap: var(--space-sm);
	}

	.search-mode__result-media {
		width: 56px;
	}

	.search-mode__result-title {
		font-size: 17px;
	}

	.search-mode__result-price {
		font-size: 16px;
	}
}

/* "Laost otsas" under a sold-out result's price, on its own line (client 06.11.2026, inc/out-of-stock.php). */
.search-mode__result-stock {
	display: block;
	font-family: var(--font-ui);
	font-weight: 500;
	font-size: 12px;
	line-height: 16px;
	color: var(--color-text);
	text-align: end;
}
