/**
 * 999DEX DESIGN SYSTEM - INTERACTIONS
 *
 * Hover, focus, active states and micro-interactions
 * Accessibility-first with keyboard navigation support
 *
 * Version: 1.0.0
 * Last Updated: November 2, 2025
 * References: Agent 2 (Animations - interaction patterns)
 */

/* ========================================
   FOCUS STATES (Accessibility)
   ======================================== */

/* Default focus outline for keyboard navigation */
*:focus {
  outline: 2px solid var(--accent-purple);
  outline-offset: 2px;
}

/* Remove focus outline for mouse users (keeps keyboard accessible) */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Visible focus for keyboard users */
*:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 2px;
}

/* Custom focus states for specific elements */
.btn:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 2px;
}

.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

/* Card focus for keyboard navigation */
.token-card:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 4px;
  transform: translateY(-4px) scale(1.02);
}

/* ========================================
   HOVER STATES
   ======================================== */

/* Links */
a {
  color: var(--accent-purple);
  text-decoration: none;
  transition: color var(--transition-normal) var(--ease-out);
}

a:hover {
  color: #9333ea;
  text-decoration: underline;
}

/* Interactive elements cursor */
button,
a,
.clickable,
[role="button"],
[tabindex="0"] {
  cursor: pointer;
}

button:disabled,
a:disabled,
.disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ========================================
   BUTTON INTERACTIONS
   ======================================== */

/* Primary button hover with glow */
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-purple);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.3);
}

/* Success button hover */
.btn-success:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-green);
}

.btn-success:active:not(:disabled) {
  transform: translateY(0);
}

/* Danger button hover */
.btn-danger:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-red);
}

.btn-danger:active:not(:disabled) {
  transform: translateY(0);
}

/* Secondary button hover */
.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.btn-secondary:active:not(:disabled) {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.1);
}

/* Ghost button hover */
.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* ========================================
   CARD INTERACTIONS
   ======================================== */

/* Token card hover (from Agent 3) */
.token-card {
  transition:
    transform 200ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 200ms ease-out,
    box-shadow 200ms ease-out;
}

.token-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.15);
}

.token-card:active {
  transform: translateY(-2px) scale(1.01);
  transition-duration: 100ms;
}

/* Generic card hover */
.card-interactive {
  cursor: pointer;
  transition:
    transform var(--transition-normal) var(--ease-out),
    box-shadow var(--transition-normal) var(--ease-out);
}

.card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

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

/* ========================================
   FORM INTERACTIONS
   ======================================== */

/* Input hover */
.form-input:hover:not(:disabled),
.form-select:hover:not(:disabled),
.form-textarea:hover:not(:disabled) {
  border-color: var(--border-hover);
}

/* Input focus */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent-purple);
  background: rgba(255, 255, 255, 0.08);
}

/* Floating label animation */
.form-floating {
  position: relative;
}

.form-floating label {
  position: absolute;
  top: 50%;
  left: var(--input-padding-x);
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition:
    transform var(--transition-normal) var(--ease-out),
    font-size var(--transition-normal) var(--ease-out),
    color var(--transition-normal) var(--ease-out);
}

.form-floating input:focus + label,
.form-floating input:not(:placeholder-shown) + label {
  transform: translateY(-40px) scale(0.85);
  color: var(--accent-purple);
  font-size: var(--font-size-sm);
}

/* Checkbox and radio interactions */
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--accent-purple);
}

input[type="checkbox"]:hover,
input[type="radio"]:hover {
  outline: 2px solid rgba(168, 85, 247, 0.3);
  outline-offset: 2px;
}

/* ========================================
   MODAL INTERACTIONS
   ======================================== */

/* Modal backdrop click hint */
.modal-backdrop {
  cursor: pointer;
}

.modal {
  cursor: default;
}

/* Modal close button hover */
.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  transform: scale(1.1);
}

.modal-close:active {
  transform: scale(0.95);
}

/* ========================================
   TOAST INTERACTIONS
   ======================================== */

/* Toast close button hover */
.toast-close:hover {
  color: var(--text-primary);
  transform: scale(1.2);
}

.toast-close:active {
  transform: scale(0.9);
}

/* Toast hover (pause auto-dismiss) */
.toast:hover {
  box-shadow: var(--shadow-2xl);
}

/* ========================================
   TABLE INTERACTIONS
   ======================================== */

/* Table row hover */
.table tbody tr {
  transition: background-color var(--transition-fast) var(--ease-out);
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Clickable table rows */
.table tbody tr.clickable {
  cursor: pointer;
}

.table tbody tr.clickable:hover {
  background: rgba(255, 255, 255, 0.08);
}

.table tbody tr.clickable:active {
  background: rgba(255, 255, 255, 0.03);
}

/* ========================================
   BADGE INTERACTIONS
   ======================================== */

/* Clickable badges */
.badge-clickable {
  cursor: pointer;
  transition:
    transform var(--transition-fast) var(--ease-out),
    box-shadow var(--transition-fast) var(--ease-out);
}

.badge-clickable:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.badge-clickable:active {
  transform: scale(0.98);
}

/* ========================================
   NAVIGATION INTERACTIONS
   ======================================== */

/* Navigation link hover */
.nav-link {
  position: relative;
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-normal) var(--ease-out);
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link.active {
  color: var(--accent-purple);
}

/* Underline animation for nav links */
.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: var(--spacing-md);
  right: var(--spacing-md);
  height: 2px;
  background: var(--accent-purple);
  transform: scaleX(0);
  transition: transform var(--transition-normal) var(--ease-out);
}

