/**
 * Trust Bar widget - centred heading above an infinite logo marquee.
 *
 * How the loop works: the track holds N identical logo groups and is animated
 * by exactly one group width (`-100% / N`). Every group measures the same, so
 * the strip looks identical at the start and the end of a cycle and an infinite
 * iteration reads as one continuous scroll - no clone bookkeeping, no JS on the
 * animation frame. trust-bar.js only sets two custom properties: how many
 * groups exist and how long one cycle should take.
 *
 * Spacing is carried by a trailing `padding-inline-end` on each group rather
 * than a `gap` on the track. That makes the pitch between logos uniform across
 * the group boundary, which is what makes the seam invisible.
 *
 * Specificity note: base rules use two class levels (e.g. `.tmt-trust-bar .x`)
 * so they beat theme/kit rules like `.container ul` or `.elementor-kit-N p`,
 * while staying below the three-class selectors Elementor generates from the
 * panel controls - those must keep winning.
 */

.tmt-trust-bar {
	--tmt-tb-gap: 60px;
	--tmt-tb-speed: 50; /* px per second, overridden by the Scroll Speed control */
	--tmt-tb-duration: 30s; /* CSS-only fallback until trust-bar.js measures */
	--tmt-tb-logo-width: auto;
	--tmt-tb-logo-height: 44px;
	--tmt-tb-logo-max-width: 200px;
	--tmt-tb-logo-fit: contain;
	--tmt-tb-logo-opacity: 1;
	--tmt-tb-logo-opacity-hover: 1;
	--tmt-tb-logo-scale-hover: 1;
	--tmt-tb-transition: 300ms;
}

/* Heading ---------------------------------------------------------------- */

.tmt-trust-bar .tmt-trust-bar__heading {
	margin: 0 0 30px;
	text-align: center;
}

/* Marquee shell ---------------------------------------------------------- */

/*
 * The container carries the panel's background / border / shadow, so clipping
 * lives on the viewport inside it - a border radius then cuts the strip
 * correctly instead of the box being clipped by its own overflow.
 */
.tmt-trust-bar .tmt-trust-bar__marquee {
	position: relative;
	width: 100%;
	margin-inline: auto;
}

.tmt-trust-bar .tmt-trust-bar__viewport {
	position: relative;
	overflow: hidden;
}

.tmt-trust-bar .tmt-trust-bar__track {
	display: flex;
	align-items: center;
	width: max-content;
	max-width: none;
	/*
	 * Own layer, so scrolling the strip never repaints the rest of the page.
	 * `will-change` is on this single element only - never on the logos.
	 */
	will-change: transform;
	transform: translate3d(0, 0, 0);
	backface-visibility: hidden;
	animation: tmt-trust-bar-scroll var(--tmt-tb-duration) linear infinite;
}

.tmt-trust-bar .tmt-trust-bar__group {
	display: flex;
	flex: 0 0 auto;
	align-items: inherit;
	gap: var(--tmt-tb-gap);
	/* Trailing gap: keeps the pitch uniform where two groups meet. */
	margin: 0;
	padding: 0;
	padding-inline-end: var(--tmt-tb-gap);
	list-style: none;
}

.tmt-trust-bar .tmt-trust-bar__item {
	display: flex;
	flex: 0 0 auto;
	align-items: inherit;
	margin: 0;
	padding: 0;
	list-style: none;
}

@keyframes tmt-trust-bar-scroll {
	from {
		transform: translate3d(0, 0, 0);
	}

	to {
		/* One group width, whatever the group count happens to be. */
		transform: translate3d(calc(-100% / var(--tmt-tb-groups, 2)), 0, 0);
	}
}

/* Direction / loop / pause ---------------------------------------------- */

/*
 * Left to right is the same keyframes played backwards, so both directions
 * share one animation and stay perfectly seamless.
 */
.tmt-trust-bar--ltr .tmt-trust-bar__track {
	animation-direction: reverse;
}

.tmt-trust-bar--once .tmt-trust-bar__track {
	animation-iteration-count: 1;
	animation-fill-mode: forwards;
}

.tmt-trust-bar--pause:hover .tmt-trust-bar__track,
.tmt-trust-bar--pause:focus-within .tmt-trust-bar__track {
	animation-play-state: paused;
}

/* Logos ------------------------------------------------------------------ */

.tmt-trust-bar .tmt-trust-bar__link {
	display: block;
	line-height: 0;
	text-decoration: none;
}

.tmt-trust-bar .tmt-trust-bar__link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 4px;
}

.tmt-trust-bar .tmt-trust-bar__logo {
	display: block;
	width: var(--tmt-tb-logo-width);
	height: var(--tmt-tb-logo-height);
	max-width: var(--tmt-tb-logo-max-width);
	object-fit: var(--tmt-tb-logo-fit);
	opacity: var(--tmt-tb-logo-opacity);
	transition:
		opacity var(--tmt-tb-transition) ease,
		transform var(--tmt-tb-transition) ease;
}

.tmt-trust-bar .tmt-trust-bar__item:hover .tmt-trust-bar__logo,
.tmt-trust-bar .tmt-trust-bar__link:focus-visible .tmt-trust-bar__logo {
	opacity: var(--tmt-tb-logo-opacity-hover);
	transform: scale(var(--tmt-tb-logo-scale-hover));
}

/* Static mode ------------------------------------------------------------ */

/*
 * Auto Scroll off: one group, centred, wrapping onto more lines on narrow
 * screens. The trailing gap is dropped so a centred row stays optically centred.
 */
.tmt-trust-bar--static .tmt-trust-bar__track {
	width: auto;
	flex-wrap: wrap;
	justify-content: center;
	row-gap: var(--tmt-tb-gap);
	will-change: auto;
	animation: none;
}

.tmt-trust-bar--static .tmt-trust-bar__group {
	flex-wrap: wrap;
	justify-content: center;
	row-gap: var(--tmt-tb-gap);
	padding-inline-end: 0;
}

/* Reduced motion --------------------------------------------------------- */

/*
 * Movement is the whole point of this widget, so for users who ask for less of
 * it the strip becomes the static layout instead. The repeated groups are
 * hidden rather than merely stopped, otherwise the same logos would read twice.
 */
@media (prefers-reduced-motion: reduce) {
	.tmt-trust-bar .tmt-trust-bar__track {
		width: auto;
		flex-wrap: wrap;
		justify-content: center;
		row-gap: var(--tmt-tb-gap);
		will-change: auto;
		animation: none;
	}

	.tmt-trust-bar .tmt-trust-bar__group {
		flex-wrap: wrap;
		justify-content: center;
		row-gap: var(--tmt-tb-gap);
		padding-inline-end: 0;
	}

	.tmt-trust-bar .tmt-trust-bar__group[data-tmt-clone] {
		display: none;
	}

	.tmt-trust-bar .tmt-trust-bar__logo {
		transition: none;
	}
}
