/**
 * ویجت شناور سکه — استایل و انیمیشن‌ها.
 *
 * همه رنگ‌ها و فاصله‌ها از متغیرهای CSS خوانده می‌شوند که سمت سرور تزریق می‌شوند.
 */

.wcr-fw {
	--wcr-fw-x: 24px;
	--wcr-fw-y: 24px;
	--wcr-fw-c1: #f6b93b;
	--wcr-fw-c2: #e55039;
	--wcr-fw-z: 99000;
	--wcr-fw-size: 62px;
	--wcr-fw-surface: rgba(255, 255, 255, 0.82);
	--wcr-fw-text: #1d2330;
	--wcr-fw-muted: #6b7280;
	--wcr-fw-border: rgba(255, 255, 255, 0.7);
	--wcr-fw-shadow: 0 18px 40px -12px rgba(15, 23, 42, 0.35);

	position: fixed;
	z-index: var(--wcr-fw-z);
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 12px;
	font-family: inherit;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
}

/* ---------- جایگاه ---------- */

.wcr-fw--bottom-right {
	inset: auto var(--wcr-fw-x) var(--wcr-fw-y) auto;
}

.wcr-fw--bottom-left {
	inset: auto auto var(--wcr-fw-y) var(--wcr-fw-x);
}

.wcr-fw--top-right {
	inset: var(--wcr-fw-y) var(--wcr-fw-x) auto auto;
	flex-direction: column-reverse;
}

.wcr-fw--top-left {
	inset: var(--wcr-fw-y) auto auto var(--wcr-fw-x);
	flex-direction: column-reverse;
}

/*
 * چسباندن فرزندان به گوشه انتخاب‌شده با مارجین خودکار فیزیکی.
 * align-items در RTL برعکس می‌شود، اما margin-left/right همیشه فیزیکی است.
 */
.wcr-fw--bottom-right > .wcr-fw__panel,
.wcr-fw--bottom-right > .wcr-fw__trigger,
.wcr-fw--top-right > .wcr-fw__panel,
.wcr-fw--top-right > .wcr-fw__trigger {
	margin-left: auto;
	margin-right: 0;
}

.wcr-fw--bottom-left > .wcr-fw__panel,
.wcr-fw--bottom-left > .wcr-fw__trigger,
.wcr-fw--top-left > .wcr-fw__panel,
.wcr-fw--top-left > .wcr-fw__trigger {
	margin-right: auto;
	margin-left: 0;
}

.wcr-fw *,
.wcr-fw *::before,
.wcr-fw *::after {
	box-sizing: border-box;
}

/* ---------- نشان (دکمه جمع‌شده) ---------- */

.wcr-fw__trigger {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	height: var(--wcr-fw-size);
	padding-block: 0;
	padding-inline: 10px 20px;
	border: 0;
	border-radius: 999px;
	background: linear-gradient(135deg, var(--wcr-fw-c1), var(--wcr-fw-c2));
	color: #fff;
	text-decoration: none;
	cursor: pointer;
	overflow: hidden;
	isolation: isolate;
	box-shadow:
		0 10px 24px -6px color-mix(in srgb, var(--wcr-fw-c2) 55%, transparent),
		0 2px 6px rgba(15, 23, 42, 0.18),
		inset 0 1px 0 rgba(255, 255, 255, 0.45);
	animation: wcr-fw-float 4.5s ease-in-out infinite;
	transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease;
}

.wcr-fw--bottom-left .wcr-fw__trigger,
.wcr-fw--top-left .wcr-fw__trigger {
	padding-inline: 20px 10px;
	flex-direction: row-reverse;
}

