/* Audio and video player (pb_video + player.js). Theme tokens from pb-base.css, so Forest and Paper each get their own. */
.pb-player {
	display: block;
	width: 520px;
	max-width: 100%;
	margin: 8px 0;
	border: 1px solid var(--line, #dfe5de);
	border-radius: var(--radius, 10px);
	background: var(--surface, #fff);
	color: var(--ink, #1f2a24);
	font-family: var(--body-font, "Vazirmatn", Tahoma, sans-serif);
	font-size: 14px;
	line-height: 1.6;
	overflow: hidden;
}
.pb-player[data-kind="video"] { width: 640px; }
/* Without JS: the browser's own player and a download link */
.pb-player audio, .pb-player video { display: block; width: 100%; }
.pb-player video { max-height: 70vh; aspect-ratio: auto 16 / 9; background: #000; } /* 16:9 until the file says otherwise */
.pb-player:not(.is-on) audio { margin: 10px 0 0; }
.pb-player-dl { display: inline-flex; align-items: center; gap: 6px; margin: 6px 12px 10px; font-weight: 700; }
.pb-player-dl small { color: var(--muted, #5f6b64); font-weight: 400; }

/* Bar: play keys, name and seek, download */
.pb-pl-bar {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
}
.pb-pl-keys { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.pb-pl-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--muted, #5f6b64);
	font-size: 15px;
	cursor: pointer;
	transition: background-color 150ms ease, color 150ms ease, transform 160ms var(--ease-out, ease-out);
}
.pb-pl-btn:active, .pb-pl-dl:active, .pb-pl-track:active, .pb-pl-tdl:active { transform: scale(.97); }
.pb-pl-btn:focus-visible, .pb-pl-dl:focus-visible, .pb-pl-tdl:focus-visible, .pb-pl-track:focus-visible, .pb-pl-range:focus-visible {
	outline: 2px solid var(--focus, #f59e0b);
	outline-offset: 2px;
}
.pb-pl-play { width: 44px; height: 44px; background: var(--link, #1f6f52); color: #fff; font-size: 17px; }
.pb-pl-play .fa-play { margin-left: 3px; } /* the triangle looks off-centre otherwise */
/* play / pause / wait swap with a short pop that confirms the press */
.pb-pl-play .fa, .pb-pl-big .fa { animation: pb-pl-pop 160ms var(--ease-out, ease-out); }
@keyframes pb-pl-pop { from { opacity: 0; transform: scale(.7); } }
.pb-pl-play .fa-spin { animation: fa-spin .8s linear infinite; } /* a quicker turn feels like a quicker load */

.pb-pl-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pb-pl-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pb-pl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.pb-pl-seek { display: flex; align-items: center; gap: 8px; }
.pb-pl-time { flex-shrink: 0; min-width: 72px; font-size: 12px; color: var(--muted, #5f6b64); font-variant-numeric: tabular-nums; text-align: right; }

/* Seek bar: a native range, so keys and screen readers work as usual */
.pb-pl-range {
	flex: 1;
	min-width: 0;
	height: 24px;
	margin: 0;
	background: transparent;
	accent-color: var(--link, #1f6f52);
	cursor: pointer;
}

/* Video: a thin track like the thread rails, filled in the link colour up to the play point */
.pb-player[data-kind="video"] .pb-pl-range { -webkit-appearance: none; appearance: none; height: 24px; }
.pb-player[data-kind="video"] .pb-pl-range::-webkit-slider-runnable-track {
	height: 4px;
	border-radius: 999px;
	background: linear-gradient(to right, var(--link, #1f6f52) var(--pb-fill, 0%), var(--line, #dfe5de) var(--pb-fill, 0%));
}
.pb-player[data-kind="video"] .pb-pl-range::-moz-range-track { height: 4px; border-radius: 999px; background: var(--line, #dfe5de); }
.pb-player[data-kind="video"] .pb-pl-range::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--link, #1f6f52); }
.pb-player[data-kind="video"] .pb-pl-range::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 14px;
	height: 14px;
	margin-top: -5px;
	border: 2px solid var(--surface, #fff);
	border-radius: 50%;
	background: var(--link, #1f6f52);
	box-shadow: 0 1px 3px rgba(31, 42, 36, .25);
}
.pb-player[data-kind="video"] .pb-pl-range::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid var(--surface, #fff); border-radius: 50%; background: var(--link, #1f6f52); }

/* Audio: the waveform is the seek bar; the range lies over it, invisible, and takes the clicks, drags and keys */
.pb-pl-wave { position: relative; flex: 1; min-width: 0; height: 34px; border-radius: 6px; }
.pb-pl-wave canvas { display: block; width: 100%; height: 100%; }
.pb-pl-wave .pb-pl-range { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
.pb-pl-wave:has(.pb-pl-range:focus-visible) { outline: 2px solid var(--focus, #f59e0b); outline-offset: 2px; }
.pb-player.is-loading .pb-pl-wave canvas { opacity: .6; }

.pb-pl-dl, a.pb-pl-dl:visited {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
	height: 34px;
	padding: 0 12px;
	border-radius: 999px;
	background: var(--chip, #eaf2ec);
	color: var(--link, #1f6f52);
	font-size: 13px;
	font-weight: 700;
	text-decoration: none;
	transition: background-color 150ms ease, transform 160ms var(--ease-out, ease-out);
}
a.pb-pl-dl:hover, a.pb-pl-tdl:hover { text-decoration: none; }

.pb-player.is-loading .pb-pl-play { cursor: progress; }
.pb-pl-msg { margin: 0 12px 10px; padding: 6px 12px; border-radius: 8px; background: #fde8e8; color: #9b2c2c; font-size: 13px; }

/* Album (canvas direction ب): header with the thread title, count, length and size; a big play and tall waveform */
.pb-player-album { width: 560px; }
.pb-al-head { display: flex; align-items: center; gap: 14px; padding: 14px 14px 6px; }
.pb-al-art {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 56px;
	height: 56px;
	border-radius: 12px;
	background: var(--chip, #eaf2ec);
	color: var(--link, #1f6f52);
	font-size: 24px;
}
.pb-al-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.7; }
.pb-al-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.pb-al-sub { font-size: 12px; color: var(--muted, #5f6b64); }
button.pb-pl-dl { border: 0; font-family: inherit; cursor: pointer; }
.pb-al-bar { padding: 6px 14px 10px; }
.pb-al-bar .pb-pl-play { width: 52px; height: 52px; font-size: 19px; }
.pb-al-bar .pb-pl-wave { height: 48px; }

/* Album: the track list under the bar */
.pb-pl-list { margin: 0; padding: 4px 6px 6px; list-style: none; border-top: 1px solid var(--line, #dfe5de); }
.pb-pl-list li { display: flex; align-items: center; gap: 4px; }
.pb-pl-track {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 40px;
	padding: 4px 8px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--ink, #1f2a24);
	font: inherit;
	text-align: start;
	cursor: pointer;
	transition: background-color 150ms ease, transform 160ms var(--ease-out, ease-out);
}
.pb-pl-num { width: 22px; flex-shrink: 0; text-align: center; color: var(--muted, #5f6b64); font-size: 12px; }
.pb-pl-tname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-pl-track small { flex-shrink: 0; color: var(--muted, #5f6b64); font-size: 12px; }
.pb-pl-track[aria-current="true"] { background: var(--chip, #eaf2ec); color: var(--link, #1f6f52); font-weight: 700; }
.pb-pl-track[aria-current="true"] .pb-pl-num { color: var(--link, #1f6f52); }
/* the playing track shows a speaker (fa-volume-up) in place of its number */
.pb-player.is-playing .pb-pl-track[aria-current="true"] .pb-pl-num { font-size: 0; }
.pb-player.is-playing .pb-pl-track[aria-current="true"] .pb-pl-num::before { content: "\f028"; font: 14px/1 FontAwesome; }
.pb-pl-tdl, a.pb-pl-tdl:visited {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	flex-shrink: 0;
	border-radius: 50%;
	color: var(--muted, #5f6b64);
	text-decoration: none;
	transition: background-color 150ms ease, color 150ms ease, transform 160ms var(--ease-out, ease-out);
}

/* Hover only where there is a real pointer: on a phone a tap would leave it stuck on */
@media (hover: hover) and (pointer: fine) {
	.pb-pl-btn:hover, .pb-pl-tdl:hover { background: var(--chip, #eaf2ec); color: var(--link, #1f6f52); }
	.pb-pl-play:hover { background: var(--link, #1f6f52); color: #fff; box-shadow: 0 0 0 4px var(--chip, #eaf2ec); }
	a.pb-pl-dl:hover { background: color-mix(in srgb, var(--chip, #eaf2ec), var(--link, #1f6f52) 10%); }
	.pb-pl-track:hover { background: var(--bg, #eef1ec); }
	.pb-pl-track[aria-current="true"]:hover { background: var(--chip, #eaf2ec); }
}

/* Video: a big play button on the frame until it plays */
.pb-pl-stage { position: relative; }
.pb-player[data-kind="video"].is-on video { cursor: pointer; }
.pb-pl-big {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 64px;
	height: 64px;
	border: 0;
	border-radius: 50%;
	background: rgba(15, 20, 17, .6);
	color: #fff;
	font-size: 24px;
	cursor: pointer;
	transition: opacity 150ms ease, transform 160ms var(--ease-out, ease-out);
}
.pb-pl-big .fa { margin-left: 4px; }
.pb-pl-big:active { transform: scale(.97); }
.pb-player.is-playing .pb-pl-big, .pb-player.is-loading .pb-pl-big { opacity: 0; pointer-events: none; }

/* Touch screens: every control at least 44 px */
@media (pointer: coarse) {
	.pb-pl-btn, .pb-pl-tdl { width: 44px; height: 44px; }
	.pb-pl-track { min-height: 44px; }
	.pb-pl-dl { height: 44px; }
}

/* Phone: download keeps its icon only; with more buttons (album, video) name and seek take the first line */
@media (max-width: 480px) {
	.pb-pl-bar { gap: 8px; }
	.pb-pl-dl span { display: none; }
	.pb-pl-dl { width: 44px; height: 44px; padding: 0; justify-content: center; }
	.pb-pl-time { min-width: 0; }
	.pb-player[data-kind="video"] .pb-pl-bar { flex-wrap: wrap; }
	.pb-player[data-kind="video"] .pb-pl-mid { order: -1; flex-basis: 100%; }
	.pb-player[data-kind="video"] .pb-pl-keys { flex: 1; justify-content: flex-end; }
	.pb-al-head { gap: 10px; padding: 12px 12px 4px; }
	.pb-al-art { width: 44px; height: 44px; border-radius: 10px; font-size: 19px; }
	.pb-al-bar { padding: 6px 12px 10px; }
}

@media (prefers-reduced-motion: reduce) {
	.pb-pl-btn, .pb-pl-dl, .pb-pl-track, .pb-pl-tdl, .pb-pl-big { transition: none; }
	.pb-pl-play .fa, .pb-pl-big .fa { animation: none; }
	.pb-pl-play .fa-spin { animation: fa-spin 2s linear infinite; }
}
