/* Avin Audio Hero — front-end player v0.5 */

.aah-player {
	--aah-primary: #3d7bff;
	--aah-accent: #ff6a3d;
	--aah-bg: rgba(4, 8, 36, .82);
	--aah-text: #fff;
	--aah-muted: rgba(255, 255, 255, .66);
	--aah-stage: 210px;
	--aah-radius: 28px;
	--aah-pad: 20px;

	position: relative;
	isolation: isolate;
	container-type: inline-size;
	width: 100%;
	max-width: 720px;
	margin-inline: auto;
	color: var(--aah-text);
	/* فونت: از Global Typography المنتور (Text)، یا از تایپوگرافی «فونت کلی پلیر» در ویجت */
	font-family: var(--e-global-typography-text-font-family, inherit);
	font-size: 14px;
	line-height: 1.6;
	-webkit-tap-highlight-color: transparent;
}

.aah-player *,
.aah-player *::before,
.aah-player *::after { box-sizing: border-box; font-family: inherit; }

:where(.aah-player) button {
	all: unset;
	box-sizing: border-box;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.aah-player :focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
	border-radius: 8px;
}

/* ---------- aura & card ---------- */

.aah-glow {
	position: absolute;
	inset: -10% -7%;
	z-index: -1;
	pointer-events: none;
	filter: blur(40px);
	opacity: .9;
	background:
		radial-gradient(46% 56% at 26% 40%, color-mix(in srgb, var(--aah-primary) 62%, transparent), transparent 70%),
		radial-gradient(40% 50% at 82% 74%, color-mix(in srgb, var(--aah-accent) 44%, transparent), transparent 72%);
}

.aah-card {
	position: relative;
	padding: var(--aah-pad);
	border-radius: var(--aah-radius);
	background:
		radial-gradient(120% 80% at 0% 0%, color-mix(in srgb, var(--aah-primary) 30%, transparent), transparent 58%),
		radial-gradient(90% 70% at 100% 100%, color-mix(in srgb, var(--aah-accent) 18%, transparent), transparent 62%),
		var(--aah-bg);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, .14),
		0 40px 80px -30px rgba(0, 0, 0, .8);
	-webkit-backdrop-filter: blur(22px) saturate(160%);
	backdrop-filter: blur(22px) saturate(160%);
	overflow: hidden;
}

/* luminous gradient border */
.aah-card::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 6;
	border-radius: inherit;
	padding: 1.5px;
	pointer-events: none;
	background: linear-gradient(135deg,
		color-mix(in srgb, var(--aah-primary) 90%, #fff),
		transparent 34%,
		transparent 66%,
		color-mix(in srgb, var(--aah-accent) 92%, #fff));
	-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
	-webkit-mask-composite: xor;
	mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.aah-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 10px;
	font-size: 12px;
}

.aah-badge {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 4px 12px;
	border-radius: 99px;
	background: rgba(255, 255, 255, .08);
	border: 1px solid rgba(255, 255, 255, .14);
	font-weight: 700;
	line-height: 1.7;
}

.aah-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--aah-accent);
	box-shadow: 0 0 10px 2px color-mix(in srgb, var(--aah-accent) 75%, transparent);
}

.aah-count { color: var(--aah-muted); font-variant-numeric: tabular-nums; }

/* ---------- layout (disc on the left, text on the right) ---------- */

.aah-body {
	direction: ltr;
	display: grid;
	grid-template-columns: minmax(0, var(--aah-stage)) minmax(0, 1fr);
	align-items: center;
	gap: 20px;
}

.aah-info {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
[dir="rtl"] .aah-head { direction: rtl; text-align: right; }

.aah-head { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

/* ---------- stage: radial visualizer + disc ---------- */

.aah-stage {
	position: relative;
	width: 100%;
	max-width: var(--aah-stage);
	aspect-ratio: 1;
	justify-self: center;
}

.aah-viz {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}

.aah-disc {
	position: absolute;
	inset: 25.5%;
	border-radius: 50%;
	transition: transform .14s linear;
	will-change: transform;
}

.aah-disc::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(2, 5, 26, .55) 0 28%, transparent 64%);
	pointer-events: none;
}

