/* ================================================
   Responsive Media Utilities — Pegasi Defense
   assets/css/media.css

   Load order: after per-page CSS, before mobile-menu.css
   ================================================ */

/* ── 1. Global image / media base ───────────────
   Prevents any image from breaking viewport width.
   display:block removes the 4px baseline gap that
   inline images leave below themselves.
   ─────────────────────────────────────────────── */
img,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

svg {
  max-width: 100%;
}

/* ── 2. .media frame utility ─────────────────────
   Wraps an <img> or <video> in a locked-aspect box.
   The child fills the frame with object-fit: cover.

   Usage:
     <div class="media media--16x9">
       <img src="photo.jpg" alt="…" loading="lazy">
     </div>
   ─────────────────────────────────────────────── */
.media {
  position: relative;
  overflow: hidden;
  width: 100%;
}

.media > img,
.media > video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Aspect ratio variants */
.media--16x9   { aspect-ratio: 16 / 9; }
.media--4x3    { aspect-ratio: 4 / 3; }
.media--3x2    { aspect-ratio: 3 / 2; }
.media--square { aspect-ratio: 1 / 1; }
.media--logo   { aspect-ratio: 5 / 2; }   /* wide horizontal logo  */

/* object-fit: contain for logos, seals, badges */
.media--contain > img,
.media--contain > video {
  object-fit: contain;
}

/* ── 3. Hero logo ────────────────────────────────
   Already sized by existing CSS; we clamp the max-
   width so it never overflows on narrow viewports.
   decoding="async" added in HTML (it starts opacity:0).
   ─────────────────────────────────────────────── */
.hero-logo {
  max-width: min(300px, 80vw);
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* ── 4. Seal carousel — CLS guard ───────────────
   .seal-item already has explicit 140×140 CSS dims.
   Adding aspect-ratio here gives the browser a box
   to reserve before the image bytes arrive, cutting
   layout shift to zero.
   ─────────────────────────────────────────────── */
.seal-item {
  aspect-ratio: 1 / 1;
  overflow: hidden;          /* belt-and-suspenders */
  flex-shrink: 0;
}

.seal-image {
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

/* ── 5. WOSB / info badge ────────────────────────
   Fixed 120×120 by existing CSS; aspect-ratio backs
   that up before the image loads.
   ─────────────────────────────────────────────── */
.info-image-compact {
  aspect-ratio: 1 / 1;
}

/* ── 6. Seal carousel overflow guard ────────────
   The full-bleed breakout (negative-margin trick)
   can trigger a scrollbar on some Android browsers.
   overflow:hidden is already set; this backs it up.
   ─────────────────────────────────────────────── */
.seals-carousel {
  max-width: 100vw;
}

/* ── 7. background-attachment: fixed — mobile fix
   iOS Safari ignores background-attachment: fixed
   and renders backgrounds at the wrong offset,
   producing a blurry or solid-colour appearance.
   All Android browsers have scroll-jank with fixed.
   Switch to scroll on every touch viewport.
   ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .section-image-bg,
  .section-careers-main {
    background-attachment: scroll !important;
  }
}

/* Also disable for users who prefer reduced motion
   (fixed parallax is a vestibular trigger)        */
@media (prefers-reduced-motion: reduce) {
  .section-image-bg,
  .section-careers-main {
    background-attachment: scroll !important;
  }
}

/* ── 8. Horizontal overflow elimination ──────────
   Fixes identified via full-site audit.
   ─────────────────────────────────────────────── */

/* 8a. Root-level overflow guard.
   Every page's minified CSS sets
   body { overflow-x: hidden }, but on most browsers
   the actual scrollable root is <html>, not <body>.
   Both must be set to reliably suppress the
   horizontal scrollbar.                            */
html { overflow-x: hidden; }

/* 8b. white-space: nowrap reset on mobile.
   about.min.css, careers.min.css, employees.min.css,
   and thelatest.min.css all set
   .contact-preview .body-text { white-space: nowrap }
   with no mobile override. On any phone narrower
   than the text string the content overflows.      */
@media (max-width: 768px) {
  .contact-preview .body-text { white-space: normal; }
}

/* 8c. iframe safe guard.
   careers.html embeds a job-board iframe that is
   given a fixed height but no explicit max-width
   constraint at the element level.                 */
iframe { max-width: 100%; }

/* 8d. info-bubble-combined flex wrap.
   The DUNS + WOSB badge + CAGE CODE row is ~370px
   wide at minimum. On 320–360px viewports the items
   overflow. Stack vertically on narrow screens.    */
@media (max-width: 480px) {
  .info-bubble-combined {
    flex-direction: column;
    align-items: center;
  }
}
