/* ═══════════════════════════════════════════════════════════════
   PROOF CRM — ANIMATIONS v1.0
   Keyframes + stagger utilities. All durations use token variables.
   ═══════════════════════════════════════════════════════════════ */

/* ─── Core Keyframes ─── */

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

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

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

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

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

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

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

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

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

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(0, 217, 255, 0.2); }
  50%      { box-shadow: 0 0 20px rgba(0, 217, 255, 0.4); }
}

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

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

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

@keyframes breathe {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

@keyframes glow-pulse {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 6px rgba(255,125,0,0.3)); }
  50%      { filter: brightness(1.15) drop-shadow(0 0 20px rgba(255,125,0,0.6)); }
}

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

@keyframes gradient-shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes ripple {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}

@keyframes border-glow {
  0%, 100% { border-color: var(--glass-border); }
  50%      { border-color: var(--brand); }
}

@keyframes shimmer-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ─── Smooth Theme Transition — applied only to theme-sensitive elements ─── */
.card, .modal, .btn, .glass-panel, [data-theme] {
  transition: background-color 0.4s var(--ease-smooth),
              color 0.3s var(--ease-smooth),
              border-color 0.3s var(--ease-smooth),
              box-shadow 0.3s var(--ease-smooth);
}

/* ─── Stagger Utilities ─── */

/* Apply to a container; children animate in sequence */
.stagger-fade > * {
  opacity: 0;
  animation: slideUpFade var(--duration-fluid) var(--ease-smooth) forwards;
}
.stagger-fade > *:nth-child(1)  { animation-delay: 0ms; }
.stagger-fade > *:nth-child(2)  { animation-delay: 60ms; }
.stagger-fade > *:nth-child(3)  { animation-delay: 120ms; }
.stagger-fade > *:nth-child(4)  { animation-delay: 180ms; }
.stagger-fade > *:nth-child(5)  { animation-delay: 240ms; }
.stagger-fade > *:nth-child(6)  { animation-delay: 300ms; }
.stagger-fade > *:nth-child(7)  { animation-delay: 360ms; }
.stagger-fade > *:nth-child(8)  { animation-delay: 420ms; }
.stagger-fade > *:nth-child(9)  { animation-delay: 480ms; }
.stagger-fade > *:nth-child(10) { animation-delay: 540ms; }

/* Table rows stagger */
.stagger-rows tbody tr {
  opacity: 0;
  animation: slideUpFade var(--duration-fluid) var(--ease-smooth) forwards;
}
.stagger-rows tbody tr:nth-child(1)  { animation-delay: 0ms; }
.stagger-rows tbody tr:nth-child(2)  { animation-delay: 40ms; }
.stagger-rows tbody tr:nth-child(3)  { animation-delay: 80ms; }
.stagger-rows tbody tr:nth-child(4)  { animation-delay: 120ms; }
.stagger-rows tbody tr:nth-child(5)  { animation-delay: 160ms; }
.stagger-rows tbody tr:nth-child(6)  { animation-delay: 200ms; }
.stagger-rows tbody tr:nth-child(7)  { animation-delay: 240ms; }
.stagger-rows tbody tr:nth-child(8)  { animation-delay: 280ms; }
.stagger-rows tbody tr:nth-child(9)  { animation-delay: 320ms; }
.stagger-rows tbody tr:nth-child(10) { animation-delay: 360ms; }

/* ─── Utility Animation Classes ─── */

.anim-fade-in     { animation: fadeIn var(--duration-fluid) var(--ease-smooth) forwards; }
.anim-slide-up    { animation: slideUpFade var(--duration-fluid) var(--ease-spring) forwards; }
.anim-slide-down  { animation: slideDownFade var(--duration-fluid) var(--ease-spring) forwards; }
.anim-scale-in    { animation: scaleIn var(--duration-fluid) var(--ease-spring) forwards; }
.anim-pulse-glow  { animation: pulse-glow 2s var(--ease-smooth) infinite; }
.anim-breathe     { animation: breathe 2s var(--ease-smooth) infinite; }
.anim-glow-pulse  { animation: glow-pulse 2.5s var(--ease-smooth) infinite; }
.anim-float       { animation: float 3s var(--ease-smooth) infinite; }
.anim-gradient    { animation: gradient-shift 6s ease infinite; background-size: 200% 200%; }