.aah-disc-in {
	position: relative;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	overflow: hidden;
	border: 2px solid rgba(255, 255, 255, .28);
	box-shadow: 0 14px 44px rgba(0, 0, 0, .6), 0 0 0 5px rgba(255, 255, 255, .05);
	animation: aah-spin 12s linear infinite;
	animation-play-state: paused;
}
.aah-player.is-playing .aah-disc-in { animation-play-state: running; }

.aah-disc-in img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* subtle light sheen over any cover */
.aah-disc-in::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	pointer-events: none;
	background: conic-gradient(from 30deg, transparent 0 10%, rgba(255, 255, 255, .22) 15%, transparent 22% 56%, rgba(255, 255, 255, .12) 64%, transparent 72%);
	mix-blend-mode: soft-light;
}

/* default vinyl cover */
.aah-disc-in.no-cover {
	background:
		conic-gradient(from 20deg, transparent 0 8%, color-mix(in srgb, var(--aah-primary) 70%, #fff) 12%, transparent 19% 50%, color-mix(in srgb, var(--aah-accent) 75%, #fff) 60%, transparent 68%),
		repeating-radial-gradient(circle, rgba(255, 255, 255, .055) 0 1px, transparent 1px 4px),
		radial-gradient(circle at 50% 50%, #0b1250, #03061f 75%);
}

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

/* ---------- play button ---------- */

.aah-player .aah-play {
	padding: 0;
	margin: 0;
	line-height: 1;
	letter-spacing: 0;
	border: 0;
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 2;
	width: 30%;
	min-width: 48px;
	aspect-ratio: 1;
	transform: translate(-50%, -50%);
	display: grid;
	place-items: center;
	border-radius: 50%;
	color: #fff;
	background: linear-gradient(145deg, color-mix(in srgb, var(--aah-accent) 78%, #fff), var(--aah-accent) 62%);
	box-shadow:
		0 0 0 6px color-mix(in srgb, var(--aah-accent) 26%, transparent),
		0 14px 36px color-mix(in srgb, var(--aah-accent) 65%, transparent),
		inset 0 2px 0 rgba(255, 255, 255, .45);
	transition: transform .28s cubic-bezier(.2, .8, .2, 1), background .3s, box-shadow .3s;
}

.aah-player .aah-play span { display: grid; place-items: center; width: 100%; height: 100%; grid-area: 1 / 1; }
.aah-player .aah-play svg { width: 46%; height: 46%; fill: currentColor; }
.aah-player .aah-play .i-play svg { transform: translateX(7%); }
.aah-player .aah-play .i-pause { display: none; }
.aah-player.is-playing .aah-play .i-pause { display: grid; }
.aah-player.is-playing .aah-play .i-play { display: none; }

.aah-player .aah-play:hover { transform: translate(-50%, -50%) scale(1.07); }
.aah-player .aah-play:active { transform: translate(-50%, -50%) scale(.94); }

/* while playing: calm glass button so the visualizer is the star */
.aah-player.is-playing .aah-play {
	background: rgba(255, 255, 255, .14);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	box-shadow:
		0 0 0 1.5px rgba(255, 255, 255, .4),
		0 10px 30px rgba(0, 0, 0, .35),
		inset 0 1px 0 rgba(255, 255, 255, .35);
}

.aah-player .aah-play::before,
.aah-player .aah-play::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var(--aah-accent);
	opacity: 0;
	pointer-events: none;
	animation: aah-ping 2.6s cubic-bezier(.2, .6, .3, 1) infinite;
}
.aah-player .aah-play::after { animation-delay: 1.3s; }
.aah-player.is-playing .aah-play::before,
.aah-player.is-playing .aah-play::after { animation: none; }

@keyframes aah-ping {
	0%   { transform: scale(1);   opacity: .7; }
	100% { transform: scale(2);   opacity: 0; }
}

.aah-hint {
	position: absolute;
	left: 50%;
	bottom: -6px;
	z-index: 3;
	transform: translateX(-50%);
	white-space: nowrap;
	padding: 3px 13px;
	font-size: 12px;
	font-weight: 700;
	border-radius: 99px;
	background: rgba(255, 255, 255, .13);
	border: 1px solid rgba(255, 255, 255, .22);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	transition: opacity .4s, transform .4s;
}
.aah-player.is-started .aah-hint { opacity: 0; transform: translate(-50%, 8px); pointer-events: none; }
.aah-player.is-error .aah-hint { opacity: 1; transform: translateX(-50%); background: rgba(190, 30, 30, .6); }

/* ---------- text ---------- */

.aah-title {
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-size: clamp(16px, 3.6cqi, 21px);
	font-weight: 800;
	font-style: normal;
	line-height: 1.55;
	color: var(--aah-text);
	letter-spacing: 0;
	text-transform: none;
}
.aah-subtitle { margin: 0; padding: 0; font-size: 13px; font-weight: 400; line-height: 1.7; color: var(--aah-muted); }
.aah-speaker {
	margin: 2px 0 0;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 12px;
	color: var(--aah-muted);
}
.aah-speaker::before {
	content: "";
	flex: none;
	width: 18px;
	height: 2px;
	border-radius: 2px;
	background: linear-gradient(90deg, var(--aah-primary), var(--aah-accent));
}
.aah-title:empty, .aah-subtitle:empty, .aah-speaker:empty { display: none; }

/* ---------- seek (always left → right) ---------- */

.aah-seek {
	direction: ltr;
	position: relative;
	height: 44px;
	cursor: pointer;
	touch-action: none;
	border-radius: 10px;
}
.aah-wave { width: 100%; height: 100%; display: block; }

.aah-times {
	direction: ltr;
	display: flex;
	justify-content: space-between;
	margin-top: -6px;
	font-size: 12px;
	line-height: 1.4;
	color: var(--aah-muted);
	font-variant-numeric: tabular-nums;
}

/* ---------- controls (always left → right) ---------- */

.aah-controls { direction: ltr; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.aah-player .aah-btn {
	flex: none;
	padding: 0;
	margin: 0;
	min-width: 0;
	min-height: 0;
	line-height: 1;
	letter-spacing: 0;
	text-transform: none;
	box-shadow: none;
	width: 36px;
	height: 36px;
	display: grid;
	place-items: center;
	border-radius: 50%;
	color: var(--aah-text);
	background: rgba(255, 255, 255, .08);
	border: 1px solid rgba(255, 255, 255, .12);
	transition: background .2s, transform .2s;
}
.aah-player .aah-btn:hover { background: rgba(255, 255, 255, .18); }
.aah-player .aah-btn:active { transform: scale(.92); }
.aah-player .aah-btn svg { display: block; width: 22px; height: 22px; fill: currentColor; overflow: visible; }
.aah-player .aah-btn[disabled] { cursor: default; }

.aah-player .aah-speed {
	flex: none;
	margin: 0;
	letter-spacing: 0;
	text-transform: none;
	box-shadow: none;
	min-width: 50px;
	height: 32px;
	padding: 0 11px;
	display: grid;
	place-items: center;
	border-radius: 99px;
	font-size: 12px;
	font-weight: 800;
	color: var(--aah-text);
	background: rgba(255, 255, 255, .08);
	border: 1px solid rgba(255, 255, 255, .12);
	font-variant-numeric: tabular-nums;
	direction: ltr;
	unicode-bidi: isolate;
	line-height: 1;
}
.aah-player .aah-speed:hover { background: rgba(255, 255, 255, .18); }

/* volume: icon + hover popover slider */
.aah-vol { position: relative; margin-inline-start: auto; display: flex; align-items: center; }
.aah-vol::after { content: ""; position: absolute; bottom: 100%; left: -24px; right: -24px; height: 20px; }
.aah-player .aah-mute { display: grid; }
.aah-player .aah-mute span { display: grid; place-items: center; grid-area: 1 / 1; }
.aah-player .aah-mute .i-mute { display: none; }
.aah-player.is-muted .aah-mute .i-mute { display: grid; }
.aah-player.is-muted .aah-mute .i-vol { display: none; }

input[type="range"].aah-volume {
	-webkit-appearance: none;
	appearance: none;
	position: absolute;
	bottom: calc(100% + 22px);
	left: 50%;
	width: 108px;
	height: 5px;
	margin: 0 0 0 -54px;
	padding: 0;
	border: 0;
	border-radius: 5px;
	outline: none;
	cursor: pointer;
	direction: ltr;
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s;
	background: linear-gradient(to right, var(--aah-accent) var(--v, 100%), rgba(255, 255, 255, .22) var(--v, 100%));
	box-shadow: 0 0 0 10px rgba(6, 12, 52, .94), 0 0 0 11px rgba(255, 255, 255, .16);
}
.aah-vol:hover .aah-volume,
.aah-vol:focus-within .aah-volume { opacity: 1; pointer-events: auto; }

.aah-volume::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #fff;
	border: 0;
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--aah-accent) 38%, transparent);
}
.aah-volume::-moz-range-thumb {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #fff;
	border: 0;
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--aah-accent) 38%, transparent);
}
@media (pointer: coarse) { .aah-volume { display: none; } }

