/* ============================================================
   ANIMATIONS.CSS — Modern Animations & Micro-Interactions
   
   Premium, smooth, and engaging animations for a modern app feel
   ============================================================ */

/* ── CSS Variables for Animations ── */
:root {
  /* Timing Functions */
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-in-out-back: cubic-bezier(0.68, -0.6, 0.32, 1.6);
  
  /* Durations */
  --duration-instant: 100ms;
  --duration-fast: 200ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 700ms;
}

/* ══════════════════════════════════════════════════════════
   PAGE TRANSITIONS
   ══════════════════════════════════════════════════════════ */

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Screen transitions */
.screen {
  animation: fadeSlideUp 0.6s var(--ease-out-expo) forwards;
}

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

/* Screen exit animation */
.screen.exiting {
  animation: fadeSlideDown 0.4s var(--ease-smooth) forwards;
}

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

/* ══════════════════════════════════════════════════════════
   ENTRANCE ANIMATIONS
   ══════════════════════════════════════════════════════════ */

/* Fade in */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Slide up */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide down */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide left */
@keyframes slideLeft {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide right */
@keyframes slideRight {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

/* Scale in bounce */
@keyframes scaleInBounce {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.97);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Pop in */
@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-5deg);
  }
  70% {
    transform: scale(1.1) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

/* Utility classes for entrance animations */
.animate-in {
  animation: slideUp 0.5s var(--ease-out-expo) forwards;
}

.animate-fade-in {
  animation: fadeIn 0.5s var(--ease-smooth) forwards;
}

.animate-scale-in {
  animation: scaleIn 0.4s var(--ease-out-expo) forwards;
}

.animate-pop-in {
  animation: popIn 0.5s var(--ease-bounce) forwards;
}

/* Stagger delays */
.animate-delay-1 { animation-delay: 0.1s; opacity: 0; }
.animate-delay-2 { animation-delay: 0.2s; opacity: 0; }
.animate-delay-3 { animation-delay: 0.3s; opacity: 0; }
.animate-delay-4 { animation-delay: 0.4s; opacity: 0; }
.animate-delay-5 { animation-delay: 0.5s; opacity: 0; }
.animate-delay-6 { animation-delay: 0.6s; opacity: 0; }
.animate-delay-7 { animation-delay: 0.7s; opacity: 0; }
.animate-delay-8 { animation-delay: 0.8s; opacity: 0; }

/* ══════════════════════════════════════════════════════════
   CARD HOVER EFFECTS WITH DEPTH
   ══════════════════════════════════════════════════════════ */

.card,
.card-flat,
.welcome-feature,
.dimension-card,
.risk-card,
.guidance-card,
.habit-card {
  transition: all 0.3s var(--ease-out-expo);
  position: relative;
}

.card:hover,
.welcome-feature:hover,
.dimension-card:hover,
.risk-card:hover,
.guidance-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.habit-card:hover {
  transform: translateX(8px) scale(1.01);
  box-shadow: 
    -4px 0 20px rgba(233, 69, 96, 0.2),
    0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Card shine effect on hover */
.card::before,
.welcome-feature::before,
.dimension-card::before,
.guidance-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.05),
    transparent
  );
  transition: left 0.5s var(--ease-smooth);
  pointer-events: none;
  border-radius: inherit;
}

.card:hover::before,
.welcome-feature:hover::before,
.dimension-card:hover::before,
.guidance-card:hover::before {
  left: 100%;
}

/* ══════════════════════════════════════════════════════════
   BUTTON ANIMATIONS
   ══════════════════════════════════════════════════════════ */

.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s var(--ease-out-expo);
  transform-origin: center;
}

/* Button hover lift */
.btn:hover {
  transform: translateY(-2px);
}

/* Button press animation */
.btn:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 0.1s;
}

