/* Mobile-First CSS Utilities for Orleans Gossiper */

/* Enhanced Mobile Breakpoints */
:root {
  --breakpoint-xs: 0px;      /* Small phones */
  --breakpoint-sm: 375px;    /* Phones */
  --breakpoint-md: 641px;    /* Large phones/small tablets */
  --breakpoint-lg: 769px;    /* Tablets */
  --breakpoint-xl: 1025px;   /* Desktop */
  
  /* Touch-friendly sizes */
  --touch-target-min: 44px;
  --touch-spacing: 12px;
  
  /* Mobile typography scale */
  --text-xs: 0.75rem;   /* 12px */
  --text-sm: 0.875rem;  /* 14px */
  --text-base: 1rem;    /* 16px - prevents iOS zoom */
  --text-lg: 1.125rem;  /* 18px */
  --text-xl: 1.25rem;   /* 20px */
  --text-2xl: 1.5rem;   /* 24px */
  --text-3xl: 1.75rem;  /* 28px */
}

/* Mobile-First Base Styles */
html {
  font-size: 16px; /* Prevent iOS zoom */
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-size: var(--text-base);
  line-height: 1.5;
  touch-action: manipulation; /* Improve touch responsiveness */
}

/* Touch Target Enhancements */
button, 
.btn, 
a[role="button"],
input[type="button"],
input[type="submit"],
.touch-target {
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  padding: var(--touch-spacing);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* Mobile Form Improvements */
input[type="text"],
input[type="email"], 
input[type="password"],
textarea,
select {
  min-height: var(--touch-target-min);
  font-size: var(--text-base); /* Prevent iOS zoom */
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  width: 100%;
  box-sizing: border-box;
}

/* Mobile Navigation */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e5e7eb;
  z-index: 50;
  padding: 8px 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.mobile-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  max-width: 500px;
  margin: 0 auto;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  text-decoration: none;
  color: #6b7280;
  font-size: var(--text-xs);
  font-weight: 500;
  min-height: var(--touch-target-min);
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
  color: #3b82f6;
  background: #eff6ff;
}

.mobile-nav-icon {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

/* Mobile Header Improvements */
.mobile-header {
  position: sticky;
  top: 0;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  z-index: 40;
  padding: 12px 16px;
}

.mobile-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 100%;
}

.mobile-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  flex: 1;
  text-align: center;
}

.mobile-header-actions {
  display: flex;
  gap: 8px;
}

/* Mobile Card Improvements */
.mobile-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #f3f4f6;
}

.mobile-card-content {
  font-size: var(--text-base);
  line-height: 1.6;
  color: #374151;
  margin-bottom: 12px;
}

.mobile-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.mobile-action-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Mobile Button Styles */
.mobile-btn {
  min-height: var(--touch-target-min);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: var(--text-sm);
  font-weight: 500;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.mobile-btn-primary {
  background: #3b82f6;
  color: white;
}

.mobile-btn-primary:hover {
  background: #2563eb;
}

.mobile-btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.mobile-btn-secondary:hover {
  background: #e5e7eb;
}

.mobile-btn-ghost {
  background: transparent;
  color: #6b7280;
  padding: 8px;
}

.mobile-btn-ghost:hover {
  color: #374151;
  background: #f9fafb;
}

/* Mobile Spacing System */
.mobile-container {
  padding: 0 16px;
  margin-bottom: 80px; /* Account for bottom nav */
}

.mobile-section {
  margin-bottom: 24px;
}

.mobile-spacing-xs { margin-bottom: 8px; }
.mobile-spacing-sm { margin-bottom: 12px; }
.mobile-spacing-md { margin-bottom: 16px; }
.mobile-spacing-lg { margin-bottom: 24px; }
.mobile-spacing-xl { margin-bottom: 32px; }

/* Responsive Image Handling */
.mobile-image {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Mobile Modal/Overlay */
.mobile-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  padding: 16px;
}

.mobile-modal-content {
  background: white;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
}

/* Swipe Indicators */
.swipe-indicator {
  position: relative;
  overflow: hidden;
}

.swipe-indicator::after {
  content: "← Swipe →";
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  font-size: var(--text-xs);
  color: #9ca3af;
  opacity: 0.7;
  pointer-events: none;
}

/* Responsive Breakpoints */
@media (max-width: 374px) {
  /* Extra small phones */
  .mobile-container {
    padding: 0 12px;
  }
  
  .mobile-title {
    font-size: var(--text-lg);
  }
  
  .mobile-nav-item {
    font-size: 0.625rem;
    padding: 6px 2px;
  }
}

@media (min-width: 375px) and (max-width: 640px) {
  /* Standard phones */
  .mobile-card {
    margin-bottom: 16px;
    padding: 18px;
  }
}

@media (min-width: 641px) {
  /* Large phones and up - start transitioning to tablet/desktop layout */
  .mobile-nav {
    display: none; /* Hide bottom nav on larger screens */
  }
  
  .mobile-container {
    margin-bottom: 0;
    max-width: 768px;
    margin-left: auto;
    margin-right: auto;
  }
  
  .mobile-card {
    padding: 24px;
    margin-bottom: 20px;
  }
}

@media (min-width: 769px) {
  /* Tablet and desktop */
  .mobile-header {
    position: static;
  }
  
  .mobile-container {
    padding: 0 32px;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .mobile-nav {
    background: #1f2937;
    border-top-color: #374151;
  }
  
  .mobile-nav-item {
    color: #9ca3af;
  }
  
  .mobile-nav-item:hover,
  .mobile-nav-item.active {
    color: #60a5fa;
    background: #1e3a8a;
  }
  
  .mobile-header {
    background: #1f2937;
    border-bottom-color: #374151;
  }
  
  .mobile-title {
    color: #f9fafb;
  }
  
  .mobile-card {
    background: #1f2937;
    border-color: #374151;
  }
  
  .mobile-card-content {
    color: #d1d5db;
  }
  
  .mobile-modal-content {
    background: #1f2937;
  }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .mobile-card {
    border: 2px solid;
  }
  
  .mobile-btn {
    border: 2px solid;
  }
}

/* Focus indicators for keyboard navigation */
.mobile-btn:focus,
.mobile-nav-item:focus,
button:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Loading states */
.mobile-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.mobile-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #e5e7eb;
  border-top: 2px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