/* ---------- playlist ---------- */

.aah-list {
	list-style: none;
	margin: 14px 0 0;
	padding: 5px;
	max-height: 146px;
	overflow: auto;
	border-radius: 16px;
	background: rgba(0, 0, 0, .24);
	border: 1px solid rgba(255, 255, 255, .08);
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, .25) transparent;
}

.aah-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 7px 9px;
	border-radius: 12px;
	cursor: pointer;
	transition: background .2s;
}
.aah-item:hover { background: rgba(255, 255, 255, .07); }
.aah-item.is-active {
	background: linear-gradient(90deg, color-mix(in srgb, var(--aah-primary) 36%, transparent), transparent);
}

.aah-item-thumb {
	flex: none;
	width: 32px;
	height: 32px;
	display: grid;
	place-items: center;
	border-radius: 10px;
	font-size: 12px;
	font-weight: 800;
	background: rgba(255, 255, 255, .09) center / cover no-repeat;
}
.aah-item-name { flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aah-item-dur { font-size: 12px; color: var(--aah-muted); font-variant-numeric: tabular-nums; }

.aah-eq { display: none; align-items: flex-end; gap: 2px; height: 14px; }
.aah-item.is-active .aah-eq { display: flex; }
.aah-eq i {
	width: 3px;
	height: 35%;
	border-radius: 2px;
	background: var(--aah-accent);
	animation: aah-eq .9s ease-in-out infinite;
	animation-play-state: paused;
}
.aah-eq i:nth-child(2) { animation-delay: .22s; }
.aah-eq i:nth-child(3) { animation-delay: .44s; }
.aah-player.is-playing .aah-eq i { animation-play-state: running; }

@keyframes aah-eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }

