/**
 * Ticker Plus — front-end and editor styles.
 *
 * The stage height is declared ONCE, here, and never set from JS. Items
 * are absolutely positioned inside the fixed-height stage so only the
 * active item is visible and swapping items can never resize the stage
 * (Benchtest rule 8). The stage height accounts for a one-line desktop
 * item and a two-line phone item via the media query at the bottom.
 *
 * All selectors are scoped to `.benchtest-ticker` so these rules do not
 * fight the theme, other plugins, or an Elementor canvas.
 *
 * @package Ticker_Plus
 */

.benchtest-ticker {
	--benchtest-ticker-stage-height: 32px;
	--benchtest-ticker-accent: #d32f2f;
	--benchtest-ticker-label-bg: #111111;
	--benchtest-ticker-label-fg: #ffffff;
	--benchtest-ticker-row-bg: #f2f2f2;
	--benchtest-ticker-text: #333333;
	--benchtest-ticker-muted: #777777;
	--benchtest-ticker-urgent-bg: #fff4e5;
	--benchtest-ticker-urgent-border: #d32f2f;

	display: flex;
	align-items: center;
	gap: 0;
	width: 100%;
	margin-block: 8px;
	background-color: var(--benchtest-ticker-row-bg);
	border-radius: 2px;
	overflow: hidden;
	font-size: 0.875rem;
	line-height: 1.2;
}

.benchtest-ticker *,
.benchtest-ticker *::before,
.benchtest-ticker *::after {
	box-sizing: border-box;
}

/* Label — black tag, white text. The red in this row is the timestamp. */
.benchtest-ticker__label {
	flex: 0 0 auto;
	align-self: stretch;
	display: inline-flex;
	align-items: center;
	padding: 0 14px;
	background-color: var(--benchtest-ticker-label-bg);
	color: var(--benchtest-ticker-label-fg);
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	white-space: nowrap;
}

/* Stage — fixed height, clipped, relative for absolute items. */
.benchtest-ticker__stage {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	height: var(--benchtest-ticker-stage-height);
	overflow: hidden;
}

.benchtest-ticker__track {
	position: absolute;
	inset: 0;
}

.benchtest-ticker__item {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0 14px;
	opacity: 0;
	visibility: hidden;
	transition: opacity 200ms ease;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.benchtest-ticker__item.is-active {
	opacity: 1;
	visibility: visible;
}

.benchtest-ticker__time {
	flex: 0 0 auto;
	color: var(--benchtest-ticker-accent);
	font-weight: 700;
	font-size: 0.8125rem;
	white-space: nowrap;
}

.benchtest-ticker__title {
	flex: 1 1 auto;
	min-width: 0;
	color: var(--benchtest-ticker-text);
	text-decoration: none;
	overflow: hidden;
	text-overflow: ellipsis;
}

.benchtest-ticker__title:hover,
.benchtest-ticker__title:focus-visible {
	text-decoration: underline;
}

.benchtest-ticker__title:focus-visible {
	outline: 2px solid var(--benchtest-ticker-accent);
	outline-offset: 2px;
}

/* Controls — icon buttons at the right. */
.benchtest-ticker__controls {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 0 6px;
	align-self: stretch;
}

.benchtest-ticker__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	margin: 0;
	border: 0;
	background: transparent;
	color: var(--benchtest-ticker-muted);
	cursor: pointer;
	border-radius: 2px;
	transition: background-color 120ms ease, color 120ms ease;
}

.benchtest-ticker__btn:hover,
.benchtest-ticker__btn:focus-visible {
	background-color: rgba(0, 0, 0, 0.06);
	color: var(--benchtest-ticker-text);
}

.benchtest-ticker__btn:focus-visible {
	outline: 2px solid var(--benchtest-ticker-accent);
	outline-offset: 1px;
}

.benchtest-ticker__btn:disabled {
	cursor: default;
	opacity: 0.45;
}

.benchtest-ticker__btn:disabled:hover {
	background-color: transparent;
	color: var(--benchtest-ticker-muted);
}

/* CSS-drawn icons. */
.benchtest-ticker__icon {
	display: inline-block;
	position: relative;
	width: 10px;
	height: 10px;
}

.benchtest-ticker__icon--pause::before,
.benchtest-ticker__icon--pause::after {
	content: "";
	position: absolute;
	top: 0;
	width: 3px;
	height: 10px;
	background-color: currentColor;
}

.benchtest-ticker__icon--pause::before {
	left: 0;
}

.benchtest-ticker__icon--pause::after {
	right: 0;
}

/* Pause icon toggles into a play triangle when the ticker is paused. */
.benchtest-ticker__pause.is-paused .benchtest-ticker__icon--pause::before {
	top: 0;
	left: 1px;
	width: 0;
	height: 0;
	background: transparent;
	border-style: solid;
	border-width: 5px 0 5px 9px;
	border-color: transparent transparent transparent currentColor;
}

.benchtest-ticker__pause.is-paused .benchtest-ticker__icon--pause::after {
	display: none;
}

.benchtest-ticker__icon--prev::before,
.benchtest-ticker__icon--next::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 7px;
	height: 7px;
	border-style: solid;
	border-width: 0 0 2px 2px;
	border-color: currentColor;
}

.benchtest-ticker__icon--prev::before {
	transform: translate(-30%, -50%) rotate(45deg);
}

.benchtest-ticker__icon--next::before {
	transform: translate(-70%, -50%) rotate(-135deg);
}

/* Urgent variant — recall / safety notice treatment. */
.benchtest-ticker--urgent {
	background-color: var(--benchtest-ticker-urgent-bg);
	border: 1px solid var(--benchtest-ticker-urgent-border);
	border-left-width: 4px;
}

.benchtest-ticker--urgent .benchtest-ticker__label {
	background-color: var(--benchtest-ticker-accent);
}

.benchtest-ticker--urgent .benchtest-ticker__time {
	color: var(--benchtest-ticker-text);
	font-weight: 800;
}

/* ---------------------------------------------------------------
 * Responsive
 *
 * The stage grows to two lines worth of height at phone width so a
 * longer headline can wrap into two lines. The value is fixed here, not
 * in JS, so item changes still cannot resize the stage. On phone the
 * label drops below the items block stacking keeps the row tidy.
 * --------------------------------------------------------------- */

@media (max-width: 600px) {
	.benchtest-ticker {
		--benchtest-ticker-stage-height: 52px;
	}

	.benchtest-ticker__label {
		padding: 0 10px;
		font-size: 0.6875rem;
	}

	.benchtest-ticker__item {
		padding: 0 10px;
		gap: 8px;
		white-space: normal;
		align-items: center;
	}

	.benchtest-ticker__title {
		white-space: normal;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}

	.benchtest-ticker__time {
		font-size: 0.75rem;
	}

	.benchtest-ticker__controls {
		padding: 0 2px;
	}

	.benchtest-ticker__btn {
		width: 22px;
		height: 22px;
	}
}

/* ---------------------------------------------------------------
 * Motion
 *
 * Only the 200ms cross-fade between items and the 120ms button
 * transitions animate. Under prefers-reduced-motion, all transitions are
 * disabled so item changes are instant (JS also suppresses autoplay).
 * --------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.benchtest-ticker__item {
		transition: none;
	}

	.benchtest-ticker__btn {
		transition: none;
	}
}
