/**
 * Vote ticker — the live marquee of who leads which race.
 *
 * Three arrangements over ONE engine. The engine owns motion, masking, pausing
 * and the reduced-motion fallback; the styles only dress the items, so a fix to
 * how the strip moves reaches all three at once.
 *
 * How the seamless loop works: the track holds the item sequence TWICE and the
 * animation translates it by exactly -50%. At the end of the cycle the second
 * copy sits precisely where the first began, so the restart is invisible. This
 * is why an item may not have a percentage width and why the track is
 * `width:max-content` — a track that fits its parent cannot loop.
 */

/* ═══════════════════════════════════════════════════════════════════════════
   Engine
   ═══════════════════════════════════════════════════════════════════════════ */

.sa-tick {
	--sa-tick-dur: 40s;
	--sa-tick-fade: 44px;
	position: relative;
	display: flex;
	flex-direction: column;
	gap: .55rem;
}

.sa-tick__row {
	position: relative;
	display: flex;
	align-items: stretch;
	min-width: 0;
}

/* The window the track moves inside. `overflow:hidden` is load-bearing, not
   tidiness: without it the duplicated sequence is a page-wide horizontal
   scrollbar. */
.sa-tick__view {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	-webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--sa-tick-fade),
		#000 calc(100% - var(--sa-tick-fade)), transparent);
	mask-image: linear-gradient(90deg, transparent, #000 var(--sa-tick-fade),
		#000 calc(100% - var(--sa-tick-fade)), transparent);
}

.sa-tick__track {
	display: flex;
	width: max-content;
	will-change: transform;
	animation: sa-tick-run var(--sa-tick-dur) linear infinite;
}

/* Direction is a reversed animation rather than a second keyframe set, so the
   two rows of a two-row strip stay in step with one another. */
.sa-tick__row[data-dir="right"] .sa-tick__track { animation-direction: reverse; }

.sa-tick__seq {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
}

@keyframes sa-tick-run {
	from { transform: translate3d(0, 0, 0); }
	to   { transform: translate3d(-50%, 0, 0); }
}

/* Pause on hover AND on keyboard focus. The second half matters: a keyboard
   user tabbing into a moving strip cannot read what they have landed on. */
.sa-tick:hover .sa-tick__track,
.sa-tick:focus-within .sa-tick__track { animation-play-state: paused; }

.sa-tick.is-paused .sa-tick__track { animation-play-state: paused; }

/* Reader-owned, and deliberately a different class from `is-paused`: that one
   belongs to the offscreen observer, and one class for both would mean
   scrolling the strip out of view and back reset the reader's choice. */
.sa-tick.is-stopped .sa-tick__track { animation-play-state: paused; }

.sa-tick__pause {
	position: absolute;
	right: 6px;
	bottom: 6px;
	z-index: 3;
	width: 28px;
	height: 28px;
	display: grid;
	place-items: center;
	padding: 0;
	cursor: pointer;
	border: 1px solid var(--sa-border);
	border-radius: 999px;
	background: color-mix(in srgb, var(--sa-bg) 78%, transparent);
	color: var(--sa-text-dim);
	transition: color .16s ease, border-color .16s ease;
}
.sa-tick__pause:hover { color: var(--sa-text); border-color: var(--sa-border-strong); }
/* Two bars while running, one triangle once stopped — drawn from the button's
   own aria-pressed state, so the glyph can never disagree with what the button
   reports. Borders rather than a clip-path: a single polygon cannot describe
   two disjoint bars, and the self-intersecting version renders as neither. */
.sa-tick__pause > span {
	width: 3px;
	height: 10px;
	border-left: 3px solid currentColor;
	border-right: 3px solid currentColor;
}
.sa-tick__pause[aria-pressed="true"] > span {
	width: 0;
	height: 0;
	border-left: 9px solid currentColor;
	border-right: 0;
	border-top: 5px solid transparent;
	border-bottom: 5px solid transparent;
	margin-left: 2px;
}

