/* ============================================================
   D.R. Healthcare — Animations CSS
   All CSS keyframes, transitions, and motion utilities
   Depends on: design-system.css
   ============================================================ */


/* ============================================================
   1. KEYFRAME DEFINITIONS
   ============================================================ */

/* --- Fade + Slide Up (primary entrance animation) --- */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Fade + Slide Down --- */
@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Fade + Slide In from Left --- */
@keyframes fadeSlideLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* --- Fade + Slide In from Right --- */
@keyframes fadeSlideRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* --- Simple Fade In --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* --- Simple Fade Out --- */
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* --- Scroll Indicator Bounce --- */
@keyframes scrollBounce {
  0%, 100% {
    transform: translateY(0);
    opacity: 1;
  }
  50% {
    transform: translateY(10px);
    opacity: 0.3;
  }
}

/* --- Pulse (opacity) --- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* --- Pulse Scale (grow/shrink) --- */
@keyframes pulseScale {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}

/* --- Shimmer (skeleton loading) --- */
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

/* --- Float (gentle up-down levitation) --- */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-12px); }
}

/* --- Float X (gentle left-right drift) --- */
@keyframes floatX {
  0%, 100% { transform: translateX(0px); }
  50%       { transform: translateX(8px); }
}

/* --- Glow Pulse (box-shadow breathe) --- */
@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(8, 84, 194, 0.3);
  }
  50% {
    box-shadow: 0 0 40px rgba(8, 84, 194, 0.6),
                0 0 60px rgba(8, 84, 194, 0.2);
  }
}

/* --- Glow Pulse Red (accent) --- */
@keyframes glowPulseRed {
  0%, 100% {
    box-shadow: 0 0 20px rgba(230, 42, 43, 0.2);
  }
  50% {
    box-shadow: 0 0 40px rgba(230, 42, 43, 0.5);
  }
}

/* --- Loader Bar Fill (CSS fallback; JS overrides width directly) --- */
@keyframes loaderBarFill {
  from { width: 0%; }
  to   { width: 100%; }
}

