/**
 * HadithWorld Animations and Effects
 * Advanced CSS animations and visual effects for modern UI
 */

/* Ripple effect for buttons */
.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.6);
  pointer-events: none;
  width: 100px;
  height: 100px;
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 0.6s linear;
}

@keyframes ripple {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0.6;
  }
  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

/* Shiny element effect */
.shiny {
  position: relative;
  overflow: hidden;
}

.shiny::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    to bottom right, 
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(30deg);
  animation: shinyEffect 3s infinite;
}

@keyframes shinyEffect {
  0% { transform: rotate(30deg) translateX(-100%); }
  100% { transform: rotate(30deg) translateX(100%); }
}

/* Pulsating element */
.pulse {
  animation: pulse 2s infinite cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Floating animation for decorative elements */
.float {
  animation: float 5s ease-in-out infinite;
}

.float-reverse {
  animation: float 6s ease-in-out infinite reverse;
}

.float-alternate {
  animation: floatAlternate 7s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-15px); }
  100% { transform: translateY(0px); }
}

@keyframes floatAlternate {
  0% { transform: translate(0, 0); }
  25% { transform: translate(10px, -10px); }
  50% { transform: translate(0, -15px); }
  75% { transform: translate(-10px, -7px); }
  100% { transform: translate(0, 0); }
}

