/* Tarqiya - Professional Modern Animation System */

/* 1. Page Transitions */
.page-enter {
  animation: pageFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* 2. Staggered Card Entrance */
.card-fade-up {
  opacity: 0;
  transform: translateY(16px);
  animation: cardEntrance 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.card-fade-up:nth-child(1) { animation-delay: 0.05s; }
.card-fade-up:nth-child(2) { animation-delay: 0.10s; }
.card-fade-up:nth-child(3) { animation-delay: 0.15s; }
.card-fade-up:nth-child(4) { animation-delay: 0.20s; }
.card-fade-up:nth-child(5) { animation-delay: 0.25s; }
.card-fade-up:nth-child(6) { animation-delay: 0.30s; }

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

/* 3. Button Micro-Interactions */
.btn {
  position: relative;
  overflow: hidden;
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              background-color 0.2s ease,
              border-color 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.btn:focus-visible {
  outline: 2px solid var(--color-main-blue);
  outline-offset: 2px;
}

/* Button Loading Spinner State */
.btn.loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}

.btn.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  margin-left: -10px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* 4. Progress Bar Animation */
.progress-bar {
  transition: width 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 5. Video Completion Celebration */
.video-completed-badge-pop {
  animation: badgePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes badgePop {
  0% { transform: scale(0.7); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* 6. Lock Opening & Card Unlock Animation */
@keyframes unlockGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(13, 100, 219, 0.5);
    border-color: var(--color-main-blue);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(13, 100, 219, 0);
    border-color: var(--color-main-blue);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(13, 100, 219, 0);
  }
}

.card-just-unlocked {
  animation: unlockGlow 1.2s ease-out;
}

/* 7. Milestone Celebration Modal (45 Videos Completed) */
.milestone-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(18, 59, 93, 0.85);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: milestoneFadeIn 0.4s ease-out forwards;
}

@keyframes milestoneFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.milestone-modal-card {
  background: var(--color-surface);
  border: 2px solid var(--color-main-blue);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  text-align: center;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  animation: milestoneCardZoom 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes milestoneCardZoom {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.milestone-badge-glow {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #0D64DB, #0074E8);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  box-shadow: 0 0 30px rgba(13, 100, 219, 0.45);
  margin-bottom: 20px;
  animation: pulseGlow 2s infinite;
}

/* 8. Exam Question Slide Transitions */
.question-slide-in {
  animation: questionSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes questionSlide {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

[dir="ltr"] .question-slide-in {
  animation: questionSlideLtr 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes questionSlideLtr {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 9. Circular Score / Results Animation */
.score-circle-anim {
  animation: scoreScale 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes scoreScale {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* 10. Certificate Reveal Animation */
.cert-reveal {
  animation: certUnfurl 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes certUnfurl {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(24px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* 11. OTP Input Auto-advance Boxes */
.otp-input-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  direction: ltr;
}

.otp-digit-input {
  width: 58px;
  height: 64px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 1.8rem;
  font-weight: 800;
  background-color: var(--color-bg);
  color: var(--color-primary);
  transition: all var(--transition-fast);
}

.otp-digit-input:focus {
  border-color: var(--color-main-blue);
  background-color: var(--color-surface);
  box-shadow: 0 0 0 3px rgba(13, 100, 219, 0.22);
  outline: none;
}

/* 12. Directional Icons Helper */
[dir="ltr"] .icon-flip {
  transform: scaleX(-1);
}

/* 13. Smooth Theme Switch Transition */
body, .app-header, .card, .btn, .form-control {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
