/*
 * Wallex Predict CTA – frontend styles
 *
 * Compact call-to-action bar (RTL) whose coin icon and title rotate. Colors
 * resolve from the Wallex theme CSS variables where present, and fall back to a
 * self-contained dark palette so the widget looks correct outside the theme too.
 */

.wallex-pcta-wrap {
	--wallex-pcta-sticky-offset: 16px;
	--wallex-pcta-sticky-zindex: 998;

	box-sizing: border-box;
	width: 100%;
	direction: rtl;
}

.wallex-pcta-wrap *,
.wallex-pcta-wrap *::before,
.wallex-pcta-wrap *::after {
	box-sizing: border-box;
}

/* ---------------------------------- Card ---------------------------------- */
.wallex-pcta {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	padding: 12px 16px;
	background: var(--color-bg, #12141c);
	border: 1px solid var(--color-stroke-2, rgba(255, 255, 255, 0.06));
	border-radius: var(--cornerRadiusXL, 16px);
	min-width: 350px;
}

/* ---------------------------------- Media --------------------------------- */
.wallex-pcta__media {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wallex-pcta__icon {
	width: 28px;
	height: 28px;
	object-fit: contain;
	border-radius: 50%;
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.wallex-pcta__icon--empty {
	display: inline-block;
	background: var(--color-stroke-2, rgba(255, 255, 255, 0.06));
}

/* Icon swap: JS toggles .is-swapping around the src change. */
.wallex-pcta.is-swapping .wallex-pcta__icon {
	opacity: 0;
	transform: translateY(-6px);
}

/* ---------------------------------- Texts --------------------------------- */
.wallex-pcta__texts {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
	text-align: start;
}

.wallex-pcta__title {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 2px;
	min-height: 1.4em;
	font-size: 0.82rem;
	font-weight: 500;
	line-height: 1.6;
	color: var(--color-text-3, rgba(255, 255, 255, 0.55));
	overflow-wrap: anywhere;
}

.wallex-pcta__title-text {
	white-space: pre-wrap;
	min-height: 21px;
}

.wallex-pcta__caret {
	display: inline-block;
	flex: 0 0 auto;
	width: 1.5px;
	height: 1em;
	background: var(--color-text-3, rgba(255, 255, 255, 0.55));
	opacity: 0;
}

.wallex-pcta.is-typing .wallex-pcta__caret {
	opacity: 1;
	animation: wallex-pcta-blink 1s steps(1, end) infinite;
}

@keyframes wallex-pcta-blink {

	0%,
	49% {
		opacity: 1;
	}

	50%,
	100% {
		opacity: 0;
	}
}

.wallex-pcta__subtitle {
	font-size: 14px;
	font-weight: 500;
	line-height: 24px;
	color: var(--color-text-1, #ffffff);
	overflow-wrap: anywhere;
}

/* --------------------------------- Button --------------------------------- */
.wallex-pcta__btn {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 11px 22px;
	font-size: 0.92rem;
	font-weight: 700;
	line-height: 1.4;
	color: var(--color-text-inverse, #ffffff);
	text-decoration: none;
	white-space: nowrap;
	background: var(--color-primary, #1273ea);
	border: 0;
	border-radius: var(--cornerRadiusFull, 999px);
	transition: filter 0.2s ease;
}

.wallex-pcta__btn:hover,
.wallex-pcta__btn:focus-visible {
	filter: brightness(1.08);
	color: var(--color-text-inverse, #ffffff);
}

/* --------------------------------- Sticky --------------------------------- */

/*
 * The placeholder holds the widget's original height in the document flow while
 * the card is pinned, so surrounding content never jumps. JS sets its height and
 * toggles .is-stuck on the wrapper.
 */
.wallex-pcta__placeholder {
	display: none;
}

.wallex-pcta-wrap--sticky.is-stuck .wallex-pcta__placeholder {
	display: block;
}

.wallex-pcta-wrap--sticky.is-stuck .wallex-pcta {
	position: fixed;
	right: 0;
	left: 0;
	bottom: var(--wallex-pcta-sticky-offset, 16px);
	z-index: var(--wallex-pcta-sticky-zindex, 998);
	width: min(100% - 24px, var(--wallex-pcta-stuck-width, 1100px));
	margin-inline: auto;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
	animation: wallex-pcta-slide-up 0.28s ease;
}

/*
 * "مخفی روی بخش مشخص": the pinned bar steps aside while one of the configured
 * sections is on screen, and slides back once it has scrolled past.
 *
 * Scoped to .is-stuck — a bar sitting in its own slot in the flow is never
 * hidden, since it isn't covering anything. `visibility` rather than `display`
 * keeps the fade animatable; the delayed visibility transition lets the fade
 * finish before the bar stops being hit-testable.
 */
.wallex-pcta-wrap--sticky.is-stuck .wallex-pcta {
	transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s;
}

.wallex-pcta-wrap--sticky.is-stuck.is-hidden-over .wallex-pcta {
	opacity: 0;
	visibility: hidden;
	transform: translateY(16px);
	pointer-events: none;
	transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
}

/*
 * "مخفی در حالت غیرچسبان": the bar exists only while pinned.
 *
 * The placeholder stays in the flow at zero height instead of being displayed
 * only while stuck. It is what marks the widget's slot in the document — the
 * scroll handler measures it to decide when to pin — while contributing no
 * height, so the widget leaves no gap behind. The card itself is out of the
 * flow entirely until .is-stuck lands, hence `display: none` rather than
 * `visibility: hidden`, which would still reserve its box.
 */
.wallex-pcta-wrap--hide-unstuck .wallex-pcta__placeholder {
	display: block;
	height: 0;
}

.wallex-pcta-wrap--hide-unstuck:not(.is-stuck):not(.is-sticky-inactive) .wallex-pcta {
	display: none;
}

/*
 * Device excluded from «فعال در دستگاه‌ها»: sticky never engages there, so a
 * hidden-until-stuck bar would never appear at all. JS sets this class to fall
 * back to an ordinary in-flow bar.
 */
.wallex-pcta-wrap--hide-unstuck.is-sticky-inactive .wallex-pcta__placeholder {
	display: none;
}

@keyframes wallex-pcta-slide-up {
	from {
		opacity: 0;
		transform: translateY(16px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* --------------------------------- Mobile --------------------------------- */
@media (max-width: 767px) {
	.wallex-pcta {
		gap: 10px;
		padding: 12px 14px;
	}

	.wallex-pcta__icon {
		width: 28px;
		height: 28px;
	}

	.wallex-pcta__subtitle {
		font-size: 0.92rem;
	}

	.wallex-pcta__btn {
		padding: 9px 16px;
		font-size: 0.85rem;
	}
}

/* ------------------------------ Accessibility ----------------------------- */
@media (prefers-reduced-motion: reduce) {

	.wallex-pcta__icon,
	.wallex-pcta__btn {
		transition: none;
	}

	.wallex-pcta.is-typing .wallex-pcta__caret {
		animation: none;
	}

	.wallex-pcta-wrap--sticky.is-stuck .wallex-pcta {
		animation: none;
		transition: none;
	}

	/* Still hidden, just without the fade — and without the delay that the
	   fade needed before dropping out of hit-testing. */
	.wallex-pcta-wrap--sticky.is-stuck.is-hidden-over .wallex-pcta {
		transform: none;
		transition: none;
	}
}