/**
 * Audio Content — player.
 *
 * Colours derive from the surrounding text colour, so the player follows
 * the theme in light and dark contexts. Override any of the custom
 * properties below (e.g. `.acp-player { --acp-accent: #c00; }`) to restyle it.
 */

.acp-player {
	--acp-accent-color: var(--acp-accent, currentColor);
	--acp-on-accent: #fff;
	--acp-radius: 16px;
	--acp-surface: rgba(127, 127, 127, 0.08);
	--acp-border: rgba(127, 127, 127, 0.28);
	--acp-track: rgba(127, 127, 127, 0.3);
	--acp-progress: 0%;

	container-type: inline-size;
	box-sizing: border-box;
	max-width: 100%;
	margin: 1.5em 0;
	padding: 16px;
	border: 1px solid var(--acp-border);
	border-radius: var(--acp-radius);
	background: var(--acp-surface);
	font-family: inherit;
	font-size: 16px;
	line-height: 1.4;
	text-align: start;
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
	.acp-player {
		--acp-surface: color-mix(in srgb, currentColor 5%, transparent);
		--acp-border: color-mix(in srgb, currentColor 16%, transparent);
		--acp-track: color-mix(in srgb, currentColor 18%, transparent);
	}
}

.acp-player *,
.acp-player *::before,
.acp-player *::after {
	box-sizing: border-box;
}

.acp-player [hidden] {
	display: none !important;
}

.acp-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Native <audio> is only the no-JavaScript fallback. */
.acp-audio {
	display: block;
	width: 100%;
}

.acp-ready .acp-audio {
	display: none;
}

/* ---------- Header: cover, title, description ---------- */

.acp-head {
	display: flex;
	gap: 12px;
	align-items: center;
	margin-bottom: 14px;
	min-width: 0;
}

.acp-player .acp-cover {
	flex: none;
	width: 64px;
	height: 64px;
	margin: 0;
	border-radius: 10px;
	object-fit: cover;
}

.acp-meta {
	min-width: 0;
}

.acp-title {
	font-weight: 700;
	font-size: 1.0625em;
	line-height: 1.3;
	overflow-wrap: anywhere;
}

.acp-title a {
	color: inherit;
	text-decoration: none;
}

.acp-title a:hover,
.acp-title a:focus-visible {
	text-decoration: underline;
}

.acp-desc {
	margin-top: 2px;
	font-size: 0.875em;
	opacity: 0.75;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
}

/* ---------- Controls ---------- */

.acp-main {
	display: flex;
	gap: 14px;
	align-items: center;
}

.acp-player .acp-btn {
	-webkit-appearance: none;
	appearance: none;
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	box-shadow: none;
	color: inherit;
	font: inherit;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.15s ease, transform 0.1s ease;
}

.acp-player .acp-btn:hover {
	background: var(--acp-track);
	color: inherit;
}

.acp-player .acp-btn:active {
	transform: scale(0.94);
}

.acp-player .acp-btn:focus-visible,
.acp-player .acp-range:focus-visible,
.acp-player .acp-speed:focus-visible,
.acp-player .acp-retry:focus-visible {
	outline: 2px solid var(--acp-accent-color);
	outline-offset: 2px;
}

.acp-icon {
	display: block;
	width: 24px;
	height: 24px;
	pointer-events: none;
}

/* Play / pause: the primary action. */
.acp-player .acp-play {
	width: 56px;
	height: 56px;
	background: var(--acp-track);
	color: var(--acp-accent-color);
}

.acp-player.acp-accented .acp-play {
	background: var(--acp-accent-color);
	color: var(--acp-on-accent);
}

.acp-player.acp-accented .acp-play:hover {
	background: var(--acp-accent-color);
	filter: brightness(1.12);
}

.acp-play .acp-icon {
	width: 28px;
	height: 28px;
}

.acp-play .acp-icon-pause,
.acp-play .acp-icon-spinner,
.acp-is-playing .acp-play .acp-icon-play,
.acp-is-loading .acp-play .acp-icon-play,
.acp-is-loading .acp-play .acp-icon-pause {
	display: none;
}

.acp-is-playing .acp-play .acp-icon-pause,
.acp-is-loading .acp-play .acp-icon-spinner {
	display: block;
}

.acp-icon-spinner {
	animation: acp-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.acp-icon-spinner {
		animation-duration: 2.4s;
	}

	.acp-player .acp-btn {
		transition: none;
	}
}

/* Timeline */
.acp-timeline {
	flex: 1;
	min-width: 0;
}