/* Ripple effect container */
.btn::after {
  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%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::after {
  width: 300px;
  height: 300px;
  transition: width 0s, height 0s;
}

/* Primary button glow */
.btn-primary {
  box-shadow: 0 4px 20px rgba(233, 69, 96, 0.25);
  transition: all 0.3s var(--ease-out-expo);
}

.btn-primary:hover {
  box-shadow: 
    0 8px 30px rgba(233, 69, 96, 0.4),
    0 0 40px rgba(233, 69, 96, 0.2);
  transform: translateY(-3px);
}

.btn-primary:active {
  box-shadow: 0 2px 10px rgba(233, 69, 96, 0.3);
}

/* Button icon animation */
.btn i,
.btn svg {
  transition: transform 0.3s var(--ease-out-expo);
}

.btn:hover i,
.btn:hover svg {
  transform: translateX(3px);
}

.btn-ghost:hover i,
.btn-ghost:hover svg {
  transform: scale(1.1);
}

/* ══════════════════════════════════════════════════════════
   LOADING STATES & SKELETONS
   ══════════════════════════════════════════════════════════ */

/* Skeleton loader */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

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

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

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

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Dots loading */
.loading-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--accent-primary);
  border-radius: 50%;
  animation: dotBounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes dotBounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ══════════════════════════════════════════════════════════
   PROGRESS ANIMATIONS
   ══════════════════════════════════════════════════════════ */

/* Progress bar fill animation */
.progress-fill {
  transition: width 0.6s var(--ease-out-expo);
  position: relative;
  overflow: hidden;
}

/* Progress bar shimmer */
.progress-fill::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: progressShimmer 2s infinite;
}

@keyframes progressShimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Progress dot animation */
.progress-fill::after {
  animation: progressDotPulse 2s ease-in-out infinite;
}

@keyframes progressDotPulse {
  0%, 100% {
    box-shadow: 0 0 12px rgba(233, 69, 96, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.6);
    transform: scale(1.2);
  }
}

/* Dimension progress dots */
.progress-dot {
  transition: all 0.4s var(--ease-out-expo);
}

.progress-dot.active {
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% {
    transform: scale(1.3);
    box-shadow: 0 0 8px rgba(233, 69, 96, 0.4);
  }
  50% {
    transform: scale(1.5);
    box-shadow: 0 0 16px rgba(233, 69, 96, 0.6);
  }
}

/* ══════════════════════════════════════════════════════════
   CELEBRATION ANIMATIONS
   ══════════════════════════════════════════════════════════ */

/* Confetti */
@keyframes confettiFall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--accent-primary);
  animation: confettiFall 3s linear forwards;
  pointer-events: none;
  z-index: 9999;
}

/* Success celebration */
@keyframes celebrate {
  0% {
    transform: scale(1);
  }
  15% {
    transform: scale(1.2) rotate(-5deg);
  }
  30% {
    transform: scale(1.1) rotate(5deg);
  }
  45% {
    transform: scale(1.15) rotate(-3deg);
  }
  60% {
    transform: scale(1.05) rotate(2deg);
  }
  75% {
    transform: scale(1.1) rotate(-1deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

.celebrate {
  animation: celebrate 0.8s var(--ease-bounce);
}

/* Success checkmark */
@keyframes checkmark {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

.checkmark-circle {
  animation: scaleInBounce 0.5s var(--ease-bounce);
}

.checkmark-check {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: checkmark 0.5s 0.3s var(--ease-out-expo) forwards;
}

/* ══════════════════════════════════════════════════════════
   QUESTION TRANSITIONS
   ══════════════════════════════════════════════════════════ */

/* Question card entrance */
.question-card {
  animation: questionSlideIn 0.4s var(--ease-out-expo);
}

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

/* Question card exit (for previous) */
.question-card.exit-left {
  animation: questionSlideOutLeft 0.3s var(--ease-smooth) forwards;
}

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

/* Question card exit (for next) */
.question-card.exit-right {
  animation: questionSlideOutRight 0.3s var(--ease-smooth) forwards;
}

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

/* ══════════════════════════════════════════════════════════
   RESPONSE OPTION ANIMATIONS
   ══════════════════════════════════════════════════════════ */

.response-option {
  transition: all 0.2s var(--ease-out-expo);
  position: relative;
}

.response-option:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 8px 20px rgba(233, 69, 96, 0.2);
}

.response-option:active {
  transform: translateY(-2px) scale(1.02);
}

/* Selection animation */
.response-option.selected {
  animation: selectPop 0.4s var(--ease-bounce);
}

@keyframes selectPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* Ripple effect for response options */
.response-option::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(233, 69, 96, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s, opacity 0.6s;
  opacity: 0;
}

.response-option:active::before {
  width: 200px;
  height: 200px;
  opacity: 1;
  transition: width 0s, height 0s, opacity 0s;
}

/* ══════════════════════════════════════════════════════════
   ICON ANIMATIONS
   ══════════════════════════════════════════════════════════ */

/* Icon wrapper hover */
.icon-wrapper {
  transition: all 0.3s var(--ease-out-expo);
}

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

/* Glow pulse for logo */
.welcome-logo {
  animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.3);
  }
  50% {
    box-shadow: 0 0 40px rgba(233, 69, 96, 0.5);
  }
}

/* Icon bounce on hover */
.icon-bounce:hover i,
.icon-bounce:hover svg {
  animation: iconBounce 0.6s var(--ease-bounce);
}

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

/* Icon rotate on hover */
.icon-rotate:hover i,
.icon-rotate:hover svg {
  animation: iconRotate 0.6s var(--ease-smooth);
}

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

/* ══════════════════════════════════════════════════════════
   DIMENSION BAR ANIMATIONS
   ══════════════════════════════════════════════════════════ */

.dimension-bar-fill {
  animation: barGrow 1s var(--ease-out-expo) forwards;
  transform-origin: left;
}

@keyframes barGrow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* Bar shimmer effect */
.dimension-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: barShimmer 2s infinite;
}

