/* ==============================================================
   EPCM OVERRIDE LAYER
   Loaded LAST (priority 9999) — overrides any Avada/Fusion/theme CSS
   that breaks responsive behavior.
   Uses !important sparingly on CRITICAL rules only.
   ============================================================== */

/* --- PREVENT ANY PARENT FROM FORCING A FIXED WIDTH --- */
html, body {
  max-width: 100vw !important;
  overflow-x: hidden !important;
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
}

/* --- ENSURE OUR CONTAINER STAYS FLUID EVEN INSIDE AVADA WRAPPERS --- */
.epcm-container {
  width: 100% !important;
  max-width: 1200px !important;
  box-sizing: border-box !important;
}

/* ==============================================================
   EDGE-TO-EDGE ON MOBILE — CRITICAL
   Avada wraps every shortcode in #content + .fusion-row which add
   left/right padding (typically 30px each side). On mobile this
   eats 60px of the 375px screen = 16% wasted.
   We cancel that padding on mobile so EPCM sections fill the screen.
   ============================================================== */
@media (max-width: 768px) {
  /* Cancel Avada row/column padding on mobile */
  body #wrapper #content,
  body #wrapper .fusion-row,
  body .fusion-fullwidth,
  body .fusion-builder-row,
  body .fusion-builder-row-inner,
  body .fusion-layout-column,
  body .fusion-column-wrapper {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Cancel Avada page wrapper horizontal padding */
  body.avada-responsive #main,
  body #main,
  body .fusion-fullwidth,
  body .post-content {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

/* --- IMAGES NEVER OVERFLOW --- */
.epcm-hero img,
.epcm-about img,
.epcm-svc-detail img,
.epcm-achievements img,
.epcm-services img {
  max-width: 100% !important;
  height: auto !important;
}

/* ==============================================================
   MOBILE (≤768px) — CRITICAL OVERRIDES
   These defeat Avada's column system that might force our grid
   to stay multi-column on mobile.
   ============================================================== */
@media (max-width: 768px) {

  /* Container padding — MINIMAL on mobile for edge-to-edge feel */
  .epcm-container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Grids → single column */
  .epcm-services-grid,
  .epcm-certs-grid,
  .epcm-ach-grid,
  .epcm-global-regions,
  .epcm-vm-grid,
  .epcm-about-grid,
  .epcm-svc-detail-grid,
  .epcm-contact-grid,
  .epcm-footer-grid,
  .epcm-inno-grid,
  .epcm-card-grid {
    grid-template-columns: 1fr !important;
  }

  /* 2-column for stats & clients on mobile */
  .epcm-hero-stats .epcm-container,
  .epcm-clients-grid,
  .epcm-card-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Force section padding down */
  .epcm-about,
  .epcm-vm-section,
  .epcm-services,
  .epcm-svc-detail,
  .epcm-innovation,
  .epcm-certs,
  .epcm-global,
  .epcm-clients,
  .epcm-achievements,
  .epcm-contact {
    padding: 56px 0 !important;
  }

  /* Force buttons full-width on mobile */
  .epcm-hero-btns {
    flex-direction: column !important;
    width: 100% !important;
  }
  .epcm-hero-btns .epcm-btn-primary,
  .epcm-hero-btns .epcm-btn-outline {
    width: 100% !important;
  }

  /* Service detail reverse → normal order on mobile */
  .epcm-svc-reverse .epcm-svc-detail-grid > *:first-child {
    order: 0 !important;
  }

  /* Navbar mobile menu */
  .epcm-nav-links {
    display: none !important;
  }
  .epcm-nav-links.open {
    display: flex !important;
    flex-direction: column !important;
  }
  .epcm-mobile-toggle {
    display: inline-flex !important;
  }

  /* Innovation timeline → vertical */
  .epcm-inno-line { display: none !important; }
  .epcm-inno-steps {
    flex-direction: column !important;
    gap: 24px !important;
  }
  .epcm-inno-step {
    flex-direction: row !important;
    text-align: left !important;
  }

  /* iOS fixed background bug */
  .epcm-image-band-bg,
  .epcm-hero-bg-img {
    background-attachment: scroll !important;
  }

  /* Form inputs — prevent iOS auto-zoom */
  .epcm-form-group input,
  .epcm-form-group select,
  .epcm-form-group textarea {
    font-size: 16px !important;
  }

  /* Ensure touch targets are large enough */
  .epcm-btn-primary,
  .epcm-btn-outline,
  .epcm-nav-links a,
  .epcm-form-submit {
    min-height: 48px !important;
  }

  /* Reset any Avada fixed widths */
  .fusion-builder-column,
  .fusion-column-wrapper,
  .fusion-row,
  .fusion-flex-container,
  .fusion-layout-column {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* ==============================================================
   SMALL MOBILE (≤480px)
   ============================================================== */
@media (max-width: 480px) {
  .epcm-clients-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .epcm-hero-title {
    font-size: clamp(30px, 9vw, 44px) !important;
  }
  .epcm-section-title {
    font-size: clamp(24px, 7vw, 32px) !important;
  }
}

/* ==============================================================
   FULL-BLEED ELEMENTS ON MOBILE
   Images, hero backgrounds, and image bands go edge-to-edge
   ============================================================== */
@media (max-width: 768px) {
  /* Hero background fills screen fully */
  .epcm-hero {
    margin-left: calc(50% - 50vw) !important;
    margin-right: calc(50% - 50vw) !important;
    width: 100vw !important;
  }
  .epcm-hero-bg-img,
  .epcm-hero-canvas,
  .epcm-hero-overlay {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }

  /* Image band goes full bleed */
  .epcm-image-band {
    margin-left: calc(50% - 50vw) !important;
    margin-right: calc(50% - 50vw) !important;
    width: 100vw !important;
  }

  /* About image on mobile — full width edge-to-edge */
  .epcm-about-img {
    border-radius: 0 !important;
    margin-left: -12px !important;
    margin-right: -12px !important;
    width: calc(100% + 24px) !important;
    max-width: none !important;
  }

  /* Service detail image edge-to-edge */
  .epcm-svc-visual {
    border-radius: 0 !important;
    margin-left: -12px !important;
    margin-right: -12px !important;
    width: calc(100% + 24px) !important;
  }

  /* Achievement images edge-to-edge */
  .epcm-ach-card {
    border-radius: 0 !important;
  }

  /* Section backgrounds fill full viewport */
  .epcm-about,
  .epcm-vm-section,
  .epcm-services,
  .epcm-svc-detail,
  .epcm-innovation,
  .epcm-certs,
  .epcm-global,
  .epcm-clients,
  .epcm-achievements,
  .epcm-contact,
  .epcm-footer {
    margin-left: calc(50% - 50vw) !important;
    margin-right: calc(50% - 50vw) !important;
    width: 100vw !important;
    max-width: 100vw !important;
  }

  /* Navbar full-width */
  .epcm-navbar {
    width: 100vw !important;
    left: 0 !important;
    right: 0 !important;
  }
}