.acp-times {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	margin-top: 2px;
	font-size: 0.8125em;
	font-variant-numeric: tabular-nums;
	opacity: 0.8;
}

.acp-status {
	flex: 1;
	text-align: center;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

/* Range inputs (seek and volume): native elements, so keyboard and screen-reader support come for free. */
.acp-player .acp-range {
	-webkit-appearance: none;
	appearance: none;
	display: block;
	width: 100%;
	height: 24px;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	box-shadow: none;
	/* Form controls don't inherit colour by default; the accent falls back to it. */
	color: inherit;
	cursor: pointer;
	touch-action: pan-y;
}

.acp-player .acp-range::-webkit-slider-runnable-track {
	height: 6px;
	border-radius: 3px;
	background: linear-gradient(to right, var(--acp-accent-color) var(--acp-progress), var(--acp-track) var(--acp-progress));
}

[dir="rtl"] .acp-player .acp-range::-webkit-slider-runnable-track {
	background: linear-gradient(to left, var(--acp-accent-color) var(--acp-progress), var(--acp-track) var(--acp-progress));
}

.acp-player .acp-range::-moz-range-track {
	height: 6px;
	border-radius: 3px;
	background: var(--acp-track);
}

.acp-player .acp-range::-moz-range-progress {
	height: 6px;
	border-radius: 3px;
	background: var(--acp-accent-color);
}

.acp-player .acp-range::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px;
	height: 16px;
	margin-top: -5px;
	border: 0;
	border-radius: 50%;
	background: var(--acp-accent-color);
	box-shadow: 0 0 0 2px var(--acp-on-accent);
}

.acp-player .acp-range::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border: 0;
	border-radius: 50%;
	background: var(--acp-accent-color);
	box-shadow: 0 0 0 2px var(--acp-on-accent);
}

/* Secondary tools */
.acp-tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px;
	margin-top: 8px;
}

.acp-spacer {
	flex: 1;
}

.acp-volume {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

/* Phones control volume with hardware buttons; the slider appears on wider players. */
.acp-player .acp-vol {
	display: none;
	width: 84px;
}

.acp-mute .acp-icon-muted,
.acp-is-muted .acp-mute .acp-icon-volume {
	display: none;
}

.acp-is-muted .acp-mute .acp-icon-muted {
	display: block;
}

.acp-player .acp-speed {
	-webkit-appearance: none;
	appearance: none;
	width: auto;
	min-width: 56px;
	height: 44px;
	margin: 0;
	padding: 0 10px;
	border: 1px solid var(--acp-border);
	border-radius: 22px;
	background: transparent;
	background-image: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	font-size: 0.875em;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	line-height: 1;
	text-align: center;
	text-align-last: center;
	cursor: pointer;
}

.acp-player .acp-speed option {
	color: initial;
}

/* Error */
.acp-error {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 12px;
	margin-top: 12px;
	padding: 10px 12px;
	border-radius: 10px;
	background: var(--acp-track);
	font-size: 0.875em;
}

.acp-player .acp-retry {
	-webkit-appearance: none;
	appearance: none;
	min-height: 36px;
	margin: 0;
	padding: 0 14px;
	border: 1px solid currentColor;
	border-radius: 18px;
	background: transparent;
	box-shadow: none;
	color: inherit;
	font: inherit;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
}

/* ---------- Wider players ---------- */

@container (min-width: 520px) {
	.acp-player {
		padding: 20px 24px;
	}

	.acp-player .acp-cover {
		width: 88px;
		height: 88px;
		border-radius: 12px;
	}

	.acp-head {
		gap: 16px;
		margin-bottom: 16px;
	}

	.acp-title {
		font-size: 1.1875em;
	}

	.acp-player .acp-vol {
		display: block;
	}

	/* Everything on one line when there is room. */
	.acp-ui {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: center;
		column-gap: 16px;
	}

	.acp-tools {
		flex-wrap: nowrap;
		margin-top: 0;
	}

	.acp-spacer {
		display: none;
	}

	.acp-error {
		grid-column: 1 / -1;
	}
}

/* Narrow players that sit in a wide container still stack the tools below. */
@container (min-width: 520px) and (max-width: 719px) {
	.acp-ui {
		display: block;
	}

	.acp-tools {
		margin-top: 8px;
	}

	.acp-spacer {
		display: block;
	}
}

/* ---------- Block alignment ---------- */

.wp-block-audio-content-player {
	margin: 1.5em 0;
}

.wp-block-audio-content-player > .acp-player {
	margin: 0;
}
