/* NIC — Motion, loading & microinteractions */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(8px) scale(0.96); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 217, 49, 0.35); }
  50%      { box-shadow: 0 0 0 8px rgba(0, 217, 49, 0); }
}
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.view-enter {
  animation: fadeInUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.view-enter--fast {
  animation: fadeIn 0.28s ease both;
}

.stagger > * {
  animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.stagger > *:nth-child(1) { animation-delay: 0.03s; }
.stagger > *:nth-child(2) { animation-delay: 0.06s; }
.stagger > *:nth-child(3) { animation-delay: 0.09s; }
.stagger > *:nth-child(4) { animation-delay: 0.12s; }
.stagger > *:nth-child(5) { animation-delay: 0.15s; }
.stagger > *:nth-child(6) { animation-delay: 0.18s; }
.stagger > *:nth-child(7) { animation-delay: 0.21s; }
.stagger > *:nth-child(8) { animation-delay: 0.24s; }

/* Skeleton */
.skeleton {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg,
    rgba(0, 0, 112, 0.06) 25%,
    rgba(0, 0, 112, 0.1) 50%,
    rgba(0, 0, 112, 0.06) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 12px;
}
[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 75%);
  background-size: 200% 100%;
}
.skeleton-row {
  display: grid;
  grid-template-columns: 1fr 0.6fr 2fr 0.8fr 1fr 0.6fr;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.skeleton-cell { height: 14px; }
.skeleton-cell--tall { height: 32px; }
.skeleton-panel { padding: 1.25rem; display: grid; gap: 0.75rem; }
.skeleton-line { height: 12px; }
.skeleton-line--lg { height: 20px; width: 60%; }
.skeleton-line--md { width: 80%; }
.skeleton-line--sm { width: 40%; }

/* Loading button */
.btn.is-loading {
  pointer-events: none;
  opacity: 0.85;
  position: relative;
  color: transparent !important;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(0, 0, 112, 0.2);
  border-top-color: var(--navy-hi);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
.btn-primary.is-loading::after {
  border-color: rgba(0, 0, 112, 0.25);
  border-top-color: var(--navy-hi);
}
.btn-glass.is-loading::after {
  border-color: rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
}

/* Toast stack */
.toast-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.55rem;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 2rem));
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-hover);
  animation: toastIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.toast.is-leaving { animation: toastOut 0.25s ease forwards; }
.toast--default { background: var(--navy-hi); color: #fff; }
.toast--success { background: var(--verde-hi); color: var(--navy-hi); }
.toast--error   { background: #991b1b; color: #fff; }
.toast__icon { font-size: 1.1rem; line-height: 1; flex: none; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-muted);
}
.empty-state__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 20px;
  background: var(--verde-soft);
  display: grid;
  place-items: center;
  font-size: 1.75rem;
  animation: pulseGlow 2.5s ease-in-out infinite;
}
[data-theme="dark"] .empty-state__icon {
  background: rgba(0, 217, 49, 0.12);
}
.empty-state h3 {
  margin: 0 0 0.35rem;
  color: var(--navy-hi);
  font-size: 1.1rem;
}
.empty-state p { margin: 0 0 1.25rem; max-width: 28rem; margin-inline: auto; }

/* Page loader overlay */
.page-loader {
  display: grid;
  gap: 0.75rem;
  padding: 2rem;
}

/* 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; }
}

@media (max-width: 760px) {
  .skeleton-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    padding: 0.85rem;
  }
  .skeleton-panel { padding: 1rem; }
  .page-loader { padding: 0; }
  .toast-stack {
    left: 1rem;
    right: 1rem;
    left: max(1rem, env(safe-area-inset-left));
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    max-width: none;
  }
  .toast { width: 100%; }
}
