/* ============================================
   PUNARJJANY ANIMATIONS & MICRO-INTERACTIONS
   Premium animations for a healthcare/wellness site
   ============================================ */

/* Respect user's motion preferences */
@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;
  }
}

/* ============================================
   HEADING ANIMATIONS
   ============================================ */

/* Letter-by-letter fade-in for main headings */
h1, h2, h3 {
  position: relative;
}

h1.animate-heading,
h2.animate-heading,
h3.animate-heading {
  display: inline-block;
}

.heading-letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(8px) translateX(-2px);
  animation: letterFadeIn 0.5s ease-out forwards;
}

@keyframes letterFadeIn {
  to {
    opacity: 1;
    transform: translateY(0) translateX(0);
  }
}

/* Staggered letter animation with varying delays */
.heading-letter:nth-child(1) { animation-delay: 0.05s; }
.heading-letter:nth-child(2) { animation-delay: 0.1s; }
.heading-letter:nth-child(3) { animation-delay: 0.15s; }
.heading-letter:nth-child(4) { animation-delay: 0.2s; }
.heading-letter:nth-child(5) { animation-delay: 0.25s; }
.heading-letter:nth-child(6) { animation-delay: 0.3s; }
.heading-letter:nth-child(7) { animation-delay: 0.35s; }
.heading-letter:nth-child(8) { animation-delay: 0.4s; }
.heading-letter:nth-child(9) { animation-delay: 0.45s; }
.heading-letter:nth-child(10) { animation-delay: 0.5s; }
.heading-letter:nth-child(11) { animation-delay: 0.55s; }
.heading-letter:nth-child(12) { animation-delay: 0.6s; }
.heading-letter:nth-child(13) { animation-delay: 0.65s; }
.heading-letter:nth-child(14) { animation-delay: 0.7s; }
.heading-letter:nth-child(15) { animation-delay: 0.75s; }
.heading-letter:nth-child(16) { animation-delay: 0.8s; }

