/* Animations CSS - Smooth Interactions for QuranAndHadith.org */

/* Global Animation Settings */
:root {
  --animation-duration-fast: 0.2s;
  --animation-duration-normal: 0.3s;
  --animation-duration-slow: 0.5s;
  --animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
  --animation-easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Page Entrance Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Animation Classes */
.animate-fade-in {
  animation: fadeIn var(--animation-duration-normal) var(--animation-easing)
    both;
}

.animate-fade-in-up {
  animation: fadeInUp var(--animation-duration-normal) var(--animation-easing)
    both;
}

.animate-fade-in-down {
  animation: fadeInDown var(--animation-duration-normal) var(--animation-easing)
    both;
}

.animate-fade-in-left {
  animation: fadeInLeft var(--animation-duration-normal) var(--animation-easing)
    both;
}

.animate-fade-in-right {
  animation: fadeInRight var(--animation-duration-normal)
    var(--animation-easing) both;
}

.animate-scale-in {
  animation: scaleIn var(--animation-duration-normal)
    var(--animation-easing-bounce) both;
}

.animate-slide-in-up {
  animation: slideInUp var(--animation-duration-normal) var(--animation-easing)
    both;
}

.animate-slide-in-down {
  animation: slideInDown var(--animation-duration-normal)
    var(--animation-easing) both;
}

/* Staggered Animation Delays */
.animate-delay-100 {
  animation-delay: 0.1s;
}
.animate-delay-200 {
  animation-delay: 0.2s;
}
.animate-delay-300 {
  animation-delay: 0.3s;
}
.animate-delay-400 {
  animation-delay: 0.4s;
}
.animate-delay-500 {
  animation-delay: 0.5s;
}
.animate-delay-600 {
  animation-delay: 0.6s;
}
.animate-delay-700 {
  animation-delay: 0.7s;
}
.animate-delay-800 {
  animation-delay: 0.8s;
}
.animate-delay-900 {
  animation-delay: 0.9s;
}
.animate-delay-1000 {
  animation-delay: 1s;
}

/* Hover Animations */
.hover-lift {
  transition: transform var(--animation-duration-normal) var(--animation-easing);
}

.hover-lift:hover {
  transform: translateY(-8px);
}

.hover-scale {
  transition: transform var(--animation-duration-normal) var(--animation-easing);
}

.hover-scale:hover {
  transform: scale(1.05);
}

.hover-glow {
  transition: box-shadow var(--animation-duration-normal)
    var(--animation-easing);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(0, 107, 92, 0.3);
}

.hover-rotate {
  transition: transform var(--animation-duration-normal) var(--animation-easing);
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

/* Button Animations */
@keyframes buttonPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 107, 92, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(0, 107, 92, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 107, 92, 0);
  }
}

.btn-pulse {
  animation: buttonPulse 2s infinite;
}

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

.btn-shine {
  position: relative;
  overflow: hidden;
}

.btn-shine::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left var(--animation-duration-slow) var(--animation-easing);
}

.btn-shine:hover::after {
  left: 100%;
}

/* Loading Animations */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

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

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-bounce {
  animation: bounce 1s infinite;
}

/* Islamic-specific Animations */
@keyframes arabicFloat {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-5px) rotate(1deg);
  }
  50% {
    transform: translateY(-10px) rotate(0deg);
  }
  75% {
    transform: translateY(-5px) rotate(-1deg);
  }
}

.arabic-text-float {
  animation: arabicFloat 4s ease-in-out infinite;
}

@keyframes quranGlow {
  0%,
  100% {
    text-shadow: 0 0 5px rgba(0, 107, 92, 0.3);
  }
  50% {
    text-shadow: 0 0 15px rgba(0, 107, 92, 0.6), 0 0 25px rgba(0, 107, 92, 0.4);
  }
}

.quran-glow {
  animation: quranGlow 3s ease-in-out infinite;
}

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

.islamic-pattern-animate {
  animation: islamicPattern 10s ease-in-out infinite;
}

/* Audio Visualizer Animation */
@keyframes audioWave {
  0%,
  100% {
    height: 4px;
  }
  50% {
    height: 20px;
  }
}

.audio-visualizer {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 24px;
}

.audio-bar {
  width: 3px;
  background: var(--primary-color);
  border-radius: 2px;
  animation: audioWave 1s ease-in-out infinite;
}

.audio-bar:nth-child(1) {
  animation-delay: 0s;
}
.audio-bar:nth-child(2) {
  animation-delay: 0.1s;
}
.audio-bar:nth-child(3) {
  animation-delay: 0.2s;
}
.audio-bar:nth-child(4) {
  animation-delay: 0.3s;
}
.audio-bar:nth-child(5) {
  animation-delay: 0.4s;
}

/* Progress Animations */
@keyframes progressFill {
  from {
    width: 0%;
  }
  to {
    width: var(--progress-width, 100%);
  }
}

.progress-animate {
  animation: progressFill 1s var(--animation-easing) forwards;
}

/* Notification Animations */
@keyframes notificationSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes notificationSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.notification-enter {
  animation: notificationSlideIn var(--animation-duration-normal)
    var(--animation-easing) forwards;
}

.notification-exit {
  animation: notificationSlideOut var(--animation-duration-normal)
    var(--animation-easing) forwards;
}

/* Modal Animations */
@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal.fade .modal-dialog {
  animation: modalSlideIn var(--animation-duration-normal)
    var(--animation-easing);
}

.modal.fade {
  animation: modalFadeIn var(--animation-duration-normal)
    var(--animation-easing);
}

