/**
 * FormCraft Advanced CAPTCHA CSS
 * Prefixed with fcac- for conflict prevention and compliance.
 */

/* Outer container — acts as the CSS container for responsive queries */
.fcac-outer-container {
	container-type: inline-size;
	container-name: fcac-outer;
	width: 100%;
}

.fcac-captcha-wrapper {
	margin: 15px 0;
	padding: 12px 16px;
	border-radius: 12px;
	background: #ffffff;
	border: 1px solid #e2e8f0;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 10px;
	width: 100%;
	box-sizing: border-box;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
	overflow: visible;
}

.fcac-captcha-wrapper:hover {
	box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
	border-color: #cbd5e1;
	transform: translateY(-2px);
}

/* Accessible hidden screen reader text */
.fcac-screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal;
}

/* Inline layout: image + refresh button sit beside the input */
.fcac-image-wrapper {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
	margin-bottom: 0;
	order: 1;
}

/* The image-box div holds the visual container — divs are never styled as inputs by form plugins */
.fcac-image-box {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	padding: 3px 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 100px;
	min-height: 44px;
	box-sizing: border-box;
	line-height: 0;
}

/* The img only needs display/dimensions — all visuals live on fcac-image-box */
.fcac-captcha-image {
	display: block;
	height: 44px;
	width: auto;
	max-width: 100%;
	object-fit: contain;
	vertical-align: middle;
	transition: filter 0.2s ease;
}

.fcac-captcha-wrapper:hover .fcac-captcha-image {
	filter: contrast(1.05);
}

.fcac-captcha-refresh {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	color: #64748b;
	border-radius: 50%;
	cursor: pointer;
	padding: 0;
	font-size: 18px;
	height: 44px;
	width: 44px;
	min-width: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	outline: none;
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
	flex-shrink: 0;
}

.fcac-captcha-refresh:hover,
.fcac-captcha-refresh:focus {
	background: #eff6ff;
	border-color: #bfdbfe;
	color: #3b82f6;
	transform: rotate(90deg);
	box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2);
}