/* --- Rotate In (scale + rotate entrance) --- */
@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-10deg) scale(0.9);
  }
  to {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

/* --- Scale In (zoom entrance) --- */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Spin (loading spinner) --- */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* --- Typing cursor blink --- */
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* --- Underline draw (for decorative text underlines) --- */
@keyframes underlineDraw {
  from { transform: scaleX(0); transform-origin: left; }
  to   { transform: scaleX(1); transform-origin: left; }
}

/* --- Number count-up pseudo (CSS anchor for JS) --- */
@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Slide in from bottom (mobile menu) --- */
@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Ripple (button click) --- */
@keyframes ripple {
  0% {
    width: 0;
    height: 0;
    opacity: 0.4;
  }
  100% {
    width: 200px;
    height: 200px;
    opacity: 0;
  }
}

/* --- Gradient shift (animated gradient backgrounds) --- */
@keyframes gradientShift {
  0%   { background-position: 0%   50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0%   50%; }
}

/* --- Particle drift upward (canvas fallback hint) --- */
@keyframes driftUp {
  0% {
    transform: translateY(0) translateX(0) scale(1);
    opacity: 0.6;
  }
  100% {
    transform: translateY(-100px) translateX(20px) scale(0.5);
    opacity: 0;
  }
}


/* ============================================================
   2. SCROLL-TRIGGERED REVEAL ANIMATIONS
      (Intersection Observer adds .revealed class via JS)
   ============================================================ */

.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity  0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

/* Reveal from left */
.reveal-left {
  opacity: 0;
  transform: translateX(-40px);
  transition:
    opacity  0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal-left.revealed {
  opacity: 1;
  transform: translateX(0);
}

/* Reveal from right */
.reveal-right {
  opacity: 0;
  transform: translateX(40px);
  transition:
    opacity  0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal-right.revealed {
  opacity: 1;
  transform: translateX(0);
}

/* Reveal scale */
.reveal-scale {
  opacity: 0;
  transform: scale(0.92);
  transition:
    opacity  0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal-scale.revealed {
  opacity: 1;
  transform: scale(1);
}

/* --- Staggered reveal for grid children --- */
.reveal-stagger > *:nth-child(1)  { transition-delay:   0ms; }
.reveal-stagger > *:nth-child(2)  { transition-delay:  80ms; }
.reveal-stagger > *:nth-child(3)  { transition-delay: 160ms; }
.reveal-stagger > *:nth-child(4)  { transition-delay: 240ms; }
.reveal-stagger > *:nth-child(5)  { transition-delay: 320ms; }
.reveal-stagger > *:nth-child(6)  { transition-delay: 400ms; }
.reveal-stagger > *:nth-child(7)  { transition-delay: 480ms; }
.reveal-stagger > *:nth-child(8)  { transition-delay: 560ms; }
.reveal-stagger > *:nth-child(9)  { transition-delay: 640ms; }
.reveal-stagger > *:nth-child(10) { transition-delay: 720ms; }
.reveal-stagger > *:nth-child(11) { transition-delay: 800ms; }
.reveal-stagger > *:nth-child(12) { transition-delay: 880ms; }

/* Also make stagger children carry the reveal state */
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(30px);
  transition:
    opacity  0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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


/* ============================================================
   3. FLOATING ANIMATION UTILITIES
   ============================================================ */

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

.float-anim-delay {
  animation: float 6s ease-in-out 2s infinite;
}

.float-anim-slow {
  animation: float 8s ease-in-out 1s infinite;
}

.float-anim-x {
  animation: floatX 7s ease-in-out infinite;
}

.float-anim-x-delay {
  animation: floatX 7s ease-in-out 1.5s infinite;
}

.pulse-anim {
  animation: pulse 2.5s ease-in-out infinite;
}

.pulse-scale-anim {
  animation: pulseScale 3s ease-in-out infinite;
}

.glow-anim {
  animation: glowPulse 3s ease-in-out infinite;
}


/* ============================================================
   4. DOCTOR CARD TRANSITION
   ============================================================ */

.doctor-card-enter {
  animation: fadeSlideUp 0.5s ease both;
}

/* Tab content switches */
.tab-content-enter {
  animation: fadeSlideUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.tab-content-exit {
  animation: fadeOut 0.25s ease both;
}


/* ============================================================
   5. LOADING SKELETON
   ============================================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  color: transparent;
  pointer-events: none;
  user-select: none;
}

.skeleton-dark {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 25%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.06) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* Skeleton shape helpers */
.skeleton-text {
  height: 14px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}

.skeleton-title {
  height: 24px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
}

.skeleton-circle {
  border-radius: 50%;
}

.skeleton-card {
  border-radius: var(--radius-lg);
}


/* ============================================================
   6. BUTTON HOVER EFFECTS (ripple + glow)
   ============================================================ */

/* Ripple burst on :active */
.btn {
  position: relative;
  overflow: hidden;
}

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

.btn:active::before {
  width: 200px;
  height: 200px;
  opacity: 0;
  transition: width 0.5s ease, height 0.5s ease, opacity 0.5s ease;
}

/* Primary button subtle glow on hover */
.btn-primary:hover {
  animation: glowPulse 1.5s ease-in-out 1;
}


/* ============================================================
   7. NAVBAR TRANSITIONS
   ============================================================ */

/* Mobile menu slide in */
.mobile-menu {
  animation: slideInDown 0.25s ease both;
}

/* Nav link underline: already handled in components.css,
   but transition is defined here for consistency */
.nav-link::after {
  transition: width 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}


/* ============================================================
   8. HERO ENTRANCE SEQUENCE
      (animation-fill-mode: both + delays = staggered)
   ============================================================ */

/* These classes can be applied in HTML if using
   CSS-only (no JS) entrance — mirrors the inline
   animation calls in components.css */

.hero-anim-1 { animation: fadeSlideUp 0.8s ease 0.3s both; }
.hero-anim-2 { animation: fadeSlideUp 0.8s ease 0.5s both; }
.hero-anim-3 { animation: fadeSlideUp 0.8s ease 0.7s both; }
.hero-anim-4 { animation: fadeSlideUp 0.8s ease 0.9s both; }
.hero-anim-5 { animation: fadeSlideUp 0.8s ease 1.1s both; }
.hero-anim-6 { animation: fadeSlideUp 0.8s ease 1.3s both; }
.hero-anim-7 { animation: fadeSlideUp 0.8s ease 1.5s both; }


/* ============================================================
   9. PAGE LOADER ANIMATIONS
   ============================================================ */

/* Loader logo entrance */
.loader-logo-enter {
  animation: scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

/* Loader tagline entrance */
.loader-tagline-enter {
  animation: fadeSlideUp 0.6s ease 0.5s both;
}

/* Loader bar entrance */
.loader-bar-enter {
  animation: fadeIn 0.4s ease 0.7s both;
}

/* Loader exit (applied by JS when loading complete) */
.loader-exit {
  animation: fadeOut 0.5s ease 0.3s both;
}


/* ============================================================
   10. STAT NUMBER COUNT-UP REVEAL
   ============================================================ */

.stat-number-reveal {
  animation: countUp 0.5s ease both;
}


/* ============================================================
   11. SECTION TRANSITION UTILITIES
   ============================================================ */

/* Generic enter transition for tab panel switching */
.panel-enter {
  animation: fadeSlideUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.panel-exit {
  animation: fadeOut 0.2s ease both;
  pointer-events: none;
}

/* Slide transitions for carousels */
.slide-enter-right {
  animation: fadeSlideRight 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.slide-enter-left {
  animation: fadeSlideLeft 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}


/* ============================================================
   12. GRADIENT TEXT SHIMMER (accent headings)
   ============================================================ */

.text-gradient-animate {
  background: linear-gradient(
    135deg,
    var(--color-primary),
    #4d9fff,
    var(--color-accent-red),
    var(--color-primary)
  );
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 5s ease infinite;
}


/* ============================================================
   13. LOADING SPINNER UTILITY
   ============================================================ */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(8, 84, 194, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner-white {
  border-color: rgba(255, 255, 255, 0.25);
  border-top-color: white;
}

.spinner-sm {
  width: 14px;
  height: 14px;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}


/* ============================================================
   14. REDUCED MOTION ACCESSIBILITY
   ============================================================ */

@media (prefers-reduced-motion: reduce) {

  /* Disable all animations and transitions for users
     who have opted into reduced motion in their OS */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* Keep reveal elements visible (since animation won't play) */
  .reveal,
  .reveal-left,
  .reveal-right,
  .reveal-scale {
    opacity: 1;
    transform: none;
  }

  .reveal-stagger > * {
    opacity: 1;
    transform: none;
  }

  /* Keep hero elements visible */
  .hero-badge,
  .hero-title,
  .hero-subtitle,
  .hero-ctas,
  .hero-info-card {
    animation: none;
    opacity: 1;
    transform: none;
  }

  /* Disable floating elements */
  .float-anim,
  .float-anim-delay,
  .float-anim-slow,
  .float-anim-x,
  .float-anim-x-delay {
    animation: none;
  }

  /* Disable glow pulses */
  .glow-anim,
  .pulse-anim,
  .pulse-scale-anim {
    animation: none;
  }

  /* Keep skeleton visible without motion */
  .skeleton,
  .skeleton-dark {
    animation: none;
    background: #e8e8e8;
  }
}