.sa-tick a { text-decoration: none; color: inherit; display: flex; align-items: center; }
.sa-tick a:focus-visible {
	outline: 2px solid var(--sa-focus, #19D3C5);
	outline-offset: 2px;
	border-radius: 10px;
}

.sa-tick .sa-tick-n { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* The "live" pulse. */
.sa-tick__pulse {
	position: relative;
	width: 7px; height: 7px; border-radius: 50%;
	background: currentColor; flex: 0 0 auto;
}
/* The ring is a pseudo-element that scales and fades — compositor-only. The
   first version animated `box-shadow`, which repaints every frame, forever,
   and kept going while the strip was off-screen. */
.sa-tick__pulse::after {
	content: "";
	position: absolute; inset: 0;
	border-radius: 50%;
	border: 1.5px solid rgba(255, 255, 255, .75);
	animation: sa-tick-pulse 1.9s ease-out infinite;
}
@keyframes sa-tick-pulse {
	0%   { transform: scale(1); opacity: .9; }
	70%  { transform: scale(3.3); opacity: 0; }
	100% { transform: scale(3.3); opacity: 0; }
}
/* No claim, no ring: a strip whose races are quiet says "Open" (ticker.php). */
.sa-tick__pulse.is-quiet { opacity: .55; }
.sa-tick__pulse.is-quiet::after { display: none; }
.sa-tick.is-paused .sa-tick__pulse::after { animation-play-state: paused; }

/* A count that just rose: one sweep, then ticker.js clears `data-move`. */
.sa-tick-i[data-move="up"] .sa-tick-votes { animation: sa-tick-rise .9s ease-out 1; }
@keyframes sa-tick-rise {
	0%   { opacity: .35; transform: translateY(4px); }
	100% { opacity: 1; transform: none; }
}

/* ── Reduced motion ────────────────────────────────────────────────────────
   Not "animation:none" alone. A stopped track is a fixed slice of the list with
   the rest unreachable — the content would be REMOVED for the people who asked
   for less motion. It becomes a real horizontal scroller instead, the second
   (decorative) copy is dropped, and the edge fade goes with it because a fade
   over a scroller hides the affordance that there is more to the right. */
@media (prefers-reduced-motion: reduce) {
	.sa-tick__track {
		animation: none;
		width: auto;
		overflow-x: auto;
		scrollbar-width: thin;
		scroll-snap-type: x proximity;
		-webkit-overflow-scrolling: touch;
	}
	.sa-tick__seq + .sa-tick__seq { display: none; }
	.sa-tick__view { -webkit-mask-image: none; mask-image: none; }
	.sa-tick__pulse::after { animation: none; display: none; }
	.sa-tick-i[data-move] .sa-tick-votes { animation: none; }
	.sa-tick__seq > * { scroll-snap-align: start; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Shared chrome — the header line styles B and C carry
   ═══════════════════════════════════════════════════════════════════════════ */

.sa-tick__head {
	display: flex;
	align-items: center;
	gap: .6rem;
	flex-wrap: wrap;
	margin: 0 0 .1rem;
}
.sa-tick__flag {
	display: inline-flex;
	align-items: center;
	gap: .45rem;
	font-size: .68rem;
	font-weight: 800;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--sa-on-accent, #fff);
	padding: .32rem .8rem;
	border-radius: var(--sa-radius-pill, 999px);
	background: var(--sa-gradient, linear-gradient(135deg, #00A870, #00B48A 50%, #0FA89C));
	box-shadow: 0 6px 18px -8px rgba(0,195,137, .9);
}
.sa-tick__title {
	font-size: .84rem;
	font-weight: 700;
	color: var(--sa-text-muted, #A9B6C8);
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   A — Broadcast
   One line, a locked gradient tab at the left, text flowing past it.
   ═══════════════════════════════════════════════════════════════════════════ */

.sa-tick--broadcast .sa-tick__row {
	min-height: 52px;
	background: linear-gradient(180deg, var(--sa-surface-1, #121A2B), var(--sa-bg-2, #0D1222));
	border-top: 1px solid var(--sa-border-strong, rgba(0,195,137, .34));
	border-bottom: 1px solid var(--sa-border-strong, rgba(0,195,137, .34));
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 10px 34px -18px rgba(0,195,137, .5);
}

/* The tab sits OUTSIDE the masked window, so the mask never fades the word
   "Live" — which is the one thing on this strip that must stay solid. */
.sa-tick--broadcast .sa-tick__tab {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: .5rem;
	padding: 0 2rem 0 1.35rem;
	background: var(--sa-gradient, linear-gradient(135deg, #00A870, #00B48A 50%, #0FA89C));
	color: var(--sa-on-accent, #fff);
	font-weight: 800;
	font-size: .72rem;
	letter-spacing: .16em;
	text-transform: uppercase;
	white-space: nowrap;
	position: relative;
	z-index: 2;
	clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
}

/* Only the trailing edge fades: the leading edge butts against the tab, and a
   fade there would put a grey gap between the two. */
.sa-tick--broadcast .sa-tick__view {
	-webkit-mask-image: linear-gradient(90deg, #000, #000 calc(100% - 54px), transparent);
	mask-image: linear-gradient(90deg, #000, #000 calc(100% - 54px), transparent);
}
.sa-tick--broadcast .sa-tick__track { align-items: center; height: 100%; }

.sa-tick--broadcast .sa-tick-i {
	display: flex;
	align-items: center;
	gap: .68rem;
	padding: 0 .95rem;
	height: 52px;
	white-space: nowrap;
	font-size: .9rem;
	transition: background .18s ease;
}
.sa-tick--broadcast .sa-tick-i:hover { background: rgba(0,195,137, .09); }

.sa-tick--broadcast .sa-tick-rank {
	font-size: .66rem;
	font-weight: 800;
	letter-spacing: .06em;
	line-height: 1;
	padding: .2rem .38rem;
	border-radius: 5px;
	background: var(--sa-surface-2, #18223A);
	color: var(--sa-text-muted, #A9B6C8);
	box-shadow: inset 0 0 0 1px var(--sa-border-strong, rgba(0,195,137, .34));
}
.sa-tick--broadcast .sa-tick-i[data-rank="1"] .sa-tick-rank {
	background: var(--sa-gold, #C6FF3D); color: var(--sa-bg, #0A0E1A); box-shadow: none;
}
.sa-tick--broadcast .sa-tick-i[data-rank="2"] .sa-tick-rank {
	background: var(--sa-violet-light, #4BE3B0); color: var(--sa-on-accent, #fff); box-shadow: none;
}

.sa-tick--broadcast .sa-tick-name { font-weight: 700; color: var(--sa-text, #EEF3F8); }
.sa-tick--broadcast .sa-tick-pct  { font-weight: 800; color: var(--sa-violet-light, #4BE3B0); font-size: .86rem; }
.sa-tick--broadcast .sa-tick-votes { color: var(--sa-text-muted, #A9B6C8); font-size: .8rem; font-weight: 600; }
.sa-tick--broadcast .sa-tick-poll {
	color: var(--sa-text-dim, #7F8CA0);
	font-size: .78rem;
	font-weight: 600;
	max-width: 22ch;
	overflow: hidden;
	text-overflow: ellipsis;
}
.sa-tick--broadcast .sa-tick-dot {
	width: 5px; height: 5px; border-radius: 50%;
	background: var(--sa-border-strong, rgba(0,195,137, .34));
	flex: 0 0 auto;
}
.sa-tick--broadcast .sa-tick-time {
	display: inline-flex;
	align-items: center;
	gap: .3rem;
	font-size: .72rem;
	font-weight: 700;
	color: var(--sa-gold, #C6FF3D);
	background: rgba(61, 228, 255, .1);
	border: 1px solid rgba(61, 228, 255, .28);
	border-radius: var(--sa-radius-pill, 999px);
	padding: .16rem .55rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   B — Exchange
   A pill per nominee: round photo, name, figure, movement chip.
   ═══════════════════════════════════════════════════════════════════════════ */

.sa-tick--exchange .sa-tick__track { align-items: center; gap: .62rem; padding: .2rem 0; }
.sa-tick--exchange .sa-tick__seq   { gap: .62rem; padding-right: .62rem; }

.sa-tick--exchange .sa-tick-i {
	display: flex;
	align-items: center;
	gap: .68rem;
	padding: .5rem .95rem .5rem .5rem;
	background: var(--sa-surface-1, #121A2B);
	border: 1px solid var(--sa-border, rgba(0,195,137, .16));
	border-radius: var(--sa-radius-pill, 999px);
	white-space: nowrap;
	transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.sa-tick--exchange .sa-tick-i:hover {
	border-color: var(--sa-violet, #00C389);
	transform: translateY(-2px);
	box-shadow: 0 10px 24px -12px rgba(0,195,137, .65);
}

/* The wrapper owns the box and the rank badge; the inner `.sa-tick-av` is what
   shining_nominee_avatar() emits — either `…--photo` holding an <img>, or the
   two-letter initials fallback. */
.sa-tick--exchange .sa-tick-avwrap {
	position: relative;
	width: 38px; height: 38px;
	flex: 0 0 auto;
}
.sa-tick-av {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%; height: 100%;
	border-radius: 50%;
	overflow: hidden;
	background: var(--sa-surface-2, #18223A);
	color: var(--sa-text-muted, #A9B6C8);
	font-size: .72rem; font-weight: 800; letter-spacing: .02em;
	box-shadow: 0 0 0 2px var(--sa-border-strong, rgba(0,195,137, .34));
}
/* TotalPoll's own read-only focal point, reproduced exactly as the leaderboard
   does it: nominee art is a full-body designed card, so a plain `object-fit`
   frames a torso. 3.08 is the frame-to-source ratio the crop is built on. */
.sa-tick-av--photo { position: relative; }
.sa-tick-av--photo img {
	position: absolute;
	width:  calc(var(--sa-focal-scale, 308%) * var(--np-zoom, 1));
	height: calc(var(--sa-focal-scale, 308%) * var(--np-zoom, 1));
	max-width: none; max-height: none;
	left: calc(var(--np-fx, .5) * (1 - 3.08 * var(--np-zoom, 1)) * 100%);
	top:  calc(var(--np-fy, .4) * (1 - 3.08 * var(--np-zoom, 1)) * 100%);
	object-fit: cover;
	object-position: center 40%;
}
.sa-tick--exchange .sa-tick-rank {
	position: absolute; left: -3px; bottom: -3px;
	width: 18px; height: 18px;
	border-radius: 50%;
	background: var(--sa-bg, #0A0E1A);
	color: var(--sa-gold, #C6FF3D);
	font-size: .6rem; font-weight: 800; font-style: normal;
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 0 0 1.5px var(--sa-gold, #C6FF3D);
}

.sa-tick--exchange .sa-tick-meta { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.sa-tick--exchange .sa-tick-name { font-size: .86rem; font-weight: 700; line-height: 1.15; }
.sa-tick--exchange .sa-tick-poll {
	font-size: .66rem; font-weight: 600;
	color: var(--sa-text-dim, #7F8CA0);
	letter-spacing: .04em; text-transform: uppercase;
	max-width: 20ch; overflow: hidden; text-overflow: ellipsis;
}
.sa-tick--exchange .sa-tick-val {
	display: flex; flex-direction: column; align-items: flex-end; gap: .1rem;
	padding-left: .42rem; margin-left: .12rem;
	border-left: 1px solid var(--sa-border, rgba(0,195,137, .16));
}
.sa-tick--exchange .sa-tick-votes { font-size: .9rem; font-weight: 800; line-height: 1.1; }
.sa-tick--exchange .sa-tick-pct {
	font-size: .66rem; font-weight: 800; line-height: 1.5;
	padding: .04rem .38rem;
	border-radius: var(--sa-radius-pill, 999px);
	color: var(--sa-violet-light, #4BE3B0);
	background: rgba(0,195,137, .12);
}
/* Set by ticker.js when a live refresh shows the figure moved. */
.sa-tick--exchange .sa-tick-i[data-move="up"] .sa-tick-pct { color: var(--sa-gold, #C6FF3D); background: rgba(61, 228, 255, .12); }
.sa-tick--exchange .sa-tick-i[data-move="down"] .sa-tick-pct { color: var(--sa-heart-2, #C6FF3D); background: rgba(255, 52, 95, .13); }

/* ═══════════════════════════════════════════════════════════════════════════
   C — Spotlight
   A wide card per nominee: 4:5 photo, big name, share bar.
   ═══════════════════════════════════════════════════════════════════════════ */

.sa-tick--spotlight .sa-tick__track { align-items: stretch; gap: .85rem; padding: .12rem 0; }
.sa-tick--spotlight .sa-tick__seq   { gap: .85rem; padding-right: .85rem; align-items: stretch; }

.sa-tick--spotlight .sa-tick-i {
	position: relative;
	display: flex;
	align-items: center;
	gap: .85rem;
	width: 326px;
	padding: .72rem .95rem .72rem .72rem;
	border-radius: 18px;
	overflow: hidden;
	background: linear-gradient(135deg, var(--sa-surface-1, #121A2B), var(--sa-bg-2, #0D1222));
	border: 1px solid var(--sa-border, rgba(0,195,137, .16));
	transition: border-color .22s ease, transform .22s ease, box-shadow .22s ease;
}
.sa-tick--spotlight .sa-tick-i::before {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	opacity: .5;
	background: radial-gradient(120% 130% at 0% 0%, rgba(0,195,137, .2), transparent 58%);
}
.sa-tick--spotlight .sa-tick-i:hover {
	border-color: var(--sa-violet, #00C389);
	transform: translateY(-3px);
	box-shadow: 0 18px 40px -20px rgba(0,195,137, .75);
}

/* 🔴 4:5, and nothing is composited over the photo. Nominee art is a DESIGNED
   card, not a headshot — see the winner block for the same rule. The rank badge
   sits in the corner of the frame rather than across the face. */
.sa-tick--spotlight .sa-tick-phwrap {
	position: relative;
	z-index: 1;
	flex: 0 0 auto;
	width: 58px;
	aspect-ratio: 4 / 5;
}
.sa-tick-ph {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%; height: 100%;
	border-radius: 12px;
	overflow: hidden;
	background: var(--sa-surface-2, #18223A);
	color: var(--sa-text-muted, #A9B6C8);
	font-size: .95rem; font-weight: 800;
	box-shadow: 0 6px 18px -8px rgba(0, 0, 0, .8),
		inset 0 0 0 1px var(--sa-border-strong, rgba(0,195,137, .34));
}
/* Same focal crop as the round avatar, at a 4:5 frame — see the note above. */
.sa-tick-ph--photo { position: relative; }
.sa-tick-ph--photo img {
	position: absolute;
	width:  calc(var(--sa-focal-scale, 308%) * var(--np-zoom, 1));
	height: calc(var(--sa-focal-scale, 308%) * var(--np-zoom, 1));
	max-width: none; max-height: none;
	left: calc(var(--np-fx, .5) * (1 - 3.08 * var(--np-zoom, 1)) * 100%);
	top:  calc(var(--np-fy, .4) * (1 - 3.08 * var(--np-zoom, 1)) * 100%);
	object-fit: cover;
	object-position: center 32%;
}
.sa-tick--spotlight .sa-tick-rank {
	font-style: normal;
	position: absolute; top: 5px; left: 5px;
	min-width: 20px; height: 20px; padding: 0 .3rem;
	border-radius: 7px;
	background: var(--sa-gradient, linear-gradient(135deg, #00A870, #00B48A 50%, #0FA89C));
	color: var(--sa-on-accent, #fff);
	font-size: .62rem; font-weight: 800;
	display: flex; align-items: center; justify-content: center;
}

.sa-tick--spotlight .sa-tick-body {
	position: relative; z-index: 1;
	flex: 1 1 auto; min-width: 0;
	display: flex; flex-direction: column; gap: .3rem;
}
.sa-tick--spotlight .sa-tick-poll {
	font-size: .62rem; font-weight: 800;
	letter-spacing: .12em; text-transform: uppercase;
	color: var(--sa-violet-light, #4BE3B0);
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sa-tick--spotlight .sa-tick-name {
	font-size: 1rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.2;
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sa-tick--spotlight .sa-tick-bar {
	height: 5px; border-radius: var(--sa-radius-pill, 999px);
	background: rgba(255, 255, 255, .09); overflow: hidden;
}
.sa-tick--spotlight .sa-tick-fill {
	display: block; height: 100%; width: 100%;
	border-radius: var(--sa-radius-pill, 999px);
	background: var(--sa-gradient, linear-gradient(135deg, #00A870, #00B48A 50%, #0FA89C));
	box-shadow: 0 0 12px rgba(0,195,137, .65);
	/* Share as a transform, not a width: a live update no longer relays the row.
	   A full-width fill SLID left (the Duel's technique) rather than scaled, so
	   its rounded end keeps its shape; the track's overflow clips the rest. */
	transform: translateX(calc((var(--w, .03) - 1) * 100%));
	transition: transform .5s ease;
}
.sa-tick--spotlight .sa-tick-foot {
	display: flex; align-items: baseline; gap: .42rem;
	font-size: .74rem; color: var(--sa-text-dim, #7F8CA0);
}
.sa-tick--spotlight .sa-tick-pct { font-weight: 800; color: var(--sa-text, #EEF3F8); font-size: .84rem; }
.sa-tick--spotlight .sa-tick-lead {
	margin-left: auto;
	font-size: .62rem; font-weight: 800;
	letter-spacing: .08em; text-transform: uppercase;
	color: var(--sa-gold, #C6FF3D);
}

@media (prefers-reduced-motion: reduce) {
	.sa-tick--spotlight .sa-tick-fill { transition: none; }
	.sa-tick .sa-tick-i { transition: none; }
	.sa-tick .sa-tick-i:hover { transform: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Narrow screens
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
	.sa-tick { --sa-tick-fade: 26px; }
	.sa-tick--broadcast .sa-tick__tab { padding: 0 1.5rem 0 .9rem; font-size: .66rem; letter-spacing: .1em; }
	.sa-tick--broadcast .sa-tick-poll { max-width: 15ch; }
	.sa-tick--broadcast .sa-tick-i { gap: .5rem; padding: 0 .7rem; }
	.sa-tick--spotlight .sa-tick-i { width: 272px; }
	.sa-tick__title { flex-basis: 100%; }
}

/* The tab's word is the only thing on the strip a very narrow phone cannot
   afford; the pulse alone still says "live". */
@media (max-width: 380px) {
	.sa-tick--broadcast .sa-tick__tab-word { display: none; }
	.sa-tick--broadcast .sa-tick__tab { padding: 0 1.25rem 0 .8rem; }
}