.anim-delay-100 { animation-delay: 100ms; }
.anim-delay-200 { animation-delay: 200ms; }
.anim-delay-300 { animation-delay: 300ms; }
.anim-delay-500 { animation-delay: 500ms; }
.anim-delay-700 { animation-delay: 700ms; }
.anim-delay-1000 { animation-delay: 1000ms; }

/* ─── Page Transition ─── */

.page-enter {
  animation: slideUpFade var(--duration-slow) var(--ease-smooth);
}

/* ─── Hover Effects ─── */

.hover-lift {
  transition: transform var(--duration-snap) var(--ease-spring),
              box-shadow var(--duration-snap) var(--ease-smooth);
}
.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.hover-glow {
  transition: box-shadow var(--duration-snap) var(--ease-smooth);
}
.hover-glow:hover {
  box-shadow: var(--shadow-glow-cyan);
}

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

/* ═════════════════════════════════════════════════════════════
   TIER 1-3 — New Animation Utilities (2026-07-18)
   ═════════════════════════════════════════════════════════════ */

/* ── Card entrance (applied via JS auto-apply) ── */
.card-rise {
  animation: scaleIn 0.4s var(--ease-spring) both;
}
.stagger-1 > *:nth-child(1) { animation-delay: 0.00s; }
.stagger-1 > *:nth-child(2) { animation-delay: 0.06s; }
.stagger-1 > *:nth-child(3) { animation-delay: 0.12s; }
.stagger-1 > *:nth-child(4) { animation-delay: 0.18s; }
.stagger-1 > *:nth-child(5) { animation-delay: 0.24s; }
.stagger-1 > *:nth-child(6) { animation-delay: 0.30s; }
.stagger-1 > *:nth-child(7) { animation-delay: 0.36s; }
.stagger-1 > *:nth-child(8) { animation-delay: 0.42s; }

