/**
 * Element Matcher Styles
 *
 * CSS for the interactive element matching game component.
 * Includes responsive design and accessibility features.
 *
 * @package InteractiveElements
 * @since 1.0.0
 */

/* ==========================================================================
   Base Element Matcher Styles
   ========================================================================== */

.ie-element-matcher {
	max-width: 100%;
	margin: 20px 0;
	user-select: none;
	position: relative;
}

/* ==========================================================================
   Progress Bar
   ========================================================================== */

.ie-progress-container {
	margin-bottom: 20px;
	padding: 15px;
	background: #f8f9fa;
	border-radius: 8px;
	border: 1px solid #e9ecef;
}

.ie-progress-label {
	font-weight: 600;
	margin-bottom: 8px;
	color: #404345;
	font-size: 14px;
}

.ie-progress-bar {
	width: 100%;
	height: 20px;
	background: #e9ecef;
	border-radius: 10px;
	overflow: hidden;
	position: relative;
}

.ie-progress-fill {
	height: 100%;
	background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
	border-radius: 10px;
	transition: width 0.3s ease;
	position: relative;
}

.ie-progress-fill::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
	animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
	0% { transform: translateX(-100%); }
	100% { transform: translateX(100%); }
}

.ie-progress-text {
	text-align: center;
	margin-top: 8px;
	font-weight: 500;
	color: #404345;
	font-size: 12px;
}

/* ==========================================================================
   Game Area Layout
   ========================================================================== */

.ie-game-area {
	display: grid;
	grid-template-columns: 1fr 300px;
	gap: 30px;
	margin-bottom: 20px;
}

@media (max-width: 768px) {
	.ie-game-area {
		grid-template-columns: 1fr;
		gap: 20px;
	}
}

/* ==========================================================================
   Product Container
   ========================================================================== */

.ie-product-container {
	position: relative;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
	overflow: hidden;
	min-height: 400px;
}

.ie-product-image {
	width: 100%;
	height: auto;
	display: block;
	max-height: 600px;
	object-fit: contain;
}

.ie-drop-zone {
	position: absolute;
	border: 2px dashed transparent;
	border-radius: 8px;
	transition: all 0.3s ease;
	z-index: 10;
}

.ie-drop-zone.drag-over {
	border-color: #007bff;
	background: rgba(0, 123, 255, 0.1);
	transform: scale(1.05);
}

.ie-drop-zone.valid-drop {
	border-color: #28a745;
	background: rgba(40, 167, 69, 0.1);
}

.ie-drop-zone.invalid-drop {
	border-color: #dc3545;
	background: rgba(220, 53, 69, 0.1);
	animation: shake 0.5s ease-in-out;
}

@keyframes shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-5px); }
	75% { transform: translateX(5px); }
}

.ie-placed-elements {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	pointer-events: none;
	z-index: 20;
}

.ie-placed-element {
	position: absolute;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: white;
	font-weight: bold;
	font-size: 14px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
	animation: element-drop 0.5s ease-out;
	z-index: 21;
}

@keyframes element-drop {
	0% {
		transform: scale(0) rotate(180deg);
		opacity: 0;
	}
	50% {
		transform: scale(1.2) rotate(90deg);
	}
	100% {
		transform: scale(1) rotate(0deg);
		opacity: 1;
	}
}

.ie-placed-element.success {
	animation: element-success 0.6s ease-out;
}

@keyframes element-success {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.3); }
}

/* ==========================================================================
   Product Thumbnails Navigation (Multi-Product Mode)
   ========================================================================== */

.ie-product-thumbnails {
	display: flex;
	justify-content: center;
	gap: 12px;
	padding: 15px;
	background: #f8f9fa;
	border-radius: 8px;
	margin-top: 15px;
	flex-wrap: wrap;
}

.ie-product-thumb {
	position: relative;
	width: 19%;
	padding: 15px;
	height: auto;
	border-radius: 8px;
	overflow: hidden;
	cursor: pointer;
	border: 3px solid #e9ecef;
	transition: all 0.3s ease;
	background: #fff;
}