.wcr-fw__trigger:hover,
.wcr-fw__trigger:focus-visible {
	transform: translateY(-4px) scale(1.04);
	box-shadow:
		0 18px 34px -8px color-mix(in srgb, var(--wcr-fw-c2) 65%, transparent),
		0 3px 8px rgba(15, 23, 42, 0.22),
		inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.wcr-fw__trigger:active {
	transform: translateY(-1px) scale(0.98);
}

.wcr-fw__trigger:focus-visible {
	outline: 3px solid rgba(255, 255, 255, 0.85);
	outline-offset: 3px;
}

/* حلقه‌های ضربانی پشت نشان */

.wcr-fw__rings {
	position: absolute;
	inset-inline-start: 8px;
	inset-block-start: 50%;
	width: 44px;
	height: 44px;
	margin-block-start: -22px;
	pointer-events: none;
}

.wcr-fw--bottom-left .wcr-fw__rings,
.wcr-fw--top-left .wcr-fw__rings {
	inset-inline-start: auto;
	inset-inline-end: 8px;
}

.wcr-fw__rings i {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.55);
	opacity: 0;
	animation: wcr-fw-ping 3s cubic-bezier(0.2, 0.7, 0.3, 1) infinite;
}

.wcr-fw__rings i:nth-child(2) { animation-delay: 1s; }
.wcr-fw__rings i:nth-child(3) { animation-delay: 2s; }

/* دایره پیشرفت سطح */

.wcr-fw__ring {
	position: absolute;
	inset-inline-start: 6px;
	inset-block-start: 50%;
	width: 48px;
	height: 48px;
	margin-block-start: -24px;
	transform: rotate(-90deg);
	pointer-events: none;
}

.wcr-fw--bottom-left .wcr-fw__ring,
.wcr-fw--top-left .wcr-fw__ring {
	inset-inline-start: auto;
	inset-inline-end: 6px;
}

.wcr-fw__ring circle {
	fill: none;
	stroke-width: 3;
	stroke-linecap: round;
}

.wcr-fw__ring-track {
	stroke: rgba(255, 255, 255, 0.28);
}

.wcr-fw__ring-fill {
	stroke: #fff;
	transition: stroke-dashoffset 1.4s cubic-bezier(0.16, 1, 0.3, 1);
	filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.7));
}

/* سکه سه‌بعدی */

.wcr-fw__coin {
	position: relative;
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	perspective: 420px;
	flex: 0 0 auto;
}

.wcr-fw__coin-inner {
	position: relative;
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	transform-style: preserve-3d;
	animation: wcr-fw-flip 6s cubic-bezier(0.45, 0.05, 0.25, 1) infinite;
}

.wcr-fw__coin-face {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	border-radius: 50%;
	font-size: 18px;
	line-height: 1;
	backface-visibility: hidden;
	background:
		radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.25) 45%, transparent 62%),
		conic-gradient(from 210deg, #fff6d5, #ffd977, #f2a93b, #ffeaa7, #f6c453, #fff6d5);
	box-shadow:
		inset 0 -2px 5px rgba(150, 95, 0, 0.4),
		inset 0 2px 4px rgba(255, 255, 255, 0.85),
		0 2px 6px rgba(120, 72, 0, 0.32);
}

.wcr-fw__coin-face--back {
	transform: rotateY(180deg);
}

/* عدد روی نشان */

.wcr-fw__count {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	z-index: 1;
	white-space: nowrap;
}

.wcr-fw--bottom-left .wcr-fw__count,
.wcr-fw--top-left .wcr-fw__count {
	align-items: flex-end;
}

.wcr-fw__count-value {
	font-size: 19px;
	font-weight: 800;
	letter-spacing: 0.2px;
	font-variant-numeric: tabular-nums;
	text-shadow: 0 1px 2px rgba(120, 60, 0, 0.35);
}

.wcr-fw__count-unit {
	font-size: 11px;
	font-weight: 600;
	opacity: 0.85;
	margin-block-start: -4px;
}

/* برق عبوری روی نشان */

.wcr-fw__shine {
	position: absolute;
	inset-block: -40%;
	inset-inline-start: -60%;
	width: 45%;
	background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
	transform: skewX(-18deg);
	animation: wcr-fw-shine 5.5s ease-in-out infinite;
	pointer-events: none;
}

/* ---------- کارت جزئیات ---------- */