/* ── Status pulse dot (green/amber/red) ── */
.status-pulse::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  background: currentColor;
  animation: breathe 1.8s ease-in-out infinite;
}
.status-pulse.green::before  { background: var(--color-success, #34c759); }
.status-pulse.amber::before  { background: var(--color-warning, #ffb340); }
.status-pulse.red::before    { background: var(--color-danger,  #ff3b30); }

/* ── Particle background (2 floating orbs) ── */
.particle-bg {
  position: relative;
  overflow: hidden;
}
.particle-bg::before,
.particle-bg::after {
  content:  '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
.particle-bg::before {
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(255,125,0,0.10), transparent 70%);
  top: -80px; right: -60px;
  animation: float 12s ease-in-out infinite;
}
.particle-bg::after {
  width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(0,200,255,0.08), transparent 70%);
  bottom: -40px; left: -50px;
  animation: float 16s ease-in-out infinite reverse;
}

/* ── Scale press feedback ── */
.scale-press:active {
  transform: scale(0.97);
  transition: transform 0.08s ease;
}

/* ── Shimmer loading skeleton ── */
.shimmer {
  background: linear-gradient(90deg,
    var(--surface-2, rgba(255,255,255,0.05)) 25%,
    var(--surface-3, rgba(255,255,255,0.10)) 37%,
    var(--surface-2, rgba(255,255,255,0.05)) 63%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* ── Toast notifications ── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 18px;
  border-radius: var(--rounded-md, 10px);
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-body);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  animation: slideInRight 0.35s var(--ease-spring) both;
  max-width: 360px;
  cursor: pointer;
}
.toast.hiding {
  animation: slideInRight 0.28s ease-in reverse forwards;
}
.toast.success { border-left: 3px solid var(--color-success); }
.toast.error   { border-left: 3px solid var(--color-danger);  }

/* ═══════════════════════════════════════════════════════════════════
   PRISM SPARKLE V2 — Light Refraction + Performance Safeguards
   Wrapped in prefers-reduced-motion. GPU-composited.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Shimmer Edge — Active Cards & Primary Buttons ── */
@media (prefers-reduced-motion: no-preference) {
  @keyframes prism-shimmer {
    0%, 100% {
      box-shadow: inset 3px 0 0 var(--brand, #B95CE4),
                  0 0 8px rgba(185, 92, 228, 0.15);
    }
    50% {
      box-shadow: inset 3px 0 0 var(--brand, #B95CE4),
                  0 0 18px rgba(185, 92, 228, 0.30);
    }
  }

  .card-active,
  .btn-primary:focus-visible,
  .s-link.active {
    animation: prism-shimmer 4s ease-in-out infinite;
    will-change: box-shadow;
  }

  @keyframes cyan-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.4); }
    50%      { box-shadow: 0 0 0 8px rgba(0, 240, 255, 0); }
  }

  .pulse-success {
    animation: cyan-pulse 2s ease-in-out infinite;
    will-change: box-shadow;
  }
}

/* ── Light Flare — Loading / Data Fetching Bar ── */
@keyframes light-flare {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.fetching-data-bar {
  background: linear-gradient(
    90deg,
    #B95CE4 0%, #C85A9E 15%, #00F0FF 30%,
    #40E8D8 50%, #00F0FF 70%, #C85A9E 85%, #B95CE4 100%
  );
  background-size: 200% auto;
  animation: light-flare 2s linear infinite;
  height: 3px;
  border-radius: 2px;
}

/* ── Chrome Edge — Subtle metallic card border ── */
.chrome-card {
  border: 1px solid rgba(242, 245, 248, 0.08);
  background: linear-gradient(
    45deg,
    rgba(28, 34, 48, 0.9) 0%,
    rgba(34, 42, 56, 0.8) 50%,
    rgba(28, 34, 48, 0.9) 100%
  );
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

/* ── High-Value Lead Badge (Amber Spark) ── */
.badge-premium {
  background: rgba(255, 179, 71, 0.15);
  color: #FFB347;
  border: 1px solid rgba(255, 179, 71, 0.3);
}

/* ── Reduced Motion Fallback ── */
@media (prefers-reduced-motion: reduce) {
  .card-active,
  .btn-primary:focus-visible,
  .s-link.active {
    border-color: rgba(185, 92, 228, 0.8);
    box-shadow: 0 0 12px rgba(185, 92, 228, 0.3);
    animation: none;
    will-change: auto;
  }
  .fetching-data-bar {
    animation: none;
    background: #B95CE4;
  }
  .pulse-success {
    animation: none;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
    will-change: auto;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   LASER TRACE — ::before mask border sweep (universal browser support)
   Uses background-position animation — works in Firefox, Safari, Chrome, Edge.
   Subtle constant shimmer + intensify on hover.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Position context for ::before pseudo ── */
.card-laser-hover,
.btn-laser-trace {
  position: relative;
  overflow: hidden;
}

/* ── Laser border ring via ::before mask-composite ── */
.card-laser-hover::before,
.btn-laser-trace::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(
    45deg,
    transparent 20%,
    var(--glow-border, var(--brand, #B95CE4)) 45%,
    rgba(255,255,255,0.3) 50%,
    var(--glow-border, var(--brand, #B95CE4)) 55%,
    transparent 80%
  );
  background-size: 400% 400%;
  animation: border-shimmer 6s linear infinite;
  mask: linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
  mask-composite: exclude;
  -webkit-mask-composite: xor;
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* ── Size-based laser speed — bigger boxes sweep slower ── */
/* Large panels (dashboard, command center, ABC hub) */
.glass-panel.card-laser-hover::before,
.abc-panel.card-laser-hover::before,
.panel.card-laser-hover::before {
  animation-duration: 10s;
}

/* Standard glass / base cards */
.glass-card.card-laser-hover::before,
.card.card-laser-hover::before {
  animation-duration: 8s;
}

/* Small stat cards — quicker sweep on tiny boxes */
.stat-card.card-laser-hover::before {
  animation-duration: 5s;
  height: auto;            /* override dashboard inline height:3px */
  opacity: 0.20;           /* override dashboard inline opacity:0 */
  inset: 0;                /* re-affirm full perimeter sweep */
}

/* ── Desktop: laser only on hover ── */
@media (hover: hover) {
  .card-laser-hover:hover::before,
  .card-laser-hover:focus-within::before {
    opacity: 0.35;
    animation-duration: 3s;
    background: linear-gradient(
      45deg,
      transparent 15%,
      var(--glow-border, var(--brand, #B95CE4)) 45%,
      rgba(255,255,255,0.5) 50%,
      var(--glow-border, var(--brand, #B95CE4)) 55%,
      transparent 85%
    );
    background-size: 400% 400%;
  }

  /* Large panels — keep hover sweep slower & proportional */
  .glass-panel.card-laser-hover:hover::before,
  .abc-panel.card-laser-hover:hover::before,
  .panel.card-laser-hover:hover::before {
    animation-duration: 6s;
  }

  .glass-card.card-laser-hover:hover::before,
  .card.card-laser-hover:hover::before {
    animation-duration: 4s;
  }
}

/* ── Mobile: laser only while touching ── */
@media (hover: none) {
  .card-laser-hover:active::before {
    opacity: 0.35;
    animation-duration: 3s;
    background: linear-gradient(
      45deg,
      transparent 15%,
      var(--glow-border, var(--brand, #B95CE4)) 45%,
      rgba(255,255,255,0.5) 50%,
      var(--glow-border, var(--brand, #B95CE4)) 55%,
      transparent 85%
    );
    background-size: 400% 400%;
  }
}

/* Button laser — more visible by default */
.btn-laser-trace::before {
  opacity: 0.35;
  animation-duration: 5s;
}
.btn-laser-trace:hover::before {
  opacity: 0.50;
  animation-duration: 2s;
}

/* Rounded variant for pill buttons */
.btn-laser-trace {
  border-radius: 8px;
}

@keyframes border-shimmer {
  0%   { background-position: 100% 0%; }
  25%  { background-position: 0% 0%; }
  50%  { background-position: 0% 100%; }
  75%  { background-position: 100% 100%; }
  100% { background-position: 100% 0%; }
}

/* ── Simple laser-hover for non-card elements (nav, links) ── */
.laser-hover {
  border: 1.5px solid transparent;
  border-radius: inherit;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.laser-hover:hover,
.laser-hover:focus-visible {
  border-color: var(--glow-border, var(--brand, #B95CE4));
  box-shadow: 0 0 12px rgba(185, 92, 228, 0.2);
}

/* ── Keep card children above the ::before laser ring ── */
.card-laser-hover > *,
.btn-laser-trace > *,
.laser-hover > * {
  position: relative;
  z-index: 1;
}

/* ── Text Laser — sweeps through nav words ── */
@media (prefers-reduced-motion: no-preference) {
  @keyframes text-laser-sweep {
    0%   { background-position: 0% center; }
    100% { background-position: 200% center; }
  }

  .s-link.laser-hover:hover .s-text,
  .nav-item.laser-hover:hover span:not(.nav-icon) {
    -webkit-text-fill-color: transparent;
    background-image: linear-gradient(
      90deg,
      var(--glow-border, var(--brand, #B95CE4)) 0%,
      var(--glow-border, var(--brand, #B95CE4)) 40%,
      rgba(255,255,255,0.35) 48%,
      rgba(255,255,255,0.35) 52%,
      var(--glow-border, var(--brand, #B95CE4)) 60%,
      var(--glow-border, var(--brand, #B95CE4)) 100%
    );
    background-size: 200% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    animation: text-laser-sweep 5s ease-in-out infinite;
  }
}

/* ── Animation Toggle ── */
html[data-animations="off"] *,
html[data-animations="off"] *::before,
html[data-animations="off"] *::after {
  animation: none !important;
  animation-duration: 0s !important;
  transition: none !important;
}
html[data-animations="off"] .btn-laser-trace,
html[data-animations="off"] .card-laser-hover:hover,
html[data-animations="off"] .laser-hover:hover {
  border: 1.5px solid var(--brand, #B95CE4);
}
html[data-animations="off"] .card-laser-hover::before,
html[data-animations="off"] .btn-laser-trace::before {
  animation: none !important;
  opacity: 0.25;
  background: var(--brand, #B95CE4);
}

@media (prefers-reduced-motion: reduce) {
  .btn-laser-trace,
  .card-laser-hover {
    border: 1.5px solid var(--accent-cyan, #00F0FF);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.15);
  }
  .card-laser-hover::before,
  .btn-laser-trace::before {
    animation: none;
    opacity: 0.25;
    background: var(--accent-cyan, #00F0FF);
  }
}
.toast.info    { border-left: 3px solid var(--color-primary);  }
