/*
 * athena/product-story, variant "synonyms" (Search synonyms page). Loaded only where the demo
 * is (kit.php enqueue_style()). The panel reuses the Search Merchandising console and result
 * rows (style.css: .athena-merch*, .athena-cat__switch, .athena-cat__option); this file adds
 * the shopper's side, the synonym's direction and the words Athena searches for.
 *
 * Every line a change writes keeps its space, and the results area keeps one page's height,
 * so nothing moves under the visitor. All text 0.875rem or larger.
 */

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

/* Wide screens: the rules are the shorter side; they stay in view beside the results
   (sticky below the site header). The panel's grid bounds them: never past the panel. */
@media (min-width: 961px) {
	.athena-syn__console {
		position: sticky;
		top: 6.5rem;
		align-self: start;
	}
}

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

/* ── The rules ─────────────────────────────────────────────── */

/* Synonyms: name and switch, then the direction, then the details. */
.athena-syn__rule--synonym .athena-merch__rule-name {
	grid-row: 1;
}

.athena-syn__rule--synonym .athena-merch__switch,
.athena-syn__rule--synonym .athena-merch__static {
	grid-row: 1;
}

.athena-syn__direction {
	grid-column: 1 / -1;
	grid-row: 2;
}

.athena-syn__rule--synonym .athena-merch__rule-body {
	grid-column: 1 / -1;
	grid-row: 3;
}

.athena-syn__line {
	color: var(--wp--preset--color--contrast);
	font-weight: 700;
}

/* The direction: the arrow between the synonym's two words (only with JavaScript; without
   it the details say which way the rule works). Above the switch's row-wide target. */
.athena-syn__direction {
	display: none;
}

.has-js .athena-syn__direction {
	position: relative;
	z-index: 1;
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	align-items: center;
	gap: 0.35rem;
	padding-block: 0.15rem 0.35rem;
}

.athena-syn__direction-label {
	grid-column: 1 / -1;
	color: var(--wp--preset--color--muted);
	font-size: 0.875rem;
	font-weight: 700;
}

/* A word wider than its button wraps (at a space, or at the soft hyphen the Serbian
   "Jedno·smerno" carries) instead of spilling past it. */
.athena-syn .athena-syn__way {
	justify-content: center;
	gap: 0.35rem;
	padding-inline: 0.4rem;
	border-radius: 12px;
	line-height: 1.2;
	white-space: normal;
	text-wrap: balance;
}

.athena-syn__arrow {
	font-size: 1.125rem;
	font-weight: 800;
	line-height: 1;
}

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

.athena-syn__shop {
	display: grid;
	gap: 0.75rem;
	align-content: start;
	min-width: 0;
	scroll-margin-top: 6.5rem;
}

.athena-syn__shop > * {
	min-width: 0;
	margin: 0 !important;
}

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

/* The count, and beside it the count without the rules (its line is always there). */
.athena-syn__count {
	min-height: 1.4em;
	font-size: 0.9375rem;
	font-weight: 750;
	line-height: 1.4;
	font-variant-numeric: tabular-nums;
}

.athena-syn__was {
	color: var(--wp--preset--color--muted);
	font-weight: 650;
}

/* The words Athena searches for: typed ones, an excluded one struck through, a synonym's
   added one highlighted. Two lines are kept for them. */
.athena-syn__reads {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.3rem 0.4rem;
	min-height: 1.9rem;
	font-size: 0.875rem;
	line-height: 1.4;
}

.athena-syn__reads-label {
	color: var(--wp--preset--color--muted);
	font-weight: 700;
}

.athena-syn__words {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 0.3rem;
}

.athena-syn__word {
	display: inline-block;
	padding: 0.05rem 0.55rem;
	border: 1px solid var(--athena-border-strong);
	border-radius: 999px;
	background: var(--wp--preset--color--raised);
	color: var(--wp--preset--color--contrast);
	font-weight: 700;
	text-decoration: none;
}

.athena-syn__word.is-removed {
	border-style: dashed;
	background: none;
	color: var(--wp--preset--color--muted);
	text-decoration: line-through 2px;
}

.athena-syn__word.is-added {
	border-color: var(--wp--preset--color--accent);
	background: var(--wp--preset--color--accent-soft);
}

/* The results and the "no match" note share one cell: one page's height, always. A row is
   --merch-row plus its padding and border (the result rows are content-box). */
.athena-syn__stage {
	display: grid;
	min-height: calc(var(--syn-size, 4) * (var(--merch-row) + 0.7rem + 2px) + (var(--syn-size, 4) - 1) * 0.5rem);
}

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

.athena-syn__none {
	display: grid;
	align-content: start;
	padding: 1.1rem 1.25rem;
	border: 1px dashed var(--athena-border-strong);
	border-radius: 12px;
	color: var(--wp--preset--color--contrast);
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.4;
}

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

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

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

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

/* Each rule is one compact row (name, effect, details toggle, switch); the synonym's
   direction is a row of its own under it, never folded away: its label above three equal
   buttons (beside them, the buttons were too narrow for their words on any phone). The
   effect wraps rather than ending in an ellipsis: unlike
   the Merchandiser's (whose date line changes length), its length never changes, so the
   rows keep their height. */
@media (max-width: 600px) {
	.has-js .athena-syn__rule--synonym .athena-merch__switch {
		grid-row: 1 / span 2;
	}

	.has-js .athena-syn__direction {
		grid-row: 3;
		padding-block: 0.1rem 0.4rem;
	}

	.athena-syn .athena-syn__way {
		padding-inline: 0.3rem;
	}

	.has-js .athena-syn .athena-merch__effect {
		white-space: normal;
		text-wrap: balance;
	}

	.has-js .athena-syn__rule--synonym .athena-merch__rule-body {
		grid-row: 4;
	}

	.athena-syn .athena-merch__changed {
		min-height: 4.2em;
	}
}

/* Narrow phones: the arrow over the word. */
@media (max-width: 379px) {
	.athena-syn .athena-syn__way {
		flex-direction: column;
		gap: 0.1rem;
		padding-block: 0.25rem;
	}

	.athena-syn .athena-merch__changed {
		min-height: 5.6em;
	}
}