.wcr-fw__panel {
	position: relative;
	width: 288px;
	max-width: calc(100vw - 32px);
	padding: 18px 18px 16px;
	border-radius: 20px;
	background: var(--wcr-fw-surface);
	border: 1px solid var(--wcr-fw-border);
	box-shadow: var(--wcr-fw-shadow);
	color: var(--wcr-fw-text);
	backdrop-filter: blur(18px) saturate(160%);
	-webkit-backdrop-filter: blur(18px) saturate(160%);
	transform-origin: bottom right;
	overflow: hidden;
}

.wcr-fw--bottom-left .wcr-fw__panel,
.wcr-fw--top-left .wcr-fw__panel { transform-origin: bottom left; }

.wcr-fw--top-right .wcr-fw__panel { transform-origin: top right; }
.wcr-fw--top-left .wcr-fw__panel { transform-origin: top left; }

.wcr-fw__panel[hidden] { display: none; }

.wcr-fw__panel.is-open {
	animation: wcr-fw-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.wcr-fw__panel.is-closing {
	animation: wcr-fw-pop-out 0.22s ease-in both;
}

/* هاله رنگی داخل کارت */

.wcr-fw__glow {
	position: absolute;
	inset-block-start: -70px;
	inset-inline-end: -70px;
	width: 190px;
	height: 190px;
	border-radius: 50%;
	background: radial-gradient(circle, color-mix(in srgb, var(--wcr-fw-c1) 55%, transparent), transparent 68%);
	filter: blur(6px);
	pointer-events: none;
	animation: wcr-fw-glow 7s ease-in-out infinite alternate;
}

.wcr-fw__close {
	position: absolute;
	inset-block-start: 10px;
	inset-inline-end: 10px;
	display: grid;
	place-items: center;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(15, 23, 42, 0.07);
	color: var(--wcr-fw-muted);
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease;
}

.wcr-fw__close:hover {
	background: rgba(15, 23, 42, 0.14);
	transform: rotate(90deg);
}

.wcr-fw__close svg {
	width: 14px;
	height: 14px;
	stroke: currentColor;
	stroke-width: 2.2;
	stroke-linecap: round;
	fill: none;
}

/* محتوای کارت با ورود پلکانی */

.wcr-fw__panel.is-open .wcr-fw__row,
.wcr-fw__panel.is-open .wcr-fw__amount,
.wcr-fw__panel.is-open .wcr-fw__progress,
.wcr-fw__panel.is-open .wcr-fw__wallet,
.wcr-fw__panel.is-open .wcr-fw__guest,
.wcr-fw__panel.is-open .wcr-fw__actions {
	animation: wcr-fw-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
	animation-delay: calc(var(--i, 0) * 60ms + 80ms);
}

.wcr-fw__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	position: relative;
	/* فضای امن تا دکمه بستن روی عنوان یا نشان سطح نیفتد. */
	padding-inline-end: 32px;
	min-height: 26px;
}

.wcr-fw__title {
	font-size: 13px;
	font-weight: 700;
	color: var(--wcr-fw-muted);
}

.wcr-fw__tier {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 999px;
	background: var(--tier, #8c8f94);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	box-shadow: 0 2px 8px -2px var(--tier, #8c8f94);
}

.wcr-fw__amount {
	display: flex;
	align-items: baseline;
	gap: 6px;
	margin-block: 6px 12px;
}

.wcr-fw__number {
	font-size: 38px;
	font-weight: 900;
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
	background: linear-gradient(135deg, var(--wcr-fw-c1), var(--wcr-fw-c2));
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	color: var(--wcr-fw-c2);
}

.wcr-fw__unit {
	font-size: 13px;
	font-weight: 700;
	color: var(--wcr-fw-muted);
}

.wcr-fw__progress { margin-block-end: 12px; }

.wcr-fw__bar {
	height: 7px;
	border-radius: 999px;
	background: rgba(15, 23, 42, 0.08);
	overflow: hidden;
}

.wcr-fw__bar span {
	display: block;
	height: 100%;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--wcr-fw-c1), var(--wcr-fw-c2));
	position: relative;
	transition: width 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.wcr-fw__bar span::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
	transform: translateX(-100%);
	animation: wcr-fw-sweep 2.4s ease-in-out infinite;
}

