/*
 * athena/product-story, variant "autocomplete" (Autocomplete feature page). Loaded only where
 * the demo is (kit.php enqueue_style()). Shared parts come from style.css: the panel, the
 * console rows of Search Merchandising (.athena-merch__rule…, switches, the phone rows with
 * "Setting details"), pill buttons (.athena-cat__option), the banner (.athena-cat__banner) and
 * the kit search box and example searches.
 *
 * The settings beside the store's search box on wide screens (sticky: the shorter side), above
 * it on phones. The dropdown shows the same sections in three layouts (simplified
 * illustrations): 1, products lead with the other sections beside them; 2, stacked; 3,
 * filters beside the products. It keeps a minimum height per layout, so typing seldom moves
 * what is under it. All text 0.875rem or larger.
 */

.athena-ac {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.75rem;
	align-content: start;
}

.athena-ac > *,
.athena-ac__shop > *,
.athena-ac__drop > *,
.athena-ac__group > * {
	min-width: 0;
	margin: 0 !important;
}

@media (min-width: 961px) {
	.athena-ac {
		grid-template-columns: 22rem minmax(0, 1fr);
		column-gap: 1.25rem;
	}

	.athena-ac__bar {
		grid-column: 1 / -1;
	}

	/* The settings are the shorter side: they stay in view beside the store, inside the panel. */
	.athena-ac__console {
		position: sticky;
		top: 6.5rem;
		align-self: start;
	}
}

.athena-story--ac .athena-story__tag,
.athena-story--ac .athena-story__note {
	font-size: 0.875rem;
}

.athena-ac :is(button, [role="option"]):focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

/* ── The settings ──────────────────────────────────────────── */

/* The layout buttons and the rotation's pause: controls only with JavaScript. */
.athena-ac__layouts,
.athena-ac__rotate {
	display: none;
}

/* The three layouts carry their names ("Products and suggestions"…), so they take a line of
   their own under the setting's name, wrapping as the width needs, at every width. */
.has-js .athena-ac__layouts {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
	grid-column: 1 / -1;
	grid-row: auto;
}

/* Wider screens: the pause sits beside the setting's name; the details take the row's full
   width under it (and under the layout buttons). */
@media (min-width: 601px) {
	.has-js .athena-ac__setting--rotate .athena-ac__rotate {
		grid-row: 1;
	}

	.has-js .athena-ac__setting:is(.athena-ac__setting--layout, .athena-ac__setting--rotate) .athena-merch__rule-body {
		grid-column: 1 / -1;
	}
}

.athena-ac__layout {
	justify-content: center;
	padding-inline: 0.8rem;
}

