/**
 * Lazy Loading CSS Styles
 * Provides visual feedback and smooth transitions for lazy loaded images
 */

/* Base lazy loading styles */
.lazy-loading {
	opacity: 0;
	transition: opacity 0.3s ease-in-out;
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: shimmer 1.5s infinite;
}

.lazy-loaded {
	opacity: 1;
	animation: fadeIn 0.5s ease-in-out;
}

/* Force visibility for images with src */
img[src]:not([src=""]) {
	opacity: 1 !important;
	visibility: visible !important;
	display: block !important;
}

/* Override lazy loading for loaded images */
img.lazy-loaded {
	opacity: 1 !important;
	visibility: visible !important;
	display: block !important;
	background: none !important;
	animation: none !important;
}

/* Specific fix for instructor images */
.instructor-thumbnail img[src]:not([src=""]) {
	opacity: 1 !important;
	visibility: visible !important;
	display: block !important;
	width: 100% !important;
	height: auto !important;
	object-fit: cover !important;
}

/* Shimmer loading animation */
@keyframes shimmer {
	0% {
		background-position: -200% 0;
	}
	100% {
		background-position: 200% 0;
	}
}

/* Fade in animation for loaded images */
@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Progressive loading styles */
.progressive-loading {
	filter: blur(5px);
	transition: filter 0.3s ease-out;
}

.progressive-loaded {
	filter: blur(0);
}

/* Loading placeholder styles */
.lazy-placeholder {
	position: relative;
	background: #f8f9fa;
	overflow: hidden;
}

.lazy-placeholder::before {
	content: "";
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(
		90deg,
		transparent,
		rgba(255, 255, 255, 0.4),
		transparent
	);
	animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
	0% {
		left: -100%;
	}
	100% {
		left: 100%;
	}
}

/* Critical images - no lazy loading */
.critical-image {
	opacity: 1;
	background: none;
	animation: none;
}

/* Responsive image containers */
.lazy-image-container {
	position: relative;
	overflow: hidden;
	background: #f8f9fa;
}

.lazy-image-container img {
	width: 100%;
	height: auto;
	display: block;
}

/* Specific container styles for better image display */
.instructor-thumbnail,
.post-thumbnail,
.event-thumbnail {
	min-height: 200px;
	position: relative;
	overflow: hidden;
	background: #f8f9fa;
}

.instructor-thumbnail img,
.post-thumbnail img,
.event-thumbnail img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: opacity 0.3s ease-in-out;
}

/* Ensure images in rows display properly */
.row .col-xl-3 img,
.row .col-md-6 img,
.row .col-sm-12 img {
	display: block;
	width: 100%;
	height: auto;
}

/* Fix for grid layout images */
.ef-instructor-item img,
.ef-blog-grid-item img,
.ef-event-item img {
	width: 100%;
	height: auto;
	object-fit: cover;
}

/* Loading spinner for images */
.lazy-spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 40px;
	height: 40px;
	border: 3px solid #f3f3f3;
	border-top: 3px solid #007bff;
	border-radius: 50%;
	animation: spin 1s linear infinite;
	z-index: 1;
}

@keyframes spin {
	0% {
		transform: translate(-50%, -50%) rotate(0deg);
	}
	100% {
		transform: translate(-50%, -50%) rotate(360deg);
	}
}

/* Hide spinner when image is loaded */
.lazy-loaded + .lazy-spinner {
	display: none;
}

/* Error state for failed image loads */
.lazy-error {
	background: #f8d7da;
	border: 1px solid #f5c6cb;
	color: #721c24;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 200px;
	font-size: 14px;
}

/* Performance optimizations */
.lazy-loading img {
	will-change: opacity;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
	.lazy-loading,
	.lazy-loaded,
	.progressive-loading,
	.progressive-loaded {
		transition: none;
		animation: none;
	}

	.lazy-spinner {
		animation: none;
	}
}

/* High contrast mode support */
@media (prefers-contrast: high) {
	.lazy-loading {
		background: #000;
	}

	.lazy-placeholder {
		background: #000;
	}
}

/* Print styles */
@media print {
	.lazy-loading,
	.lazy-spinner,
	.lazy-placeholder::before {
		display: none !important;
	}

	img {
		opacity: 1 !important;
		filter: none !important;
	}
}
