/* ============================================================
   FohBoh.ai — Mobile Responsive Fix v1
   Shared stylesheet, linked from every V2 page. Scoped to known
   inline-style patterns so nothing here changes desktop rendering.
   Session notes: see FohBoh-Mobile-Fix-SessionNotes.docx
   ============================================================ */

/* 0. Root cause: every page wrapped its content in a div with
   min-width: 1120px, which forced phones to render a shrunk,
   zoomed-out desktop layout with horizontal scroll. */
html, body { overflow-x: hidden; }
div[style*="min-width: 1120px"] {
  min-width: 0 !important;
  width: 100% !important;
}

/* 1. Primary nav → hamburger below 900px.
   mobile-fix.js adds/toggles the .fb-nav-open class and the button. */
@media (max-width: 900px) {
  nav[style*="padding: 14px 64px"] {
    padding: 14px 20px !important;
    flex-wrap: nowrap !important;
    position: relative;
  }
  nav[style*="padding: 14px 64px"] > a:not(:first-child):not(:last-child) {
    display: none;
  }
  nav[style*="padding: 14px 64px"].fb-nav-open {
    flex-wrap: wrap !important;
    row-gap: 12px;
  }
  nav[style*="padding: 14px 64px"].fb-nav-open > a:not(:first-child):not(:last-child) {
    display: block;
  }
  .fb-hamburger { display: inline-flex !important; }
}
.fb-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid #e8e8ed;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  padding: 7px 11px;
  cursor: pointer;
  order: 99;
}

/* 2. Content grids — collapse to a single column on phones/small tablets. */
@media (max-width: 760px) {
  div[style*="grid-template-columns: 6fr 5fr"],
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 1fr 1fr"],
  div[style*="grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr"],
  div[style*="grid-template-columns: 3fr 1fr 1fr 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 380px"],
  div[style*="grid-template-columns: 1fr 400px"],
  div[style*="grid-template-columns: 1fr 430px"],
  div[style*="grid-template-columns: 220px 1fr auto"],
  div[style*="grid-template-columns: 1fr 60px 1.3fr 60px 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* 2b. Wide multi-column stat/footer rows: 2 columns on tablets, so
   mid-size screens don't drop straight from 6 columns to 1. */
@media (max-width: 980px) and (min-width: 761px) {
  div[style*="grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr"],
  div[style*="grid-template-columns: 3fr 1fr 1fr 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* 3. Label/value key rows (vendor & pricing detail pages) — stack
   instead of forcing a fixed left column phones can't afford. */
@media (max-width: 600px) {
  div[style*="grid-template-columns: 190px 1fr"],
  div[style*="grid-template-columns: 210px 1fr"],
  div[style*="grid-template-columns: 230px 1fr"],
  div[style*="grid-template-columns: 150px 1fr 40px"] {
    grid-template-columns: 1fr !important;
  }
}

/* 4. Dense evidence/ledger rows (CAAR example page) are genuine
   tabular data — collapsing them would break column meaning, so
   they scroll horizontally inside their card instead. */
@media (max-width: 760px) {
  div[style*="border-radius: 18px; overflow: hidden"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  div[style*="grid-template-columns: 90px 1fr 180px 140px"],
  div[style*="grid-template-columns: 150px 130px 1fr 110px 110px 120px"],
  div[style*="grid-template-columns: 1.4fr 160px 1fr"],
  div[style*="grid-template-columns: 180px 1fr 140px"] {
    min-width: 640px;
  }
}

/* 5. Homepage platform-diagram mockup. It was built for desktop only:
   a fixed 780px canvas (rotated 3deg) rendered at zoom:0.5 to fit the
   hero card, with an inner 170px/56px/1fr grid (icon column | arrow |
   product-card stack). None of that scales — on a phone the 1fr column
   gets squeezed so hard that nowrap badges ("Deterministic core",
   "Certified-only") clip off the right edge. Neutralize the desktop
   scaling trick and let it stack full-width instead. */
@media (max-width: 820px) {
  div[style*="zoom: 0.5"] { zoom: 1 !important; }
  div[style*="width: 780px"] {
    width: 100% !important;
    max-width: 100% !important;
    transform: none !important;
  }
  div[style*="grid-template-columns: 170px 56px 1fr"] {
    grid-template-columns: 1fr !important;
    justify-items: center;
    row-gap: 12px;
  }
  img[style*="width: 430px"] { width: 100% !important; max-width: 320px; height: auto !important; }
}

/* 6. Any space-between flex row (card titles next to a badge, CTA text
   next to buttons, footer rows) — these pair a flexible item with a
   nowrap/flex-shrink:0 item and no wrap, so on a phone the second item
   either clips or spills outside the card. Wrapping is a no-op when
   content already fits, so this is safe sitewide. */
@media (max-width: 700px) {
  [style*="justify-content: space-between"] {
    flex-wrap: wrap !important;
    row-gap: 14px;
  }
}

/* 7. Fluid hero type. */
@media (max-width: 640px) {
  h1 { font-size: clamp(28px, 8vw, 40px) !important; line-height: 1.15 !important; }
}

/* 8. Universal 64px desktop gutter. Nearly every full-width section on
   every page uses 64px as its horizontal padding or margin (nav, hero,
   stat rows, footer rows, CTA cards, legal pages) — on a 375px phone
   that alone consumes a third of the screen before any content renders,
   which is why cards, buttons and CTA rows were spilling past the edge
   even after the grid/flex fixes above. Reduce just the horizontal
   component; top/bottom spacing (never 64px in this codebase) is
   untouched. Scoped to elements that actually declare padding/margin,
   so fixed-size icons/badges that merely happen to be 64px square
   (checked against the live site) are not matched. */
@media (max-width: 700px) {
  [style*="padding:"][style*="64px"] {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
  [style*="margin:"][style*="64px"] {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* 9. General safety net. */
img, iframe, video { max-width: 100%; }
