/**
 * ECS Broadcast Archive — player and list styling.
 *
 * Shares the visual language of the ECS Radio Player: same dark card, same
 * derived team-colour palette, same restraint about motion. The difference is
 * that this one has a timeline, so it carries a scrubber, skip buttons and a
 * speed control that a live stream has no use for.
 *
 * Every colour is a custom property written inline per block, so two players
 * on one page can wear different team colours without collision.
 */

.ecs-archive {
	--ecs-card: #17191E;
	--ecs-card-2: #1E2127;
	--ecs-ink: #ECEEF1;
	--ecs-dim: #8B929C;
	--ecs-rule: #292D34;
	--ecs-accent: #C8102E;
	--ecs-accent-ink: #FFFFFF;
	--ecs-pad: 18px;

	font-family: inherit;
	max-width: 100%;
	margin: 0 0 28px;

	/*
	 * NOTE: no `color` here, deliberately.
	 *
	 * This wrapper is transparent and sits on whatever the theme's page
	 * background is. An earlier version set color:var(--ecs-ink) at this
	 * level, which is a LIGHT colour intended for the dark card — so any
	 * child not sitting on the card rendered white-on-white and vanished.
	 *
	 * Text colour is set on the card surfaces instead, and every piece of
	 * text now lives on one of them. If you add anything to this block,
	 * put it inside .ecs-archive-player or .ecs-archive-list, or give it an
	 * explicit colour that works on an unknown background.
	 */
}

.ecs-archive *,
.ecs-archive *::before,
.ecs-archive *::after {
	box-sizing: border-box;
}

.ecs-archive-heading {
	margin: 0;
	font-size: 18px;
	font-weight: 650;
	line-height: 1.25;
	color: var(--ecs-ink);
	overflow-wrap: anywhere;
	min-width: 0;
}

/* Standalone heading on the empty-state card, which has no bar. */
.ecs-archive-heading.is-standalone {
	margin-bottom: 12px;
}

/* ---------- header bar ---------- */

/*
 * Sits inside the card, above the artwork, carrying the player's title and
 * the recording count. Both used to render outside the card on the page
 * background, where they inherited a light text colour meant for the dark
 * surface and became invisible on a white theme.
 */
.ecs-archive-bar {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 14px;
	flex-wrap: wrap;
	padding-bottom: 13px;
	margin-bottom: 15px;
	border-bottom: 1px solid var(--ecs-rule);
}

/* ---------- player ---------- */

.ecs-archive-player {
	background: var(--ecs-card);
	color: var(--ecs-ink);
	border: 1px solid var(--ecs-rule);
	border-radius: 10px 10px 0 0;
	padding: var(--ecs-pad);
	border-bottom: 0;
}

.ecs-archive-head {
	display: flex;
	gap: 16px;
	align-items: flex-start;
	margin-bottom: 16px;
}

.ecs-archive-art {
	flex: 0 0 84px;
	width: 84px;
	aspect-ratio: 1 / 1;
	border-radius: 6px;
	overflow: hidden;
	background: var(--ecs-card-2);
}

.ecs-archive-art img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.ecs-archive-meta {
	flex: 1 1 auto;
	min-width: 0;
}

.ecs-archive-eyebrow {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	align-items: baseline;
	font-size: 11px;
	letter-spacing: 0.11em;
	text-transform: uppercase;
	font-weight: 700;
	color: var(--ecs-dim);
	margin-bottom: 5px;
	min-height: 1em;
}

.ecs-archive-date {
	color: var(--ecs-accent);
}

.ecs-archive-title {
	margin: 0;
	font-size: 19px;
	line-height: 1.3;
	font-weight: 650;
	color: var(--ecs-ink);
	overflow-wrap: anywhere;
}

/*
 * Notes carry a left rule in the accent so they read as an aside from the
 * broadcaster rather than as part of the title block. Collapses entirely
 * when a recording has none, which is most of them.
 */
