/* ========================================
   MOBILE-FIRST OPTIMIZATION
   ======================================== */

/* Base: Mobile-first styles (default for all screen sizes) */

/* Prevent horizontal overflow */
* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  width: 100%;
}

body {
  overflow-x: hidden;
  width: 100%;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Mobile-first container */
.container {
  width: 100%;
  max-width: 100%;
  padding: 0 1rem;
  margin: 0 auto;
}

/* Mobile-first typography - start small, scale up */
h1 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  line-height: 1.2;
  font-weight: 700;
}

h2 {
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1.3;
  font-weight: 700;
}

h3 {
  font-size: clamp(1.125rem, 2.5vw, 1.5rem);
  line-height: 1.4;
  font-weight: 600;
}

p {
  font-size: clamp(0.9rem, 2vw, 1rem);
  line-height: 1.6;
}

/* Mobile-first images - responsive by default */
img,
picture,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Mobile-first buttons - minimum touch target 44x44px */
button,
.btn,
a.btn,
input[type="button"],
input[type="submit"] {
  min-height: 44px;
  min-width: 44px;
  padding: 0.75rem 1.25rem;
  font-size: clamp(0.875rem, 2vw, 1rem);
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Mobile-first links - ensure they're tappable */
a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Mobile-first spacing */
section {
  padding: clamp(2rem, 5vw, 4rem) 0;
}

/* Mobile-first grid - single column by default */
.grid,
.services-grid,
.core-services__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* Mobile-first cards */
.card,
.core-service-card {
  width: 100%;
  max-width: 100%;
  margin-bottom: 1rem;
}

/* Prevent text overflow */
* {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Mobile-first forms */
input,
textarea,
select {
  width: 100%;
  max-width: 100%;
  font-size: 16px; /* Prevents zoom on iOS */
  padding: 0.75rem;
  min-height: 44px;
  touch-action: manipulation;
}

/* Mobile-first navigation */
.nav-list {
  flex-direction: column;
  gap: 0.5rem;
}

/* Mobile-first header */
.header {
  width: 100%;
  max-width: 100%;
}

.header-container {
  width: 100%;
  max-width: 100%;
  padding: 0 1rem;
}

/* Mobile-first footer */
.footer {
  width: 100%;
  max-width: 100%;
  padding: 2rem 1rem;
}

/* ========================================
   TABLET AND UP (min-width: 768px)
   ======================================== */
@media (min-width: 768px) {
  .container {
    max-width: 1200px;
    padding: 0 2rem;
  }

  .grid,
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .core-services__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .nav-list {
    flex-direction: row;
  }

  section {
    padding: clamp(3rem, 6vw, 5rem) 0;
  }
}

/* ========================================
   DESKTOP AND UP (min-width: 1024px)
   ======================================== */
@media (min-width: 1024px) {
  .container {
    padding: 0 2.5rem;
  }

  .grid,
  .services-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }

  .core-services__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========================================
   LARGE DESKTOP (min-width: 1200px)
   ======================================== */
@media (min-width: 1200px) {
  .container {
    max-width: 1200px;
    padding: 0 3rem;
  }
}

/* ========================================
   MOBILE-SPECIFIC FIXES
   ======================================== */

/* Ensure no horizontal scroll */
@media (max-width: 767px) {
  * {
    max-width: 100vw;
  }

  body {
    overflow-x: hidden;
    width: 100vw;
  }

  .container {
    padding: 0 clamp(0.75rem, 3vw, 1rem);
    width: 100%;
    max-width: 100vw;
  }
  
  /* Smaller phones - adjust container padding */
  @media (max-width: 480px) {
    .container {
      padding: 0 0.75rem;
    }
  }
  
  @media (max-width: 375px) {
    .container {
      padding: 0 0.5rem;
    }
  }
  
  @media (max-width: 320px) {
    .container {
      padding: 0 0.5rem;
    }
  }

  /* Stack all grids on mobile */
  .grid,
  .services-grid,
  .core-services__grid,
  .hero-cards-grid {
    grid-template-columns: 1fr !important;
  }

  /* Full-width cards on mobile */
  .card,
  .core-service-card,
  .hero-card {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  /* Mobile-optimized buttons */
  .btn,
  button {
    width: 100%;
    max-width: 100%;
  }

  /* Mobile-optimized spacing */
  section {
    padding: 2rem 0;
  }

  /* Mobile-optimized typography */
  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  p {
    font-size: 0.95rem;
  }
}

/* ========================================
   ACCESSIBILITY & PERFORMANCE
   ======================================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card,
  .core-service-card {
    border: 2px solid;
  }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
  /* Add dark mode styles if needed */
}

