/*
 * EBR Comment Captcha - Frontend Styles
 * Author: EBR - doonaweb.ir
 *
 * زبان طراحی هم‌راستا با پنل تنظیمات افزونه (کارت‌های گرد با سایه نرم و
 * دکمه‌های سرمه‌ای/کپسولی) اما رنگ اصلی/پس‌زمینه/متن، گردی گوشه‌ها و
 * اندازه فونت همگی از طریق متغیرهای CSS زیر از تنظیمات افزونه قابل تغییرند.
 *
 * جهت (راست‌چین/چپ‌چین) بر اساس ویژگی dir که سرور روی wrap تنظیم می‌کند
 * مشخص می‌شود؛ به همین دلیل از خاصیت‌های منطقی CSS (inset-inline-*) به‌جای
 * left/right فیزیکی استفاده شده تا هم برای سایت‌های راست‌چین و هم چپ‌چین
 * درست کار کند.
 */

.ebr-captcha-wrap {
	--ebr-primary: #2271b1;
	--ebr-bg: #f7f7f7;
	--ebr-text: #23282d;
	--ebr-radius: 8px;
	--ebr-font-size: 15px;

	max-width: 420px;
	margin: 14px 0;
	padding: 18px 20px;
	background: var(--ebr-bg);
	color: var(--ebr-text);
	border: 1px solid rgba(0, 0, 0, 0.07);
	border-radius: var(--ebr-radius);
	box-shadow: 0 4px 18px -10px rgba(0, 0, 0, 0.16);
	box-sizing: border-box;
	font-family: inherit;
	font-size: var(--ebr-font-size);
}

.ebr-captcha-wrap * {
	box-sizing: border-box;
}

.ebr-captcha-label {
	display: block;
	font-size: 0.87em;
	font-weight: 600;
	margin-bottom: 12px;
	opacity: 0.85;
}

.ebr-captcha-body {
	min-height: 3.2em;
	display: flex;
	align-items: center;
}

.ebr-captcha-loading {
	font-size: 0.87em;
	opacity: 0.6;
}

.ebr-captcha-status {
	font-size: 0.8em;
	margin-top: 9px;
	min-height: 1.2em;
	font-weight: 500;
	transition: color 0.2s ease;
}

.ebr-captcha-status.is-success {
	color: #1a7f37;
}

.ebr-captcha-status.is-error {
	color: #c0392b;
}

/* هانی‌پات - کاملاً مخفی از دید کاربر واقعی اما در دسترس ربات‌های ساده */
.ebr-hp-field-wrap {
	position: absolute !important;
	inset-inline-start: -9999px !important;
	top: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ---------- سبک ریاضی / تصویری (فیلد ورودی متن) ---------- */
.ebr-captcha-input-row {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	flex-wrap: wrap;
}

.ebr-captcha-question {
	font-size: 1.5em;
	font-weight: 800;
	letter-spacing: 0.4px;
	white-space: nowrap;
	background: rgba(0, 0, 0, 0.045);
	padding: 0.5em 0.85em;
	border-radius: calc(var(--ebr-radius) / 1.4);
	line-height: 1;
}

.ebr-captcha-question img {
	display: block;
	border-radius: calc(var(--ebr-radius) / 1.4);
	max-width: 100%;
	height: auto;
}

.ebr-captcha-text-input {
	flex: 1 1 120px;
	min-width: 90px;
	padding: 0.68em 0.9em;
	border: 1.5px solid rgba(0, 0, 0, 0.14);
	border-radius: calc(var(--ebr-radius) / 1.4);
	font-size: 1.05em;
	font-weight: 600;
	background: #fff;
	color: var(--ebr-text);
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.ebr-captcha-text-input:focus {
	outline: none;
	border-color: var(--ebr-primary);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--ebr-primary) 18%, transparent);
}

.ebr-captcha-text-input:disabled {
	opacity: 0.85;
}

.ebr-captcha-input-row.is-success .ebr-captcha-text-input {
	border-color: #1a7f37;
	background: color-mix(in srgb, #1a7f37 6%, #fff);
}

.ebr-captcha-input-row.is-error .ebr-captcha-text-input {
	border-color: #c0392b;
	animation: ebr-shake 0.32s ease;
}

@keyframes ebr-shake {
	10%, 90% { transform: translateX(-1px); }
	20%, 80% { transform: translateX(2px); }
	30%, 50%, 70% { transform: translateX(-4px); }
	40%, 60% { transform: translateX(4px); }
}

.ebr-captcha-refresh,
.ebr-captcha-submit {
	flex: 0 0 auto;
	height: 2.7em;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.9em;
	line-height: 1;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.ebr-captcha-refresh {
	background: transparent;
	border: 1.5px solid rgba(0, 0, 0, 0.14);
	color: var(--ebr-text);
	width: 2.7em;
	border-radius: calc(var(--ebr-radius) / 1.4);
	padding: 0;
}

.ebr-captcha-refresh:hover {
	border-color: var(--ebr-primary);
	color: var(--ebr-primary);
}

.ebr-captcha-refresh:active {
	transform: scale(0.92) rotate(-30deg);
}

.ebr-captcha-submit {
	background: var(--ebr-primary);
	border: 1.5px solid var(--ebr-primary);
	color: #fff;
	padding: 0 1.35em;
	border-radius: 100px;
	font-size: 0.85em;
	font-weight: 700;
	position: relative;
	box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--ebr-primary) 65%, transparent);
}

