/* ============================================
   FenceX - Professional Interaction System
   TickTick-inspired hover, focus, and active states
   ============================================ */

/* Base Interactive Element */
.fx-interactive {
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.fx-interactive:hover {
  transform: translateY(-1px);
}

.fx-interactive:active {
  transform: translateY(0);
}

.fx-interactive:focus-visible {
  outline: 2px solid var(--color-accent, #5a8dff);
  outline-offset: 2px;
}

/* Button Variants */
.fx-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: none;
  text-decoration: none;
}

.fx-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.fx-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.fx-btn:focus-visible {
  outline: 1px solid var(--color-accent, #5a8dff);
  outline-offset: 3px;
}

.fx-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Primary Button */
.fx-btn-primary {
  background: var(--color-accent, #3b82f6);
  color: #fff;
  border: none;
  position: relative;
  overflow: hidden;
}

.fx-btn-primary:hover {
  background: var(--color-accent-hover, #60a5fa);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.28);
}

.fx-btn-primary:active {
  background: var(--color-accent, #3b82f6);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2);
  transform: translateY(1px);
}

:root[data-theme='light'] .fx-btn-primary:hover {
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.25);
}

/* Secondary Button */
.fx-btn-secondary {
  background: transparent;
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.12));
  color: var(--color-text-primary, #EAF2FF);
}

.fx-btn-secondary:hover {
  background: var(--color-surface, rgba(255, 255, 255, 0.06));
  border-color: var(--color-accent, #5a8dff);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

/* Ghost Button */
.fx-btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--color-text-primary, #EAF2FF);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.fx-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.fx-btn-ghost:active {
  background: rgba(255, 255, 255, 0.06);
}

:root[data-theme='light'] .fx-btn-ghost {
  background: rgba(12, 26, 43, 0.04);
  border-color: rgba(12, 26, 43, 0.15);
  color: var(--color-text-primary);
}

:root[data-theme='light'] .fx-btn-ghost:hover {
  background: rgba(12, 26, 43, 0.08);
  border-color: rgba(12, 26, 43, 0.25);
}

/* Danger Button */
.fx-btn-danger {
  background: rgba(255, 69, 69, 0.15);
  border: 1px solid rgba(255, 69, 69, 0.3);
  color: #ff7676;
}

.fx-btn-danger:hover {
  background: rgba(255, 69, 69, 0.25);
  border-color: rgba(255, 69, 69, 0.5);
  box-shadow: 0 8px 20px rgba(255, 69, 69, 0.25);
}

:root[data-theme='light'] .fx-btn-danger {
  color: #b02a2a;
  background: rgba(255, 107, 107, 0.15);
}

/* Link Variant */
.fx-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-accent, #5a8dff);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.fx-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--color-accent, #5a8dff);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.2s ease;
}

.fx-link:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.fx-link:hover {
  color: var(--color-accent, #5a8dff);
  filter: brightness(1.2);
}

/* Chip / Pill Button */
.fx-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.12));
  background: transparent;
  color: var(--color-text-primary, #EAF2FF);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.fx-chip:hover {
  background: var(--color-surface, rgba(255, 255, 255, 0.08));
  border-color: var(--color-accent, #5a8dff);
  transform: translateY(-1px);
}

.fx-chip:active {
  transform: translateY(0);
}

.fx-chip.active {
  background: var(--color-accent-soft, rgba(90, 141, 255, 0.18));
  border-color: var(--color-accent, #5a8dff);
  color: var(--color-accent, #5a8dff);
}

/* Card Link */
.fx-card-link {
  display: block;
  border-radius: 24px;
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.08));
  background: var(--fx-panel, rgba(4, 13, 33, 0.82));
  padding: 32px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.fx-card-link::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(90, 141, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.fx-card-link:hover {
  transform: translateY(-4px);
  border-color: var(--color-accent, #5a8dff);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

.fx-card-link:hover::before {
  opacity: 1;
}

.fx-card-link:active {
  transform: translateY(-2px);
}

/* Nav Link */
.fx-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--color-text-muted, rgba(234, 242, 255, 0.7));
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.fx-nav-link:hover {
  background: var(--color-surface, rgba(255, 255, 255, 0.06));
  color: var(--color-text-primary, #EAF2FF);
}

.fx-nav-link.active {
  background: var(--color-accent-soft, rgba(90, 141, 255, 0.18));
  color: var(--color-accent, #5a8dff);
}

.fx-nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--color-accent, #5a8dff);
  border-radius: 0 2px 2px 0;
}

/* Icon Button */
.fx-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.12));
  background: var(--color-surface, rgba(255, 255, 255, 0.04));
  color: var(--color-text-primary, #EAF2FF);
  transition: all 0.2s ease;
  cursor: pointer;
}

.fx-icon-btn:hover {
  background: var(--color-accent-soft, rgba(90, 141, 255, 0.18));
  border-color: var(--color-accent, #5a8dff);
  transform: scale(1.05);
}

.fx-icon-btn:active {
  transform: scale(0.98);
}

/* Input Focus States */
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--color-accent, #5a8dff);
  outline-offset: 2px;
  border-color: var(--color-accent, #5a8dff);
}

/* Disabled State */
.fx-btn:disabled,
.fx-chip:disabled,
.fx-icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Loading State */
.fx-btn.loading,
.fx-chip.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.fx-btn.loading::after,
.fx-chip.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  animation: fx-spin 0.6s linear infinite;
}

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

/* ============================================
   Global Animation Utilities
   Premium, fast micro-interactions (150-250ms)
   ============================================ */

/* Fade In */
@keyframes fx-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Fade In Up */
@keyframes fx-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Down */
@keyframes fx-fade-in-down {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scale In */
@keyframes fx-scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Slide In Left */
@keyframes fx-slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide In Right */
@keyframes fx-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Pop */
@keyframes fx-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Shake (for errors) */
@keyframes fx-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Pulse glow */
@keyframes fx-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(90, 141, 255, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(90, 141, 255, 0); }
}

/* Animation utility classes */
.fx-animate-fade-in {
  animation: fx-fade-in 0.2s ease-out forwards;
}

.fx-animate-fade-in-up {
  animation: fx-fade-in-up 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.fx-animate-fade-in-down {
  animation: fx-fade-in-down 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.fx-animate-scale-in {
  animation: fx-scale-in 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.fx-animate-slide-in-left {
  animation: fx-slide-in-left 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.fx-animate-slide-in-right {
  animation: fx-slide-in-right 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.fx-animate-pop {
  animation: fx-pop 0.3s ease-out;
}

.fx-animate-shake {
  animation: fx-shake 0.4s ease-out;
}

.fx-animate-pulse-glow {
  animation: fx-pulse-glow 2s ease-in-out infinite;
}

/* Stagger animation delays */
.fx-stagger-1 { animation-delay: 0.05s; }
.fx-stagger-2 { animation-delay: 0.1s; }
.fx-stagger-3 { animation-delay: 0.15s; }
.fx-stagger-4 { animation-delay: 0.2s; }
.fx-stagger-5 { animation-delay: 0.25s; }

/* Initially hidden for stagger animations */
[class*="fx-stagger-"] {
  opacity: 0;
}

/* Small Button Variant */
.fx-btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

/* Large Button Variant */
.fx-btn-lg {
  padding: 16px 32px;
  font-size: 1.05rem;
}

/* Light Theme Adjustments */
:root[data-theme='light'] .fx-btn-secondary {
  border-color: rgba(12, 26, 43, 0.12);
}

:root[data-theme='light'] .fx-btn-secondary:hover {
  background: rgba(12, 26, 43, 0.04);
  border-color: var(--color-accent, #3462ff);
}

:root[data-theme='light'] .fx-chip {
  border-color: rgba(12, 26, 43, 0.12);
}

:root[data-theme='light'] .fx-chip:hover {
  background: rgba(12, 26, 43, 0.04);
}

:root[data-theme='light'] .fx-card-link {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(12, 26, 43, 0.12);
}

:root[data-theme='light'] .fx-card-link:hover {
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

/* ============================================
   Alive Hover - Subtle tilt/shift on cards
   ============================================ */
.fx-alive-tilt {
  transition: transform 100ms ease-out, box-shadow 150ms ease;
  will-change: transform;
}

.fx-alive-tilt:hover {
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16);
}

:root[data-theme='light'] .fx-alive-tilt:hover {
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

/* Alive Glow — radial light that follows cursor on tilt */
.fx-alive-glow {
  position: relative;
  overflow: hidden;
  --glow-x: 50%;
  --glow-y: 50%;
}

.fx-alive-glow::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    ellipse 50% 60% at var(--glow-x) var(--glow-y),
    rgba(120, 170, 255, 0.18),
    transparent 70%
  );
  opacity: 0;
  transition: opacity 150ms ease;
  pointer-events: none;
  z-index: 2;
}

.fx-alive-glow:hover::after {
  opacity: 1;
}

:root[data-theme='light'] .fx-alive-glow::after {
  background: radial-gradient(
    ellipse 50% 60% at var(--glow-x) var(--glow-y),
    rgba(59, 130, 246, 0.12),
    transparent 70%
  );
}

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

  .fx-btn:hover,
  .fx-card-link:hover,
  .fx-feature-card:hover,
  .fx-icon-btn:hover,
  .fx-interactive:hover,
  .fx-alive-tilt:hover {
    transform: none !important;
  }

  [class*="fx-animate-"],
  [class*="fx-stagger-"] {
    animation: none !important;
    opacity: 1 !important;
  }
}
