/**
 * Gravity Forms Captcha Loader Styling
 * Implements modern UI/UX design tokens, glassmorphism, 3x3 visual grid, and rich feedback.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

.wp-captcha-gform-wrapper {
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	max-width: 480px;
	margin: 2rem auto;
	box-sizing: border-box;
}

.wp-captcha-gform-wrapper * {
	box-sizing: border-box;
}

/* Captcha Challenge Widget Card */
.wp-captcha-widget-card {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 20px;
	padding: 24px;
	box-shadow: 0 10px 30px -5px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.03);
	transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Card Header */
.wp-captcha-card-header {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-bottom: 20px;
	border-bottom: 1px solid #f1f5f9;
	padding-bottom: 16px;
}

.wp-captcha-header-icon {
	background: #f5f3ff;
	color: #6366f1;
	width: 44px;
	height: 44px;
	border-radius: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.wp-captcha-header-titles h3 {
	margin: 0 0 4px 0;
	font-size: 16px;
	font-weight: 700;
	color: #1e293b;
	line-height: 1.2;
}

.wp-captcha-header-titles p {
	margin: 0;
	font-size: 13px;
	color: #64748b;
	line-height: 1.4;
}

/* Challenge Category instruction */
.wp-captcha-challenge-instruction {
	font-size: 14px;
	color: #334155;
	font-weight: 500;
	margin-bottom: 16px;
}

.wp-captcha-target-category-label {
	display: inline-block;
	background: #f5f3ff;
	color: #4f46e5;
	font-weight: 700;
	padding: 2px 10px;
	border-radius: 6px;
	font-size: 14px;
	border: 1px solid #e0e7ff;
	text-transform: capitalize;
}

/* 3x3 Responsive Grid */
.wp-captcha-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 12px;
	margin-bottom: 24px;
}

/* Captcha Item Cards */
.wp-captcha-grid-item {
	position: relative;
	aspect-ratio: 1 / 1;
	background: #f8fafc;
	border: 1.5px solid #e2e8f0;
	border-radius: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #475569;
	padding: 16px;
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
	user-select: none;
}

.wp-captcha-grid-item svg {
	width: 100%;
	height: 100%;
	max-width: 44px;
	max-height: 44px;
	transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Card Hover States */
.wp-captcha-grid-item:hover {
	border-color: #a5b4fc;
	background: #ffffff;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px -1px rgba(99, 102, 241, 0.1);
	color: #312e81;
}

.wp-captcha-grid-item:hover svg {
	transform: scale(1.1);
}

/* Active / Selected State */
.wp-captcha-grid-item.selected {
	background: #eef2ff;
	border-color: #4f46e5;
	color: #4f46e5;
	box-shadow: 0 0 0 1px #4f46e5, 0 4px 12px -2px rgba(79, 70, 229, 0.2);
}

.wp-captcha-grid-item.selected svg {
	transform: scale(1.05);
}

/* Selected checkmark pill overlay */
.wp-captcha-item-checkmark {
	position: absolute;
	top: 8px;
	right: 8px;
	background: #4f46e5;
	color: #ffffff;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
	opacity: 0;
	transform: scale(0.5);
	transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wp-captcha-grid-item.selected .wp-captcha-item-checkmark {
	opacity: 1;
	transform: scale(1);
}

/* Placeholder Skeletons (while loading challenge) */
.wp-captcha-card-placeholder {
	aspect-ratio: 1 / 1;
	background: #f1f5f9;
	border-radius: 14px;
}

/* Pulse Animation for Loader */
.animate-pulse {
	animation: pulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
	0%, 100% {
		opacity: 1;
		background-color: #f1f5f9;
	}
	50% {
		opacity: .4;
		background-color: #e2e8f0;
	}
}

/* Footer Section */
.wp-captcha-card-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	border-top: 1px solid #f1f5f9;
	padding-top: 18px;
}

/* Premium Buttons styling */
.wp-captcha-btn {
	border: none;
	border-radius: 10px;
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
}

.wp-captcha-btn-secondary {
	background: #f1f5f9;
	color: #475569;
	width: 44px;
	height: 44px;
	flex-shrink: 0;
}

.wp-captcha-btn-secondary:hover {
	background: #e2e8f0;
	color: #1e293b;
}

/* Refresh spin micro-animation */
.wp-captcha-btn-refresh svg {
	transition: transform 0.4s ease;
}

.wp-captcha-btn-refresh:hover svg {
	transform: rotate(180deg);
}

.wp-captcha-btn-primary {
	background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
	color: #ffffff;
	padding: 0 20px;
	height: 44px;
	flex-grow: 1;
	box-shadow: 0 4px 10px -1px rgba(79, 70, 229, 0.25);
}

.wp-captcha-btn-primary:hover:not(:disabled) {
	background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
	transform: translateY(-1px);
	box-shadow: 0 8px 16px -2px rgba(79, 70, 229, 0.35);
}

.wp-captcha-btn-primary:active:not(:disabled) {
	transform: translateY(1px);
}

.wp-captcha-btn-primary:disabled {
	background: #cbd5e1;
	color: #94a3b8;
	cursor: not-allowed;
	box-shadow: none;
}

/* SKELETON LOADER FOR FORM */
.wp-captcha-form-loading-skeleton {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 20px;
	padding: 30px;
	box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.skeleton-line {
	background: #f1f5f9;
	border-radius: 6px;
	margin-bottom: 16px;
}

.skeleton-title {
	width: 40%;
	height: 24px;
	margin-bottom: 24px;
}

.skeleton-input {
	width: 100%;
	height: 44px;
}

.skeleton-textarea {
	width: 100%;
	height: 100px;
}

.skeleton-button {
	width: 30%;
	height: 44px;
	margin-bottom: 0;
	background: #e2e8f0;
}

/* Secure Form Entry Fade in Animation */
.wp-captcha-form-container {
	animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInUp {
	from {
		opacity: 0;
		transform: translateY(15px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* Error message alerts */
.wp-captcha-error-notice {
	background: #fef2f2;
	border: 1px solid #fecaca;
	border-radius: 10px;
	color: #991b1b;
	padding: 12px 16px;
	font-size: 13px;
	font-weight: 500;
	margin-bottom: 16px;
	display: flex;
	align-items: center;
	gap: 8px;
	animation: shake 0.4s ease-in-out;
}

@keyframes shake {
	0%, 100% { transform: translateX(0); }
	20%, 60% { transform: translateX(-4px); }
	40%, 80% { transform: translateX(4px); }
}

/* UNSPLASH PHOTO CAPTCHA ENHANCEMENTS */
.wp-captcha-grid-item.has-image {
	padding: 0 !important;
	overflow: hidden;
	position: relative;
	background: #f1f5f9;
}

.wp-captcha-grid-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.wp-captcha-grid-item.has-image:hover:not(.selected) .wp-captcha-grid-image {
	transform: scale(1.06);
	opacity: 0.95;
}

.wp-captcha-grid-item.has-image.selected .wp-captcha-grid-image {
	transform: scale(0.94);
	opacity: 0.85;
}

/* Adjust checkmark positioning and sizing when overlaying photos */
.wp-captcha-grid-item.has-image .wp-captcha-item-checkmark {
	top: 8px;
	right: 8px;
	background: #4f46e5;
	border: 1.5px solid #ffffff;
	box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}
