/* ============================================
   AL-HIRA PUBLIC SCHOOL — Animations
   Transitions, micro-animations, keyframes
   ============================================ */

/* === Keyframe Animations === */

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

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

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

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

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

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

@keyframes scaleOut {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.9);
    opacity: 0;
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.1);
  }
}

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

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

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

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

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

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

@keyframes drawIn {
  from { stroke-dashoffset: 1000; }
  to { stroke-dashoffset: 0; }
}

@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 0.5;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* === Page Transition Classes === */
.page-enter {
  animation: fadeInUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-exit {
  animation: fadeOut 0.2s ease-out forwards;
}

/* === Stagger Children Animation === */
.stagger-enter > * {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* === Card Hover Lift === */
.hover-lift {
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* === Button Ripple Effect === */
.btn-ripple {
  position: relative;
  overflow: hidden;
}

.btn-ripple .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  animation: ripple 0.6s ease-out forwards;
  pointer-events: none;
}

/* === Loading Spinner === */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

.spinner-dark {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--color-primary);
}

/* === Full Page Loader === */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: var(--z-max);
  gap: var(--space-6);
  transition: opacity 0.5s ease;
}

.page-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.page-loader-logo {
  width: 64px;
  height: 64px;
  animation: logoFloat 2s ease-in-out infinite;
}

.page-loader-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-xl);
}

.page-loader-bar {
  width: 180px;
  height: 3px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.page-loader-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-gold));
  border-radius: var(--radius-full);
  width: 0%;
  animation: loaderProgress 1.5s ease-in-out forwards;
}

@keyframes loaderProgress {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

.page-loader-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
}

/* === Count-up Animation === */
.count-up {
  display: inline-block;
  animation: countUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* === Chart Draw-in === */
.chart-animate {
  animation: fadeInUp 0.6s ease-out forwards;
}

/* === Micro-interactions === */
.interactive {
  transition: transform var(--transition-fast);
}

.interactive:active {
  transform: scale(0.97);
}

/* === Toast Exit === */
.toast-exit {
  animation: slideOutRight 0.3s ease-in forwards;
}

/* === Skeleton Shimmer (defined once) === */
.shimmer {
  background: linear-gradient(
    90deg,
    var(--color-bg) 25%,
    var(--color-border-light) 50%,
    var(--color-bg) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* === Checkbox Animation === */
.checkbox-animated {
  transition: all var(--transition-fast);
}

.checkbox-animated:checked {
  animation: scaleIn 0.2s ease-out;
}

/* === Focus Ring === */
.focus-ring:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* === Error Shake === */
.error-shake {
  animation: shake 0.4s ease-in-out;
}

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