/* 
 * MOBILE OPTIMIZATIONS
 * Ensures optimal display and performance on mobile devices
 */

/* ===== MOBILE VIEWPORT FIXES ===== */

/* Fix for iOS viewport height issues */
@supports (-webkit-touch-callout: none) {
  /* iOS only */
  .modal-overlay,
  .landing-container {
    min-height: -webkit-fill-available;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
  }
}

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

/* Increase touch targets for mobile */
@media (max-width: 768px) {
  .nav-contact-btn,
  .policies-btn,
  .social-link,
  .form-submit,
  .modal-close,
  .policy-nav-btn {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Add padding to clickable areas */
  .nav-contact-btn,
  .form-submit {
    padding: 12px 24px;
  }
  
  .social-link,
  .policies-btn {
    width: 48px;
    height: 48px;
  }
}

/* ===== RESPONSIVE TYPOGRAPHY ===== */

@media (max-width: 768px) {
  /* Prevent text from being too small */
  body {
    font-size: 16px;
    line-height: 1.6;
  }
  
  /* Adjust heading sizes */
  h1 {
    font-size: 2rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  /* Form labels */
  .form-group label {
    font-size: 14px;
  }
}

/* ===== MOBILE LAYOUT ADJUSTMENTS ===== */

@media (max-width: 768px) {
  /* Adjust navigation */
  .hero-nav {
    padding: var(--space-lg) var(--space-lg);
  }
  
  /* Adjust modal padding */
  .modal-content {
    width: 95%;
    max-width: 95%;
    margin: var(--space-md);
    padding: var(--space-lg);
    max-height: 90vh;
  }
  
  /* Adjust action area spacing */
  .action-area {
    gap: var(--space-sm);
    padding-left: var(--space-lg);
    padding-right: var(--space-lg);
    padding-bottom: calc(var(--space-2xl) + env(safe-area-inset-bottom, 0));
  }
  
  /* Stack policy navigation on mobile */
  .policies-nav {
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .policy-nav-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Disable animations on low-end devices */
@media (max-width: 768px) and (hover: none) {
  * {
    animation-duration: 0.3s !important;
    transition-duration: 0.3s !important;
  }
  
  /* Disable complex animations */
  .modal-content {
    animation: none !important;
    transform: none !important;
  }
}

/* ===== ORIENTATION HANDLING ===== */

/* Landscape mode adjustments */
@media (max-width: 896px) and (orientation: landscape) {
  .modal-content {
    max-height: 85vh;
    margin: var(--space-sm);
  }
  
  .landing-container {
    min-height: 100vh;
  }
  
  /* Consistent spacing in landscape */
  .action-area {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0));
  }
}

/* ===== MOBILE SCROLLING ===== */

/* Improve scrolling performance */
.modal-content,
.policy-content {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

/* Prevent body scroll when modal is open */
body.modal-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
  -webkit-overflow-scrolling: auto;
}

/* ===== KEYBOARD HANDLING ===== */

/* Prevent zoom on input focus (already in cross-browser but reinforced) */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px !important;
    transform: scale(1) !important;
  }
  
  /* Adjust form spacing when keyboard is visible */
  .contact-form.keyboard-visible {
    padding-bottom: 50vh;
  }
}

/* ===== MOBILE IMAGE OPTIMIZATIONS ===== */

@media (max-width: 768px) {
  /* Optimize background image for mobile */
  .background-image {
    /* Use smaller image on mobile */
    object-fit: cover;
    object-position: center;
  }
  
  /* Reduce overlay opacity on mobile for better visibility */
  .background-overlay {
    background: rgba(10, 10, 15, 0.7);
  }
}

/* ===== MOBILE-SPECIFIC HOVER STATES ===== */

/* Remove hover effects on touch devices */
@media (hover: none) and (pointer: coarse) {
  .nav-contact-btn:hover,
  .policies-btn:hover,
  .social-link:hover,
  .form-submit:hover,
  .policy-nav-btn:hover {
    transform: none !important;
    box-shadow: none !important;
    background-color: inherit !important;
  }
  
  /* Add active states for feedback */
  .nav-contact-btn:active,
  .policies-btn:active,
  .social-link:active,
  .form-submit:active {
    transform: scale(0.95) !important;
    opacity: 0.8;
  }
}

/* ===== SAFE AREA INSETS (iPhone X+) ===== */

@supports (padding: max(0px)) {
  .hero-nav {
    padding-top: max(var(--space-md), env(safe-area-inset-top));
  }
  
  .action-area {
    padding-bottom: max(var(--space-xl), env(safe-area-inset-bottom));
  }
  
  .modal-content {
    margin-top: max(var(--space-md), env(safe-area-inset-top));
    margin-bottom: max(var(--space-md), env(safe-area-inset-bottom));
  }
}

/* ===== MOBILE PERFORMANCE HINTS ===== */

/* Optimize rendering performance */
.background-container,
.modal-overlay {
  will-change: auto;
  contain: layout style paint;
}

/* Reduce paint areas on mobile */
@media (max-width: 768px) {
  .social-link,
  .nav-contact-btn,
  .policies-btn {
    will-change: auto;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }
}

/* ===== END MOBILE OPTIMIZATIONS ===== */