/* TTFN SoundCloud Player — the player.
 * Copyright (c) 2026 TTFN TV Limited. All rights reserved.
 * Scoped to .ttfnscp, with !important where bbc.bm's tagDiv theme styles lists, links and images
 * inside text blocks (".tagdiv-type img { margin-bottom: 21px }" and the like). Fonts come from the
 * page. Sizes follow the box's own width (container queries): the home page's Radio News column is
 * about 430 px on a computer and 335 px on a phone; a post's column about 700 px. */

.ttfnscp {
	--ttfnscp-accent: #005db6;        /* bbc.bm's headings and buttons */
	--ttfnscp-accent-dark: #00478c;
	--ttfnscp-ink: #111318;
	--ttfnscp-muted: #5d6470;
	--ttfnscp-line: #e1e5ec;
	--ttfnscp-soft: #eef4fb;
	--ttfnscp-art: 120px;
	--ttfnscp-btn: 48px;

	container: ttfnscp / inline-size;
	position: relative;
	margin: 0 0 24px;
	padding: 14px;
	background: #fff;
	border: 1px solid var(--ttfnscp-line);
	border-radius: 10px;
	color: var(--ttfnscp-ink);
	font-size: 14px;
	line-height: 1.35;
	text-align: left;
}

.ttfnscp *, .ttfnscp *::before, .ttfnscp *::after { box-sizing: border-box; }
.ttfnscp a { text-decoration: none !important; box-shadow: none !important; border: 0 !important; }
.ttfnscp img { display: block; max-width: none; margin: 0 !important; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
.ttfnscp .ttfnscp-list,
.ttfnscp .ttfnscp-list > .ttfnscp-item { margin: 0 !important; padding: 0 !important; list-style: none !important; }
.ttfnscp .ttfnscp-item::before, .ttfnscp .ttfnscp-item::marker { content: none !important; }
.ttfnscp :focus-visible { outline: 3px solid var(--ttfnscp-accent); outline-offset: 2px; border-radius: 4px; }

/* A block editor embed keeps a 16:9 box for the iframe it held: not needed for this one. */
.wp-block-embed__wrapper:has(> .ttfnscp)::before { display: none !important; }

/* ---- What's playing ------------------------------------------------------- */

.ttfnscp .ttfnscp-now {
	display: grid;
	grid-template-columns: var(--ttfnscp-art) minmax(0, 1fr);
	gap: 14px;
	align-items: center;
}

.ttfnscp .ttfnscp-art {
	display: block;
	width: var(--ttfnscp-art);
	aspect-ratio: 1 / 1;
	border-radius: 6px;
	overflow: hidden;
	background: var(--ttfnscp-soft);
}
.ttfnscp .ttfnscp-art img { width: 100%; height: 100%; object-fit: cover; }

.ttfnscp .ttfnscp-main { min-width: 0; }
.ttfnscp .ttfnscp-head { display: flex; align-items: center; gap: 12px; }

.ttfnscp .ttfnscp-btn {
	flex: none;
	display: grid;
	place-items: center;
	width: var(--ttfnscp-btn);
	height: var(--ttfnscp-btn);
	border-radius: 50%;
	background: var(--ttfnscp-accent);
	color: #fff !important;
	cursor: pointer;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	transition: background .15s, transform .1s;
}
.ttfnscp .ttfnscp-btn:hover { background: var(--ttfnscp-accent-dark); }
.ttfnscp .ttfnscp-btn:active { transform: scale(.95); }
.ttfnscp .ttfnscp-btn:focus-visible { border-radius: 50%; }

.ttfnscp .ttfnscp-i { grid-area: 1 / 1; width: 24px; height: 24px; }
.ttfnscp .ttfnscp-i-play { margin-left: 2px; }
.ttfnscp .ttfnscp-i-pause,
.ttfnscp .ttfnscp-i-wait { display: none; }
.ttfnscp[data-state="playing"] .ttfnscp-i-play,
.ttfnscp[data-state="loading"] .ttfnscp-i-play { display: none; }
.ttfnscp[data-state="playing"] .ttfnscp-i-pause { display: block; }
.ttfnscp[data-state="loading"] .ttfnscp-i-wait { display: block; animation: ttfnscp-spin .9s linear infinite; }
@keyframes ttfnscp-spin { to { transform: rotate(360deg); } }

.ttfnscp .ttfnscp-names { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ttfnscp .ttfnscp-user {
	font-size: 12.5px;
	color: var(--ttfnscp-muted) !important;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.ttfnscp .ttfnscp-user:hover { color: var(--ttfnscp-ink) !important; }
.ttfnscp .ttfnscp-title {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
	font-size: 15.5px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--ttfnscp-ink) !important;
	overflow-wrap: anywhere;
}
.ttfnscp .ttfnscp-title:hover { color: var(--ttfnscp-accent) !important; }

/* ---- Position ------------------------------------------------------------- */

.ttfnscp .ttfnscp-seek {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 12px;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	color: var(--ttfnscp-muted);
}
.ttfnscp .ttfnscp-at, .ttfnscp .ttfnscp-len { flex: none; min-width: 2.6em; }
.ttfnscp .ttfnscp-len { text-align: right; }

.ttfnscp .ttfnscp-bar {
	position: relative;
	flex: 1;
	height: 20px;
	cursor: pointer;
	touch-action: pan-y;             /* a sideways drag moves the position; up and down still scrolls */
	-webkit-tap-highlight-color: transparent;
}
.ttfnscp .ttfnscp-bar::before {
	content: "";
	position: absolute;
	left: 0; right: 0; top: 8px;
	height: 4px;
	border-radius: 2px;
	background: #d9dfe8;
}
.ttfnscp .ttfnscp-fill {
	position: absolute;
	left: 0; top: 8px;
	height: 4px;
	width: 0;
	border-radius: 2px;
	background: var(--ttfnscp-accent);
}
.ttfnscp .ttfnscp-fill::after {      /* the knob, once a track is under way */
	content: "";
	position: absolute;
	right: -6px; top: -4px;
	width: 12px; height: 12px;
	border-radius: 50%;
	background: var(--ttfnscp-accent);
	box-shadow: 0 0 0 2px #fff;
	opacity: 0;
	transition: opacity .15s;
}
.ttfnscp:is([data-state="playing"], [data-state="paused"], [data-state="loading"]) .ttfnscp-fill::after { opacity: 1; }
.ttfnscp .ttfnscp-bar:focus-visible { outline-offset: 0; }

.ttfnscp .ttfnscp-msg { font-size: 13px; color: #b32d2e; }
.ttfnscp .ttfnscp-msg:not(:empty) { margin-top: 8px; }
.ttfnscp .ttfnscp-msg a { color: var(--ttfnscp-accent) !important; font-weight: 600; text-decoration: underline !important; }

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

.ttfnscp .ttfnscp-list {
	margin-top: 14px !important;
	border-top: 1px solid var(--ttfnscp-line);
}
.ttfnscp--single .ttfnscp-list { display: none; }

.ttfnscp .ttfnscp-item { border-bottom: 1px solid var(--ttfnscp-line); }
.ttfnscp .ttfnscp-row {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 6px 6px;
	color: var(--ttfnscp-ink) !important;
	-webkit-tap-highlight-color: transparent;
	transition: background .12s;
}
.ttfnscp .ttfnscp-row:hover { background: #f6f8fb; }
.ttfnscp .ttfnscp-item[aria-current="true"] .ttfnscp-row { background: var(--ttfnscp-soft); }
.ttfnscp .ttfnscp-item[aria-current="true"] .ttfnscp-name { color: var(--ttfnscp-accent); font-weight: 700; }

.ttfnscp .ttfnscp-thumb {
	position: relative;
	flex: none;
	width: 32px; height: 32px;
	border-radius: 4px;
	overflow: hidden;
	background: var(--ttfnscp-soft);
}
.ttfnscp .ttfnscp-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* "Now playing" bars over the picture of the track that's playing. */
.ttfnscp .ttfnscp-eq {
	position: absolute;
	inset: 0;
	display: none;
	align-items: flex-end;
	justify-content: center;
	gap: 2px;
	padding: 8px 7px;
	background: rgba(0, 45, 90, .55);
}
.ttfnscp .ttfnscp-eq i { display: block; width: 4px; height: 40%; background: #fff; border-radius: 1px; }
.ttfnscp[data-state="playing"] .ttfnscp-item[aria-current="true"] .ttfnscp-eq,
.ttfnscp[data-state="loading"] .ttfnscp-item[aria-current="true"] .ttfnscp-eq,
.ttfnscp[data-state="paused"] .ttfnscp-item[aria-current="true"] .ttfnscp-eq { display: flex; }
.ttfnscp[data-state="playing"] .ttfnscp-item[aria-current="true"] .ttfnscp-eq i { animation: ttfnscp-eq 1s ease-in-out infinite; }
.ttfnscp .ttfnscp-eq i:nth-child(2) { animation-delay: -.35s !important; }
.ttfnscp .ttfnscp-eq i:nth-child(3) { animation-delay: -.7s !important; }
@keyframes ttfnscp-eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }

.ttfnscp .ttfnscp-name {
	flex: 1;
	min-width: 0;
	font-size: 14px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.ttfnscp .ttfnscp-dur {
	flex: none;
	font-size: 12.5px;
	font-variant-numeric: tabular-nums;
	color: var(--ttfnscp-muted);
}

/* ---- Credit --------------------------------------------------------------- */

/* SoundCloud's official black logo on SoundCloud orange (#FF5500), bottom right, linking to the work:
 * its brand rules for a player of your own (no recolouring; at least 30 px wide). */
.ttfnscp .ttfnscp-foot { display: flex; justify-content: flex-end; margin-top: 10px; line-height: 0; }
.ttfnscp .ttfnscp-sc {
	display: inline-flex;
	align-items: center;
	padding: 5px 8px;
	border-radius: 4px;
	background: #ff5500;
	transition: filter .15s;
}
.ttfnscp .ttfnscp-sc:hover { filter: brightness(1.06); }
.ttfnscp .ttfnscp-sc img { width: 100px; height: 12px; max-width: none; }

/* ---- Narrow: the home page's column on a phone ---------------------------- */

@container ttfnscp (max-width: 460px) {
	/* (A container query styles what's inside the box, not the box: hence .ttfnscp-now.) */
	.ttfnscp .ttfnscp-now { --ttfnscp-art: 84px; --ttfnscp-btn: 44px; gap: 12px; }
	.ttfnscp .ttfnscp-title { font-size: 14.5px; }
	.ttfnscp .ttfnscp-head { gap: 10px; }
}
@container ttfnscp (max-width: 360px) {
	/* The position bar goes under the picture, the full width of the box. */
	.ttfnscp .ttfnscp-now { --ttfnscp-art: 64px; grid-template-columns: var(--ttfnscp-art) minmax(0, 1fr); }
	.ttfnscp .ttfnscp-main { display: contents; }
	.ttfnscp .ttfnscp-head { grid-column: 2; }
	.ttfnscp .ttfnscp-seek, .ttfnscp .ttfnscp-msg { grid-column: 1 / -1; margin-top: 0; }
	.ttfnscp .ttfnscp-msg:empty { display: none; }
	.ttfnscp .ttfnscp-title { -webkit-line-clamp: 3; line-clamp: 3; }
}

@media (prefers-reduced-motion: reduce) {
	.ttfnscp *, .ttfnscp *::before, .ttfnscp *::after { animation-duration: 0s !important; transition: none !important; }
	.ttfnscp[data-state="loading"] .ttfnscp-i-wait { animation: ttfnscp-spin 1.6s linear infinite !important; }
}
