/**
 * Modern Enhancements CSS
 * Includes: Preloader, Animations, Transitions, Custom Cursor, Performance Optimizations
 */

/* ============================================
   PRELOADER
   ============================================ */
#preloader {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: #fafafa;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.5s ease, visibility 0.5s ease;
}

#preloader.fade-out {
	opacity: 0;
	visibility: hidden;
}

.loader {
	position: relative;
	width: 80px;
	height: 80px;
}

.loader-circle {
	position: absolute;
	width: 100%;
	height: 100%;
	border: 3px solid transparent;
	border-top-color: #CA82F8;
	border-radius: 50%;
	animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.loader-circle:nth-child(2) {
	border-top-color: #FFE9E3;
	animation-delay: 0.15s;
	width: 90%;
	height: 90%;
	top: 5%;
	left: 5%;
}

.loader-circle:nth-child(3) {
	border-top-color: #CA82F8;
	animation-delay: 0.3s;
	width: 80%;
	height: 80%;
	top: 10%;
	left: 10%;
	opacity: 0.7;
}

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

.loader-text {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	font-family: 'Playfair Display', Georgia, serif;
	font-size: 14px;
	letter-spacing: 3px;
	color: #CA82F8;
	animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
	0%, 100% { opacity: 0.6; }
	50% { opacity: 1; }
}

/* ============================================
   SCROLL REVEAL ANIMATIONS
   ============================================ */
.reveal-on-scroll {
	opacity: 0;
	transform: translateY(50px);
	transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal-on-scroll.revealed {
	opacity: 1;
	transform: translateY(0);
}

.reveal-on-scroll.fade-left {
	transform: translateX(-50px);
}

.reveal-on-scroll.fade-left.revealed {
	transform: translateX(0);
}

.reveal-on-scroll.fade-right {
	transform: translateX(50px);
}

.reveal-on-scroll.fade-right.revealed {
	transform: translateX(0);
}

.reveal-on-scroll.scale-up {
	transform: scale(0.9);
}

.reveal-on-scroll.scale-up.revealed {
	transform: scale(1);
}

/* Stagger animation delays */
.reveal-on-scroll:nth-child(1) { transition-delay: 0.1s; }
.reveal-on-scroll:nth-child(2) { transition-delay: 0.2s; }
.reveal-on-scroll:nth-child(3) { transition-delay: 0.3s; }
.reveal-on-scroll:nth-child(4) { transition-delay: 0.4s; }
.reveal-on-scroll:nth-child(5) { transition-delay: 0.5s; }

/* ============================================
   ENHANCED HEADER
   ============================================ */
header {
	transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

header.scrolled {
	background: rgba(255, 255, 255, 0.98);
	box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
	backdrop-filter: blur(10px);
}

header.header-hidden {
	transform: translateY(-100%);
}

/* ============================================
   AUDIO CONTROLS
   ============================================ */
.audio-controls {
	position: fixed;
	bottom: 30px;
	right: 30px;
	z-index: 1000;
}

.audio-toggle {
	width: 50px;
	height: 50px;
	border-radius: 50%;
	background: #CA82F8;
	border: none;
	color: white;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 20px rgba(202, 130, 248, 0.4);
	transition: all 0.3s ease;
	font-size: 20px;
}

.audio-toggle:hover {
	transform: scale(1.1);
	box-shadow: 0 6px 30px rgba(202, 130, 248, 0.6);
}

.audio-toggle.playing {
	animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
	0% {
		box-shadow: 0 0 0 0 rgba(202, 130, 248, 0.7);
	}
	70% {
		box-shadow: 0 0 0 15px rgba(202, 130, 248, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(202, 130, 248, 0);
	}
}

/* ============================================
   CUSTOM CURSOR (Optional)
   ============================================ */
.custom-cursor,
.custom-cursor-dot {
	position: fixed;
	top: 0;
	left: 0;
	pointer-events: none;
	z-index: 10000;
	mix-blend-mode: difference;
}

.custom-cursor {
	width: 40px;
	height: 40px;
	border: 2px solid #CA82F8;
	border-radius: 50%;
	transform: translate(-50%, -50%);
	transition: width 0.3s ease, height 0.3s ease, border-color 0.3s ease;
}

.custom-cursor-dot {
	width: 6px;
	height: 6px;
	background: #CA82F8;
	border-radius: 50%;
	transform: translate(-50%, -50%);
}

.custom-cursor.cursor-hover {
	width: 60px;
	height: 60px;
	border-color: #FFE9E3;
}

.custom-cursor-dot.cursor-hover {
	width: 8px;
	height: 8px;
	background: #FFE9E3;
}

/* Hide default cursor on desktop */
@media (min-width: 768px) {
	body.custom-cursor-enabled {
		cursor: none;
	}
	body.custom-cursor-enabled a,
	body.custom-cursor-enabled button {
		cursor: none;
	}
}

/* ============================================
   LAZY LOADING IMAGES
   ============================================ */
img[data-src] {
	opacity: 0;
	transition: opacity 0.5s ease;
}

img[data-src].loaded {
	opacity: 1;
}

/* ============================================
   ENHANCED ANIMATIONS
   ============================================ */
.animate-box {
	transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
	            transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth hover effects */
.btn,
a,
.work-entry .work-img,
.article .blog-img {
	transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   ENHANCED FORM STYLES
   ============================================ */
.form-group {
	position: relative;
}

.form-control {
	transition: all 0.3s ease;
}

.form-control:focus {
	transform: translateY(-2px);
	box-shadow: 0 4px 20px rgba(202, 130, 248, 0.15);
}

/* Floating labels */
.form-group label {
	position: absolute;
	top: 15px;
	left: 15px;
	color: #999;
	transition: all 0.3s ease;
	pointer-events: none;
}

.form-control:focus + label,
.form-control.has-value + label {
	top: -10px;
	left: 10px;
	font-size: 12px;
	color: #CA82F8;
	background: white;
	padding: 0 5px;
}

/* ============================================
   ENHANCED CAROUSEL
   ============================================ */
.owl-carousel {
	transition: opacity 0.5s ease;
}

.owl-carousel .owl-item {
	backface-visibility: hidden;
	transform: translateZ(0);
}

/* ============================================
   SCROLL PROGRESS BAR
   ============================================ */
.scroll-progress {
	position: fixed;
	top: 0;
	left: 0;
	width: 0;
	height: 3px;
	background: linear-gradient(90deg, #CA82F8, #FFE9E3);
	z-index: 9998;
	transition: width 0.1s ease;
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */
/* GPU acceleration for animations */
.animate-box,
.work-entry .work-img,
.article .blog-img img {
	will-change: transform, opacity;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/* ============================================
   ENHANCED MOBILE STYLES
   ============================================ */
@media (max-width: 768px) {
	.audio-controls {
		bottom: 20px;
		right: 20px;
	}

	.audio-toggle {
		width: 45px;
		height: 45px;
		font-size: 18px;
	}

	.reveal-on-scroll {
		transform: translateY(30px);
	}
	
	/* Ensure SoundCloud iframes are responsive */
	.blog-img iframe {
		height: 250px !important;
	}
}

/* Extra small devices */
@media (max-width: 576px) {
	#preloader .loader {
		width: 60px;
		height: 60px;
	}
	
	.loader-text {
		font-size: 12px;
	}
	
	.audio-toggle {
		width: 40px;
		height: 40px;
		font-size: 16px;
	}
	
	.back-to-top {
		width: 40px;
		height: 40px;
		font-size: 16px;
	}
	
	/* Make SoundCloud embeds smaller on mobile */
	.blog-img iframe {
		height: 200px !important;
	}
}

/* ============================================
   LOADING STATES
   ============================================ */
.loading {
	position: relative;
	pointer-events: none;
	opacity: 0.6;
}

.loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 20px;
	margin: -10px 0 0 -10px;
	border: 2px solid #CA82F8;
	border-top-color: transparent;
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

/* ============================================
   ENHANCED SHADOWS
   ============================================ */
.card-shadow {
	box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
	transition: box-shadow 0.3s ease;
}

.card-shadow:hover {
	box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
}

/* ============================================
   GRADIENT TEXT
   ============================================ */
.gradient-text {
	background: linear-gradient(135deg, #CA82F8, #FFE9E3);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

/* ============================================
   GLASSMORPHISM EFFECT
   ============================================ */
.glass {
	background: rgba(255, 255, 255, 0.7);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ============================================
   SMOOTH PAGE TRANSITIONS
   ============================================ */
body.loaded {
	animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}