/* Scroll Animations */
@keyframes scrollIndicator {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  50% {
    opacity: 0.5;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.scroll-indicator-animate {
  animation: scrollIndicator 2s ease-in-out infinite;
}

/* Text Animation Effects */
@keyframes typewriter {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

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

.typewriter {
  overflow: hidden;
  white-space: nowrap;
  animation: typewriter 2s steps(40, end) forwards;
  position: relative;
}

.typewriter::after {
  content: "|";
  position: absolute;
  right: 0;
  animation: cursorBlink 1s infinite;
}

/* Card Flip Animation */
@keyframes cardFlip {
  0% {
    transform: rotateY(0);
  }
  50% {
    transform: rotateY(-90deg);
  }
  100% {
    transform: rotateY(0);
  }
}

.card-flip {
  animation: cardFlip 0.6s var(--animation-easing);
}

/* Parallax Effects */
.parallax-slow {
  transform: translateY(var(--scroll-offset, 0px));
  transition: transform 0.1s linear;
}

.parallax-medium {
  transform: translateY(calc(var(--scroll-offset, 0px) * 0.5));
  transition: transform 0.1s linear;
}

.parallax-fast {
  transform: translateY(calc(var(--scroll-offset, 0px) * 0.2));
  transition: transform 0.1s linear;
}

/* Gradient Animations */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.gradient-animate {
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
}

/* Interactive Animations */
.interactive-scale {
  transition: transform var(--animation-duration-fast) var(--animation-easing);
}

.interactive-scale:active {
  transform: scale(0.95);
}

.interactive-rotate {
  transition: transform var(--animation-duration-normal) var(--animation-easing);
}

.interactive-rotate:hover {
  transform: rotate(360deg);
}

/* Page Transition Animations */
@keyframes pageSlideInLeft {
  from {
    opacity: 0;
    transform: translateX(-100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pageSlideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.page-enter-left {
  animation: pageSlideInLeft var(--animation-duration-slow)
    var(--animation-easing);
}

.page-enter-right {
  animation: pageSlideInRight var(--animation-duration-slow)
    var(--animation-easing);
}

/* Skeleton Loading Animations */
@keyframes skeletonShimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.skeleton-loading {
  background: linear-gradient(
    90deg,
    var(--medium-gray) 25%,
    var(--light-gray) 50%,
    var(--medium-gray) 75%
  );
  background-size: 200px 100%;
  animation: skeletonShimmer 1.2s ease-in-out infinite;
}

/* Islamic Calligraphy Animation */
@keyframes calligraphyDraw {
  from {
    stroke-dashoffset: 1000;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.calligraphy-animate {
  stroke-dasharray: 1000;
  animation: calligraphyDraw 3s ease-in-out forwards;
}

/* Prayer Time Animation */
@keyframes prayerTimePulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.05);
  }
}

.prayer-time-active {
  animation: prayerTimePulse 2s ease-in-out infinite;
}

/* Qibla Direction Animation */
@keyframes qiblaRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(var(--qibla-direction, 0deg));
  }
}

.qibla-animate {
  animation: qiblaRotate 1s var(--animation-easing) forwards;
}

/* Audio Spectrum Animation */
@keyframes spectrumBounce {
  0%,
  100% {
    transform: scaleY(0.2);
  }
  50% {
    transform: scaleY(1);
  }
}

.spectrum-bar {
  width: 4px;
  background: var(--primary-color);
  margin: 0 1px;
  animation: spectrumBounce 0.5s ease-in-out infinite alternate;
}

.spectrum-bar:nth-child(1) {
  animation-delay: 0.1s;
}
.spectrum-bar:nth-child(2) {
  animation-delay: 0.2s;
}
.spectrum-bar:nth-child(3) {
  animation-delay: 0.3s;
}
.spectrum-bar:nth-child(4) {
  animation-delay: 0.4s;
}
.spectrum-bar:nth-child(5) {
  animation-delay: 0.5s;
}

/* Intersection Observer Animation Classes */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s var(--animation-easing),
    transform 0.6s var(--animation-easing);
}

.animate-on-scroll.in-view {
  opacity: 1;
  transform: translateY(0);
}

.animate-on-scroll-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.6s var(--animation-easing),
    transform 0.6s var(--animation-easing);
}

.animate-on-scroll-left.in-view {
  opacity: 1;
  transform: translateX(0);
}

.animate-on-scroll-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.6s var(--animation-easing),
    transform 0.6s var(--animation-easing);
}

.animate-on-scroll-right.in-view {
  opacity: 1;
  transform: translateX(0);
}

.animate-on-scroll-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.6s var(--animation-easing),
    transform 0.6s var(--animation-easing);
}

.animate-on-scroll-scale.in-view {
  opacity: 1;
  transform: scale(1);
}

/* Counter Animation */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.counter-animate {
  animation: countUp 0.5s var(--animation-easing) forwards;
}

/* Responsive Animation Adjustments */
@media (max-width: 768px) {
  .animate-fade-in-up,
  .animate-fade-in-down,
  .animate-fade-in-left,
  .animate-fade-in-right {
    animation-duration: var(--animation-duration-fast);
  }

  .hover-lift:hover,
  .hover-scale:hover {
    transform: none;
  }

  .parallax-slow,
  .parallax-medium,
  .parallax-fast {
    transform: none;
  }
}

/* Performance Optimizations */
.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

.will-change-auto {
  will-change: auto;
}

/* GPU Acceleration */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Animation State Classes */
.animation-paused {
  animation-play-state: paused;
}

.animation-running {
  animation-play-state: running;
}

.animation-forwards {
  animation-fill-mode: forwards;
}

.animation-backwards {
  animation-fill-mode: backwards;
}

.animation-both {
  animation-fill-mode: both;
}
