/* ============================================================
   IMGCNV — Universal Mobile Responsive Layer
   Loaded on every page, after page-specific CSS, so it can
   patch overflow / layout issues regardless of each tool's
   own class names. Written defensively with !important only
   where needed to guarantee no horizontal scroll and usable
   tap targets on phones.
   ============================================================ */

/* ---------- Base safety ---------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
html, body {
  max-width: 100%;
  overflow-x: hidden;
}
* {
  -webkit-tap-highlight-color: transparent;
}

/* Keep focus visible for keyboard users without adding a ring on tap/click */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid #0EA5E9;
  outline-offset: 2px;
}

/* Respect safe areas on notch devices when installed as a PWA */
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Media never overflows its container */
img, svg, video, canvas, iframe, embed, object {
  max-width: 100%;
  height: auto;
}

/* Tables scroll instead of breaking layout */
table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
}

pre, code {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Form controls never force horizontal scroll, and never
   trigger iOS Safari's auto-zoom-on-focus (needs >=16px) */
input, select, textarea, button {
  max-width: 100%;
}
input[type="text"], input[type="email"], input[type="url"],
input[type="search"], input[type="number"], input[type="tel"],
input[type="password"], textarea, select {
  font-size: 16px;
}

/* Comfortable tap targets on touch devices */
@media (max-width: 768px) {
  button, .btn, a.btn, [class*="-btn"], [class$="Btn"],
  input[type="submit"], input[type="button"] {
    min-height: 44px;
  }
}

/* ---------- Generic layout containment ---------- */
@media (max-width: 768px) {
  [class*="container"], [class*="wrapper"], [class*="-section"],
  section {
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Any multi-column grid collapses to a fluid single/double
     column layout instead of a fixed track count that overflows */
  [class*="grid"], [class*="-cards"], [class*="cards-"],
  [class*="benefits"], [class*="features"], [class*="options"] {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
    gap: 12px !important;
  }

  /* Button / control rows wrap instead of overflowing */
  [class*="controls"], [class*="-buttons"], [class*="buttons-"],
  [class*="actions"], [class*="toolbar"] {
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 8px !important;
  }

  /* Modals / dialogs stay within the viewport */
  [class*="modal-content"], [class*="modal-box"], [class*="dialog"] {
    width: 92vw !important;
    max-width: 92vw !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
  }
}

/* ---------- Small phones (SE / narrow Android) ---------- */
@media (max-width: 420px) {
  [class*="container"], [class*="wrapper"], [class*="-section"] {
    padding-left: 12px;
    padding-right: 12px;
  }
  h1 { font-size: clamp(1.4rem, 7vw, 1.9rem) !important; }
  h2 { font-size: clamp(1.2rem, 6vw, 1.6rem) !important; }
}

/* ---------- Landscape phones: avoid full-height overlays trapping content ---------- */
@media (max-height: 480px) and (orientation: landscape) {
  [class*="modal"] {
    overflow-y: auto !important;
  }
}