.athena-ac__layout[aria-pressed="true"],
.athena-ac__tab[aria-pressed="true"] {
	border-color: var(--wp--preset--color--contrast);
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

.has-js .athena-ac__rotate {
	position: relative;
	z-index: 1;
	display: inline-grid;
	grid-auto-flow: column;
	grid-column: 2;
	grid-row: 1 / span 2;
	align-items: center;
	gap: 0.35rem;
	min-width: 2.75rem;
	min-height: 2.75rem;
	padding: 0 0.85rem;
	border: 1px solid var(--athena-border-strong);
	border-radius: 999px;
	background: var(--wp--preset--color--raised);
	color: var(--wp--preset--color--contrast);
	font: inherit;
	font-size: 0.875rem;
	font-weight: 700;
	cursor: pointer;
}

.athena-ac__rotate:hover {
	border-color: var(--wp--preset--color--brand);
}

/* Pause or play: the icon and word of the shown mode; both words share a cell (no width jump). */
.athena-ac__rotate[data-mode="pause"] .athena-ac__rotate-play,
.athena-ac__rotate[data-mode="play"] .athena-ac__rotate-pause {
	display: none;
}

.athena-ac__rotate-label {
	display: grid;
}

.athena-ac__rotate-label > span {
	grid-area: 1 / 1;
}

.athena-ac__rotate[data-mode="pause"] [data-label="play"],
.athena-ac__rotate[data-mode="play"] [data-label="pause"] {
	visibility: hidden;
}

/* ── The shopper's side ─────────────────────────────────────── */

.athena-ac__shop {
	display: grid;
	gap: 0.6rem;
	align-content: start;
	scroll-margin-top: 6.5rem;
}

.athena-ac__shop:focus {
	outline: none;
}

/* What the dropdown shows: two lines kept, so a long line moves nothing. */
.athena-ac__count {
	min-height: 2.8em;
	font-weight: 650;
}

/* The dropdown under the box. */
.athena-ac__drop {
	display: grid;
	gap: 0.6rem;
	align-content: start;
	min-height: 30rem;
	padding: 0.85rem;
	border: 1px solid var(--athena-border-strong);
	border-radius: 16px;
	background: var(--wp--preset--color--surface);
	box-shadow: 0 10px 28px rgb(7 7 32 / 0.08);
}

.athena-ac__drop[data-layout="2"] {
	min-height: 36rem;
}

/* "Simplified illustration", on the dropdown itself. */
.athena-ac__tag {
	justify-self: start;
	padding: 0.1rem 0.6rem;
	border-radius: 999px;
	background: var(--wp--preset--color--accent-soft);
	color: var(--wp--preset--color--contrast);
	font-size: 0.875rem;
	font-weight: 700;
}

/* Search tabs (layouts 1 and 2). */
.athena-ac__tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.athena-ac__tabs[hidden],
.athena-ac__filters[hidden],
.athena-ac__banner[hidden],
.athena-ac__zero[hidden],
.athena-ac__list[hidden],
.athena-ac__group[hidden],
.athena-ac__option[hidden],
.athena-ac__product[hidden] {
	display: none;
}

.athena-ac__tab {
	min-height: 2.75rem;
	padding: 0.3rem 0.95rem;
	border: 1px solid var(--athena-border-strong);
	border-radius: 999px;
	background: var(--wp--preset--color--raised);
	color: var(--wp--preset--color--contrast);
	font: inherit;
	font-size: 0.875rem;
	font-weight: 700;
	cursor: pointer;
}

/* Layout 3: filters inside the box. */
.athena-ac__filters {
	display: grid;
	gap: 0.6rem;
	align-content: start;
}

.athena-ac__filter {
	display: grid;
	gap: 0.3rem;
}

.athena-ac__filter > * {
	margin: 0 !important;
}

.athena-ac__filter-label {
	color: var(--wp--preset--color--muted);
	font-size: 0.875rem;
	font-weight: 700;
}

.athena-ac__filter-options {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
}

.athena-ac__filter-option {
	white-space: normal;
}

/* The autocomplete banner, with the keyword it is attached to. */
.athena-ac__banner-tag {
	margin: 0 0 0.25rem !important;
	font-size: 0.875rem;
	font-weight: 700;
	opacity: 0.9;
}

/* The listbox: groups of options. */
.athena-ac__list {
	display: grid;
	gap: 0.75rem;
	align-content: start;
}

.athena-ac__group {
	display: grid;
	gap: 0.2rem;
	align-content: start;
}

.athena-ac__group-title {
	color: var(--wp--preset--color--muted);
	font-size: 0.875rem;
	font-weight: 750;
	letter-spacing: 0.02em;
}

.athena-ac__options {
	display: grid;
	gap: 0.15rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.athena-ac__option {
	display: flex;
	align-items: center;
	gap: 0.55rem;
	min-height: 2.75rem;
	padding: 0.25rem 0.6rem;
	border-radius: 10px;
	color: var(--wp--preset--color--contrast);
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.3;
	cursor: pointer;
}

.athena-ac__option:hover,
.athena-ac__option.is-active,
.athena-ac__product:hover,
.athena-ac__product.is-active {
	background: var(--wp--preset--color--raised);
	box-shadow: inset 0 0 0 1px var(--athena-border-strong);
}

.athena-ac__icon {
	flex: none;
	color: var(--wp--preset--color--muted);
}

/* The typed beginning of a suggestion; the completion is bolder. */
.athena-ac__text {
	font-weight: 750;
}

.athena-ac__typed {
	font-weight: 500;
}

/* Products: rows by default (photo, name, price), tiles in layouts 1 and 3 (below). */
.athena-ac__group--products .athena-ac__options {
	gap: 0.35rem;
}

.athena-ac__product {
	display: grid;
	grid-template-columns: 4.25rem minmax(0, 1fr);
	align-items: center;
	gap: 0.65rem;
	min-height: 2.75rem;
	padding: 0.3rem;
	border-radius: 12px;
	cursor: pointer;
}

.athena-ac__thumb {
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: 8px;
	background: var(--story-packshot);
}

.athena-ac__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.athena-ac__info {
	display: grid;
	gap: 0.1rem;
	min-width: 0;
}

.athena-ac__name {
	display: -webkit-box;
	overflow: hidden;
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.3;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
}

.athena-ac__price {
	font-size: 0.9375rem;
	font-weight: 650;
}

/* First Click Product Boost: the pinned product says so. */
.athena-ac__mark,
.athena-ac__pin-cue {
	display: none;
}

.athena-ac__product.is-pinned {
	box-shadow: inset 0 0 0 2px var(--wp--preset--color--accent);
}

.athena-ac__product.is-pinned .athena-ac__mark {
	display: inline-block;
	justify-self: start;
	padding: 0.05rem 0.55rem;
	border-radius: 999px;
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	font-size: 0.875rem;
	font-weight: 700;
}

.athena-ac__product.is-pinned .athena-ac__pin-cue {
	display: block;
	color: var(--athena-success);
	font-size: 0.875rem;
	font-weight: 750;
}

/* The zero-results message (Settings → Autocomplete), or a tab or filter that leaves nothing. */
.athena-ac__zero {
	padding: 0.85rem 1rem;
	border: 1px dashed var(--athena-border-strong);
	border-radius: 12px;
	color: var(--wp--preset--color--contrast);
	font-size: 0.9375rem;
	font-weight: 650;
	line-height: 1.4;
}

.athena-ac__zero.is-message {
	font-size: 1rem;
	font-weight: 700;
}

/* "Kept out by Excluded Categories: …": its line is always there. */
.athena-ac__cue {
	min-height: 1.4em;
	color: var(--wp--preset--color--muted);
	font-size: 0.875rem;
	font-weight: 650;
	line-height: 1.4;
}

/* ── The three layouts (wide enough for two columns) ───────── */

/* Before typing, every layout lists the sections side by side; a pinned product leads. */
@media (min-width: 601px) {
	.athena-ac__drop.is-empty .athena-ac__list {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.athena-ac__drop.is-empty .athena-ac__group--products {
		grid-column: 1 / -1;
	}

	.athena-ac__drop.is-empty .athena-ac__group--products .athena-ac__product {
		max-width: 26rem;
	}

	/* Layout 1: products lead (tiles), the suggestions and categories beside them. */
	.athena-ac__drop[data-layout="1"]:not(.is-empty) .athena-ac__list {
		grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
		grid-auto-flow: dense;
	}

	.athena-ac__drop[data-layout="1"]:not(.is-empty) .athena-ac__group--products {
		grid-column: 1;
		grid-row: 1 / span 3;
	}

	.athena-ac__drop[data-layout="1"]:not(.is-empty) :is(.athena-ac__group--suggest, .athena-ac__group--cats) {
		grid-column: 2;
	}

	/* Layout 3: the filters beside the products. */
	.athena-ac__drop[data-layout="3"]:not(.is-empty) {
		grid-template-columns: 12rem minmax(0, 1fr);
		column-gap: 1rem;
	}

	.athena-ac__drop[data-layout="3"]:not(.is-empty) > :not(.athena-ac__filters) {
		grid-column: 2;
	}

	.athena-ac__drop[data-layout="3"]:not(.is-empty) .athena-ac__filters {
		grid-column: 1;
		grid-row: 2 / span 4;
	}

	.athena-ac__drop[data-layout="3"]:not(.is-empty) .athena-ac__tag {
		grid-column: 1 / -1;
	}
}

/* Layouts 1 and 3: product tiles (photo over name). */
.athena-ac__drop:is([data-layout="1"], [data-layout="3"]):not(.is-empty) .athena-ac__group--products .athena-ac__options {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.athena-ac__drop:is([data-layout="1"], [data-layout="3"]):not(.is-empty) .athena-ac__product {
	grid-template-columns: minmax(0, 1fr);
	align-content: start;
	align-items: start;
}

/* While typing, suggestions first, then categories, then products (layouts 2 and phones). */
.athena-ac__drop:not(.is-empty) .athena-ac__group--suggest {
	order: 1;
}

.athena-ac__drop:not(.is-empty) .athena-ac__group--cats {
	order: 2;
}

.athena-ac__drop:not(.is-empty) .athena-ac__group--products {
	order: 3;
}

@media (min-width: 601px) {
	.athena-ac__drop[data-layout="1"]:not(.is-empty) .athena-ac__group--products {
		order: 0;
	}
}

/* ── Phones ─────────────────────────────────────────────────── */

@media (max-width: 600px) {
	.athena-ac {
		gap: 0.5rem;
	}

	.athena-ac__drop {
		gap: 0.45rem;
		min-height: 24rem;
		padding: 0.5rem 0.6rem 0.6rem;
	}

	.athena-ac__shop {
		gap: 0.45rem;
	}

	/* Four lines hold the longest settings message at this width (EN and SR), so switching a
	   layout never moves the shopper's side. */
	.athena-ac .athena-merch__changed {
		min-height: 5.6em;
	}

	/* The example searches speak for themselves: their label is for screen readers (as in the
	   Search Merchandising demo), so the dropdown starts higher. */
	.athena-ac__shop .athena-kit-picks__label {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.athena-ac__drop[data-layout="2"] {
		min-height: 28rem;
	}

	.athena-ac__count {
		font-size: 0.875rem;
	}

	/* The example searches: the buttons in one row. */
	.athena-ac__shop .athena-kit-picks {
		gap: 0.3rem;
	}

	.athena-ac__shop .athena-kit-picks__pick {
		flex: 1 1 0;
		justify-content: center;
		min-width: 0;
		padding-inline: 0.4rem;
	}

	/* Layout 3's filters: label above, options on one or two lines. */
	.athena-ac__filters {
		gap: 0.4rem;
	}

	/* The named buttons say what the one-line effect would: the row shows the setting's name
	   and, under it, the buttons; "Setting details" explains the layouts. */
	.has-js .athena-ac__setting--layout .athena-merch__effect {
		display: none;
	}

	.has-js .athena-ac__setting--layout .athena-merch__rule-name {
		grid-row: 1 / span 2;
		align-self: center;
	}

	/* The named layouts on two even rows: the longest name across the row, the other two
	   sharing the row under it (a name may wrap onto a second line on narrow phones). */
	.has-js .athena-ac__layouts {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.athena-ac .athena-ac__layout {
		padding-inline: 0.5rem;
		white-space: normal;
		text-align: center;
	}

	.athena-ac .athena-ac__layout:first-child {
		grid-column: 1 / -1;
	}

	.has-js .athena-ac__rotate {
		grid-column: 3;
		padding-inline: 0.6rem;
	}
}

/* Narrow phones: the longest message takes a fifth line. */
@media (max-width: 379px) {
	.athena-ac .athena-merch__changed {
		min-height: 7em;
	}
}