.fcac-captcha-refresh:focus-visible {
	outline: 2px solid #3b82f6;
	outline-offset: 2px;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

.fcac-captcha-refresh:active {
	transform: scale(0.9) rotate(90deg);
}

/* Input wrapper is inline, no separate block */
.fcac-input-wrapper {
	display: flex;
	align-items: center;
	flex: 1;
	min-width: 0;
	order: 0;
}

.fcac-captcha-input {
	padding: 9px 14px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	width: 100%;
	min-width: 140px;
	font-size: 16px !important;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
	color: #334155;
	background: #f8fafc;
	box-sizing: border-box;
	transition: all 0.2s ease;
	letter-spacing: 2px !important;
}

.fcac-captcha-input::placeholder {
	color: #64748b; /* Improved contrast ratio to meet WCAG AA */
	letter-spacing: normal !important;
}

.fcac-captcha-input:focus {
	border-color: #3b82f6;
	background: #fff;
	outline: none;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.fcac-captcha-input:focus-visible {
	outline: 2px solid #3b82f6;
	outline-offset: 1px;
}

/* Strict Honeypot Hidden Fields */
.fcac-honeypot {
	display: none !important;
	visibility: hidden !important;
	opacity: 0 !important;
	width: 0 !important;
	height: 0 !important;
	position: absolute !important;
	z-index: -9999 !important;
}

/* --- .fcac-stacked: applied by JS ResizeObserver when outer container < 380px --- */
.fcac-outer-container.fcac-stacked .fcac-captcha-wrapper {
	flex-direction: column;
	align-items: stretch;
	width: 100%;
}

.fcac-outer-container.fcac-stacked .fcac-image-wrapper {
	order: 0;
	width: 100%;
	justify-content: center;
	flex-shrink: unset;
	padding: 8px 0 4px;
}

.fcac-outer-container.fcac-stacked .fcac-input-wrapper {
	order: 1;
	width: 100%;
}

.fcac-outer-container.fcac-stacked .fcac-captcha-input {
	width: 100%;
	min-width: unset;
}

/* --- Container Query: stack when the form column is narrow (modern browsers) --- */
@container fcac-outer (max-width: 380px) {
	.fcac-captcha-wrapper {
		flex-direction: column;
		align-items: stretch;
		width: 100%;
	}

	/* Image row on top, full width */
	.fcac-image-wrapper {
		order: 0;
		width: 100%;
		justify-content: center;
		flex-shrink: unset;
		padding: 8px 0 4px;
	}

	/* Input row below, full width */
	.fcac-input-wrapper {
		order: 1;
		width: 100%;
	}

	.fcac-captcha-input {
		width: 100%;
		min-width: unset;
	}
}

/* Viewport fallback for very small screens */
@media (max-width: 480px) {
	.fcac-captcha-wrapper {
		width: 100%;
		flex-direction: column;
		align-items: stretch;
	}

	.fcac-image-wrapper {
		order: 0;
		width: 100%;
		justify-content: center;
		flex-shrink: unset;
		padding: 8px 0 4px;
	}

	.fcac-input-wrapper {
		order: 1;
		width: 100%;
	}

	.fcac-captcha-input {
		width: 100%;
		min-width: unset;
	}
}

/* Spinner Keyframes & Class */
@keyframes fcac-spin {
	from {
		transform: rotate(0deg);
	}

	to {
		transform: rotate(360deg);
	}
}

.fcac-spinning {
	animation: fcac-spin 0.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* --- CAPTCHA Themes --- */

/* 1. Sleek Dark Theme */
.fcac-theme-dark {
	background: #1e1e1e !important;
	border: 1px solid #333 !important;
	color: #fff !important;
}

.fcac-theme-dark .fcac-captcha-image {
	border-color: #444 !important;
	background: #111 !important;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5) !important;
}

.fcac-theme-dark .fcac-captcha-refresh {
	background: #2a2a2a !important;
	border-color: #444 !important;
	color: #ccc !important;
}

.fcac-theme-dark .fcac-captcha-refresh:hover {
	background: #3a3a3a !important;
	color: #fff !important;
}

.fcac-theme-dark .fcac-captcha-input {
	background: #111 !important;
	border-color: #444 !important;
	color: #fff !important;
}

/* 2. Neon Security Theme */
.fcac-theme-neon {
	background: #0d0d0d !important;
	border: 1px solid #39ff14 !important;
	box-shadow: 0 0 10px rgba(57, 255, 20, 0.2) !important;
	color: #39ff14 !important;
}

.fcac-theme-neon .fcac-captcha-image {
	border-color: #39ff14 !important;
	background: #000 !important;
}

.fcac-theme-neon .fcac-captcha-refresh {
	background: #1a1a1a !important;
	border-color: #39ff14 !important;
	color: #39ff14 !important;
}

.fcac-theme-neon .fcac-captcha-refresh:hover {
	background: #39ff14 !important;
	color: #000 !important;
	box-shadow: 0 0 10px rgba(57, 255, 20, 0.4) !important;
}

.fcac-theme-neon .fcac-captcha-input {
	background: #000 !important;
	border-color: #39ff14 !important;
	color: #39ff14 !important;
}

.fcac-theme-neon .fcac-captcha-input:focus {
	box-shadow: 0 0 10px rgba(57, 255, 20, 0.4) !important;
}

/* 3. Glassmorphism Theme */
.fcac-theme-glass {
	background: rgba(255, 255, 255, 0.15) !important;
	backdrop-filter: blur(10px) !important;
	-webkit-backdrop-filter: blur(10px) !important;
	border: 1px solid rgba(255, 255, 255, 0.25) !important;
	box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07) !important;
}

.fcac-theme-glass .fcac-captcha-image {
	border: 1px solid rgba(255, 255, 255, 0.2) !important;
	background: rgba(255, 255, 255, 0.8) !important;
}

/* 4. Sunset Glow Theme */
.fcac-theme-sunset {
	background: #fff5f5 !important;
	border: 2px solid transparent !important;
	background-image: linear-gradient(#fff5f5, #fff5f5), linear-gradient(135deg, #ff7e5f, #feb47b) !important;
	background-origin: border-box !important;
	background-clip: padding-box, border-box !important;
	box-shadow: 0 4px 15px rgba(255, 126, 95, 0.1) !important;
}

.fcac-theme-sunset .fcac-captcha-refresh {
	background: linear-gradient(135deg, #ff7e5f, #feb47b) !important;
	color: #fff !important;
	border: none !important;
}

.fcac-theme-sunset .fcac-captcha-refresh:hover {
	opacity: 0.9 !important;
}

/* ==========================================================================
   WPForms Specific Overrides (No !important)
   ========================================================================== */

.wpforms-container .fcac-captcha-wrapper {
	margin: 15px 0;
	padding: 10px 14px;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid rgba(0, 0, 0, 0.08);
	display: inline-flex;
	flex-direction: row;
	align-items: center;
	gap: 10px;
	max-width: 100%;
	box-sizing: border-box;
}

.wpforms-container .fcac-screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal;
}

.wpforms-container .fcac-image-wrapper {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
	margin-bottom: 0;
	order: 1;
}

.wpforms-container .fcac-captcha-image {
	border: none;
	border-radius: 4px;
	background: transparent;
	display: block;
	height: 40px;
	width: auto;
}

.wpforms-container button.fcac-captcha-refresh,
.wpforms-container .wpforms-field button.fcac-captcha-refresh {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	color: #64748b;
	border-radius: 50%;
	cursor: pointer;
	padding: 0;
	font-size: 18px;
	line-height: 1;
	height: 36px;
	width: 36px;
	min-width: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	outline: none;
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.wpforms-container .fcac-input-wrapper {
	display: flex;
	align-items: center;
	flex: 1;
	min-width: 0;
	order: 0;
}

div.wpforms-container .wpforms-form .wpforms-field input[type=text].fcac-captcha-input {
	padding: 8px 12px;
	border: 1px solid #ccc;
	border-radius: 4px;
	width: 100%;
	min-width: 140px;
	font-size: 16px !important;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
	letter-spacing: 2px !important;
	box-sizing: border-box;
	display: block;
}

.wpforms-container button.fcac-captcha-refresh,
.wpforms-container .wpforms-field button.fcac-captcha-refresh {
	height: 44px;
	width: 44px;
	min-width: 44px;
}

/* Accessibility: prefers-reduced-motion support */
@media (prefers-reduced-motion: reduce) {
	.fcac-captcha-refresh,
	.fcac-captcha-refresh:hover,
	.fcac-captcha-refresh:focus,
	.fcac-captcha-refresh:active {
		transition: none !important;
		transform: none !important;
		animation: none !important;
	}
	.fcac-spinning {
		animation: none !important;
	}
	.fcac-captcha-image,
	.fcac-captcha-input {
		transition: none !important;
	}
}