/**
 * TOKEN CARD COMPONENT - 999DEX
 *
 * Pump.fun-level quality token cards with smooth animations,
 * hover effects, skeleton loaders, and responsive design.
 *
 * Version: 1.0.0
 * Agent: Implementation Agent 11
 * Date: November 2, 2025
 * References: Agent 3 (Token Card Specs), Agent 9 (Design System)
 */

/* ========================================
   SHIMMER ANIMATION
   ======================================== */

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

/* ========================================
   TOKEN CARD BASE
   ======================================== */

.token-card {
  background: var(--card-bg);
  border: var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--spacing-md);
  transition: var(--transition-all-normal);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  position: relative;
  overflow: hidden;
}

/* Hover state - pump.fun style */
.token-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Active/click state */
.token-card:active {
  transform: translateY(-2px) scale(1.01);
}

/* ========================================
   IMAGE SECTION
   ======================================== */

.token-card__image-wrapper {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-tertiary);
  width: 100%;
  /* Height auto from aspect-ratio */
}

.token-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal) var(--ease-out);
}

/* Image hover zoom */
.token-card:hover .token-card__image {
  transform: scale(1.05);
}

/* Loading state shimmer */
.token-card__image[data-loading="true"],
.token-card__image-wrapper.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* ========================================
   BADGES (NEW/TRENDING)
   ======================================== */

.token-card__badges {
  position: absolute;
  top: var(--spacing-sm);
  left: var(--spacing-sm);
  display: flex;
  gap: var(--spacing-xs);
  z-index: 2;
}

.token-card__badge {
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  backdrop-filter: blur(4px);
}

.token-card__badge--new {
  background: var(--accent-green);
  color: var(--bg-primary);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.token-card__badge--trending {
  background: var(--accent-red);
  color: white;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.token-card__badge--graduated {
  background: var(--accent-purple);
  color: white;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

/* ========================================
   INFO SECTION
   ======================================== */

.token-card__info {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.token-card__name {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: var(--transition-colors);
}

.token-card:hover .token-card__name {
  color: var(--accent-purple);
}

.token-card__symbol {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

.token-card__description {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  line-height: var(--line-height-normal);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: var(--spacing-xs);
}

/* ========================================
   STATS SECTION
   ======================================== */

.token-card__stats {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.token-card__stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-xs);
}

.token-card__stat-label {
  color: var(--text-tertiary);
  font-weight: var(--font-weight-medium);
}

.token-card__stat-value {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

/* Specific stat colors */
.token-card__market-cap {
  color: var(--accent-purple);
}

.token-card__volume {
  color: var(--accent-cyan);
}

.token-card__creator {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100px;
  font-family: var(--font-family-mono);
}

/* ========================================
   PROGRESS BAR (BONDING CURVE)
   ======================================== */

.token-card__progress-section {
  margin-top: var(--spacing-sm);
}

.token-card__progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.token-card__progress-label {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  font-weight: var(--font-weight-medium);
}

.token-card__progress-percentage {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.token-card__progress {
  width: 100%;
  height: var(--spacing-xs);
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.token-card__progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--text-primary), rgba(255, 255, 255, 0.8));
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  transition: width var(--transition-slow);
  border-radius: var(--radius-sm);
  position: relative;
}

/* Progress fill glow effect */
.token-card__progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6));
  border-radius: 2px;
}

/* ========================================
   FOOTER SECTION (HOLDERS/TRADES)
   ======================================== */

.token-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--spacing-sm);
  border-top: 1px solid var(--border-secondary);
  margin-top: var(--spacing-sm);
}

.token-card__footer-stat {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-weight: var(--font-weight-medium);
}

.token-card__footer-stat-value {
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
}

/* ========================================
   RESPONSIVE GRID
   ======================================== */

.token-grid {
  display: grid;
  gap: var(--token-grid-gap-desktop);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

/* Mobile: 2 columns, smaller cards */
@media (max-width: 768px) {
  .token-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--token-grid-gap-mobile);
  }

  .token-card {
    padding: var(--spacing-sm);
  }

  .token-card__name {
    font-size: var(--font-size-sm);
  }

  .token-card__symbol {
    font-size: var(--font-size-xs);
  }

  .token-card__description {
    display: none; /* Hide description on mobile for cleaner look */
  }
}

/* Tablet: 3-4 columns */
@media (min-width: 769px) and (max-width: 1024px) {
  .token-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--token-grid-gap-tablet);
  }
}

/* Large desktop: 5-6 cards per row */
@media (min-width: 1440px) {
  .token-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--token-grid-gap-desktop);
  }
}

/* ========================================
   SKELETON LOADERS
   ======================================== */

.token-card--skeleton .skeleton-title {
  height: 20px;
  width: 70%;
  margin-bottom: var(--spacing-xs);
}

.token-card--skeleton .skeleton-text {
  height: 14px;
  margin-bottom: var(--spacing-xs);
}

/* ========================================
   ANIMATIONS & SPECIAL EFFECTS
   ======================================== */

/* New token animation (slide in + glow) */
@keyframes slideInGlow {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  50% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 1;
  }
}

.token-card--new {
  animation: slideInGlow 600ms var(--ease-out);
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

/* Pulse animation for updates */
@keyframes pulseBorder {
  0%, 100% {
    border-color: var(--border-primary);
  }
  50% {
    border-color: rgba(168, 85, 247, 0.6);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
  }
}

.token-card--pulse {
  animation: pulseBorder 1s ease-in-out;
}

/* Graduation celebration animation */
@keyframes celebrate {
  0%, 100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.05) rotate(-2deg);
  }
  75% {
    transform: scale(1.05) rotate(2deg);
  }
}

.token-card--celebrate {
  animation: celebrate 1.2s ease-in-out;
  box-shadow: 0 0 30px rgba(168, 85, 247, 0.5);
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus state for keyboard navigation */
.token-card:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .token-card {
    border-width: 2px;
  }

  .token-card:hover {
    border-width: 3px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .token-card,
  .token-card__image,
  .token-card__progress-fill {
    transition: none;
  }

  .token-card:hover {
    transform: none;
  }

  .token-card:hover .token-card__image {
    transform: none;
  }

  .token-card--new,
  .token-card--pulse,
  .token-card--celebrate {
    animation: none;
  }

  .token-card__image-wrapper.skeleton {
    animation: none;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .token-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
  }

  .token-card:hover {
    transform: none;
    box-shadow: none;
  }

  .token-card__badge {
    box-shadow: none;
  }
}
