/* Mobile-First Design System */

/* CSS Custom Properties for Mobile */
:root {
  /* Mobile spacing scale */
  --mobile-xs: 0.25rem;   /* 4px */
  --mobile-sm: 0.5rem;    /* 8px */
  --mobile-md: 0.75rem;   /* 12px */
  --mobile-lg: 1rem;      /* 16px */
  --mobile-xl: 1.5rem;    /* 24px */
  --mobile-2xl: 2rem;     /* 32px */
  --mobile-3xl: 3rem;     /* 48px */
  
  /* Mobile touch targets */
  --touch-target-min: 44px;
  --touch-target-ideal: 48px;
  
  /* Mobile safe areas */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  
  /* Mobile breakpoints */
  --mobile-breakpoint: 480px;
  --tablet-breakpoint: 768px;
}

/* Mobile-only styles */
@media (max-width: 767px) {
  
  /* Base mobile optimizations */
  * {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* Allow text selection in specific areas */
  .mobile-selectable,
  input, textarea, [contenteditable] {
    -webkit-user-select: text;
    user-select: text;
  }
  
  /* Prevent overscroll but keep smooth scrolling */
  html, body {
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  /* Mobile viewport optimizations */
  html {
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
  }
  
  body {
    font-size: 16px; /* Prevent iOS zoom on input focus */
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Ensure body respects safe areas */
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
  }
  
  /* Mobile spacing utilities */
  .mobile-space-xs { margin-bottom: var(--mobile-xs); }
  .mobile-space-sm { margin-bottom: var(--mobile-sm); }
  .mobile-space-md { margin-bottom: var(--mobile-md); }
  .mobile-space-lg { margin-bottom: var(--mobile-lg); }
  .mobile-space-xl { margin-bottom: var(--mobile-xl); }
  .mobile-space-2xl { margin-bottom: var(--mobile-2xl); }
  
  /* Mobile padding utilities */
  .mobile-p-xs { padding: var(--mobile-xs); }
  .mobile-p-sm { padding: var(--mobile-sm); }
  .mobile-p-md { padding: var(--mobile-md); }
  .mobile-p-lg { padding: var(--mobile-lg); }
  .mobile-p-xl { padding: var(--mobile-xl); }
  .mobile-p-2xl { padding: var(--mobile-2xl); }
  
  /* Mobile touch targets */
  .mobile-touch-target {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .mobile-touch-target-ideal {
    min-height: var(--touch-target-ideal);
    min-width: var(--touch-target-ideal);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Mobile card optimizations */
  .mobile-card {
    border-radius: 16px;
    padding: var(--mobile-lg);
    margin-bottom: var(--mobile-md);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
  }
  
  .mobile-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  }
  
  /* Mobile button optimizations */
  .mobile-button {
    height: var(--touch-target-ideal);
    padding: 0 var(--mobile-lg);
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }
  
  .mobile-button:active {
    transform: scale(0.96);
  }
  
  /* Mobile input optimizations */
  .mobile-input {
    height: var(--touch-target-ideal);
    padding: 0 var(--mobile-md);
    border-radius: 12px;
    font-size: 16px; /* Prevent iOS zoom */
    border: 2px solid transparent;
    transition: all 0.2s ease;
  }
  
  .mobile-input:focus {
    border-color: hsl(var(--primary));
    outline: none;
    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1);
  }
  
  /* Mobile navigation optimizations */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: hsl(var(--background) / 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid hsl(var(--border) / 0.2);
    padding-bottom: calc(var(--safe-area-bottom) + 10px);
  }
  
  /* iPhone home button protection - extra padding for devices with home indicator */
  @supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-nav {
      padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
    }
  }
  
  /* Additional protection for devices without safe area support */
  @supports not (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-nav {
      padding-bottom: 30px;
    }
  }
  
  /* Mobile safe area utilities */
  .mobile-safe-top {
    padding-top: var(--safe-area-top);
  }
  
  .mobile-safe-bottom {
    padding-bottom: var(--safe-area-bottom);
  }
  
  /* Fixed header with safe area support */
  .mobile-fixed-header {
    position: fixed;
    top: 12px; /* Move header down by 20px */
    left: 0;
    right: 0;
    z-index: 1000;
    background: hsl(var(--background) / 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid hsl(var(--border) / 0.2);
    padding-top: calc(var(--safe-area-top) + 28px);
    padding-bottom: 1px;
  }
  
  /* Mobile gesture optimizations */
  .mobile-gesture-area {
    touch-action: pan-y;
  }
  
  .mobile-gesture-horizontal {
    touch-action: pan-x;
  }
  
  /* Mobile performance optimizations */
  .mobile-optimized {
    will-change: transform;
    transform: translateZ(0);
  }
  
  /* Mobile progress bar optimizations */
  .mobile-progress-container {
    overflow: visible !important;
    position: relative;
  }
  
  .mobile-progress-bar {
    position: absolute;
    z-index: 10;
  }
  
  /* Ensure progress bars are visible on mobile */
  .mobile-journey-view {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Mobile typography optimizations */
  .mobile-text-xs { font-size: 12px; line-height: 16px; }
  .mobile-text-sm { font-size: 14px; line-height: 20px; }
  .mobile-text-base { font-size: 16px; line-height: 24px; }
  .mobile-text-lg { font-size: 18px; line-height: 28px; }
  .mobile-text-xl { font-size: 20px; line-height: 28px; }
  .mobile-text-2xl { font-size: 24px; line-height: 32px; }
  .mobile-text-3xl { font-size: 30px; line-height: 36px; }
  
  /* Mobile grid optimizations */
  .mobile-grid {
    display: grid;
    gap: var(--mobile-md);
    grid-template-columns: 1fr;
  }
  
  .mobile-grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .mobile-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  /* Mobile flex optimizations */
  .mobile-flex {
    display: flex;
    gap: var(--mobile-sm);
  }
  
  .mobile-flex-col {
    display: flex;
    flex-direction: column;
    gap: var(--mobile-sm);
  }
  
  /* Mobile animation optimizations */
  .mobile-fade-in {
    animation: mobileFadeIn 0.3s ease-out;
  }
  
  .mobile-slide-up {
    animation: mobileSlideUp 0.3s ease-out;
  }
  
  .mobile-scale-in {
    animation: mobileScaleIn 0.2s ease-out;
  }
  
  /* Mobile loading states */
  .mobile-loading {
    opacity: 0.6;
    pointer-events: none;
  }
  
  .mobile-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid hsl(var(--primary));
    border-top-color: transparent;
    border-radius: 50%;
    animation: mobileSpin 1s linear infinite;
  }
  
  /* Mobile haptic feedback simulation */
  .mobile-haptic {
    transition: all 0.1s ease;
  }
  
  .mobile-haptic:active {
    transform: scale(0.95);
  }
  
  /* Mobile accessibility */
  .mobile-focus-visible {
    outline: 2px solid hsl(var(--primary));
    outline-offset: 2px;
  }
  
  /* Mobile dark mode optimizations */
  @media (prefers-color-scheme: dark) {
    .mobile-card {
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
  }
}

/* Mobile animations */
@keyframes mobileFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

@keyframes mobileSpin {
  to {
    transform: rotate(360deg);
  }
}

/* Mobile-specific component overrides */
@media (max-width: 767px) {
  /* Override existing components for mobile */
@media (max-width: 767px) {
  .card {
    border-radius: 16px;
    padding: var(--mobile-lg);
    margin-bottom: var(--mobile-md);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
  }
  
  .card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  }
  @media (prefers-color-scheme: dark) {
    .card {
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
  }
  .button {
    height: var(--touch-target-ideal);
    padding: 0 var(--mobile-lg);
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }
  
  .button:active {
    transform: scale(0.96);
  }
  .input {
    height: var(--touch-target-ideal);
    padding: 0 var(--mobile-md);
    border-radius: 12px;
    font-size: 16px; /* Prevent iOS zoom */
    border: 2px solid transparent;
    transition: all 0.2s ease;
  }
  
  .input:focus {
    border-color: hsl(var(--primary));
    outline: none;
    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1);
  }
}
  
  /* Mobile-specific spacing overrides */
  .space-y-4 > * + * {
    margin-top: var(--mobile-md);
  }
  
  .space-y-6 > * + * {
    margin-top: var(--mobile-lg);
  }
  
  .space-y-8 > * + * {
    margin-top: var(--mobile-xl);
  }
  
  /* Mobile-specific padding overrides */
  .p-4 {
    padding: var(--mobile-lg);
  }
  
  .p-6 {
    padding: var(--mobile-xl);
  }
  
  .px-4 {
    padding-left: var(--mobile-lg);
    padding-right: var(--mobile-lg);
  }
  
  .py-4 {
    padding-top: var(--mobile-lg);
    padding-bottom: var(--mobile-lg);
  }
} 
