/*
 * athena/product-story, variant "typo": Typo tolerance and zero results
 * (/features/typo-tolerance-zero-results/). Loaded only where the demo is (kit.php
 * enqueue_style()). Shared parts come from style.css: the panel, the kit search box and
 * example searches, pill buttons (.athena-cat__option) and the result rows (.athena-merch__*).
 *
 * The same search two ways: a plain keyword match beside Athena on wide screens; on phones
 * and tablets the two columns share one cell and a two-button switch shows one of them
 * (only with JavaScript; without it they are stacked). Each column's list keeps the height
 * of one page (--typo-rows rows); the dead end and the product page take its place in the
 * same cell; the hint, the counts and the "Understood as …" cue keep their lines. Nothing
 * moves when a search changes. All text 0.875rem or larger.
 */

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

.athena-typo > *,
.athena-typo__search > *,
.athena-typo__col > *,
.athena-typo__page > *,
.athena-typo__dead > * {
	min-width: 0;
	margin: 0 !important;
}

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

.athena-typo :is(button):focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

/* The search box and the example searches under it. */
.athena-typo__search {
	display: grid;
	gap: 0.6rem;
}

@media (min-width: 961px) {
	.athena-typo__search .athena-kit-search {
		max-width: 36rem;
	}
}

/* The example searches' row: wraps on wide screens; on phones one row that scrolls sideways
   under its label (below). */
.athena-typo__pick-row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

/* An example search: what it shows ("Typo"), then the words. */
.athena-typo__tag {
	font-weight: 600;
}

.athena-typo__words {
	font-weight: 750;
}

/* What to look at for this search: lines kept for the longest hint. */
.athena-typo__hint {
	min-height: 2.8em;
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.4;
}

/* Phones and tablets: the switch between the two columns (only with JavaScript). */
.athena-typo__views {
	display: none;
}

.athena-typo__view {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-height: 2.75rem;
	padding: 0.3rem 0.75rem;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--wp--preset--color--contrast);
	font: inherit;
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
}

.athena-typo__view:hover {
	background: var(--wp--preset--color--raised);
}

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

/* Each column's count beside its button. */
.athena-typo__badge {
	display: inline-grid;
	place-items: center;
	min-width: 1.6rem;
	height: 1.6rem;
	padding: 0 0.4rem;
	border-radius: 999px;
	background: var(--wp--preset--color--accent-soft);
	color: var(--wp--preset--color--contrast);
	font-size: 0.875rem;
	font-variant-numeric: tabular-nums;
}

.athena-typo__view[aria-pressed="true"] .athena-typo__badge {
	background: color-mix(in srgb, var(--wp--preset--color--base) 22%, transparent);
	color: inherit;
}

/* The two columns: side by side on wide screens. */
.athena-typo__compare {
	--typo-rows: 4;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1rem;
	align-items: start;
}

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

.athena-typo__col {
	display: grid;
	gap: 0.5rem;
	align-content: start;
	padding: 1rem;
	border: 1px solid var(--athena-border-strong);
	border-radius: 16px;
	background: var(--wp--preset--color--surface);
}

.athena-typo__col--athena {
	border-color: var(--wp--preset--color--accent);
	box-shadow: inset 0 0 0 1px var(--wp--preset--color--accent);
}

.athena-typo__head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.15rem 1rem;
}

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

.athena-typo__name {
	font-size: 1rem;
	font-weight: 800;
	line-height: 1.3;
}

.athena-typo__count {
	min-height: 1.4em;
	font-size: 0.9375rem;
	font-weight: 750;
	line-height: 1.4;
	font-variant-numeric: tabular-nums;
}

/* The keyword match's rule, and what Athena did: two lines kept for each. */
.athena-typo__cue {
	min-height: 2.8em;
	font-size: 0.9375rem;
	line-height: 1.4;
}

.athena-typo__cue--rule {
	color: var(--wp--preset--color--muted);
	font-size: 0.875rem;
	font-weight: 600;
}

.athena-typo__cue--athena {
	font-weight: 650;
}

