/*
 * Marquee — one real items group plus N-1 aria-hidden, inert clones. The track
 * translates by exactly one group width per cycle (-100% / N) for a seamless
 * loop.
 */

.marquee {
	overflow: clip;
	/* The track is four copies wide, so the marquee's intrinsic width means
	   nothing. As a Row child it would push the page sideways and squeeze its
	   siblings. Containing inline size makes it 0: Fill then takes only the
	   space left over. */
	contain: inline-size;
	/*
	 * Pause on interaction — WCAG 2.2.2. :active covers touch (tap and hold),
	 * since :hover is unreliable there and a text-only marquee has nothing
	 * focusable for :focus-within to catch.
	 */
}

.marquee:hover .marquee__track,
.marquee:focus-within .marquee__track,
.marquee:active .marquee__track {
	animation-play-state: paused;
}

.marquee__track {
	display: flex;
	align-items: center;
	width: max-content;
	/*
	 * NO gap here. It would make the width N*group + (N-1)*gap, so -100%/N falls
	 * short by (1/N)*gap per cycle and the loop visibly jumps. Inter-group
	 * spacing lives on the group's margin-inline-end instead.
	 */
	animation: wage-marquee-scroll var(--marquee-duration, 30s) linear infinite;
	will-change: transform;
}

.marquee__group {
	display: flex;
	align-items: center;
	gap: var(--marquee-gap, var(--wp--preset--spacing--s));
	flex-shrink: 0;
	margin-inline-end: var(--marquee-gap, var(--wp--preset--spacing--s));
}

/* Flex, not block, so inline content cannot float high in an oversized line
   box — keeps each item centred against the separators. */
.marquee__group > * {
	display: flex;
	align-items: center;
	white-space: nowrap;
	margin: 0;
}

/* A Query Loop as the items: its Post Template is the row, each post one item
   at the same gap, whatever layout the Post Template was given. */
.marquee__group .wp-block-post-template {
	display: flex;
	align-items: center;
	gap: var(--marquee-gap, var(--wp--preset--spacing--s));
	margin: 0;
	padding: 0;
	list-style: none;
}

.marquee__group .wp-block-post-template > * {
	margin: 0;
}

/* The separator is drawn after every item rather than being markup, so it
   never reaches the accessibility tree and never needs escaping. After EVERY
   item, last included, so the seam between one group and the next clone gets
   one too. Falls back to `none` so an empty separator leaves no stray gap. */
.marquee__group > *::after {
	content: var(--marquee-separator, none);
	margin-inline-start: var(--marquee-gap, var(--wp--preset--spacing--s));
	color: var(--marquee-separator-foreground, var(--wp--preset--color--primary));
	line-height: 1;
}

/* Translate exactly one slot per cycle: -100% / 4 = -25%. Must match the four
   groups render.php emits (WAGE_MARQUEE_COPIES). */
@keyframes wage-marquee-scroll {
	from { transform: translateX(0); }
	to   { transform: translateX(-25%); }
}

/* Fade edges: items fade out at both ends instead of cutting off. A mask, not
   an overlay, so it works over any background. --marquee-fade is the band width (6% per side, as in the PHP trust strip). */
.marquee--fade {
	mask-image: linear-gradient(to right, transparent, #000 var(--marquee-fade, 6%), #000 calc(100% - var(--marquee-fade, 6%)), transparent);
}

.marquee--reverse .marquee__track {
	animation-direction: reverse;
}

/*
 * Reduced motion: animation off and clones hidden, with the x-axis made
 * scrollable so the content is still reachable.
 *
 * The editor is this state always (index.js renders one group on the track,
 * no clones): items size exactly as on the site, nothing moves, and the strip
 * scrolls sideways to reach items past the edge.
 */
@media (prefers-reduced-motion: reduce) {
	.marquee {
		overflow-x: auto;
		scrollbar-width: none;
	}

	.marquee__track {
		animation: none;
	}

	.marquee__group[aria-hidden="true"] {
		display: none;
	}
}

.editor-styles-wrapper .marquee {
	overflow-x: auto;
	scrollbar-width: none;
}

.editor-styles-wrapper .marquee__track {
	animation: none;
}
