/**
 * MP3 audio player — branded RTL player for core/audio blocks.
 *
 * Progressive enhancement: the native <audio controls> renders normally until
 * assets/js/components/audio-player.js adds `.is-enhanced` to the wrapper, at
 * which point the raw control is hidden and the custom UI takes over. Because
 * the only hide rule is gated on `.is-enhanced` (never a first-paint default),
 * there is no FOUC and the file is safe to load without special deferral.
 *
 * @package Hamechadesh
 */

.hm-audio-player {
	margin-block: var(--hm-space-lg);
	max-width: 100%;
}

/* Native control stays visible as a fallback until JS enhances the player. */
.hm-audio-player.is-enhanced .hm-audio-player__native {
	display: none;
}

.hm-audio-player__native {
	width: 100%;
	max-width: 100%;
}

.hm-audio-player__ui {
	display: flex;
	align-items: center;
	gap: var(--hm-space-sm);
	padding: 10px 14px;
	background: var(--hm-color-bg-alt);
	border: 1px solid var(--hm-color-border);
	border-radius: var(--hm-radius-lg);
	box-shadow: var(--hm-shadow-sm);
	font-family: var(--hm-font-primary);
}

/* === Buttons === */
.hm-audio-player__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--hm-color-text);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: background-color var(--hm-transition-fast),
		color var(--hm-transition-fast),
		transform var(--hm-transition-fast);
}

.hm-audio-player__btn svg {
	display: block;
	width: 22px;
	height: 22px;
}

.hm-audio-player__btn:hover {
	background: rgba(33, 33, 33, 0.06);
}

.hm-audio-player__btn:active {
	transform: scale(0.92);
}

.hm-audio-player__btn:focus-visible {
	outline: 2px solid var(--hm-color-accent);
	outline-offset: 2px;
}

/* Play/pause — accent-filled and larger, the primary action. */
.hm-audio-player__play {
	width: 44px;
	height: 44px;
	background: var(--hm-color-accent);
	color: #fff;
}

.hm-audio-player__play svg {
	width: 24px;
	height: 24px;
}

.hm-audio-player__play:hover {
	background: var(--hm-color-accent);
	filter: brightness(1.08);
}

.hm-audio-player__skip {
	color: var(--hm-color-text-muted);
}

.hm-audio-player__skip:hover {
	color: var(--hm-color-text);
}

/* === Scrubber === */
.hm-audio-player__progress {
	flex: 1 1 auto;
	min-width: 48px;
	padding-block: 10px; /* enlarge the pointer/touch hit area */
	cursor: pointer;
	touch-action: none;  /* let pointer drag work on touch without scrolling */
}

.hm-audio-player__progress:focus-visible {
	outline: 2px solid var(--hm-color-accent);
	outline-offset: 3px;
	border-radius: 4px;
}

.hm-audio-player__track {
	position: relative;
	height: 5px;
	border-radius: 999px;
	background: var(--hm-color-border);
}

.hm-audio-player__fill {
	position: absolute;
	inset-block: 0;
	left: 0; /* LTR track: playback fills left-to-right */
	width: 0;
	border-radius: 999px;
	background: var(--hm-color-accent);
}

.hm-audio-player__thumb {
	position: absolute;
	top: 50%;
	right: -6px; /* rides the leading edge of the fill */
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--hm-color-accent);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
	transform: translateY(-50%);
	opacity: 0;
	transition: opacity var(--hm-transition-fast);
}

.hm-audio-player__progress:hover .hm-audio-player__thumb,
.hm-audio-player__progress:focus-visible .hm-audio-player__thumb {
	opacity: 1;
}

/* === Time === */
.hm-audio-player__time {
	flex: 0 0 auto;
	font-size: var(--hm-font-size-sm);
	color: var(--hm-color-text-muted);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	unicode-bidi: isolate;
}

.hm-audio-player__current {
	color: var(--hm-color-text);
}

/* === Volume === */
.hm-audio-player__volume {
	display: flex;
	align-items: center;
	gap: 4px;
	flex: 0 0 auto;
}

.hm-audio-player__vol-slider {
	width: 72px;
	accent-color: var(--hm-color-accent);
	cursor: pointer;
}

/* === Responsive === */
@media (max-width: 600px) {
	.hm-audio-player__ui {
		gap: 6px;
		padding: 8px 10px;
	}

	.hm-audio-player__btn {
		width: 34px;
		height: 34px;
	}

	.hm-audio-player__play {
		width: 40px;
		height: 40px;
	}

	/* System volume handles this on touch devices — reclaim the width. */
	.hm-audio-player__vol-slider {
		display: none;
	}
}