.ecs-archive-notes {
	margin-top: 8px;
	padding-left: 11px;
	border-left: 2px solid var(--ecs-accent);
	font-size: 13px;
	line-height: 1.5;
	color: var(--ecs-dim);
}

.ecs-archive-notes:empty {
	display: none;
}

/* ---------- controls ---------- */

.ecs-archive-controls {
	display: flex;
	align-items: center;
	gap: 12px;
}

.ecs-archive-play {
	position: relative;
	flex: none;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	border: 0;
	background: var(--ecs-accent);
	color: var(--ecs-accent-ink);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	transition: transform 0.12s ease;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.ecs-archive-play svg {
	width: 21px;
	height: 21px;
}

.ecs-archive-play:hover { transform: scale(1.06); }
.ecs-archive-play:active { transform: scale(0.97); }

/*
 * Focus rings: keyboard only, and always in the accent colour.
 *
 * Two separate problems are handled here.
 *
 * First, these controls are real <button> elements, so a theme's generic
 * `button:focus { outline: ... }` rule applies to them. That is where the
 * stray white ring on a clicked row came from — it was the theme's, not
 * ours. Explicitly clearing :focus stops it.
 *
 * Second, clearing focus outright would strip the only cue a keyboard user
 * has for where they are. So the ring is restored under :focus-visible,
 * which browsers set for keyboard navigation but not for mouse clicks.
 *
 * A clicked row still shows it was clicked — accent bar down the left edge
 * and a lifted background — which is the quieter, more deliberate signal.
 */
.ecs-archive-play:focus,
.ecs-archive-skip:focus,
.ecs-archive-rate:focus,
.ecs-archive-row:focus,
.ecs-archive-seek:focus {
	outline: none;
	box-shadow: none;
}

.ecs-archive-play:focus-visible,
.ecs-archive-skip:focus-visible,
.ecs-archive-rate:focus-visible,
.ecs-archive-seek:focus-visible {
	outline: 2px solid var(--ecs-accent);
	outline-offset: 2px;
}

/*
 * Rows use an inset ring. A row is full-bleed inside the list, so an outset
 * outline would be clipped by the container's overflow and appear as a ring
 * with its sides sliced off.
 */
.ecs-archive-row:focus-visible {
	outline: 2px solid var(--ecs-accent);
	outline-offset: -2px;
}

/* The selected row keeps its accent bar; restore it after the focus rules. */
.ecs-archive-row.is-selected:focus-visible {
	box-shadow: inset 3px 0 0 var(--ecs-accent);
}

.ecs-archive-play .ecs-icon-pause,
.ecs-archive.is-playing .ecs-archive-play .ecs-icon-play {
	display: none;
}

.ecs-archive.is-playing .ecs-archive-play .ecs-icon-pause {
	display: block;
}

.ecs-archive-spinner {
	display: none;
	position: absolute;
	width: 19px;
	height: 19px;
	border: 2px solid rgba(0, 0, 0, 0.25);
	border-top-color: currentColor;
	border-radius: 50%;
	animation: ecs-arch-spin 0.7s linear infinite;
}

.ecs-archive.is-loading .ecs-archive-spinner { display: block; }
.ecs-archive.is-loading .ecs-archive-play svg { visibility: hidden; }

@keyframes ecs-arch-spin { to { transform: rotate(360deg); } }

/*
 * Skip buttons carry their interval as a number inside the arrow, the way
 * podcast apps do. Without the number, users have to guess whether it is 10,
 * 15 or 30 seconds.
 */
.ecs-archive-skip {
	position: relative;
	flex: none;
	width: 34px;
	height: 34px;
	border: 0;
	background: none;
	color: var(--ecs-dim);
	cursor: pointer;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 6px;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.ecs-archive-skip:hover { color: var(--ecs-ink); }

.ecs-archive-skip svg {
	width: 26px;
	height: 26px;
}

.ecs-archive-skip-n {
	position: absolute;
	top: 55%;
	left: 50%;
	transform: translate(-50%, -50%);
	font-size: 8.5px;
	font-weight: 700;
	letter-spacing: -0.02em;
	pointer-events: none;
}

.ecs-archive-scrub {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1 1 auto;
	min-width: 0;
}

.ecs-archive-time {
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	color: var(--ecs-dim);
	flex: none;
	min-width: 34px;
}

.ecs-archive-total { text-align: right; }

.ecs-archive-seek {
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	flex: 1 1 auto;
	min-width: 0;
	height: 20px;
	cursor: pointer;
	margin: 0;
	touch-action: manipulation;
}

.ecs-archive-seek::-webkit-slider-runnable-track {
	height: 4px;
	border-radius: 2px;
	background: linear-gradient(
		to right,
		var(--ecs-accent) 0 var(--fill, 0%),
		var(--ecs-rule) var(--fill, 0%) 100%
	);
}

.ecs-archive-seek::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 13px;
	height: 13px;
	border-radius: 50%;
	background: var(--ecs-accent);
	margin-top: -4.5px;
	border: 0;
}

.ecs-archive-seek::-moz-range-track {
	height: 4px;
	border-radius: 2px;
	background: var(--ecs-rule);
}

.ecs-archive-seek::-moz-range-progress {
	height: 4px;
	border-radius: 2px;
	background: var(--ecs-accent);
}

.ecs-archive-seek::-moz-range-thumb {
	width: 13px;
	height: 13px;
	border-radius: 50%;
	background: var(--ecs-accent);
	border: 0;
}

.ecs-archive-rate {
	flex: none;
	min-width: 38px;
	height: 28px;
	border: 1px solid var(--ecs-rule);
	background: none;
	color: var(--ecs-dim);
	border-radius: 100px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	padding: 0 8px;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.ecs-archive-rate:hover {
	color: var(--ecs-ink);
	border-color: var(--ecs-accent);
}

.ecs-archive-msg {
	display: none;
	margin-top: 10px;
	font-size: 12.5px;
	color: var(--ecs-dim);
}

.ecs-archive.has-msg .ecs-archive-msg { display: block; }

/* ---------- list ---------- */

.ecs-archive-list {
	background: var(--ecs-card);
	color: var(--ecs-ink);
	border: 1px solid var(--ecs-rule);
	border-radius: 0 0 10px 10px;
	/*
	 * overflow:hidden is here only to clip the row backgrounds to the rounded
	 * bottom corners. There is deliberately NO max-height and no inner
	 * scrollbar.
	 *
	 * An earlier version capped the list at 420px and scrolled inside it. That
	 * is a worse experience than it sounds: a scroll region nested in a page
	 * traps the wheel, is awkward on a trackpad, hides how much is there, and
	 * makes browser find-in-page skip over rows that are not scrolled into
	 * view. Letting the list run its natural length means Ctrl+F finds every
	 * game and the page scrolls the way every other page does.
	 *
	 * If an archive ever grows to the point where the page is unwieldy, the
	 * answer is the shortcode's limit attribute, not a scrollbar.
	 */
	overflow: hidden;
}

.ecs-archive-row {
	display: flex;
	align-items: center;
	gap: 13px;
	width: 100%;
	padding: 11px 16px;
	background: none;
	border: 0;
	border-top: 1px solid var(--ecs-rule);
	color: inherit;
	cursor: pointer;
	text-align: left;
	font: inherit;
	transition: background 0.15s ease;
	-webkit-tap-highlight-color: transparent;
}

.ecs-archive-row:first-child { border-top: 0; }

.ecs-archive-row:hover {
	background: var(--ecs-card-2);
}

.ecs-archive-row.is-selected {
	background: var(--ecs-card-2);
	box-shadow: inset 3px 0 0 var(--ecs-accent);
}

.ecs-archive-row-icon {
	flex: none;
	width: 26px;
	height: 26px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--ecs-dim);
	position: relative;
}

.ecs-archive-row-icon svg { width: 17px; height: 17px; }

.ecs-archive-row.is-selected .ecs-archive-row-icon { color: var(--ecs-accent); }

/* Pause icon and equaliser only appear on the row that is actually playing. */
.ecs-archive-row .ecs-row-pause,
.ecs-archive-row .ecs-archive-bars { display: none; }

.ecs-archive-row.is-playing .ecs-row-play { display: none; }
.ecs-archive-row.is-playing .ecs-archive-bars { display: flex; }

/*
 * A three-bar equaliser marking the playing row. Cheap, instantly readable,
 * and it does not repeat the information the play button already shows.
 */
.ecs-archive-bars {
	align-items: flex-end;
	gap: 2px;
	height: 15px;
}

.ecs-archive-bars i {
	display: block;
	width: 3px;
	background: var(--ecs-accent);
	border-radius: 1px;
	animation: ecs-arch-bar 1s ease-in-out infinite;
}

.ecs-archive-bars i:nth-child(1) { height: 40%; animation-delay: -0.2s; }
.ecs-archive-bars i:nth-child(2) { height: 100%; animation-delay: -0.5s; }
.ecs-archive-bars i:nth-child(3) { height: 65%; animation-delay: -0.8s; }

@keyframes ecs-arch-bar {
	0%, 100% { transform: scaleY(0.4); }
	50%      { transform: scaleY(1); }
}

.ecs-archive-row-body {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.ecs-archive-row-title {
	font-size: 14px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--ecs-ink);
	overflow-wrap: anywhere;
}

.ecs-archive-row-sub {
	font-size: 11.5px;
	color: var(--ecs-dim);
	line-height: 1.35;
}

.ecs-archive-row-time {
	flex: none;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	color: var(--ecs-dim);
}

.ecs-archive-count {
	font-size: 11.5px;
	color: var(--ecs-dim);
	letter-spacing: 0.04em;
	white-space: nowrap;
	flex: none;
}

/* ---------- empty ---------- */

.ecs-archive-empty {
	background: var(--ecs-card);
	color: var(--ecs-dim);
	border: 1px solid var(--ecs-rule);
	border-radius: 10px;
	padding: 34px 20px;
	text-align: center;
	color: var(--ecs-dim);
}

.ecs-archive-empty p { margin: 0; }

.ecs-archive-empty-hint {
	margin-top: 11px !important;
	font-size: 12.5px;
	color: #F0A83C;
}

/* ---------- phones ---------- */

@media (max-width: 560px) {
	.ecs-archive { --ecs-pad: 14px; }

	.ecs-archive-art { flex-basis: 62px; width: 62px; }

	.ecs-archive-title { font-size: 17px; }

	/*
	 * Controls wrap to two rows on a narrow screen: transport on top, the
	 * scrubber given the full width beneath. Squeezing a seek bar in beside
	 * four buttons on a 360px screen leaves it about 90px wide, which is
	 * unusable for scrubbing a two-hour recording.
	 */
	.ecs-archive-controls {
		flex-wrap: wrap;
		gap: 10px;
	}

	.ecs-archive-scrub {
		order: 3;
		flex-basis: 100%;
		min-width: 100%;
	}

	.ecs-archive-rate { margin-left: auto; }


	.ecs-archive-row { padding: 10px 13px; }
}

@media (pointer: coarse) {
	.ecs-archive-play { width: 54px; height: 54px; }
	.ecs-archive-play svg { width: 24px; height: 24px; }

	.ecs-archive-skip { width: 44px; height: 44px; }
	.ecs-archive-skip svg { width: 30px; height: 30px; }

	.ecs-archive-seek { height: 34px; }

	.ecs-archive-seek::-webkit-slider-thumb {
		width: 18px;
		height: 18px;
		margin-top: -7px;
	}

	.ecs-archive-seek::-moz-range-thumb { width: 18px; height: 18px; }

	.ecs-archive-row { padding-top: 14px; padding-bottom: 14px; }

	.ecs-archive-play:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.ecs-archive *,
	.ecs-archive *::before,
	.ecs-archive *::after {
		animation: none !important;
		transition: none !important;
	}
}
