/* CyberGate Micro-Animations — subtle delight without distraction */

:root {
  --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
  --ease-snappy: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --micro-duration: 520ms;
  --micro-stagger: 55ms;
  --micro-lift: -3px;
}

/* ── Reveal on enter ── */
@keyframes micro-rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes micro-pop {
  0% { opacity: 0; transform: scale(0.82); }
  70% { transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

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

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

@keyframes micro-pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(207, 23, 53, 0.35); }
  70% { box-shadow: 0 0 0 8px rgba(207, 23, 53, 0); }
  100% { box-shadow: 0 0 0 0 rgba(207, 23, 53, 0); }
}

@keyframes micro-glow-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(207, 23, 53, 0.15); }
  50% { box-shadow: 0 0 20px 2px rgba(207, 23, 53, 0.12); }
}

@keyframes micro-flow-pulse {
  0%, 100% { transform: scale(1); border-color: var(--brand-crimson); }
  50% { transform: scale(1.06); border-color: var(--brand-crimson-hover); }
}

@keyframes micro-toast-in {
  from { opacity: 0; transform: translateX(24px) scale(0.94); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes micro-toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(24px); }
}

@keyframes micro-flash-in {
  0% { opacity: 0; transform: translateY(-8px) scale(0.98); }
  60% { transform: translateY(2px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes micro-ripple {
  to { transform: scale(2.8); opacity: 0; }
}

.micro-reveal {
  opacity: 0;
  will-change: opacity, transform;
}

.micro-reveal.is-visible {
  animation: micro-rise var(--micro-duration) var(--ease-snappy) forwards;
  animation-delay: var(--micro-delay, 0ms);
}

/* ── Interactive feedback ── */
.btn,
.quick-action-btn,
.icon-btn,
.rail-link,
.pagination a,
.export-tile,
.conv-item {
  transition:
    transform 140ms var(--ease-snappy),
    box-shadow 180ms ease,
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease;
}

.btn:active,
.quick-action-btn:active,
.icon-btn:active {
  transform: scale(0.96);
}

.btn-primary:active {
  box-shadow: 0 4px 14px rgba(207, 23, 53, 0.35);
}

.card,
.page-kpi,
.kpi-card,
.export-tile,
.toolbar-card,
.table-shell,
.detail-hero,
.tabs-card {
  transition:
    transform 220ms var(--ease-snappy),
    box-shadow 220ms ease,
    border-color 180ms ease;
}

.card:hover,
.page-kpi:hover,
.kpi-card:hover,
.export-tile:hover {
  transform: translateY(var(--micro-lift));
  box-shadow: 0 14px 32px rgba(16, 42, 86, 0.09);
}

.rail-link.active {
  animation: micro-pulse-ring 2.4s ease-out infinite;
}

.rail-link:hover svg {
  transform: scale(1.08);
}

.rail-link svg {
  transition: transform 180ms var(--ease-spring);
}

.rail-logo {
  transition: transform 220ms var(--ease-spring), box-shadow 220ms ease;
}

.rail-logo:hover {
  transform: scale(1.05) rotate(-2deg);
  box-shadow: 0 8px 20px rgba(16, 42, 86, 0.25);
}

/* ── KPI & numbers ── */
.kpi-value,
.page-kpi .kpi-value,
.flow-count {
  transition: color 300ms ease;
}

.kpi-value.is-counting,
.page-kpi .kpi-value.is-counting {
  color: var(--brand-crimson);
}

/* ── Progress bars ── */
.progress-fill {
  transition: width 900ms var(--ease-out-expo);
  position: relative;
  overflow: hidden;
}

.progress-fill.is-animated::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.45) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: micro-shimmer 1.8s ease-in-out 0.6s 1;
}

/* ── Tables ── */
.data-table tbody tr {
  transition: background 140ms ease, transform 160ms var(--ease-snappy);
}

.data-table tbody tr:hover {
  transform: translateX(3px);
}

.data-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--brand-crimson);
}

/* ── Badges & pills ── */
.badge,
.updated-pill {
  animation: micro-pop 420ms var(--ease-spring) both;
}

/* ── Tabs ── */
.tab,
.topbar-tab {
  position: relative;
  transition: color 180ms ease;
}

.tab.active,
.topbar-tab.active {
  animation: micro-pop 320ms var(--ease-spring);
}

/* ── Flash & toast ── */
.flash-msg {
  animation: micro-flash-in 480ms var(--ease-spring);
}

.toast {
  animation: micro-toast-in 380ms var(--ease-spring);
}

.toast.is-leaving {
  animation: micro-toast-out 260ms ease forwards;
}

/* ── Search & modals ── */
.search-dialog.open {
  animation: fadeIn 180ms ease;
}

.search-dialog.open .search-box {
  animation: micro-rise 380ms var(--ease-spring);
}

.search-result {
  transition: background 120ms ease, transform 120ms var(--ease-snappy), padding-left 120ms ease;
}

.search-result:hover {
  transform: translateX(4px);
  padding-left: 24px;
}

.modal {
  animation: modalIn 320ms var(--ease-spring);
}

/* ── Dashboard flow hub ── */
.flow-center {
  animation: micro-flow-pulse 3s ease-in-out infinite;
}

.flow-node {
  transition: transform 220ms var(--ease-spring);
}

.flow-node:hover {
  transform: scale(1.06);
}

.today-slot {
  transition: transform 180ms var(--ease-snappy), box-shadow 180ms ease, border-color 180ms ease;
}

.today-slot:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 42, 86, 0.08);
}

/* ── Detail hero avatar ── */
.detail-hero-avatar {
  animation: micro-pop 560ms var(--ease-spring) 80ms both;
}

/* ── Form focus delight ── */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  transition: border-color 140ms ease, box-shadow 220ms var(--ease-snappy), transform 140ms ease;
  transform: translateY(-1px);
}

/* ── Click ripple ── */
.btn-primary,
.quick-action-btn.primary {
  position: relative;
  overflow: hidden;
}

.micro-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: scale(0);
  animation: micro-ripple 520ms ease-out;
  pointer-events: none;
}

/* ── Empty state gentle float ── */
.empty-state-card svg,
.empty-state svg {
  animation: micro-flow-pulse 4s ease-in-out infinite;
}

/* ── Auth / login pages ── */
.auth-card {
  animation: micro-rise 560ms var(--ease-spring) both;
}

.auth-logo {
  animation: micro-pop 480ms var(--ease-spring) 120ms both;
}

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

  .micro-reveal {
    opacity: 1;
  }

  .card:hover,
  .page-kpi:hover,
  .kpi-card:hover,
  .export-tile:hover,
  .data-table tbody tr:hover {
    transform: none;
  }
}