.ie-product-thumb:hover {
	border-color: #007bff;
	transform: translateY(-2px);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.ie-product-thumb.active {
	border-color: #007bff;
	box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.ie-product-thumb:focus {
	outline: 2px solid #007bff;
	outline-offset: 2px;
}

.ie-product-thumb:focus:not(:focus-visible) {
	outline: none;
}

.ie-product-thumb:focus-visible {
	outline: 2px solid #007bff;
	outline-offset: 2px;
}

.ie-product-thumb.completed {
	border-color: #28a745;
}

.ie-product-thumb.completed .ie-thumb-completed-overlay {
	display: flex !important;
}

.ie-product-thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	max-height: 180px;
}

.ie-thumb-label {
	display: block;
	text-align: center;
	font-size: 12px;
	font-weight: 500;
	color: #495057;
	padding: 4px 6px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ie-thumb-completed-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(40, 167, 69, 0.85);
	display: flex;
	align-items: center;
	justify-content: center;
}

.ie-thumb-completed-overlay .dashicons {
	color: white;
	font-size: 28px;
	width: 28px;
	height: 28px;
}

/* Multi-product game area layout adjustment */
.ie-multi-product .ie-game-area {
	grid-template-columns: 1fr 420px;
	grid-template-rows: auto auto;
}

.ie-multi-product .ie-product-container {
	grid-column: 1;
	grid-row: 1;
	place-items: center;
	place-content: center;
}

.ie-multi-product .ie-product-thumbnails {
	grid-column: 1 / -1;
	grid-row: 2;
}

.ie-multi-product .ie-elements-palette {
	grid-column: 2;
	grid-row: 1;
}

@media (max-width: 768px) {
	.ie-product-thumbnails {
		gap: 8px;
		padding: 10px;
	}

	.ie-product-thumb {
		width: 65px;
		height: 65px;
	}

	.ie-multi-product .ie-game-area {
		grid-template-columns: 1fr;
		grid-template-rows: auto auto auto;
	}

	.ie-multi-product .ie-elements-palette {
		grid-column: 1;
		grid-row: 1;
	}

	.ie-multi-product .ie-product-container {
		grid-column: 1;
		grid-row: 2;
	}

	.ie-multi-product .ie-product-thumbnails {
		grid-column: 1;
		grid-row: 3;
	}
}

/* ==========================================================================
   Elements Palette
   ========================================================================== */

.ie-elements-palette {
	background: #fff;
	border-radius: 0;
	padding: 0;
	box-shadow: none;
	height: fit-content;
}

.ie-elements-palette h3 {
	margin: 0 0 20px 0;
	color: #495057;
	font-size: 18px;
	font-weight: 600;
	text-align: center;
}

.ie-elements-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 15px;
}

@media (max-width: 768px) {
	.ie-elements-grid {
		grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
		gap: 10px;
	}
}

/* ==========================================================================
   Individual Elements
   ========================================================================== */

.ie-element {
	background: #fff;
	border: 2px solid #e9ecef;
	border-radius: 12px;
	padding: 15px;
	text-align: center;
	cursor: grab;
	transition: all 0.3s ease;
	position: relative;
	overflow: hidden;
}

.ie-element:hover {
	border-color: #007bff;
	transform: translateY(-2px);
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.ie-element:active {
	cursor: grabbing;
	transform: scale(0.95);
}

.ie-element.dragging {
	opacity: 0.8;
	transform: rotate(5deg) scale(1.1);
	z-index: 1000;
}

.ie-element.used {
	opacity: 0.5;
	cursor: not-allowed;
	border-color: #6c757d;
}

.ie-element.used:hover {
	transform: none;
	box-shadow: none;
}

.ie-element-image {
	width: 100%;
	aspect-ratio: 1;
	border-radius: 50%;
	margin: 0 auto 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ie-element-img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	border-radius: 50%;
}

.ie-element-info-btn {
	position: absolute;
	top: -5px;
	right: -5px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: #fff;
	border: 1px solid #ddd;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	transition: all 0.3s ease;
}

.ie-element-info-btn:hover {
	background: #f0f0f0;
	transform: scale(1.1);
}

.ie-element-info-btn .dashicons {
	font-size: 12px;
	color: #666;
	width: 12px;
	height: 12px;
}

.ie-element-image img {
	width: 30px;
	height: 30px;
	object-fit: contain;
}

.ie-element-symbol {
	font-weight: bold;
	font-size: 16px;
	color: white;
	text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.ie-element-data {
	display: none;
}

/* ==========================================================================
   Game Controls
   ========================================================================== */

.ie-game-controls {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 15px;
	flex-wrap: wrap;
	margin-bottom: 20px;
}

.ie-game-controls button {
	background: #007bff;
	color: white;
	border: none;
	padding: 10px 20px;
	border-radius: 6px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.3s ease;
	font-size: 14px;
}

.ie-game-controls button:hover {
	background: #0056b3;
	transform: translateY(-1px);
}

.ie-hint-button {
	background: #ffc107 !important;
	color: #212529 !important;
}

.ie-hint-button:hover {
	background: #e0a800 !important;
}

.ie-reset-button {
	background: #6c757d !important;
}

.ie-reset-button:hover {
	background: #545b62 !important;
}

.ie-attempts-counter {
	color: #6c757d;
	font-size: 14px;
	font-weight: 500;
}

/* ==========================================================================
   Element Info Modal
   ========================================================================== */

.ie-element-info-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.8);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10000;
	animation: modal-fade-in 0.3s ease-out;
}

.ie-element-info-modal .ie-modal-content {
	position: relative;
	background: white;
	border-radius: 16px;
	width: 90%;
	max-width: 600px;
	box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
	animation: modal-slide-up 0.3s ease-out;
}

.ie-element-info-modal .ie-modal-header {
	position: absolute;
	top: 0;
	left: auto;
	right: 0;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20px 20px 10px;
	border: none;
}

.ie-element-modal-title {
	display: none;
}

