/**
 * iPad Optimizations
 * Fixes text overlap, spacing, and layout issues on iPad devices
 * Covers iPad (768px-1024px) and iPad Pro portrait (834px)
 */

/* ========================================
   iPad Portrait and Landscape (768px - 1024px)
   ======================================== */
@media (min-width: 768px) and (max-width: 1024px) {
  /* Prevent text overlap in header */
  .header-content {
    gap: 1rem !important;
    padding: 0 1rem !important;
  }

  .logo-section {
    min-width: 0 !important;
    flex: 0 1 auto !important;
    max-width: 200px !important;
  }

  .header .company-name,
  .header .logo-text {
    font-size: clamp(1.2rem, 2.5vw, 1.5rem) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Mobile menu toggle - ensure it's visible and properly sized */
  .mobile-menu-toggle {
    width: 48px !important;
    height: 48px !important;
    flex-shrink: 0 !important;
    margin-left: 1rem !important;
  }

  /* Navigation menu - prevent overlap */
  .header .nav.nav-open {
    padding: 0 !important;
  }

  .header .nav.nav-open .nav-list {
    padding: 1.5rem 2rem 2rem !important;
    gap: 1rem !important;
  }

  .header .nav.nav-open .nav-item {
    margin-bottom: 0.5rem !important;
  }

  .header .nav.nav-open .nav-link-container {
    padding: 1.25rem 1.5rem !important;
  }

  .header .nav.nav-open .nav-link {
    font-size: 1.1rem !important;
    line-height: 1.4 !important;
  }

  /* Mobile menu header - prevent text overlap */
  .header .mobile-menu-header {
    padding: 1rem 1.5rem !important;
    gap: 1rem !important;
  }

  .header .mobile-menu-title {
    font-size: 1.1rem !important;
    max-width: calc(100% - 60px) !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* Container spacing */
  .container {
    padding: 0 2rem !important;
    max-width: 100% !important;
  }

  /* Prevent text overlap in cards and sections */
  section {
    padding: 3rem 2rem !important;
  }

  /* Typography - prevent overlap */
  h1 {
    font-size: clamp(2rem, 4vw, 2.5rem) !important;
    line-height: 1.2 !important;
    margin-bottom: 1.5rem !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }

  h2 {
    font-size: clamp(1.75rem, 3.5vw, 2.25rem) !important;
    line-height: 1.3 !important;
    margin-bottom: 1.25rem !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }

  h3 {
    font-size: clamp(1.5rem, 3vw, 1.875rem) !important;
    line-height: 1.4 !important;
    margin-bottom: 1rem !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }

  p {
    font-size: 1.05rem !important;
    line-height: 1.7 !important;
    margin-bottom: 1rem !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }

  /* Grid layouts - optimize for iPad */
  .services-grid,
  .types-grid,
  .features-grid,
  .gallery-grid,
  .reasons-grid,
  .service-areas-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 2rem !important;
    padding: 0 1rem !important;
  }

  /* Cards - prevent overlap */
  .service-card,
  .type-card,
  .feature-item,
  .reason-item,
  .step,
  .service-area-group,
  .service-box,
  .image-card {
    padding: 2rem !important;
    margin-bottom: 1.5rem !important;
    min-height: auto !important;
  }

  /* Buttons - proper spacing */
  .btn,
  .btn-primary,
  .btn-secondary {
    padding: 1rem 2rem !important;
    font-size: 1rem !important;
    min-height: 48px !important;
    white-space: nowrap !important;
  }

  .btn-row {
    gap: 1rem !important;
    flex-wrap: wrap !important;
  }

  /* Hero sections - prevent overlap */
  .page-hero,
  .home-hero-compact {
    padding: 2rem 1.5rem !important;
  }

  .page-hero__container {
    padding: 0 2rem !important;
  }

  .page-hero__title {
    font-size: clamp(2.25rem, 5vw, 3rem) !important;
    line-height: 1.1 !important;
    margin-bottom: 1rem !important;
  }

  .page-hero__subtitle {
    font-size: clamp(1.1rem, 2.5vw, 1.35rem) !important;
    line-height: 1.6 !important;
    max-width: 800px !important;
  }

  /* Lists - prevent overlap */
  ul, ol {
    padding-left: 1.5rem !important;
    margin-bottom: 1.5rem !important;
  }

  li {
    margin-bottom: 0.75rem !important;
    line-height: 1.6 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }

  /* Images - proper sizing */
  img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Prevent horizontal overflow */
  body, html {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Background image is now handled by hero-background.css - clean implementation */

  * {
    box-sizing: border-box !important;
  }
}

/* ========================================
   iPad Pro Portrait (834px) - Specific adjustments
   ======================================== */
@media (min-width: 834px) and (max-width: 834px) {
  .container {
    padding: 0 2.5rem !important;
  }

  section {
    padding: 3.5rem 2.5rem !important;
  }

  .services-grid,
  .types-grid,
  .features-grid {
    gap: 2.5rem !important;
  }
}

/* ========================================
   iPad Landscape (1024px) - Edge case
   ======================================== */
@media (min-width: 1024px) and (max-width: 1024px) {
  /* Ensure hamburger menu still works at exactly 1024px */
  .mobile-menu-toggle {
    display: flex !important;
  }

  .nav:not(.nav-open) {
    display: none !important;
  }
}

