/* ========================================
   MOBILE-FIRST UI SYSTEM
   Instagram/TikTok-level mobile experience
   ======================================== */

/* Base Mobile Animations */
@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

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

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

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

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

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

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

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

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-3deg); }
  75% { transform: rotate(3deg); }
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes ripple {
  0% { transform: scale(0); opacity: 0.5; }
  100% { transform: scale(4); opacity: 0; }
}

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

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.3); }
  50% { box-shadow: 0 0 40px rgba(139, 92, 246, 0.5); }
}

@keyframes bounce-once {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(0.95); }
  50% { transform: scale(1.05); }
  75% { transform: scale(0.98); }
}

@keyframes checkmark-draw {
  0% { stroke-dashoffset: 24; }
  100% { stroke-dashoffset: 0; }
}

@keyframes confetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-100px) rotate(720deg); opacity: 0; }
}

.animate-bounce-in {
  animation: bounceIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.animate-slide-up {
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-slide-down {
  animation: slideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-in {
  animation: fadeIn 0.25s ease-out forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 0.4s ease-out forwards;
  opacity: 0;
}

.animate-scale-in {
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-pulse-ring {
  animation: pulse-ring 1s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-wiggle {
  animation: wiggle 0.5s ease-in-out;
}

.animate-heartbeat {
  animation: heartbeat 1s ease-in-out infinite;
}

.animate-gradient {
  background-size: 200% 200%;
  animation: gradient-shift 3s ease infinite;
}

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

.animate-bounce-once {
  animation: bounce-once 0.5s ease-in-out;
}

/* Staggered animations for lists */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }

/* Skeleton loading shimmer */
.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 infinite;
}

/* ========================================
   TOUCH & INTERACTION STYLES
   ======================================== */

/* Touch feedback with ripple effect */
.touch-feedback {
  position: relative;
  overflow: hidden;
  transition: transform 0.1s ease-out, opacity 0.1s ease-out;
  -webkit-tap-highlight-color: transparent;
}

.touch-feedback:active {
  transform: scale(0.97);
}

.touch-feedback::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.15), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.touch-feedback:active::after {
  opacity: 1;
}

/* Press states for buttons */
.press-scale {
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}

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

/* Long press indicator */
.long-press {
  position: relative;
}

.long-press::before {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px solid transparent;
  border-radius: inherit;
  transition: border-color 0.3s;
}

.long-press:active::before {
  border-color: var(--brand-500);
  animation: pulse-ring 1s infinite;
}

/* Mobile card styles */
.mobile-card {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* ========================================
   SWIPE GESTURES & HINTS
   ======================================== */

/* Swipe action hints */
.swipe-hint {
  position: relative;
  overflow: hidden;
}

.swipe-hint::after {
  content: '';
  position: absolute;
  top: 0;
  right: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(139, 92, 246, 0.1) 50%,
    transparent 100%
  );
  animation: swipeHint 2s ease-in-out infinite;
}

@keyframes swipeHint {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(20%); }
}

/* Swipeable card */
.swipe-card {
  touch-action: pan-y;
  will-change: transform;
  transition: transform 0.2s ease-out;
}

.swipe-card.swiping {
  transition: none;
}

/* Swipe delete action */
.swipe-delete {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: linear-gradient(90deg, transparent, #ef4444);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 20px;
  opacity: 0;
  transition: opacity 0.2s;
}

.swipe-card.reveal-delete .swipe-delete {
  opacity: 1;
}

/* ========================================
   PULL TO REFRESH
   ======================================== */

/* Pull to refresh indicator */
.pull-indicator {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pull-indicator.pulling {
  transform: translateY(60px);
}

.pull-indicator.refreshing {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: translateY(60px) rotate(0deg); }
  to { transform: translateY(60px) rotate(360deg); }
}

/* Pull to refresh container */
.ptr-container {
  position: relative;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ptr-element {
  position: absolute;
  top: -60px;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.ptr-container.refreshing .ptr-element {
  transform: translateY(60px);
}

/* ========================================
   BOTTOM SHEET & MODALS
   ======================================== */

/* Bottom sheet styles */
.bottom-sheet {
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px 24px 0 0;
  max-height: 90vh;
}

.bottom-sheet.open {
  transform: translateY(0);
}

/* Bottom sheet handle */
.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: 12px auto;
}

/* Modal backdrop blur */
.modal-backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ========================================
   SAFE AREAS FOR NOTCHED DEVICES
   ======================================== */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .pb-safe {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  
  .mb-safe {
    margin-bottom: env(safe-area-inset-bottom);
  }
  
  .bottom-safe {
    bottom: env(safe-area-inset-bottom);
  }
  
  .pt-safe {
    padding-top: max(16px, env(safe-area-inset-top));
  }
  
  .h-safe-bottom {
    height: calc(100% - env(safe-area-inset-bottom));
  }
}

/* ========================================
   MOBILE-SPECIFIC UTILITIES
   ======================================== */

/* Hide scrollbar on mobile */
@media (max-width: 768px) {
  .hide-scrollbar::-webkit-scrollbar {
    display: none;
  }
  
  .hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  
  /* Smoother scrolling */
  .smooth-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  /* Horizontal scroll snap */
  .snap-scroll-x {
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  
  .snap-item {
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }
  
  /* Prevent text selection on interactive elements */
  button, a, .no-select {
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* Larger touch targets */
  .touch-target {
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Mobile typography */
  .mobile-heading {
    font-size: clamp(1.25rem, 5vw, 1.75rem);
    line-height: 1.2;
  }
  
  .mobile-text {
    font-size: clamp(0.875rem, 3.5vw, 1rem);
    line-height: 1.5;
  }
}

/* ========================================
   PAGE TRANSITIONS
   ======================================== */

/* Smooth page transitions */
.page-enter {
  opacity: 0;
  transform: translateX(10px);
}

.page-enter-active {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

.page-exit {
  opacity: 1;
}

.page-exit-active {
  opacity: 0;
  transition: opacity 0.15s ease-in;
}

/* iOS-style page slide */
.slide-right-enter {
  transform: translateX(100%);
}

.slide-right-enter-active {
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-right-exit-active {
  transform: translateX(-30%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   MOBILE CARD STYLES
   ======================================== */

/* Compact card for mobile */
.card-compact {
  padding: 12px;
  border-radius: 16px;
}

/* Card with touch feedback */
.card-touch {
  transition: transform 0.15s, box-shadow 0.15s;
}

.card-touch:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Floating card effect */
.card-float {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s, box-shadow 0.3s;
}

.card-float:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

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

/* Skeleton loading */
.skeleton-line {
  height: 16px;
  border-radius: 8px;
  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 infinite;
}

.skeleton-circle {
  border-radius: 50%;
  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 infinite;
}

/* Loading spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Text glow effect */
.text-glow {
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.3), 0 0 40px rgba(139, 92, 246, 0.2);
}

.text-glow-brand {
  text-shadow: 0 0 20px rgba(139, 92, 246, 0.5), 0 0 40px rgba(139, 92, 246, 0.3);
}

/* Card hover glow */
.hover-glow {
  transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.15), 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Number counter animation helper */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Smooth state transitions */
.state-transition {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   MOBILE NAV SPECIFIC
   ======================================== */

/* Nav item active state with gradient */
.nav-active-gradient {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(59, 130, 246, 0.1));
}

/* Nav item indicator */
.nav-indicator {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brand-500);
  box-shadow: 0 0 8px var(--brand-500);
}

/* Floating action button */
.fab {
  position: fixed;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 50;
}

.fab:active {
  transform: scale(0.92);
}

.fab-gradient {
  background: linear-gradient(135deg, var(--brand-500), #8b5cf6);
}

/* ========================================
   GLASSMORPHISM MOBILE
   ======================================== */

.glass-mobile {
  background: rgba(18, 18, 23, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