.wcr-fw__next {
	display: block;
	margin-block-start: 6px;
	font-size: 11.5px;
	color: var(--wcr-fw-muted);
}

.wcr-fw__wallet {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 9px 12px;
	margin-block-end: 12px;
	border-radius: 12px;
	background: rgba(15, 23, 42, 0.05);
	font-size: 12.5px;
}

.wcr-fw__guest {
	margin: 6px 0 14px;
	font-size: 13.5px;
	color: var(--wcr-fw-text);
}

.wcr-fw__actions {
	display: flex;
	gap: 8px;
}

.wcr-fw__btn {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 38px;
	padding: 0 12px;
	border-radius: 11px;
	font-size: 12.5px;
	font-weight: 700;
	text-decoration: none;
	text-align: center;
	background: rgba(15, 23, 42, 0.06);
	color: var(--wcr-fw-text);
	transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.wcr-fw__btn:hover {
	transform: translateY(-2px);
	background: rgba(15, 23, 42, 0.11);
}

.wcr-fw__btn--primary {
	background: linear-gradient(135deg, var(--wcr-fw-c1), var(--wcr-fw-c2));
	color: #fff;
	box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--wcr-fw-c2) 75%, transparent);
}

.wcr-fw__btn--primary:hover {
	background: linear-gradient(135deg, var(--wcr-fw-c1), var(--wcr-fw-c2));
	box-shadow: 0 12px 22px -8px color-mix(in srgb, var(--wcr-fw-c2) 85%, transparent);
}

/* ---------- جشن سکه جدید ---------- */

.wcr-fw__burst {
	position: absolute;
	bottom: var(--wcr-fw-size);
	width: 0;
	height: 0;
	pointer-events: none;
}

.wcr-fw--bottom-right .wcr-fw__burst,
.wcr-fw--top-right .wcr-fw__burst { right: 34px; }

.wcr-fw--bottom-left .wcr-fw__burst,
.wcr-fw--top-left .wcr-fw__burst { left: 34px; }

.wcr-fw--top-right .wcr-fw__burst,
.wcr-fw--top-left .wcr-fw__burst {
	bottom: auto;
	top: var(--wcr-fw-size);
}

.wcr-fw__gain {
	position: absolute;
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	padding: 4px 12px;
	border-radius: 999px;
	background: linear-gradient(135deg, #22c55e, #16a34a);
	color: #fff;
	font-size: 13px;
	font-weight: 800;
	white-space: nowrap;
	box-shadow: 0 8px 20px -8px rgba(22, 163, 74, 0.9);
	animation: wcr-fw-gain 2.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.wcr-fw__spark {
	position: absolute;
	top: 0;
	left: 0;
	margin: -3.5px 0 0 -3.5px;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--spark, #ffd166);
	animation: wcr-fw-spark 1.1s ease-out forwards;
}

/* ---------- انیمیشن‌ها ---------- */

@keyframes wcr-fw-float {
	0%, 100% { transform: translateY(0); }
	50%      { transform: translateY(-6px); }
}

@keyframes wcr-fw-ping {
	0%   { transform: scale(0.72); opacity: 0.75; }
	70%  { transform: scale(1.55); opacity: 0; }
	100% { transform: scale(1.55); opacity: 0; }
}

@keyframes wcr-fw-flip {
	0%, 55%  { transform: rotateY(0deg); }
	75%, 100% { transform: rotateY(360deg); }
}

@keyframes wcr-fw-shine {
	0%, 62%  { transform: translateX(0) skewX(-18deg); }
	100%     { transform: translateX(520%) skewX(-18deg); }
}

@keyframes wcr-fw-sweep {
	0%   { transform: translateX(-100%); }
	60%, 100% { transform: translateX(100%); }
}

@keyframes wcr-fw-glow {
	0%   { transform: translate(0, 0) scale(1); opacity: 0.75; }
	100% { transform: translate(-18px, 14px) scale(1.15); opacity: 1; }
}

@keyframes wcr-fw-pop {
	0%   { opacity: 0; transform: scale(0.86) translateY(14px); }
	100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes wcr-fw-pop-out {
	0%   { opacity: 1; transform: scale(1) translateY(0); }
	100% { opacity: 0; transform: scale(0.92) translateY(8px); }
}

@keyframes wcr-fw-rise {
	0%   { opacity: 0; transform: translateY(10px); }
	100% { opacity: 1; transform: translateY(0); }
}

@keyframes wcr-fw-gain {
	0%   { opacity: 0; transform: translate(-50%, -4px) scale(0.7); }
	18%  { opacity: 1; transform: translate(-50%, -30px) scale(1.08); }
	32%  { transform: translate(-50%, -38px) scale(1); }
	78%  { opacity: 1; transform: translate(-50%, -62px) scale(1); }
	100% { opacity: 0; transform: translate(-50%, -92px) scale(0.9); }
}

@keyframes wcr-fw-spark {
	0%   { opacity: 1; transform: translate(0, 0) scale(1); }
	100% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, -40px)) scale(0.2); }
}

