/**
 * Portal CSS - #CancelaOVape
 * Animations and custom styles for the user portal
 */

/* =============================================================================
   CELEBRATION ANIMATIONS
   ============================================================================= */

/* Confetti animation for unlocked achievements */
@keyframes confetti-fall {
  0% {
    transform: translateY(-100%) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

@keyframes confetti-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -10px;
  z-index: 1000;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--confetti-color, #10b981);
  animation: confetti-fall 3s ease-out forwards, confetti-shake 0.5s ease-in-out infinite;
}

/* Badge unlock animation */
@keyframes badge-unlock {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(10deg);
  }
  70% {
    transform: scale(0.9) rotate(-5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes badge-glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(16, 185, 129, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.8), 0 0 40px rgba(16, 185, 129, 0.4);
  }
}

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

.badge-unlocked {
  animation: badge-unlock 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

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

.badge-new {
  animation: badge-pulse 1s ease-in-out infinite;
}

/* Star burst effect */
@keyframes star-burst {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: scale(2) rotate(180deg);
    opacity: 0;
  }
}

.star-burst {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.star-burst::before,
.star-burst::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.3) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  animation: star-burst 0.8s ease-out forwards;
}

/* =============================================================================
   XP HISTORY TIMELINE
   ============================================================================= */

.xp-timeline {
  position: relative;
  padding-left: 24px;
}

.xp-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, #10b981 0%, #d1fae5 100%);
}

.xp-timeline-item {
  position: relative;
  padding-bottom: 16px;
  opacity: 0;
  transform: translateX(-20px);
  animation: slide-in 0.3s ease-out forwards;
}

.xp-timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 2px #10b981;
}

@keyframes slide-in {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

/* XP gain popup */
@keyframes xp-popup {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-50px) scale(1.2);
    opacity: 0;
  }
}

.xp-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  font-weight: bold;
  color: #10b981;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: xp-popup 1.5s ease-out forwards;
  pointer-events: none;
  z-index: 1000;
}

/* =============================================================================
   CHALLENGE COUNTDOWN
   ============================================================================= */

.challenge-card {
  transition: all 0.3s ease;
}

.challenge-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.countdown-timer {
  font-variant-numeric: tabular-nums;
}

@keyframes countdown-pulse {
  0%, 100% {
    color: #ef4444;
  }
  50% {
    color: #fbbf24;
  }
}

.countdown-urgent {
  animation: countdown-pulse 1s ease-in-out infinite;
}

/* Progress bar animation */
@keyframes progress-fill {
  from {
    width: 0;
  }
}

.progress-animated {
  animation: progress-fill 1s ease-out forwards;
}

/* =============================================================================
   HEALTH TIMELINE SCROLL ANIMATIONS
   ============================================================================= */

.health-milestone {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.health-milestone.visible {
  opacity: 1;
  transform: translateY(0);
}

.health-milestone.achieved .milestone-icon {
  animation: milestone-celebrate 0.6s ease-out;
}

@keyframes milestone-celebrate {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.3);
  }
  60% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

/* Timeline connector animation */
.timeline-connector {
  height: 0;
  transition: height 0.5s ease-out;
}

.timeline-connector.visible {
  height: 100%;
}

/* Milestone checkmark animation */
@keyframes checkmark-draw {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

.milestone-checkmark {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.milestone-checkmark.visible {
  animation: checkmark-draw 0.5s ease-out forwards;
}

/* =============================================================================
   SHARE PROGRESS CARD
   ============================================================================= */

.share-card {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 16px;
  padding: 24px;
  color: white;
  position: relative;
  overflow: hidden;
}

.share-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  pointer-events: none;
}

.share-card-content {
  position: relative;
  z-index: 1;
}

/* =============================================================================
   BREATHING EXERCISE ENHANCEMENTS
   ============================================================================= */

.breathing-circle {
  transition: all 0.3s ease;
}

.breathing-circle.inhale {
  transform: scale(1.5);
  background: rgba(16, 185, 129, 0.3);
}

.breathing-circle.hold {
  transform: scale(1.5);
  background: rgba(59, 130, 246, 0.3);
}

.breathing-circle.exhale {
  transform: scale(1);
  background: rgba(16, 185, 129, 0.1);
}

/* Ripple effect */
@keyframes ripple {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

.breathing-ripple {
  position: absolute;
  border-radius: 50%;
  border: 2px solid #10b981;
  animation: ripple 2s ease-out infinite;
}

/* =============================================================================
   UTILITY ANIMATIONS
   ============================================================================= */

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

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

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

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

.animate-fade-in {
  animation: fade-in 0.5s ease-out forwards;
}

.animate-fade-in-up {
  animation: fade-in-up 0.5s ease-out forwards;
}

.animate-fade-in-down {
  animation: fade-in-down 0.5s ease-out forwards;
}

.animate-bounce-in {
  animation: bounce-in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

/* Stagger children animations */
.stagger-children > * {
  opacity: 0;
  animation: fade-in-up 0.4s ease-out forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

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

/* =============================================================================
   MOBILE-SPECIFIC IMPROVEMENTS
   ============================================================================= */

/* Alpine.js x-collapse support */
[x-cloak] { display: none !important; }

/* Improve touch targets on mobile */
@media (max-width: 640px) {
  /* Larger touch area for country selector */
  .portal-country-selector {
    min-height: 48px;
    min-width: 100px;
  }

  /* Reduce content padding for more screen space */
  .portal-login-card {
    padding: 1.25rem;
  }

  /* Compact margin for mobile */
  .portal-logo-section {
    margin-bottom: 1rem;
  }

  /* Make buttons easier to tap */
  button,
  a.btn,
  [type="submit"] {
    min-height: 44px;
  }
}

/* Onboarding progress bars - thicker on mobile for visibility */
@media (max-width: 640px) {
  .story-progress-bar {
    height: 3px !important;
  }
}

/* Login page specific mobile adjustments */
@media (max-width: 375px) {
  /* Even smaller screens (iPhone SE, etc.) */
  .portal-login-hero {
    min-height: 70vh;
  }
}
