/* Self-Hosted Waveform Player — "Smooth envelope" style */

.shwp-player {
	--shwp-accent: #111111;
	--shwp-on-accent: #ffffff;
	--shwp-wave: #dededb;
	--shwp-bg: #ffffff;
	--shwp-text: #111111;
	--shwp-muted: #6b6b6b;
	--shwp-border: #e3e3e0;
	--shwp-btn-hover: rgba(0, 0, 0, 0.06);
	--shwp-cover-size: 72px;
	--shwp-wave-height: 64px;
	--shwp-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

	container-type: inline-size;
	container-name: shwp;
	box-sizing: border-box;
	display: block;
	width: 100%;
	max-width: 100%;
	margin: 1.5em 0;
	background: var(--shwp-bg);
	color: var(--shwp-text);
	border: 1px solid var(--shwp-border);
	border-radius: 6px;
	overflow: hidden;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	line-height: 1.35;
	text-align: left;
	-webkit-font-smoothing: antialiased;
}

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

.shwp-theme-dark {
	--shwp-accent: #ffffff;
	--shwp-on-accent: #111111;
	--shwp-wave: #4d4d4d;
	--shwp-bg: #161616;
	--shwp-text: #f2f2f2;
	--shwp-muted: #9a9a9a;
	--shwp-border: #2a2a2a;
	--shwp-btn-hover: rgba(255, 255, 255, 0.08);
}

/* ---------- Layout ----------
   Narrow (phones):   [cover][title / artist / time]
                      [waveform ..................]
                      [controls ..................]
   Wide (≥460px):     [cover][title ........ time]
                      [cover][waveform ..........]
                      [cover][controls ..........]
*/

.shwp-inner {
	display: grid;
	grid-template-columns: var(--shwp-cover-size) minmax(0, 1fr);
	grid-template-areas:
		"cover    head"
		"wave     wave"
		"controls controls";
	gap: 12px 14px;
	padding: 12px;
	align-items: center;
}

.shwp-no-cover .shwp-inner {
	grid-template-columns: minmax(0, 1fr);
	grid-template-areas:
		"head"
		"wave"
		"controls";
}

@container shwp (min-width: 460px) {
	.shwp-inner {
		--shwp-cover-size: 132px;
		--shwp-wave-height: 72px;
		grid-template-areas:
			"cover head"
			"cover wave"
			"cover controls";
		grid-template-rows: auto 1fr auto;
		gap: 8px 20px;
		padding: 14px 20px 14px 14px;
	}
	.shwp-no-cover .shwp-inner {
		grid-template-areas:
			"head"
			"wave"
			"controls";
		padding: 14px 20px;
	}
	.shwp-player .shwp-head {
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: baseline;
	}
	.shwp-player .shwp-clock {
		justify-self: end;
	}
}

@container shwp (min-width: 680px) {
	.shwp-inner {
		--shwp-cover-size: 184px;
		--shwp-wave-height: 84px;
		gap: 10px 28px;
		padding: 14px 24px 14px 14px;
	}
	.shwp-player .shwp-title {
		font-size: 24px;
	}
}

/* Share page: bigger artwork and waveform. */
@container shwp (min-width: 680px) {
	.shwp-player--share .shwp-inner {
		--shwp-cover-size: 260px;
		--shwp-wave-height: 130px;
		gap: 14px 32px;
		padding: 24px 32px 24px 24px;
	}
	.shwp-player.shwp-player--share .shwp-title {
		font-size: 30px;
	}
	.shwp-player.shwp-player--share .shwp-clock {
		font-size: 15px;
	}
}

@container shwp (max-width: 459.98px) {
	.shwp-player--share .shwp-inner {
		--shwp-cover-size: 100%;
		--shwp-wave-height: 80px;
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas:
			"cover"
			"head"
			"wave"
			"controls";
	}
	.shwp-player--share .shwp-cover {
		max-width: 420px;
		width: 100%;
		margin: 0 auto;
	}
}

/* ---------- Cover ---------- */

.shwp-cover {
	grid-area: cover;
	width: var(--shwp-cover-size);
	aspect-ratio: 1 / 1;
	border-radius: 2px;
	overflow: hidden;
	background: var(--shwp-btn-hover);
	align-self: start;
}

.shwp-cover img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

/* Safety net: tags injected by wpautop() or page builders must not affect the layout.
   (Not inside the description, where line breaks are real content.) */
.shwp-player > br,
.shwp-inner br,
.shwp-player > p:empty,
.shwp-inner p:empty {
	display: none !important;
}

/* Themes often outline anything focused; keep the outline for keyboard users only. */
.shwp-player button:focus:not(:focus-visible),
.shwp-player a:focus:not(:focus-visible),
.shwp-wave:focus:not(:focus-visible) {
	outline: none;
}

.shwp-player > p,
.shwp-inner > p,
.shwp-head > p,
.shwp-controls > p {
	display: contents;
}

/* ---------- Head: title, artist, time ---------- */

.shwp-head {
	grid-area: head;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 4px 16px;
	min-width: 0;
}

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

.shwp-title {
	color: var(--shwp-text);
	font-size: 20px;
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: 1.2;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow-wrap: anywhere;
}

