/* =========================================================
   SHBD Metal — Global Mobile Fixes
   Linked from every page. Safety net for small screens:
   kills horizontal overflow, scrolls wide tables, collapses
   multi-column grids, scales type. Page-specific components
   keep their own media queries; this layer handles the
   common failure modes across the whole site.
   ========================================================= */

/* Desktop: hide mobile-only structures (drawer head row, Industries mobile variants) */
.nav-drawer-head,
.ind-mobile-grid,
.ind-mobile-cta,
.ind-final {
  display: none !important;
}

@media (max-width: 900px) {
  /* 1. Never allow page-level horizontal scroll (main cause of "broken" mobile view) */
  body, html { overflow-x: hidden !important; }

  /* 2. Fixed/wide containers shrink to viewport */
  .site-header,
  .header-inner,
  [class*="container"],
  [class*="-container"],
  [class*="wrap"],
  [class*="inner"] {
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .site-header { width: 100% !important; left: 0 !important; right: 0 !important; }
  .header-inner { flex-wrap: wrap; }

  /* 3. Embedded media never exceeds viewport */
  img, video, iframe, canvas, svg, embed, object {
    max-width: 100% !important;
    height: auto;
  }

  /* 4. Wide tables scroll horizontally instead of being clipped */
  table {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: normal;
  }
  table thead, table tbody, table tr { display: table; width: 100%; table-layout: fixed; }
  table td, table th { white-space: normal !important; word-break: break-word; }

  /* 5. Multi-column grids collapse to a single column */
  [class*="grid"], [class*="-grid"] { grid-template-columns: 1fr !important; }

  /* 5b. Flex list items wrap (long text in hero bullet lists) */
  li { flex-wrap: wrap; }
  li > * { max-width: 100%; }
  [class*="-bullets"] li, [class*="-benefits"] li { text-align: left; }

  /* 6. Type scales down to fit */
  h1 { font-size: clamp(21px, 5.8vw, 28px) !important; line-height: 1.3 !important; }
  h2 { font-size: clamp(18px, 5vw, 24px) !important; line-height: 1.3 !important; }
  h3 { font-size: 16px !important; line-height: 1.35 !important; }
  .section-title { font-size: 25px !important; }

  /* 7. Section spacing breathes on small screens */
  section, [class*="-section"], [class*="section"] { padding-left: 0 !important; padding-right: 0 !important; }
}

@media (max-width: 480px) {
  h1 { font-size: 20px !important; }
  h2 { font-size: 17px !important; }
  [class*="grid"], [class*="-grid"] { grid-template-columns: 1fr !important; }
}

/* =========================================================
   MOBILE NAV DRAWER — full rebuild (overrides style.css ≤768px)
   ========================================================= */
@media (max-width: 1024px) {
  /* ---- header alignment ---- */
  .site-header { height: var(--nav-height, 64px); }
  .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-wrap: nowrap;
  }
  .logo { flex: 0 0 auto; min-width: 0; }
  .logo-text { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* ---- hamburger ---- */
  .menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    margin-left: auto;
    background: #f4f6f9;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    z-index: 1002;
  }
  .menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #1a3a5c;
    border-radius: 2px;
    transition: transform .3s ease, opacity .3s ease;
  }
  .menu-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .menu-toggle.active span:nth-child(2) { opacity: 0; }
  .menu-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* ---- drawer panel (3erp style: dark #1a1a1a, slides in from RIGHT) ---- */
  .main-nav {
    position: fixed !important;
    top: 0 !important;
    left: auto !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    padding-left: 0 !important;
    background: #1a1a1a !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;   /* kill inherited align-items:center — children full-width, X truly flush-left */
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1) !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-shadow: -4px 0 24px rgba(0,0,0,0.35) !important;
    border: none !important;
    z-index: 1001 !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  .main-nav.open { transform: translateX(0) !important; }

  /* ---- drawer top bar: logo left, white ✕ right ---- */
  .nav-drawer-head {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    flex-wrap: nowrap !important;
    padding: 12px 24px 0 !important;
    background: #1a1a1a !important;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
    flex: 0 0 auto !important;
  }
  .nav-drawer-brand {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    text-decoration: none !important;
    min-width: 0 !important;
    max-width: calc(100% - 60px) !important;
    margin: 0 !important;
    flex: 0 1 auto !important;
  }
  .nav-drawer-logo {
    width: 32px !important;
    height: 32px !important;
    object-fit: contain !important;
    flex: 0 0 auto !important;
    /* original full-color brand logo — no filter */
  }
  .nav-drawer-title {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    white-space: nowrap !important;
    overflow: visible !important;
  }
  .nav-close {
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    cursor: pointer !important;
    flex: 0 0 auto !important;
    order: -1 !important;          /* force leftmost in the header row */
    margin: 0 !important;
    padding: 0 !important;
  }
  .nav-close-icon {
    width: 20px !important;
    height: 20px !important;
    object-fit: contain !important;
    display: block !important;
  }

  /* ---- menu list (scrollable middle zone) ---- */
  .main-nav .nav-list {
    flex-direction: column;
    width: 100%;
    padding: 0;
    margin: -10px 0 0 !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .main-nav .nav-item { width: 100%; border-bottom: 1px solid rgba(255,255,255,0.08); }
  .main-nav .nav-link {
    width: 100%;
    height: auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 500;
    color: #ffffff !important;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
  }
  .nav-link .arrow { transition: transform 0.3s ease; font-size: 13px; color: #ffffff !important; }
  .nav-item.open > .nav-link .arrow { transform: rotate(180deg); }
  .nav-item.open > .nav-link { color: #FF591B; }

  /* ---- accordion dropdowns (dark submenu) ---- */
  #servicesDropdown.dropdown-mega,
  .dropdown-industries,
  .dropdown-resources {
    display: none !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 0 24px !important;
    background: #262626 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    position: static !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  .nav-item.open #servicesDropdown.dropdown-mega,
  .nav-item.open .dropdown-industries,
  .nav-item.open .dropdown-resources {
    display: block !important;
    animation: gmNavFade 0.22s ease;
  }
  @keyframes gmNavFade {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .nav-item.open #servicesDropdown.dropdown-mega a,
  .nav-item.open .dropdown-industries a,
  .nav-item.open .dropdown-resources a {
    padding: 13px 0;
    color: #ffffff;
    font-size: 14.5px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  /* ---- Services submenu: pure white text ---- */
  .nav-item.open #servicesDropdown.dropdown-mega .dropdown-heading {
    color: #ffffff !important;
  }
  .nav-item.open #servicesDropdown.dropdown-mega .dropdown-link {
    color: #ffffff !important;
  }
  .nav-item.open #servicesDropdown.dropdown-mega .dropdown-link:hover,
  .nav-item.open #servicesDropdown.dropdown-mega .dropdown-heading:hover {
    color: #FF591B !important;
  }

  /* ---- Resources panel: white icons + white text ---- */
  .nav-item.open .dropdown-resources .resources-link {
    color: #ffffff !important;
  }
  .nav-item.open .dropdown-resources .resources-link i {
    color: #FF591B !important;
  }
  .nav-item.open .dropdown-resources .resources-link-text strong {
    color: #ffffff !important;
  }
  .nav-item.open .dropdown-resources .resources-link-text span {
    color: rgba(255,255,255,0.75) !important;
  }
  .nav-item.open .dropdown-resources .resources-column-heading {
    color: #ffffff !important;
  }

  /* ---- Industries dropdown (dark single-column list) ---- */
  .ind-final { display: none !important; }
  .ind-final-title {
    display: block !important;
    margin: 0 !important;
    padding: 6px 0 6px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.4px !important;
    color: rgba(255,255,255,0.5) !important;
  }
  .ind-acc-check:checked ~ .dropdown .ind-final { display: block !important; }
  .ind-final-link {
    display: block !important;
    padding: 13px 0 !important;
    font-size: 14.5px !important;
    font-weight: 500 !important;
    color: #ffffff !important;
    text-decoration: none !important;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .ind-final-link:active { color: #FF591B !important; }
  .ind-final-cta {
    display: block !important;
    padding: 14px 0 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #FF591B !important;
    text-decoration: none !important;
  }
  .ind-acc-check:checked ~ .dropdown .ind-mega { display: none !important; }

  /* ---- CTA pinned to drawer bottom (fixed, does not scroll) ---- */
  .main-nav .header-actions {
    padding: 16px 20px !important;
    margin-top: auto !important;
    background: #1a1a1a !important;
    border-top: 1px solid rgba(255,255,255,0.08) !important;
    position: static !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    flex: 0 0 auto !important;
  }
  .main-nav .header-actions .btn {
    width: 100% !important;
    text-align: center !important;
    padding: 15px 24px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    background: #FF591B !important;
    color: #ffffff !important;
    border-radius: 6px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
  }

  /* ---- Industries: CSS-only accordion (checkbox) ---- */
  .ind-acc-check:checked ~ .nav-link { color: #FF591B !important; }
  .ind-acc-check:checked ~ .nav-link .arrow { transform: rotate(180deg); }
  .ind-acc-check:checked ~ .dropdown {
    display: block !important;
    max-height: 60vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    z-index: 1050 !important;
    -webkit-overflow-scrolling: touch;
  }
  .ind-acc-check:checked ~ .dropdown .ind-mega { display: none !important; }

  /* ---- backdrop ---- */
  .nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }
  .nav-backdrop.show { opacity: 1; visibility: visible; }

  /* Hide the header hamburger while the drawer is open (drawer has its own ✕) */
  body.nav-lock .menu-toggle {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* ---- scroll lock ---- */
  body.nav-lock { overflow: hidden !important; }
}


/* ---- topbar visible on mobile; header sits below it, drawer starts under it ---- */
@media (max-width: 768px) {
  .topbar { display: block !important; }
  .topbar-text { display: none !important; }
  .topbar-inner { justify-content: center !important; gap: 4px 10px !important; padding: 0 12px !important; }
  .topbar-left { gap: 4px 10px !important; justify-content: center !important; flex: none !important; }
  .topbar-contact { font-size: 11px !important; gap: 3px !important; }
  .topbar-right { gap: 2px !important; }
  .topbar-social { width: 24px !important; height: 24px !important; }
  .topbar-social svg { width: 13px !important; height: 13px !important; }
  .site-header { top: 40px !important; height: 80px !important; }
  .header-inner { padding: 0 20px !important; }
  .main-nav { top: 40px !important; height: calc(100vh - 40px) !important; height: calc(100dvh - 40px) !important; min-height: calc(100vh - 40px) !important; }
}