.ebr-captcha-submit:hover {
	filter: brightness(1.08);
	transform: translateY(-1px);
	box-shadow: 0 8px 16px -6px color-mix(in srgb, var(--ebr-primary) 70%, transparent);
}

.ebr-captcha-submit:active {
	transform: scale(0.97);
}

.ebr-captcha-submit:disabled {
	opacity: 0.55;
	cursor: default;
	filter: none;
	transform: none;
	box-shadow: none;
}

.ebr-captcha-submit.is-verified {
	background: #1a7f37;
	border-color: #1a7f37;
	opacity: 1;
	box-shadow: 0 6px 14px -6px rgba(26, 127, 55, 0.5);
}

.ebr-captcha-submit.is-loading {
	color: transparent;
}

.ebr-captcha-submit.is-loading::after {
	content: "";
	position: absolute;
	width: 1.05em;
	height: 1.05em;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.45);
	border-top-color: #fff;
	animation: ebr-spin 0.6s linear infinite;
}

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

/* ---------- سبک اسلایدر (کپسولی، هم‌راستا با پیش‌نمایش پنل تنظیمات) ---------- */
.ebr-slider-track {
	position: relative;
	width: 100%;
	height: 3.15em;
	background: rgba(0, 0, 0, 0.055);
	border-radius: 100px;
	overflow: hidden;
	user-select: none;
	-webkit-user-select: none;
	touch-action: none;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}

.ebr-slider-fill {
	position: absolute;
	top: 0;
	inset-inline-start: 0;
	height: 100%;
	width: 0;
	background: linear-gradient(
		90deg,
		color-mix(in srgb, var(--ebr-primary) 30%, transparent),
		color-mix(in srgb, var(--ebr-primary) 14%, transparent)
	);
}

.ebr-slider-track:not(.is-dragging) .ebr-slider-fill {
	transition: width 0.25s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.ebr-slider-text {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.87em;
	font-weight: 500;
	opacity: 0.65;
	pointer-events: none;
	transition: color 0.2s ease, opacity 0.2s ease;
}

.ebr-slider-handle {
	position: absolute;
	top: 0.27em;
	inset-inline-start: 0.27em;
	width: 2.6em;
	height: 2.6em;
	border-radius: calc(var(--ebr-radius) / 1.4);
	background: var(--ebr-primary);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: grab;
	font-size: 1.05em;
	box-shadow: 0 2px 6px color-mix(in srgb, var(--ebr-primary) 45%, transparent);
}

.ebr-slider-track:not(.is-dragging) .ebr-slider-handle {
	transition: inset-inline-start 0.25s cubic-bezier(0.2, 0.8, 0.3, 1), background 0.2s ease, box-shadow 0.2s ease;
}

.ebr-slider-handle:active {
	cursor: grabbing;
}

.ebr-slider-track:not(.is-verified):not(.is-dragging) .ebr-slider-handle {
	animation: ebr-pulse 2.4s ease-in-out infinite;
}

@keyframes ebr-pulse {
	0%, 100% { box-shadow: 0 2px 6px color-mix(in srgb, var(--ebr-primary) 45%, transparent); }
	50% { box-shadow: 0 2px 14px color-mix(in srgb, var(--ebr-primary) 70%, transparent); }
}

.ebr-slider-track.is-verified {
	background: rgba(26, 127, 55, 0.12);
}

.ebr-slider-track.is-verified .ebr-slider-handle {
	background: #1a7f37;
	box-shadow: 0 2px 6px rgba(26, 127, 55, 0.4);
}

.ebr-slider-track.is-verified .ebr-slider-text {
	color: #1a7f37;
	opacity: 1;
	font-weight: 700;
}

/* ---------- تم تیره ---------- */
.ebr-theme-dark {
	--ebr-bg: #1e1f22;
	--ebr-text: #f0f0f1;
}

.ebr-theme-dark.ebr-captcha-wrap {
	border-color: rgba(255, 255, 255, 0.06);
	box-shadow: 0 4px 18px -10px rgba(0, 0, 0, 0.5);
}

.ebr-theme-dark .ebr-captcha-text-input {
	background: #2a2b2e;
	border-color: rgba(255, 255, 255, 0.15);
	color: #f0f0f1;
}

.ebr-theme-dark .ebr-captcha-question {
	background: rgba(255, 255, 255, 0.08);
}

.ebr-theme-dark .ebr-captcha-refresh {
	border-color: rgba(255, 255, 255, 0.2);
	color: #f0f0f1;
}

.ebr-theme-dark .ebr-slider-track {
	background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 480px) {
	.ebr-captcha-wrap {
		max-width: 100%;
	}

	.ebr-captcha-question {
		font-size: 1.3em;
		padding: 0.45em 0.7em;
	}

	.ebr-captcha-submit {
		flex: 1 1 100%;
		order: 3;
	}
}
