/*
 * Premium Motion System — Phase 1
 * Single source of truth for motion tokens, keyframes, and interaction utilities.
 * Lazy-loaded by components that need it.
 * All effects assume overflow-hidden parent for containment.
 */

:root {
  /* Easing tokens */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  /* Duration tokens */
  --duration-instant: 100ms;
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

/* ─── Keyframes ─── */

@keyframes icon-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

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

@keyframes press-down {
  0% { transform: scale(1); }
  50% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

@keyframes glow-contained {
  0%, 100% { box-shadow: inset 0 0 0 0 hsl(var(--primary) / 0); }
  50% { box-shadow: inset 0 0 20px 0 hsl(var(--primary) / 0.08); }
}

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

@keyframes icon-bounce-in {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ─── Interaction utilities ─── */

.motion-press {
  transition: transform var(--duration-fast) var(--ease-spring),
              box-shadow var(--duration-fast) var(--ease-smooth);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.motion-press:active {
  transform: scale(0.97);
}

.motion-lift {
  transition: transform var(--duration-normal) var(--ease-out-expo),
              box-shadow var(--duration-normal) var(--ease-smooth);
}
.motion-lift:hover {
  transform: translateY(-1px);
}

/* Combined press + lift for interactive cards */
.motion-press.motion-lift:hover {
  transform: translateY(-1px);
}
.motion-press.motion-lift:active {
  transform: scale(0.97) translateY(0);
}

/* ─── Icon utilities ─── */

.motion-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--duration-fast) var(--ease-spring),
              color var(--duration-normal) var(--ease-smooth),
              opacity var(--duration-normal) var(--ease-smooth);
  -webkit-user-select: none;
  user-select: none;
}
.motion-icon:hover {
  transform: scale(1.1);
}
.motion-icon:active {
  transform: scale(0.85);
}

.motion-icon-pulse {
  animation: icon-breathe 2s var(--ease-smooth) infinite;
}

.motion-icon-loading {
  animation: icon-spin-contained 1s linear infinite;
  opacity: 0.6;
}

.motion-icon-bounce-in {
  animation: icon-bounce-in var(--duration-slow) var(--ease-spring) forwards;
}

/* ─── Effect utilities (must live inside overflow-hidden parent) ─── */

.motion-glow {
  animation: glow-contained 3s var(--ease-smooth) infinite;
}

.motion-shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    hsl(var(--primary) / 0.06) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer-sweep 2.5s var(--ease-smooth) infinite;
}

/* ─── Container utility ─── */

.motion-container {
  overflow: hidden;
  border-radius: 1rem; /* rounded-2xl */
  position: relative;
  isolation: isolate;
}

/* ─── Focus-visible premium ring ─── */

.motion-focus-ring:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px hsl(var(--background)),
              0 0 0 4px hsl(var(--primary) / 0.4);
}

/* ═══════════════════════════════════════════════
   Phase 3: AI Feature Styling
   Distinct visual treatments for AI-powered features.
   All effects contained within overflow-hidden parents.
   ═══════════════════════════════════════════════ */

/* AI shimmer — a brighter, wider sweep than standard shimmer */
@keyframes ai-shimmer {
  0% { background-position: -300% 0; }
  100% { background-position: 300% 0; }
}

/* AI border glow — subtle pulsing border highlight */
@keyframes ai-border-glow {
  0%, 100% { border-color: hsl(var(--primary) / 0.15); }
  50% { border-color: hsl(var(--primary) / 0.35); }
}

/* AI icon float — gentle vertical hover */
@keyframes ai-icon-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* AI sparkle — brief flash on load */
@keyframes ai-sparkle {
  0% { opacity: 0; transform: scale(0.8) rotate(-10deg); }
  50% { opacity: 1; transform: scale(1.1) rotate(5deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ─── AI utility classes ─── */

/* Container shimmer overlay — place as pseudo or child inside overflow-hidden */
.ai-shimmer-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 0%,
    transparent 35%,
    hsl(var(--primary) / 0.04) 45%,
    hsl(var(--primary) / 0.08) 50%,
    hsl(var(--primary) / 0.04) 55%,
    transparent 65%,
    transparent 100%
  );
  background-size: 300% 100%;
  animation: ai-shimmer 4s var(--ease-smooth) infinite;
  pointer-events: none;
  z-index: 1;
}

/* AI card treatment — pulsing border + inner glow */
.ai-card {
  animation: ai-border-glow 3s var(--ease-smooth) infinite;
  position: relative;
}
.ai-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 24px 0 hsl(var(--primary) / 0.04);
  pointer-events: none;
}

/* AI icon — gentle float animation */
.ai-icon-float {
  animation: ai-icon-float 3s var(--ease-smooth) infinite;
}

/* AI sparkle entrance */
.ai-sparkle-in {
  animation: ai-sparkle var(--duration-slow) var(--ease-spring) forwards;
}

/* AI badge — small accent indicator */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 9999px;
  background: linear-gradient(135deg, hsl(var(--primary) / 0.12), hsl(var(--primary) / 0.06));
  color: hsl(var(--primary));
  border: 1px solid hsl(var(--primary) / 0.15);
}

/* AI gradient accent line — thin top highlight for AI cards */
.ai-accent-line {
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    hsl(var(--primary) / 0.3),
    hsl(var(--primary) / 0.5),
    hsl(var(--primary) / 0.3),
    transparent
  );
  z-index: 2;
  pointer-events: none;
}