/* ---------- live subtitles ---------- */

.aah-subs {
	margin-top: 14px;
	min-height: 3.1em;
	display: grid;
	place-items: center;
	padding: 8px 18px;
	border-radius: 16px;
	text-align: center;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.8;
	color: var(--aah-text);
}
.aah-subs[hidden] { display: none; }
.aah-subs.is-on {
	background: rgba(0, 0, 0, .24);
	border: 1px solid rgba(255, 255, 255, .08);
	animation: aah-sub-in .35s cubic-bezier(.2, .8, .2, 1);
}
@keyframes aah-sub-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}

/* ---------- attention nudge (once, only if the visitor has not started) ---------- */

.aah-player.is-nudge .aah-stage { animation: aah-pop 1.1s cubic-bezier(.3, 1.4, .4, 1) 2; }
.aah-player.is-nudge .aah-hint { animation: aah-wiggle .8s ease 3; }
.aah-player.is-nudge .aah-play::before,
.aah-player.is-nudge .aah-play::after { animation-duration: 1.2s; }

@keyframes aah-pop {
	0%, 100% { transform: scale(1); }
	40%      { transform: scale(1.05); }
}
@keyframes aah-wiggle {
	0%, 100% { transform: translateX(-50%) rotate(0); }
	25%      { transform: translateX(-50%) rotate(-4deg); }
	75%      { transform: translateX(-50%) rotate(4deg); }
}

/* ---------- end-of-voice call to action ---------- */

.aah-cta {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: grid;
	place-items: center;
	padding: var(--aah-pad);
	text-align: center;
	background: color-mix(in srgb, var(--aah-bg) 82%, #000);
	-webkit-backdrop-filter: blur(14px);
	backdrop-filter: blur(14px);
	opacity: 0;
	visibility: hidden;
	transition: opacity .5s ease, visibility 0s linear .5s;
}
.aah-player.is-ended .aah-cta {
	opacity: 1;
	visibility: visible;
	transition: opacity .5s ease;
}
.aah-cta-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 18px;
	max-width: 440px;
	transform: translateY(10px) scale(.97);
	transition: transform .55s cubic-bezier(.2, .9, .3, 1.1) .08s;
}
.aah-player.is-ended .aah-cta-inner { transform: none; }