@keyframes barShimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* ══════════════════════════════════════════════════════════
   BADGE ANIMATIONS
   ══════════════════════════════════════════════════════════ */

.results-level-badge,
.question-dimension-badge {
  animation: badgeSlideIn 0.5s var(--ease-out-expo);
}

@keyframes badgeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ══════════════════════════════════════════════════════════
   HAPTIC FEEDBACK SIMULATION
   ══════════════════════════════════════════════════════════ */

.haptic-light {
  animation: hapticLight 0.1s ease;
}

@keyframes hapticLight {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.98);
  }
}

.haptic-medium {
  animation: hapticMedium 0.15s ease;
}

@keyframes hapticMedium {
  0%, 100% {
    transform: scale(1);
  }
  33% {
    transform: scale(0.96);
  }
  66% {
    transform: scale(1.02);
  }
}

.haptic-heavy {
  animation: hapticHeavy 0.2s ease;
}

@keyframes hapticHeavy {
  0%, 100% {
    transform: scale(1);
  }
  25% {
    transform: scale(0.94);
  }
  50% {
    transform: scale(1.04);
  }
  75% {
    transform: scale(0.98);
  }
}

/* ══════════════════════════════════════════════════════════
   SMOOTH STATE TRANSITIONS
   ══════════════════════════════════════════════════════════ */

/* Fade transition */
.fade-enter {
  opacity: 0;
}

.fade-enter-active {
  opacity: 1;
  transition: opacity 0.3s var(--ease-smooth);
}

.fade-exit {
  opacity: 1;
}

.fade-exit-active {
  opacity: 0;
  transition: opacity 0.3s var(--ease-smooth);
}

/* Slide transition */
.slide-enter {
  transform: translateX(100%);
}

.slide-enter-active {
  transform: translateX(0);
  transition: transform 0.3s var(--ease-out-expo);
}

.slide-exit {
  transform: translateX(0);
}

.slide-exit-active {
  transform: translateX(-100%);
  transition: transform 0.3s var(--ease-out-expo);
}

/* ══════════════════════════════════════════════════════════
   ACCESSIBILITY - REDUCED MOTION
   ══════════════════════════════════════════════════════════ */

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

/* ══════════════════════════════════════════════════════════
   MOBILE OPTIMIZATIONS
   ══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Reduce animation intensity on mobile */
  .card:hover,
  .welcome-feature:hover,
  .dimension-card:hover {
    transform: translateY(-4px) scale(1.01);
  }
  
  .btn:hover {
    transform: translateY(-1px);
  }
  
  /* Faster animations on mobile */
  .question-card {
    animation-duration: 0.3s;
  }
}