/* "0 → 2 results": the searches the shopper gets back. */
.athena-typo__gain {
	display: inline-block;
	padding: 0 0.5rem;
	border: 1px solid currentcolor;
	border-radius: 999px;
	color: var(--athena-success);
	font-weight: 800;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.athena-typo__gain[hidden] {
	display: none;
}

/* One page of results; the dead end and the product page share its cell. A row is
   --merch-row plus its padding and border (the result rows are content-box). */
.athena-typo__stage {
	display: grid;
	min-height: calc((var(--merch-row) + 0.7rem + 2px) * var(--typo-rows) + 0.5rem * (var(--typo-rows) - 1));
}

.athena-typo__stage > * {
	grid-area: 1 / 1;
	min-width: 0;
	margin: 0 !important;
}

/* The dead end: what a plain keyword match leaves the shopper with. */
.athena-typo__dead {
	display: grid;
	align-content: center;
	justify-items: center;
	gap: 0.4rem;
	padding: 1rem;
	border: 1px dashed var(--athena-border-strong);
	border-radius: 14px;
	background: var(--wp--preset--color--raised);
	color: var(--wp--preset--color--muted);
	text-align: center;
}

.athena-typo__dead[hidden],
.athena-typo__page[hidden] {
	display: none;
}

.athena-typo__dead-title {
	color: var(--wp--preset--color--contrast);
	font-size: 1.0625rem;
	font-weight: 800;
	line-height: 1.3;
	overflow-wrap: anywhere;
}

.athena-typo__dead-text {
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.4;
}

/* No match on Athena's side (noMatch 'message'): a clear message, not a dead end. */
.athena-typo__dead--athena {
	border-style: solid;
	border-color: var(--athena-border-strong);
	background: var(--wp--preset--color--base);
}

/* Redirect to product: the page the search opens. */
.athena-typo__page {
	display: grid;
	grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
	grid-template-rows: auto auto auto 1fr;
	align-content: start;
	gap: 0.35rem 1rem;
	padding: 1rem;
	border: 1px solid var(--wp--preset--color--accent);
	border-radius: 14px;
	background: var(--wp--preset--color--raised);
}

.athena-typo__page-label {
	grid-column: 1 / -1;
	color: var(--wp--preset--color--muted);
	font-size: 0.875rem;
	font-weight: 750;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.athena-typo__page-photo {
	grid-row: 2 / span 3;
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: 10px;
	background: var(--story-packshot);
}

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

.athena-typo__page-name {
	font-size: 1.125rem;
	font-weight: 800;
	line-height: 1.3;
}

.athena-typo__page-price {
	font-size: 1rem;
	font-weight: 650;
}

/* Phones and tablets: one column at a time, chosen with the switch; both share one cell, so
   the panel keeps the taller one's height. Without JavaScript they are stacked. */
@media (max-width: 960px) {
	.has-js .athena-typo__views {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 0.25rem;
		padding: 0.25rem;
		border: 1px solid var(--athena-border-strong);
		border-radius: 999px;
		background: var(--wp--preset--color--surface);
	}

	.has-js .athena-typo__compare > * {
		grid-area: 1 / 1;
	}

	.has-js .athena-story--typo[data-view="keyword"] .athena-typo__col--athena,
	.has-js .athena-story--typo[data-view="athena"] .athena-typo__col--keyword {
		visibility: hidden;
	}
}

/* Phones: rows hold a two-line name and the price; the example searches wrap. */
@media (max-width: 600px) {
	.athena-typo {
		--merch-row: 4.75rem;
		gap: 0.6rem;
	}

	.athena-typo__col {
		padding: 0.75rem;
	}

	.athena-typo__hint,
	.athena-typo__cue--athena {
		min-height: 4.2em;
	}

	.athena-typo__view {
		gap: 0.35rem;
		padding-inline: 0.4rem;
		border-radius: 22px;
		font-size: 0.875rem;
		text-wrap: balance;
	}

	/* Two digits fit, so the buttons keep their widths whatever the counts. */
	.athena-typo__badge {
		box-sizing: border-box;
		min-width: 1.75rem;
		padding: 0 0.25rem;
	}

	/* "Athena" is short: it takes its own width, the keyword label the rest, so the
	   longer label stays on one line from about 390px (two lines at 320px). */
	.has-js .athena-typo__views {
		grid-template-columns: minmax(0, 1fr) auto;
		border-radius: 26px;
	}

	/* The label above, the five examples in one sideways row with a faded end (the Category
	   demo's style-tile pattern), so the results start close to the demo's top. */
	.has-js .athena-typo__picks {
		display: grid;
		gap: 0.35rem;
	}

	.athena-typo__pick-row {
		flex-wrap: nowrap;
		margin: -4px -4px 0;
		padding: 4px 1.5rem 4px 4px;
		overflow-x: auto;
		overflow-y: hidden;
		overscroll-behavior-x: contain;
		scrollbar-width: none;
		-webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
		mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
	}

	.athena-typo__pick-row::-webkit-scrollbar {
		display: none;
	}

	.athena-typo__pick {
		flex: 0 0 auto;
		white-space: nowrap;
	}

	.athena-typo__page {
		grid-template-columns: minmax(0, 1fr);
	}

	.athena-typo__page-photo {
		grid-row: auto;
		max-width: 14rem;
	}
}

@media (max-width: 379px) {
	.athena-typo__hint {
		min-height: 5.6em;
	}
}