.wcr-fw__trigger.is-bumped {
	animation: wcr-fw-bump 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes wcr-fw-bump {
	0%   { transform: scale(1); }
	35%  { transform: scale(1.14) rotate(-2deg); }
	60%  { transform: scale(0.97) rotate(1deg); }
	100% { transform: scale(1) rotate(0); }
}

/* ---------- حالت تاریک ---------- */

@media (prefers-color-scheme: dark) {
	.wcr-fw {
		--wcr-fw-surface: rgba(24, 28, 38, 0.88);
		--wcr-fw-text: #f3f4f6;
		--wcr-fw-muted: #9ca3af;
		--wcr-fw-border: rgba(255, 255, 255, 0.1);
		--wcr-fw-shadow: 0 20px 45px -14px rgba(0, 0, 0, 0.7);
	}

	.wcr-fw__bar,
	.wcr-fw__wallet,
	.wcr-fw__btn,
	.wcr-fw__close {
		background: rgba(255, 255, 255, 0.08);
	}

	.wcr-fw__btn { color: #f3f4f6; }
	.wcr-fw__btn:hover { background: rgba(255, 255, 255, 0.15); }
	.wcr-fw__close { color: #cbd5e1; }
}

/* ---------- موبایل ---------- */

@media (max-width: 600px) {
	.wcr-fw {
		--wcr-fw-size: 54px;
	}

	.wcr-fw__trigger { padding-inline: 8px 16px; }

	.wcr-fw--bottom-left .wcr-fw__trigger,
	.wcr-fw--top-left .wcr-fw__trigger { padding-inline: 16px 8px; }
	.wcr-fw__count-value { font-size: 17px; }
	.wcr-fw__number { font-size: 32px; }
	.wcr-fw__panel { width: 260px; }
}

.wcr-fw--desktop-only {
	display: flex;
}

@media (max-width: 782px) {
	.wcr-fw--desktop-only { display: none; }
}

/* ---------- احترام به تنظیم کاهش حرکت ---------- */

.wcr-fw--static .wcr-fw__trigger,
.wcr-fw--static .wcr-fw__coin-inner,
.wcr-fw--static .wcr-fw__rings i,
.wcr-fw--static .wcr-fw__shine,
.wcr-fw--static .wcr-fw__glow,
.wcr-fw--static .wcr-fw__bar span::after {
	animation: none;
}

.wcr-fw--static .wcr-fw__shine { display: none; }

@media (prefers-reduced-motion: reduce) {
	.wcr-fw *,
	.wcr-fw *::before,
	.wcr-fw *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}

	.wcr-fw__shine,
	.wcr-fw__rings { display: none; }
}

/* ---------- جایگزین برای مرورگرهای بدون color-mix ---------- */

@supports not (background: color-mix(in srgb, red 50%, blue)) {
	.wcr-fw__trigger {
		box-shadow: 0 10px 24px -6px rgba(15, 23, 42, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.45);
	}

	.wcr-fw__glow {
		background: radial-gradient(circle, var(--wcr-fw-c1), transparent 68%);
		opacity: 0.5;
	}

	.wcr-fw__btn--primary {
		box-shadow: 0 8px 18px -8px rgba(15, 23, 42, 0.5);
	}
}