.nav-link:hover::after,
.nav-link.active::after {
  transform: scaleX(1);
}

/* ========================================
   SCROLL INTERACTIONS
   ======================================== */

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Scroll to top button */
.scroll-to-top {
  position: fixed;
  bottom: var(--spacing-lg);
  right: var(--spacing-lg);
  width: 48px;
  height: 48px;
  background: var(--accent-purple);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  transition:
    opacity var(--transition-normal) var(--ease-out),
    transform var(--transition-normal) var(--ease-out);
  z-index: var(--z-fixed);
}

.scroll-to-top.visible {
  opacity: 1;
  transform: scale(1);
}

.scroll-to-top:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-glow-purple);
}

.scroll-to-top:active {
  transform: scale(0.95);
}

/* ========================================
   DRAG AND DROP INTERACTIONS
   ======================================== */

/* Drag over state */
.drag-drop-zone {
  border: 2px dashed var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  text-align: center;
  transition:
    border-color var(--transition-normal) var(--ease-out),
    background-color var(--transition-normal) var(--ease-out);
}

.drag-drop-zone:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.03);
}

.drag-drop-zone.drag-over {
  border-color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.1);
}

/* ========================================
   LOADING STATES
   ======================================== */

/* Button loading state */
.btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 400ms linear infinite;
}

/* Card loading state */
.card.loading {
  pointer-events: none;
  opacity: 0.7;
}

/* ========================================
   SELECTION INTERACTIONS
   ======================================== */

/* Text selection color */
::selection {
  background: rgba(168, 85, 247, 0.3);
  color: var(--text-primary);
}

::-moz-selection {
  background: rgba(168, 85, 247, 0.3);
  color: var(--text-primary);
}

/* Disable text selection on UI elements */
button,
.btn,
.badge,
.token-card,
[role="button"] {
  user-select: none;
}

/* ========================================
   ACTIVE/PRESSED STATES
   ======================================== */

/* Generic active state */
.active-press {
  transition: transform var(--transition-fast) var(--ease-in-out);
}

.active-press:active {
  transform: scale(0.95);
}

/* Icon button active state */
.icon-btn:active {
  transform: scale(0.9);
}

/* ========================================
   RIPPLE EFFECT (Material Design)
   ======================================== */

.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  opacity: 0;
}

.ripple:active::before {
  width: 300px;
  height: 300px;
  opacity: 1;
  transition: width 600ms, height 600ms, opacity 300ms;
}

/* ========================================
   TOOLTIP INTERACTIONS
   ======================================== */

.tooltip-content {
  opacity: 0;
  transform: translateX(-50%) translateY(-4px);
  transition:
    opacity var(--transition-normal) var(--ease-out),
    transform var(--transition-normal) var(--ease-out);
}

.tooltip:hover .tooltip-content {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========================================
   PROGRESS BAR INTERACTIONS
   ======================================== */

.progress-bar {
  transition: width 300ms var(--ease-out);
}

/* Animated progress on hover */
.progress:hover .progress-bar {
  box-shadow: 0 0 8px currentColor;
}

/* ========================================
   ACCESSIBILITY: REDUCED MOTION
   ======================================== */

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

  html {
    scroll-behavior: auto !important;
  }

  /* Maintain hover states but remove transitions */
  .token-card:hover,
  .card-interactive:hover,
  .btn:hover {
    transition: none;
  }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */

@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .token-card:hover {
    transform: none;
    border-color: var(--border-primary);
    box-shadow: var(--card-shadow);
  }

  /* Larger touch targets */
  button,
  .btn,
  a,
  input,
  select,
  textarea {
    min-height: 44px;
    min-width: 44px;
  }

  /* Remove hover transitions on touch */
  * {
    transition-duration: 0ms;
  }

  /* Keep active states for feedback */
  .token-card:active {
    transform: scale(0.98);
  }

  .btn:active {
    transform: scale(0.95);
  }
}

/* ========================================
   CUSTOM CURSOR STATES
   ======================================== */

.cursor-pointer {
  cursor: pointer;
}

.cursor-not-allowed {
  cursor: not-allowed;
}

.cursor-grab {
  cursor: grab;
}

.cursor-grabbing {
  cursor: grabbing;
}

.cursor-help {
  cursor: help;
}

/* ========================================
   FOCUS TRAPPING (for modals, dropdowns)
   ======================================== */

.focus-trap {
  position: relative;
}

.focus-trap::before,
.focus-trap::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
}
