/**
 * Qing Marquee (seamless carousel) styles.
 *
 * The track holds one or more identical groups laid out in a row. JS
 * duplicates the group so the second copy takes over exactly as the first
 * scrolls out, producing a seamless loop. The animation distance is the
 * width of a single group (translateX -50% when two groups are present,
 * or a per-instance --qing-marquee-shift when more copies are added).
 */

.qing-marquee {
	width: 100%;
	overflow: hidden;
	position: relative;
}

.qing-marquee__track {
	display: flex;
	flex-wrap: nowrap;
	width: max-content;
	will-change: transform;
	animation-name: qing-marquee-scroll;
	animation-timing-function: linear;
	animation-iteration-count: infinite;
	animation-duration: var(--qing-marquee-duration, 20s);
}

.qing-marquee__group {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	flex: 0 0 auto;
	white-space: nowrap;
}

/* Direction */
.qing-marquee[data-direction="right"] .qing-marquee__track {
	animation-direction: reverse;
}

/* Pause on hover */
.qing-marquee[data-pause="1"]:hover .qing-marquee__track {
	animation-play-state: paused;
}

/* Pause while dragging / not ready */
.qing-marquee.is-paused .qing-marquee__track {
	animation-play-state: paused;
}

/* ---- Items ------------------------------------------------------------ */
.qing-marquee__text {
	display: inline-block;
	font-size: 64px;
	font-weight: 700;
	line-height: 1.1;
	color: #2323ff;
	text-decoration: none;
	white-space: nowrap;
	transition: color 0.2s ease;
}

a.qing-marquee__text:hover {
	opacity: 0.85;
}

.qing-marquee__img {
	display: block;
	height: 64px;
	width: auto;
	object-fit: contain;
	flex: 0 0 auto;
}

/* Link wrapper around an image item. Must not disturb the flex layout:
 * it takes over the `flex: 0 0 auto` the bare <img> used to carry. */
.qing-marquee__link--image {
	display: block;
	flex: 0 0 auto;
	line-height: 0; /* kill the inline descender gap under the image */
	text-decoration: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.qing-marquee__link--image:hover {
	opacity: var(--qing-marquee-img-hover-opacity, 0.85);
}

/* Keyboard focus needs a visible ring. The marquee clips overflow, so use
 * an inset ring instead of a outline that would be cut off. */
.qing-marquee__link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
	border-radius: 2px;
}

/* Pause the scroll while any item is focused, otherwise a keyboard user
 * cannot see or activate what they have tabbed to. */
.qing-marquee:focus-within .qing-marquee__track {
	animation-play-state: paused;
}

/* ======================================================================
 * Keyframes
 * Shift by exactly one group's width. JS sets --qing-marquee-shift to the
 * width (in px) of a single group so the loop is pixel-perfect regardless
 * of how many duplicate groups were added.
 * ====================================================================== */
@keyframes qing-marquee-scroll {
	from {
		transform: translateX(0);
	}
	to {
		transform: translateX(calc(-1 * var(--qing-marquee-shift, 50%)));
	}
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
	.qing-marquee__track {
		animation-duration: 0s !important;
		animation: none;
	}
}