/* Gradient text animation for hero and main titles */
.gradient-text {
  background: linear-gradient(135deg, var(--green) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s ease-in-out infinite;
}

@keyframes gradientShift {
  0% {
    background: linear-gradient(135deg, var(--green) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
  }
  50% {
    background: linear-gradient(135deg, var(--accent) 0%, var(--green) 100%);
    -webkit-background-clip: text;
  }
  100% {
    background: linear-gradient(135deg, var(--green) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
  }
}

/* Smooth underline animation on heading hover */
h1:hover::after,
h2:hover::after,
h3:hover::after {
  animation: underlineExpand 0.4s ease-out;
}

@keyframes underlineExpand {
  from {
    width: 0;
    left: 0;
  }
  to {
    width: 100%;
    left: 0;
  }
}

/* ============================================
   TEXT & CONTENT ANIMATIONS
   ============================================ */

/* Typewriter effect for taglines and quotes */
.typewriter {
  overflow: hidden;
  border-right: 2px solid var(--green);
  white-space: nowrap;
  animation: typing 2.5s steps(60, end), blink 0.75s step-end infinite;
}

@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blink {
  from, to { border-right-color: var(--green); }
  50% { border-right-color: transparent; }
}

/* Fade-in + slide animation for paragraphs on scroll */
.fade-in-up {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Slide-in from left animation */
.slide-in-left {
  opacity: 0;
  transform: translateX(-32px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.slide-in-left.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Slide-in from right animation */
.slide-in-right {
  opacity: 0;
  transform: translateX(32px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.slide-in-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Staggered list item animations */
.stagger-list > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.stagger-list > *.visible {
  opacity: 1;
  transform: translateY(0);
}

.stagger-list > *:nth-child(1) { transition-delay: 0s; }
.stagger-list > *:nth-child(2) { transition-delay: 0.1s; }
.stagger-list > *:nth-child(3) { transition-delay: 0.2s; }
.stagger-list > *:nth-child(4) { transition-delay: 0.3s; }
.stagger-list > *:nth-child(5) { transition-delay: 0.4s; }
.stagger-list > *:nth-child(6) { transition-delay: 0.5s; }

/* ============================================
   NUMBER COUNTER ANIMATIONS
   ============================================ */

.counter {
  font-family: 'Playfair Display', serif;
  font-size: 2.1rem;
  color: var(--green);
  font-weight: 600;
}

.counter.animate {
  animation: countUp 2s ease-out forwards;
}

@keyframes countUp {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================
   HERO & BANNER ANIMATIONS
   ============================================ */

/* Parallax scrolling effect for hero */
.parallax-bg {
  background-attachment: fixed;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

/* Floating/breathing animation for background images */
.floating-image {
  animation: floating 4s ease-in-out infinite;
}

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

/* Subtle zoom and pan effects on hero */
.zoom-pan {
  animation: zoomPan 20s ease-in-out infinite;
}

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

/* Animated gradient overlay */
.gradient-overlay {
  background: linear-gradient(
    45deg,
    rgba(47, 158, 79, 0.1) 0%,
    rgba(79, 157, 110, 0.05) 50%,
    rgba(47, 158, 79, 0.1) 100%
  );
  animation: gradientMove 6s ease-in-out infinite;
}

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

/* ============================================
   INTERACTIVE ELEMENTS
   ============================================ */

/* Enhanced button hover animations */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.btn:hover::before {
  animation: ripple 0.6s ease-out;
}

@keyframes ripple {
  to {
    width: 300px;
    height: 300px;
    opacity: 0;
  }
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(-1px);
}

/* Icon animations - rotate, pulse, scale on hover */
.icon-animate {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-rotate:hover {
  transform: rotate(12deg) scale(1.1);
}

.icon-pulse:hover {
  animation: pulse-scale 0.6s ease-out;
}

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

/* Navigation link hover effects */
nav a {
  position: relative;
  transition: color 0.3s ease;
}

nav a::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--green);
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

nav a:hover::before {
  width: 100%;
}

/* Card hover animations with lift and glow */
.card, .testi-card, .healing-card {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.card:hover,
.testi-card:hover,
.healing-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(47, 158, 79, 0.12);
}

/* Border glow effect on card hover */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  padding: 1px;
  background: linear-gradient(135deg, var(--green), var(--accent));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.card:hover::before {
  opacity: 0.3;
}

/* ============================================
   MICRO-INTERACTIONS
   ============================================ */

/* Smooth transitions on all state changes */
.transition-smooth {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* SVG icon animations */
svg.icon-bounce {
  animation: bounce 1s ease-in-out;
}

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

svg.icon-spin {
  animation: spin 2s linear infinite;
}

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

/* Image loading animation fade-in */
img.fade-load {
  opacity: 0;
  transition: opacity 0.6s ease;
}

img.fade-load.loaded {
  opacity: 1;
}

/* Smooth modal/popup transitions */
.modal-enter {
  animation: modalFadeIn 0.3s ease-out;
}

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

.modal-exit {
  animation: modalFadeOut 0.2s ease-out forwards;
}

@keyframes modalFadeOut {
  to {
    opacity: 0;
    transform: scale(0.95) translateY(16px);
  }
}

/* ============================================
   PROGRESS BARS & ANIMATED COUNTERS
   ============================================ */

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  width: 0;
  animation: fillProgress 1.5s ease-out forwards;
  border-radius: 3px;
}

@keyframes fillProgress {
  to {
    width: 100%;
  }
}

.progress-bar-fill:nth-child(1) { animation-delay: 0s; }
.progress-bar-fill:nth-child(2) { animation-delay: 0.1s; }
.progress-bar-fill:nth-child(3) { animation-delay: 0.2s; }

/* ============================================
   SMOOTH SCROLL TO ANCHOR ANIMATIONS
   ============================================ */

.scroll-anchor {
  scroll-margin-top: 100px;
}

/* Text reveal effects for important quotes */
.text-reveal {
  overflow: hidden;
  line-height: 1.4;
}

.text-reveal-char {
  display: inline-block;
  opacity: 0;
  transform: translateY(16px);
  animation: revealChar 0.5s ease-out forwards;
}

@keyframes revealChar {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   ENHANCED EXISTING ANIMATIONS
   ============================================ */

/* Improved fade-in animation */
.fade-in {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered fade-in for grid items */
.grid-item {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.grid-item.visible {
  opacity: 1;
  transform: translateY(0);
}

.grid-item:nth-child(1) { transition-delay: 0s; }
.grid-item:nth-child(2) { transition-delay: 0.08s; }
.grid-item:nth-child(3) { transition-delay: 0.16s; }
.grid-item:nth-child(4) { transition-delay: 0.24s; }
.grid-item:nth-child(5) { transition-delay: 0.32s; }
.grid-item:nth-child(6) { transition-delay: 0.4s; }
.grid-item:nth-child(7) { transition-delay: 0.48s; }
.grid-item:nth-child(8) { transition-delay: 0.56s; }

/* Image hover zoom with smooth transition */
.image-hover-zoom {
  overflow: hidden;
  border-radius: 16px;
}

.image-hover-zoom img {
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.image-hover-zoom:hover img {
  transform: scale(1.08);
}

/* ============================================
   TESTIMONIAL ANIMATIONS
   ============================================ */

.testimonial-quote {
  font-style: italic;
  color: var(--ink-soft);
  border-left: 3px solid var(--green);
  padding-left: 20px;
}

.testimonial-quote::before {
  content: '"';
  font-size: 3rem;
  color: var(--green);
  opacity: 0.2;
  position: absolute;
  margin-top: -10px;
  margin-left: -25px;
}

/* ============================================
   FLOATING ELEMENTS
   ============================================ */

.float-up {
  animation: floatUp 3s ease-in-out infinite;
}

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

.float-slow {
  animation: floatSlow 4s ease-in-out infinite;
}

@keyframes floatSlow {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-20px) rotate(2deg);
  }
}

/* ============================================
   PULSE ANIMATIONS
   ============================================ */

.pulse-subtle {
  animation: pulseSubtle 2s ease-in-out infinite;
}

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

.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(47, 158, 79, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(47, 158, 79, 0);
  }
}

/* ============================================
   SECTION ENTRANCE ANIMATIONS
   ============================================ */

.section-enter {
  animation: sectionFadeSlide 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* ============================================
   BADGE & LABEL ANIMATIONS
   ============================================ */

.badge-pulse {
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.85;
  }
}

/* ============================================
   LOADER ANIMATIONS
   ============================================ */

.loader-dots {
  display: inline-flex;
  gap: 4px;
}

.loader-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: loaderBounce 1.4s ease-in-out infinite;
}

.loader-dot:nth-child(1) { animation-delay: -0.32s; }
.loader-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes loaderBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 1;
  }
  30% {
    transform: translateY(-10px);
    opacity: 0.7;
  }
}

/* ============================================
   ACCESSIBILITY & RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  /* Reduce animation complexity on mobile */
  .parallax-bg {
    background-attachment: scroll;
  }

  .heading-letter {
    animation-duration: 0.3s;
  }

  .fade-in-up {
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
  }

  .card:hover {
    transform: translateY(-4px);
  }

  svg.icon-bounce {
    animation: bounceMobile 0.8s ease-in-out;
  }

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

/* High performance: use will-change sparingly */
.will-animate {
  will-change: transform, opacity;
}

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

/* GPU acceleration for smooth animations */
.gpu-accelerate {
  transform: translateZ(0);
  will-change: transform;
}