.ie-element-info-modal .ie-modal-header .ie-element-modal-title {
	margin: 0;
	color: #333;
	font-size: 18px;
}

.ie-close-element-modal {
	background: none;
	border: none;
	cursor: pointer;
	padding: 5px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.3s ease;
}

.ie-close-element-modal:hover {
	background: #f0f0f0;
}

.ie-close-element-modal .dashicons {
	color: #666;
	font-size: 32px;
	width: 34px;
	height: 34px;
}

.ie-element-info-modal .ie-modal-body {
	padding: 20px;
	text-align: center;
}

.ie-element-modal-image {
	margin-bottom: 15px;
}

.ie-element-modal-image img {
	width: 172px;
	height: 172px;
	object-fit: contain;
	border-radius: 0;
	border: none;
}

.ie-element-modal-image .ie-element-symbol {
	display: inline-flex;
	width: 80px;
	height: 80px;
	border-radius: 50%;
	align-items: center;
	justify-content: center;
	font-size: 24px;
	font-weight: bold;
	color: white;
	text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.ie-element-modal-description {
	color: inherit;
	line-height: 1.6;
	font-size: 18px;
}

/* ==========================================================================
   Success Modal
   ========================================================================== */

.ie-success-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.8);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10000;
	animation: modal-fade-in 0.3s ease-out;
}

@keyframes modal-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

.ie-modal-content {
	background: white;
	border-radius: 16px;
	padding: 40px;
	text-align: center;
	max-width: 400px;
	width: 90%;
	box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
	animation: modal-slide-up 0.3s ease-out;
}

@keyframes modal-slide-up {
	from {
		transform: translateY(50px);
		opacity: 0;
	}
	to {
		transform: translateY(0);
		opacity: 1;
	}
}

.ie-success-icon {
	font-size: 4rem;
	margin-bottom: 20px;
	animation: success-bounce 0.6s ease-out;
}

@keyframes success-bounce {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.2); }
}

.ie-modal-content .ie-modal-title {
	color: #28a745;
	margin-bottom: 20px;
	font-size: 24px;
}

.ie-success-stats {
	color: #6c757d;
	margin-bottom: 30px;
	font-size: 14px;
}

.ie-modal-actions {
	display: flex;
	gap: 15px;
	justify-content: center;
}

.ie-modal-actions button {
	background: #007bff;
	color: white;
	border: none;
	padding: 12px 24px;
	border-radius: 6px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.3s ease;
}

.ie-play-again-button {
	background: #28a745 !important;
}

.ie-next-product-button {
	background: #007bff !important;
}

.ie-close-modal-button {
	background: #6c757d !important;
}

.ie-modal-actions button:hover {
	transform: translateY(-1px);
	opacity: 0.9;
}


/* ==========================================================================
   Error Styles
   ========================================================================== */

.ie-error {
	background: #f8d7da;
	color: #721c24;
	padding: 15px;
	border: 1px solid #f5c6cb;
	border-radius: 6px;
	margin: 20px 0;
}

/* ==========================================================================
   Keyboard Instructions
   ========================================================================== */

.ie-keyboard-instructions {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ==========================================================================
   Screen Reader Announcements (visually hidden)
   ========================================================================== */

.ie-sr-only,
.ie-sr-announcements {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ==========================================================================
   Keyboard Selected State
   ========================================================================== */

.ie-element.ie-keyboard-selected {
	border-color: #007bff;
	box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.4), 0 6px 12px rgba(0, 0, 0, 0.15);
	transform: translateY(-2px);
	animation: ie-pulse-selected 1.5s ease-in-out infinite;
}

@keyframes ie-pulse-selected {
	0%, 100% {
		box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.4), 0 6px 12px rgba(0, 0, 0, 0.15);
	}
	50% {
		box-shadow: 0 0 0 6px rgba(0, 123, 255, 0.2), 0 6px 12px rgba(0, 0, 0, 0.15);
	}
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.ie-element:focus {
	outline: 2px solid #007bff;
	outline-offset: 2px;
}

.ie-element:focus:not(:focus-visible) {
	outline: none;
}

.ie-element:focus-visible {
	outline: 2px solid #007bff;
	outline-offset: 2px;
}

.ie-drop-zone:focus {
	outline: 2px solid #007bff;
	outline-offset: 2px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
	.ie-element-matcher *,
	.ie-element-matcher *::before,
	.ie-element-matcher *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/* High contrast mode */
@media (prefers-contrast: more) {
	.ie-element-matcher {
		border: 2px solid;
	}
	
	.ie-element {
		border-width: 3px;
	}
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.ie-element-matcher.loading {
	opacity: 0.7;
	pointer-events: none;
}

.ie-element-matcher.loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 40px;
	height: 40px;
	margin: -20px 0 0 -20px;
	border: 4px solid #f3f3f3;
	border-top: 4px solid #007bff;
	border-radius: 50%;
	animation: loading-spinner 1s linear infinite;
	z-index: 1001;
}

@keyframes loading-spinner {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}