/* Gradient text effect */
.gradient-text {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Fancy focus states */
.fancy-focus {
  transition: box-shadow 0.3s ease;
}

.fancy-focus:focus {
  outline: none;
  box-shadow: 
    0 0 0 3px var(--primary-light),
    0 5px 15px rgba(0, 0, 0, 0.05);
}

/* Card tilting effect on hover */
.tilt-card {
  transition: transform 0.2s ease;
  perspective: 1000px;
}

.tilt-card:hover {
  transform: rotateX(2deg) rotateY(2deg);
}

/* Button states */
.btn-loading {
  position: relative;
  cursor: wait;
  color: transparent !important;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: calc(50% - 10px);
  left: calc(50% - 10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

/* Element entrance animations */
.fade-in {
  animation: fadeIn 0.6s ease forwards;
}

.slide-up {
  animation: slideUp 0.6s ease forwards;
}

.slide-left {
  animation: slideLeft 0.6s ease forwards;
}

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

@keyframes slideUp {
  from { 
    opacity: 0; 
    transform: translateY(20px);
  }
  to { 
    opacity: 1; 
    transform: translateY(0);
  }
}

@keyframes slideLeft {
  from { 
    opacity: 0; 
    transform: translateX(20px);
  }
  to { 
    opacity: 1; 
    transform: translateX(0);
  }
}

/* Interactive hover borders */
.interactive-border {
  position: relative;
}

.interactive-border::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 1px solid var(--primary-color);
  opacity: 0;
  transform: scale(1.1);
  transition: all 0.3s ease;
  pointer-events: none;
  border-radius: inherit;
  z-index: 1;
}

.interactive-border:hover::before {
  opacity: 1;
  transform: scale(1);
}

/* Typing animation effect */
.typing-animation::after {
  content: '|';
  animation: typing 1s infinite;
}

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

/* Glass morphism effect */
.glass {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* Highlight text on hover */
.highlight-on-hover {
  position: relative;
  z-index: 1;
}

.highlight-on-hover::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 30%;
  background-color: var(--primary-light);
  z-index: -1;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
}

.highlight-on-hover:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Focus-within effects for containers */
.focus-within-container {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.focus-within-container:focus-within {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Responsive hover states */
@media (max-width: 768px) {
  /* Disable hover effects on mobile and replace with active state */
  .mobile-hover-disable:hover {
    transform: none !important;
    box-shadow: none !important;
  }
  
  .mobile-hover-disable:active {
    transform: translateY(-2px) !important;
    transition: transform 0.1s ease !important;
  }
}

/**
 * HadithWorld Animations - Enhanced Version
 */

/* Card entry animations */
@keyframes fadeScale {
  0% {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Button hover effects */
@keyframes buttonGlow {
  0% {
    box-shadow: 0 5px 15px rgba(63, 81, 181, 0.2);
  }
  50% {
    box-shadow: 0 5px 25px rgba(63, 81, 181, 0.4);
  }
  100% {
    box-shadow: 0 5px 15px rgba(63, 81, 181, 0.2);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

@keyframes borderBeam {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 130% 0%;
  }
}

/* Apply animations to elements */
.hadith-card {
  animation: fadeScale 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards;
  animation-delay: calc(var(--card-index, 0) * 0.1s);
  will-change: transform, opacity;
  transform-origin: center bottom;
}

.search-button:hover {
  animation: buttonGlow 2s infinite;
}

.btn-view-details:hover, .btn-share:hover {
  animation: buttonGlow 2s infinite;
}

/* Shine effect for borders */
.shine-border {
  position: relative;
  overflow: hidden;
}

.shine-border::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translateX(-100%);
  animation: shimmer 3s infinite;
  pointer-events: none;
}

/* Special border beam effect - inspired by Magic UI */
.border-beam {
  position: relative;
}

.border-beam::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 2px;
  border-radius: var(--card-radius);
  background: linear-gradient(
    90deg,
    var(--primary-color),
    var(--accent-color),
    var(--primary-color)
  );
  background-size: 300% 100%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: borderBeam 3s linear infinite;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hadith-card:hover .border-beam::before,
.hadith-card:hover.border-beam::before {
  opacity: 1;
}

/* Magic hover effects for cards */
.magic-card {
  position: relative;
  transition: all 0.3s ease;
  background-origin: border-box;
  background-clip: content-box, border-box;
  isolation: isolate;
}

.magic-card-effect-container {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.magic-card:hover .magic-card-effect-container {
  opacity: 1;
}

.magic-gradient {
  position: absolute;
  border-radius: inherit;
  background: linear-gradient(
    135deg,
    var(--primary-light) 0%,
    var(--primary-color) 50%,
    var(--accent-color) 100%
  );
  filter: blur(15px);
  opacity: 0.3;
  width: 100%;
  height: 100%;
  transform: translateY(10px) scale(0.95);
  transition: all 0.3s ease;
  z-index: -1;
}

.magic-card:hover .magic-gradient {
  transform: translateY(0) scale(1);
  opacity: 0.5;
}

/* Arabic text subtle animation */
.arabic-text {
  position: relative;
  overflow: hidden;
}

.arabic-text::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 4px;
  background: var(--accent-color);
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.4s ease;
}

.hadith-card:hover .arabic-text::after {
  transform: translateX(0);
  opacity: 1;
}

/* Subtle text shadow for Arabic text to improve readability */
.hadith-card .arabic-text {
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Metadata badges animation */
.hadith-meta span {
  transition: all 0.3s ease;
  overflow: hidden;
  position: relative;
}

.hadith-meta span::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255,255,255,0), rgba(255,255,255,0.2), rgba(255,255,255,0));
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.hadith-meta span:hover::before {
  transform: translateX(100%);
}

/* Search term badge hover effect */
.search-term {
  position: relative;
  transition: all 0.3s ease;
}

.search-term::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 50%;
  right: 50%;
  height: 2px;
  background: var(--accent-color);
  transition: all 0.3s ease;
}

.search-term:hover::after {
  left: 0;
  right: 0;
}

/* Dynamic heading underline animation */
.hadithworld-search-header h2 {
  position: relative;
}

.hadithworld-search-header h2::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 50px;
  height: 3px;
  background: linear-gradient(to right, var(--primary-color), var(--accent-color));
  transition: width 0.3s ease;
}

.hadithworld-search-header h2:hover::after {
  width: 100%;
}

/* Pagination animations */
.hadith-pagination .page-numbers {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.hadith-pagination .page-numbers::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(63,81,181,0.05), rgba(63,81,181,0.2));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hadith-pagination .page-numbers:hover::before {
  opacity: 1;
}

/* Staggered animation for cards */
.hadith-results {
  position: relative;
}

.hadith-card:nth-child(1) {
  --card-index: 0;
}

.hadith-card:nth-child(2) {
  --card-index: 1;
}

.hadith-card:nth-child(3) {
  --card-index: 2;
}

.hadith-card:nth-child(4) {
  --card-index: 3;
}

.hadith-card:nth-child(5) {
  --card-index: 4;
}

.hadith-card:nth-child(6) {
  --card-index: 5;
}

.hadith-card:nth-child(7) {
  --card-index: 6;
}

.hadith-card:nth-child(8) {
  --card-index: 7;
}

.hadith-card:nth-child(9) {
  --card-index: 8;
}

.hadith-card:nth-child(10) {
  --card-index: 9;
}

/* Button press animation */
.search-button:active,
.btn-view-details:active,
.btn-share:active {
  transform: translateY(1px);
  transition: transform 0.1s ease;
}

/* Loading effect animation */
@keyframes pulse {
  0% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.6;
  }
}

.loading {
  animation: pulse 1.5s infinite ease-in-out;
}

/* Slide-in animation for result count */
@keyframes slideInRight {
  0% {
    transform: translateX(30px);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

.search-results-count {
  animation: slideInRight 0.5s ease-out forwards;
  animation-delay: 0.2s;
  opacity: 0;
}

/* Border Beam Effect for Compact Cards */
.hadith-card-compact.border-beam {
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.hadith-card-compact.border-beam::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  background: linear-gradient(45deg, 
    var(--primary-color), 
    transparent 30%, 
    transparent 70%, 
    var(--primary-color) 100%
  );
  border-radius: inherit;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hadith-card-compact.border-beam:hover::before {
  opacity: 1;
  animation: rotateGradient 3s linear infinite;
}

/* Add subtle shimmer effect to attribute badges */
.attr-badge {
  position: relative;
  overflow: hidden;
}

.attr-badge::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  animation: shimmerEffect 2s infinite;
}

@keyframes shimmerEffect {
  0% {
    left: -100%;
  }
  100% {
    left: 200%;
  }
}

@keyframes rotateGradient {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 100% 100%;
  }
}

/* Fix for animations to ensure they don't interfere with sticky elements */
body .shiny::after,
body .border-beam::before,
body .magic-card-effect-container,
body .magic-gradient,
body .ripple-effect {
  pointer-events: none !important;
  z-index: 1 !important;
}

/* Ensure animations don't change stacking context and interfere with theme elements */
body .hadith-card-compact,
body .hadith-card,
body .hadithworld-search-header,
body .hadithworld-search-results,
body .search-filters,
body .search-container {
  transform-style: flat !important;
  backface-visibility: visible !important;
  perspective: none !important;
  transform: none !important;
}

/* Ensure our plugin doesn't interfere with theme's sticky positioning */
body .sticky,
body .sticky-header,
body [class*="sticky-"],
body .site-header.sticky,
body .site-header.fixed,
body header.sticky,
body header.fixed,
body .ai-sticky-element,
body .ai-sticky,
body [class*="ai-sticky"],
body .elementor-sticky,
body [data-sticky],
body [data-sticky-container],
body .sticky-element,
body .sticky-container,
body .sticky-wrapper {
  /* Override any conflicting styles */
  position: sticky !important;
  z-index: 9999 !important;
  will-change: auto !important;
  transform: none !important;
  backface-visibility: visible !important;
}

/* When sticky elements are detected, disable any problematic CSS */
body.has-sticky-elements * {
  transform-style: flat !important;
  backface-visibility: visible !important;
} 