/* ===== Custom Animations & Styles for Dr. Piyush Malik Website ===== */

/* --- Base Reset & Smooth Scroll & 60fps --- */
html {
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
}

/* GPU acceleration for all animated elements */
.animate-on-scroll, .animate-slide-left, .animate-slide-right, .animate-scale,
.card-hover, .card-hover-scale, .btn-primary, .btn-outline, .float, .float-delayed,
.float-slow, .blob, .timeline-dot, .nav-link {
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* --- Word Roller Animation (60fps) --- */
.word-roller {
  display: inline-block;
  height: 1.15em;
  overflow: hidden;
  vertical-align: bottom;
  position: relative;
}
.word-roller-inner {
  display: flex;
  flex-direction: column;
  transition: transform 0.5s cubic-bezier(0.65, 0, 0.35, 1);
  will-change: transform;
}
.word-roller-word {
  height: 1.15em;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* --- Scroll-Triggered Animation Classes --- */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

.animate-slide-left {
  opacity: 0;
  transform: translateX(-60px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.animate-slide-left.visible {
  opacity: 1;
  transform: translateX(0);
}

.animate-slide-right {
  opacity: 0;
  transform: translateX(60px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.animate-slide-right.visible {
  opacity: 1;
  transform: translateX(0);
}

.animate-scale {
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.animate-scale.visible {
  opacity: 1;
  transform: scale(1);
}

.animate-fade {
  opacity: 0;
  transition: opacity 1s ease;
}
.animate-fade.visible {
  opacity: 1;
}

/* Stagger delay utilities */
.delay-100 { transition-delay: 0.1s; }
.delay-200 { transition-delay: 0.2s; }
.delay-300 { transition-delay: 0.3s; }
.delay-400 { transition-delay: 0.4s; }
.delay-500 { transition-delay: 0.5s; }
.delay-600 { transition-delay: 0.6s; }
.delay-700 { transition-delay: 0.7s; }

/* --- Keyframe Animations --- */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-12px); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(13, 148, 136, 0.2); }
  50% { box-shadow: 0 0 40px rgba(13, 148, 136, 0.4); }
}

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

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

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

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes blink-caret {
  from, to { border-color: transparent; }
  50% { border-color: #0d9488; }
}

@keyframes blob {
  0% { transform: translate(0px, 0px) scale(1); }
  33% { transform: translate(30px, -50px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.9); }
  100% { transform: translate(0px, 0px) scale(1); }
}

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

@keyframes bounce-in {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); opacity: 1; }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

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

/* --- Utility Animation Classes --- */
.float { animation: float 4s ease-in-out infinite; }
.float-delayed { animation: float 4s ease-in-out 1s infinite; }
.float-slow { animation: float 6s ease-in-out infinite; }
.pulse-glow { animation: pulse-glow 3s ease-in-out infinite; }
.gradient-animate {
  background-size: 200% 200%;
  animation: gradient-shift 4s ease infinite;
}
.spin-slow { animation: spin-slow 20s linear infinite; }
.blob-animate { animation: blob 7s infinite; }
.bounce-in { animation: bounce-in 0.8s cubic-bezier(0.16, 1, 0.3, 1); }
.shimmer-bg {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/* --- Hero Animations --- */
.hero-title {
  animation: slide-in-down 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.hero-subtitle {
  animation: slide-in-up 1s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}
.hero-cta {
  animation: slide-in-up 1s cubic-bezier(0.16, 1, 0.3, 1) 0.5s both;
}
.hero-image {
  animation: fade-in 1.2s ease 0.4s both;
}

/* --- Card Hover Effects --- */
.card-hover {
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
}
.card-hover:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
}

.card-hover-scale {
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
}
.card-hover-scale:hover {
  transform: scale(1.03);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
}

/* --- Button Effects --- */
.btn-primary {
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.btn-primary::before {
  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 0.5s ease;
}
.btn-primary:hover::before {
  left: 100%;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(13, 148, 136, 0.3);
}

.btn-outline {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}
.btn-outline:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(13, 148, 136, 0.15);
}

/* --- Gradient Text --- */
.gradient-text {
  background: linear-gradient(135deg, #0d9488, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-animated {
  background: linear-gradient(135deg, #0d9488, #3b82f6, #8b5cf6, #0d9488);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 4s ease infinite;
}

/* --- Decorative Blobs --- */
.blob {
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.15;
  position: absolute;
  pointer-events: none;
}

/* --- Timeline --- */
.timeline-line {
  position: relative;
}
.timeline-line::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, #0d9488, #3b82f6);
  transform: translateX(-50%);
}

.timeline-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d9488, #3b82f6);
  border: 3px solid white;
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.2);
  position: relative;
  z-index: 10;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.timeline-dot:hover {
  transform: scale(1.3);
  box-shadow: 0 0 0 8px rgba(13, 148, 136, 0.2);
}

/* --- Nav --- */
.nav-glass {
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.nav-link {
  position: relative;
  transition: color 0.3s ease;
}
.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #0d9488, #3b82f6);
  transition: width 0.3s ease;
}
.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* --- Section Divider --- */
.section-divider {
  height: 4px;
  background: linear-gradient(90deg, transparent, #0d9488, #3b82f6, transparent);
  border-radius: 2px;
}

/* --- Counter Animation --- */
.counter-value {
  animation: counter 0.6s ease both;
}

/* --- Mobile Nav --- */
.mobile-nav {
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.mobile-nav.open {
  transform: translateX(0);
}

/* --- Form Styles --- */
.form-input {
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.form-input:focus {
  border-color: #0d9488;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, #0d9488, #3b82f6);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: #0d9488; }

/* --- Selection --- */
::selection {
  background: rgba(13, 148, 136, 0.15);
  color: #0d9488;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .animate-on-scroll, .animate-slide-left, .animate-slide-right, .animate-scale, .animate-fade {
    opacity: 1;
    transform: none;
  }
}
