/* MOBILE-FIRST RESPONSIVE DESIGN SYSTEM
   ======================================
   Production-ready responsive CSS with three tiers:
   - Mobile (320px-768px): Full optimization
   - Tablet (769px-1024px): Moderate scaling  
   - Desktop (1025px+): UNCHANGED (preserved)
*/

/* ====== MOBILE-FIRST BASE (320px - 768px) ====== */

@media (max-width: 768px) {
  /* Typography - aggressive scaling for small screens */
  .section-pad {
    padding: 48px 0 !important;
  }

  .section-title {
    font-size: clamp(1.5rem, 7vw, 2.2rem) !important;
    line-height: 1.1;
  }

  .section-copy {
    font-size: 0.95rem;
    line-height: 1.6;
  }

  /* Hero Section */
  .ref-hero-content {
    padding: 32px 16px 140px !important;
  }

  .ref-hero h1 {
    font-size: clamp(2rem, 12vw, 3rem) !important;
    line-height: 1;
    margin-top: 8px;
  }

  .ref-hero p:not(.eyebrow) {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-top: 12px;
  }

  /* Hero Stats - 2-column mobile grid */
  .hero-stat-band {
    grid-template-columns: repeat(2, 1fr) !important;
    bottom: -16px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
  }

  .hero-stat-band div {
    min-height: 80px !important;
    padding: 12px !important;
  }

  .hero-stat-band strong {
    font-size: clamp(1.3rem, 5vw, 1.8rem) !important;
  }

  .hero-stat-band span {
    font-size: 0.7rem;
    margin-top: 6px;
  }

  /* Service Cards - CRITICAL FIX */
  .service-card {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .service-card img {
    height: 160px !important;
    max-height: 160px;
  }

  .service-card div {
    padding: 12px !important;
  }

  .service-card h3 {
    font-size: 1rem;
    margin-top: 6px;
  }

  .service-card p {
    font-size: 0.8rem;
    margin-top: 6px;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .service-card ul {
    display: none !important;
  }

  /* About Section */
  .about-story {
    padding-top: 16px !important;
  }

  .about-story h3 {
    font-size: clamp(1.3rem, 6vw, 1.8rem) !important;
  }

  .about-pill-grid {
    gap: 10px;
    margin-top: 16px;
  }

  .about-pill-grid article {
    padding: 12px !important;
  }

  /* Gallery - Mobile proportions */
  .gallery-wall {
    grid-auto-rows: 160px !important;
    gap: 8px;
  }

  .gallery-hero-tile {
    grid-column: auto !important;
    grid-row: auto !important;
  }

  /* CTA Section */
  .cta-band {
    padding: 20px !important;
    gap: 14px !important;
  }

  .cta-band h2 {
    font-size: clamp(1.5rem, 6vw, 2rem) !important;
    margin-top: 8px;
  }

  .cta-band p:not(.eyebrow) {
    font-size: 0.9rem;
    margin-top: 8px;
  }

  /* Project Cards */
  .project-card {
    grid-template-columns: 1fr !important;
  }

  .project-card img {
    min-height: 180px !important;
  }

  .project-card > div {
    padding: 14px !important;
  }

  /* Leader Cards */
  .leader-card {
    grid-template-columns: 1fr !important;
    padding: 14px !important;
    gap: 12px !important;
  }

  .leader-photo {
    max-height: 260px;
  }

  /* Floating Actions - Show and reduce size */
  .floating-actions {
    display: flex !important;
    right: 10px !important;
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
    width: 56px;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    z-index: 60;
  }

  .floating-actions a,
  .floating-actions button {
    width: 40px !important;
    height: 40px !important;
  }

  .floating-actions .btn-label {
    display: none !important;
  }

  .floating-actions img {
    width: 20px !important;
    height: 20px !important;
  }

  /* Contact Section */
  .contact-panel h2 {
    font-size: clamp(1.5rem, 6vw, 2rem) !important;
  }

  .contact-list {
    gap: 10px;
    margin-top: 20px;
  }

  .contact-list a,
  .contact-list div {
    padding: 12px !important;
  }

  /* Form */
  .form-grid {
    gap: 12px !important;
    grid-template-columns: 1fr !important;
  }

  .field-input {
    min-height: 44px !important;
    padding: 0 12px !important;
    font-size: 14px;
  }

  /* Footer */
  .footer-layout {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  .footer-layout > div,
  .footer-layout > nav {
    border-right: none !important;
    padding-right: 0 !important;
  }

  /* Safety/Why sections */
  .safety-list {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .safety-list article {
    padding: 14px !important;
  }

  .why-points {
    gap: 10px;
    margin-top: 16px;
  }

  .why-points article {
    padding: 12px !important;
    gap: 8px 10px;
  }

  .why-image {
    min-height: 260px !important;
  }

  /* Client logos */
  .client-logo-row {
    gap: 10px;
  }

  .client-logo-row span {
    min-height: 80px;
  }

  /* Tags */
  .tag-list {
    gap: 6px;
  }

  .tag-list span {
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.75rem;
  }

  /* Performance */
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ====== TABLET OPTIMIZATION (769px - 1024px) ====== */

@media (min-width: 769px) and (max-width: 1024px) {
  .section-pad {
    padding: 64px 0 !important;
  }

  .section-title {
    font-size: clamp(2rem, 5vw, 3rem) !important;
  }

  .ref-hero-content {
    padding: 48px 16px 180px !important;
  }

  .ref-hero h1 {
    font-size: clamp(2.2rem, 8vw, 4.5rem) !important;
  }

  /* Service Cards - 2-column on tablet */
  .service-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px;
  }

  .service-card {
    grid-template-columns: 1fr !important;
  }

  .service-card img {
    height: 180px !important;
  }

  .service-card div {
    padding: 14px !important;
  }

  /* Hero Stats */
  .hero-stat-band div {
    min-height: 95px !important;
    padding: 14px !important;
  }

  .hero-stat-band strong {
    font-size: clamp(1.4rem, 3vw, 2rem) !important;
  }

  /* Gallery */
  .gallery-wall {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-auto-rows: 200px;
  }

  /* Leader Cards */
  .leader-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .leader-card {
    grid-template-columns: 140px 1fr !important;
  }

  /* CTA */
  .cta-band {
    padding: 28px !important;
  }

  .cta-band h2 {
    font-size: clamp(1.8rem, 5vw, 3rem) !important;
  }

  /* Contact */
  .contact-layout {
    grid-template-columns: 0.4fr 0.6fr !important;
  }

  .contact-panel h2 {
    font-size: clamp(1.8rem, 4vw, 2.8rem) !important;
  }

  .form-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Client logos */
  .client-logo-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Safety/Why */
  .safety-list {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Floating actions */
  .floating-actions a,
  .floating-actions button {
    width: 42px !important;
    height: 42px !important;
  }
}

/* ====== EXTRA SMALL MOBILE (320px - 414px) ====== */

@media (max-width: 414px) {
  .section-pad {
    padding: 36px 0 !important;
  }

  .ref-hero-content {
    padding: 24px 12px 120px !important;
  }

  .ref-hero h1 {
    font-size: clamp(1.4rem, 10vw, 2.2rem) !important;
  }

  .hero-stat-band {
    left: 6px !important;
    right: 6px !important;
  }

  .hero-stat-band div {
    min-height: 72px !important;
    padding: 10px !important;
  }

  .service-card div {
    padding: 10px !important;
  }

  .service-card img {
    height: 140px !important;
  }

  .cta-band {
    padding: 16px !important;
  }

  .contact-panel {
    padding: clamp(14px, 3vw, 20px) !important;
  }

  .form-grid {
    gap: 10px;
  }

  .field-input {
    min-height: 42px;
  }

  .floating-actions {
    right: 8px !important;
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
    width: 52px;
    padding: 6px;
  }

  .floating-actions a,
  .floating-actions button {
    width: 38px !important;
    height: 38px !important;
  }
}

/* ====== ACCESSIBILITY ====== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ====== LANDSCAPE ORIENTATION FIX ====== */

@media (max-width: 768px) and (orientation: landscape) {
  .ref-hero {
    min-height: auto !important;
  }

  .ref-hero-content {
    padding: 20px 16px 80px !important;
  }

  .section-pad {
    padding: 32px 0 !important;
  }
}
