/* =====================================================
   Leaforge Final Mobile Polish
   Fixes:
   1. Remove white space above mobile header
   2. Keep header fixed/sticky cleanly at top
   3. Force all mobile cards/grids to one card per row
   4. Resize images neatly inside mobile cards
===================================================== */

@media (max-width: 991px) {
  html,
  body {
    margin: 0 !important;
    padding-top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  body.home-page,
  body:not(.home-page),
  body.lf-header-scrolled,
  body.home-page.lf-header-scrolled,
  html.lf-header-scrolled {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }

  body > *:first-child,
  header:first-child,
  .lf-fw2-header:first-child {
    margin-top: 0 !important;
  }

  .lf-fw2-header {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 999999 !important;
    background: #034336 !important;
    transform: none !important;
  }

  .lf-fw2-topbar,
  .lf-fw2-header .lf-fw2-topbar,
  .lf-fw2-header.is-scrolled .lf-fw2-topbar {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    overflow: hidden !important;
  }

  .lf-fw2-main,
  .lf-fw2-header .lf-fw2-main,
  .lf-fw2-header.is-scrolled .lf-fw2-main {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 74px !important;
    min-height: 74px !important;
    max-height: 74px !important;
    background: #034336 !important;
    border: 0 !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12) !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
  }

  .lf-fw2-main-inner {
    height: 74px !important;
    min-height: 74px !important;
    max-height: 74px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 16px !important;
    margin: 0 auto !important;
  }

  .lf-fw2-logo {
    min-width: 0 !important;
    width: auto !important;
    max-width: calc(100vw - 86px) !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
  }

  .lf-fw2-logo img,
  .lf-fw2-logo-img {
    width: auto !important;
    max-width: min(230px, calc(100vw - 92px)) !important;
    max-height: 56px !important;
    height: auto !important;
    object-fit: contain !important;
    display: block !important;
  }

  .lf-fw2-logo-normal {
    display: block !important;
  }

  .lf-fw2-logo-scrolled {
    display: none !important;
  }

  .lf-fw2-menu-toggle {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    width: 44px !important;
    height: 42px !important;
    min-width: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid rgba(255,255,255,0.38) !important;
    border-radius: 8px !important;
    background: rgba(255,255,255,0.08) !important;
  }

  .lf-fw2-menu-toggle span {
    display: block !important;
    width: 23px !important;
    height: 2px !important;
    background: #ffffff !important;
    border-radius: 999px !important;
  }

  .lf-fw2-nav {
    display: none !important;
  }

  .lf-mega-menu.is-open {
    display: block !important;
  }

  /* Keep hero section directly under header without top blank area */
  main,
  .lf-inner-hero,
  .lf-page-hero,
  .lf-contact-hero,
  body.home-page .lf-home-hero-slider {
    margin-top: 0 !important;
  }

  .lf-inner-hero,
  .lf-page-hero,
  .lf-contact-hero {
    padding-top: 64px !important;
  }

  body.home-page .lf-home-slide {
    padding-top: 54px !important;
  }

  /* One card per row on mobile everywhere */
  [class*="grid"],
  [class*="Grid"],
  [class*="cards"],
  [class*="Cards"],
  .row,
  .lf-why-grid,
  .lf-v7-why-grid,
  .lf-card-grid,
  .lf-v7-projects-grid,
  .lf-bc-dev-grid,
  .lf-bc-support-grid,
  .lf-modern-card-grid,
  .lf-r5-steps-grid,
  .lf-r8-steps-grid,
  .lf-r5-fit-grid,
  .lf-r5-home-style-grid,
  .lf-ri-card-grid,
  .lf-industry-grid,
  .lf-help-grid,
  .bc-services-grid,
  .feature-grid,
  .lf-about-grid,
  .lf-services-grid,
  .lf-modules-grid,
  .lf-benefits-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 20px !important;
    width: 100% !important;
  }

  .row > *,
  [class*="col-"],
  [class*="column"],
  [class*="Column"] {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
  }

  /* Mobile card readability */
  [class*="card"],
  [class*="Card"],
  .lf-why-card,
  .lf-v7-why-feature,
  .why-card,
  .choose-card,
  .lf-v7-project-card,
  .lf-industry-card,
  .lf-modern-card,
  .lf-bc-dev-card,
  .lf-bc-support-card,
  .lf-r5-step-card,
  .lf-r8-step-card,
  .lf-ri-card,
  .lf-fit-card {
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    overflow: hidden !important;
  }

  [class*="card"] h2,
  [class*="Card"] h2,
  [class*="card"] h3,
  [class*="Card"] h3 {
    overflow-wrap: anywhere !important;
  }

  /* Images must fit mobile cards cleanly */
  .lf-v7-project-card > img,
  .lf-industry-card > img,
  .lf-industry-image img,
  .lf-rapid5-image-box img,
  .lf-rapid8-image-box img,
  .lf-rapid-why-image img,
  .lf-page-reusable-about-image img,
  .lf-page-reusable-diagram-image img,
  .about-visual img,
  .about-banner img,
  .team-image img,
  .lf-about-image img,
  .lf-service-image img,
  .lf-image-box img,
  .image-box img,
  .story-box img,
  .story-image img,
  .lf-card-image img,
  .lf-card-img img,
  .lf-blog-image img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 16 / 10 !important;
    object-fit: cover !important;
    object-position: center center !important;
    display: block !important;
    border-radius: 16px !important;
  }

  /* Do not stretch icons and logos */
  .lf-fw2-logo img,
  .lf-footer-logo img,
  [class*="icon"] img,
  [class*="Icon"] img,
  .lf-fit-icon img,
  .lf-step-icon img,
  .lf-why-icon img,
  .lf-card-icon img {
    aspect-ratio: auto !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    border-radius: 0 !important;
  }
}

@media (max-width: 575px) {
  .lf-fw2-main,
  .lf-fw2-header .lf-fw2-main,
  .lf-fw2-main-inner {
    height: 70px !important;
    min-height: 70px !important;
    max-height: 70px !important;
  }

  .lf-fw2-logo img,
  .lf-fw2-logo-img {
    max-width: min(210px, calc(100vw - 86px)) !important;
    max-height: 52px !important;
  }

  .lf-inner-hero,
  .lf-page-hero,
  .lf-contact-hero {
    padding-top: 50px !important;
  }

  body.home-page .lf-home-slide {
    padding-top: 46px !important;
  }

  [class*="card"],
  [class*="Card"],
  .lf-v7-project-card,
  .lf-industry-card,
  .lf-modern-card,
  .lf-bc-dev-card,
  .lf-bc-support-card,
  .lf-r5-step-card,
  .lf-r8-step-card,
  .lf-ri-card,
  .lf-fit-card {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
}