.aah-cta-title {
	margin: 0;
	font-size: clamp(19px, 3.6cqi, 26px);
	font-weight: 800;
	line-height: 1.6;
}
.aah-cta-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.aah-player a.aah-cta-btn {
	display: inline-grid;
	place-items: center;
	min-height: 48px;
	padding: 0 30px;
	border-radius: 99px;
	font-size: 15px;
	font-weight: 800;
	color: #fff;
	text-decoration: none;
	background: linear-gradient(145deg, color-mix(in srgb, var(--aah-accent) 80%, #fff), var(--aah-accent) 62%);
	box-shadow:
		0 12px 32px color-mix(in srgb, var(--aah-accent) 55%, transparent),
		inset 0 2px 0 rgba(255, 255, 255, .4);
	transition: transform .2s, box-shadow .2s;
}
.aah-player a.aah-cta-btn:hover { transform: translateY(-2px); color: #fff; }

.aah-player .aah-replay {
	min-height: 48px;
	padding: 0 22px;
	display: inline-grid;
	place-items: center;
	border-radius: 99px;
	font-size: 14px;
	font-weight: 700;
	color: var(--aah-text);
	background: rgba(255, 255, 255, .08);
	border: 1px solid rgba(255, 255, 255, .16);
	transition: background .2s;
}
.aah-player .aah-replay:hover { background: rgba(255, 255, 255, .17); }

/* ============================================================
   Responsive — driven by the width of the widget itself
   ============================================================ */

/* ≤ 470px: compact "mini player" (disc + title on top, wave & controls full width) */
@container (max-width: 470px) {
	.aah-card { padding: calc(var(--aah-pad) * .7); }
	.aah-top { margin-bottom: 8px; }
	.aah-body {
		grid-template-columns: clamp(104px, 31cqi, 150px) minmax(0, 1fr);
		column-gap: 14px;
		row-gap: 6px;
	}
	.aah-info { display: contents; }
	.aah-stage { grid-column: 1; grid-row: 1; }
	.aah-head { grid-column: 2; grid-row: 1; align-self: center; }
	.aah-title { font-size: clamp(15px, 4.6cqi, 18px); }
	.aah-subtitle { font-size: 12.5px; }
	.aah-seek { grid-column: 1 / -1; height: 38px; margin-top: 4px; }
	.aah-times { grid-column: 1 / -1; margin-top: -4px; }
	.aah-controls { grid-column: 1 / -1; justify-content: space-between; gap: 4px; }
	.aah-vol { margin-inline-start: 0; }
	.aah-player .aah-btn { width: 34px; height: 34px; }
	.aah-player .aah-btn svg { width: 20px; height: 20px; }
	.aah-player .aah-speed { min-width: 46px; height: 30px; padding: 0 9px; }
	.aah-hint { font-size: 10.5px; padding: 2px 9px; bottom: -4px; }
	.aah-list { max-height: 116px; margin-top: 10px; }
	.aah-subs { font-size: 13.5px; min-height: 2.8em; margin-top: 10px; padding: 6px 12px; }
	.aah-cta-title { font-size: 17px; }
	.aah-cta-inner { gap: 12px; }
}

/* ≤ 330px: tiniest phones */
@container (max-width: 330px) {
	.aah-body { grid-template-columns: 92px minmax(0, 1fr); column-gap: 10px; }
	.aah-speaker, .aah-count { display: none; }
	.aah-badge { font-size: 11px; padding: 3px 10px; }
	.aah-player .aah-btn { width: 31px; height: 31px; }
	.aah-player .aah-btn svg { width: 18px; height: 18px; }
	.aah-player .aah-speed { min-width: 40px; font-size: 11px; }
	.aah-player .aah-play { min-width: 40px; }
	.aah-item-thumb { width: 28px; height: 28px; }
}

/* short viewports (landscape phones): keep it low */
@media (max-height: 480px) and (orientation: landscape) {
	.aah-list { max-height: 80px; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.aah-disc-in { animation: none !important; }
	.aah-player .aah-play::before, .aah-play::after { animation: none !important; }
	.aah-eq i { animation: none !important; height: 70%; }
	.aah-player .aah-play, .aah-hint, .aah-disc { transition: none; }
	.aah-player.is-nudge .aah-stage, .aah-player.is-nudge .aah-hint, .aah-subs.is-on { animation: none !important; }
	.aah-cta, .aah-cta-inner { transition: none !important; }
}