.shwp-artist {
	color: var(--shwp-muted);
	font-size: 14px;
	margin-top: 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.shwp-clock {
	flex: none;
	font-family: var(--shwp-mono);
	font-size: 13px;
	color: var(--shwp-text);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.shwp-time-dur-wrap {
	color: var(--shwp-muted);
}

.shwp-time-dur:empty,
.shwp-time-dur-wrap:has(.shwp-time-dur:empty) {
	display: none;
}

/* ---------- Waveform ---------- */

.shwp-wave {
	grid-area: wave;
	position: relative;
	width: 100%;
	height: var(--shwp-wave-height);
	cursor: pointer;
	/* Vertical swipes scroll the page; taps and sideways drags seek. */
	touch-action: pan-y;
	user-select: none;
	-webkit-user-select: none;
	-webkit-tap-highlight-color: transparent;
}

.shwp-wave canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}

.shwp-time-hover {
	position: absolute;
	top: 0;
	left: 0;
	padding: 2px 6px;
	border-radius: 3px;
	background: var(--shwp-accent);
	color: var(--shwp-on-accent);
	font-family: var(--shwp-mono);
	font-size: 11px;
	line-height: 14px;
	font-variant-numeric: tabular-nums;
	pointer-events: none;
	z-index: 2;
}

.shwp-time-hover[hidden] {
	display: none;
}

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

.shwp-controls {
	grid-area: controls;
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
}

.shwp-player .shwp-play,
.shwp-player .shwp-skip {
	position: relative;
	flex: 0 0 auto;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: none;
	-webkit-tap-highlight-color: transparent;
}

.shwp-player .shwp-play {
	width: 48px;
	height: 48px;
	background: var(--shwp-accent);
	color: var(--shwp-on-accent);
	transition: transform 0.15s ease, opacity 0.15s ease;
}

.shwp-player .shwp-play:hover {
	background: var(--shwp-accent);
	opacity: 0.88;
}

.shwp-player .shwp-play:active {
	transform: scale(0.96);
}

.shwp-player .shwp-skip {
	width: 44px;
	height: 44px;
	background: transparent;
	color: var(--shwp-text);
	transition: background-color 0.15s ease;
}

.shwp-player .shwp-skip:hover {
	background: var(--shwp-btn-hover);
	color: var(--shwp-text);
}

.shwp-skip svg {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	display: block;
}

.shwp-play svg {
	width: 40%;
	height: 40%;
	fill: currentColor;
	display: block;
}

.shwp-icon-play {
	margin-left: 2px;
}

.shwp-icon-pause,
.shwp-player.is-playing .shwp-icon-play {
	display: none !important;
}

.shwp-player.is-playing .shwp-icon-pause {
	display: block !important;
}

.shwp-spinner {
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	border: 2px solid transparent;
	border-top-color: var(--shwp-accent);
	opacity: 0;
	pointer-events: none;
}

.shwp-player.is-loading .shwp-spinner {
	opacity: 1;
	animation: shwp-spin 0.8s linear infinite;
}

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

/* Share + download: text links on the right of the controls. */
.shwp-player .shwp-share,
.shwp-player .shwp-download {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	margin: 0;
	padding: 0 4px;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--shwp-text);
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.2;
	text-decoration: underline;
	text-underline-offset: 3px;
	box-shadow: none;
	white-space: nowrap;
	cursor: pointer;
}

/* The first of them is pushed to the right edge. */
.shwp-player .shwp-share,
.shwp-player .shwp-skip.shwp-fwd + .shwp-download {
	margin-left: auto;
}

.shwp-player .shwp-share + .shwp-download {
	margin-left: 10px;
}

.shwp-player .shwp-share:hover,
.shwp-player .shwp-download:hover {
	background: transparent;
	color: var(--shwp-text);
	opacity: 0.7;
}

.shwp-player .shwp-share.is-copied {
	text-decoration: none;
	opacity: 1;
}

.shwp-share svg,
.shwp-download svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	display: block;
	flex: none;
}

/* Phones: icon-only share/download, unless the label is showing "Link copied". */
@container shwp (max-width: 459.98px) {
	.shwp-player .shwp-share:not(.is-copied) .shwp-share-label,
	.shwp-player .shwp-download > span {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}
	.shwp-player .shwp-share,
	.shwp-player .shwp-download {
		min-width: 44px;
		justify-content: center;
	}
	.shwp-player .shwp-share + .shwp-download {
		margin-left: 0;
	}
}


.shwp-player .shwp-play:focus-visible,
.shwp-player .shwp-skip:focus-visible,
.shwp-player .shwp-download:focus-visible,
.shwp-player .shwp-share:focus-visible,
.shwp-player .shwp-wave:focus-visible {
	outline: 2px solid var(--shwp-accent);
	outline-offset: 2px;
}

/* ---------- Description, error ---------- */

.shwp-description {
	padding: 14px 16px 16px;
	border-top: 1px solid var(--shwp-border);
	font-size: 14px;
	line-height: 1.6;
	color: var(--shwp-text);
	overflow-wrap: anywhere;
}

.shwp-description p {
	margin: 0 0 0.8em;
}

.shwp-description p:last-child {
	margin-bottom: 0;
}

.shwp-error {
	padding: 8px 16px;
	background: #fdecea;
	color: #8a1c13;
	font-size: 13px;
}

.shwp-error[hidden] {
	display: none;
}

.shwp-notice {
	padding: 10px 14px;
	border-left: 4px solid #111;
	background: #f4f4f4;
	color: #333;
	font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
	.shwp-player .shwp-play,
	.shwp-player .shwp-skip {
		transition: none;
	}
	.shwp-player.is-loading .shwp-spinner {
		animation-duration: 2s;
	}
}
