/* ShieldTech — shared mobile responsive layer.
   Loaded via <helmet> on every site page. Desktop (>768px) is untouched;
   below 768px these rules re-flow the existing inline-styled layout:
   grids stack, flex rows wrap, oversized paddings compress, the desktop
   nav hides (mobile-nav.js provides the tab bar + menu). */

@media (max-width: 768px) {
  /* decorative glows bleed past the viewport by design — clip at the root */
  html, body { overflow-x: clip !important; }

  /* bottom tab bar removed; no reserved padding */

  /* ---- header: logo + phone pill only; desktop nav hidden ---- */
  header { padding-top: env(safe-area-inset-top) !important; }
  header nav[aria-label="Primary"] { display: none !important; }
  header a[href^="tel:"] { margin-left: auto !important; font-size: 12px !important; padding: 8px 13px !important; }
  header img[alt="ShieldTech Security"] { height: 28px !important; }

  /* ---- grids: everything stacks to one column ---- */
  main [style*="grid-template-columns"],
  footer [style*="grid-template-columns"],
  header [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* small-item grids (logos, chips, stats — minmax mins of 100–199px) go 2-up */
  main [style*="minmax(min(100%, 1"],
  main [style*="minmax(min(100%,1"] { grid-template-columns: repeat(2, 1fr) !important; }

  /* ---- accordions: every summary is a row, question left, +/chevron pinned right at one fixed width ---- */
@media (max-width: 768px) {
  main summary { display: flex !important; flex-wrap: nowrap !important; justify-content: space-between !important; align-items: center !important; gap: 14px !important; grid-template-columns: none !important; min-height: 48px; }
  main summary > :first-child { flex: 1 1 auto; min-width: 0; }
  main summary > :last-child:not(:first-child) { flex: 0 0 auto !important; min-width: 28px; text-align: center !important; display: inline-flex; align-items: center; justify-content: center; }
  main summary > :last-child:not(:first-child):not([style*="width"]) { width: 28px !important; }
  main summary::-webkit-details-marker { display: none; }
  main summary { list-style: none; }
}

/* ---- flex rows wrap instead of overflowing (column stacks must NOT wrap: wrap on a column stretches
          children to fill the column, e.g. the contact cards grid grew to 1284px) ---- */
  main [style*="display: flex"]:not([style*="flex-wrap"]):not([style*="nowrap"]):not([style*="flex-direction: column"]) { flex-wrap: wrap; }
  main [style*="flex-direction: column"] { flex-wrap: nowrap !important; }
  /* icon/badge + text rows: never wrap the text under the badge; badge keeps its size, text shrinks */
  main [style*="display: flex"][style*="align-items: center"] > span[aria-hidden="true"][style*="width: 44px"],
  main [style*="display: flex"][style*="align-items: center"] > span[aria-hidden="true"][style*="width: 40px"],
  main [style*="display: flex"][style*="align-items: center"] > span[aria-hidden="true"][style*="width: 36px"] { flex: 0 0 auto; }
  main [style*="display: flex"][style*="align-items: center"]:has(> span[aria-hidden="true"][style*="width: 44px"]),
  main [style*="display: flex"][style*="align-items: center"]:has(> span[aria-hidden="true"][style*="width: 40px"]),
  main [style*="display: flex"][style*="align-items: center"]:has(> span[aria-hidden="true"][style*="width: 36px"]) { flex-wrap: nowrap !important; }
  main [style*="display: flex"][style*="align-items: center"]:has(> span[aria-hidden="true"]) > span:not([aria-hidden]) { min-width: 0; flex: 1 1 auto; }

  /* ---- side-by-side panels that used a border divider ---- */
  main [style*="border-left: 1px solid"][style*="padding-left: 36px"],
  header [style*="border-left: 1px solid"][style*="padding-left: 36px"] {
    border-left: none !important; padding-left: 0 !important;
    border-top: 1px solid rgba(255,255,255,0.08); padding-top: 22px;
  }

  /* ---- compress desktop-scale section padding ---- */
  main [style*="padding: 110px"], main [style*="padding: 100px"],
  main [style*="padding: 96px"],  main [style*="padding: 90px"],
  main [style*="padding: 84px"],  main [style*="padding: 80px"],
  main [style*="padding: 76px"],  main [style*="padding: 70px"],
  main [style*="padding: 68px"],  main [style*="padding: 64px"],
  main [style*="padding: 60px"],  main [style*="padding: 56px"],
  main [style*="padding: 52px"],  main [style*="padding: 48px"] {
    padding-top: 44px !important; padding-bottom: 44px !important;
  }

  /* ---- tighten big vertical gaps and margins ---- */
  main [style*="gap: 64px"], main [style*="gap: 60px"], main [style*="gap: 56px"],
  main [style*="gap: 52px"], main [style*="gap: 48px"], main [style*="gap: 44px"],
  main [style*="gap: 40px"], main [style*="gap: 36px"] { gap: 26px !important; }
  main [style*="gap: 32px"], main [style*="gap: 30px"], main [style*="gap: 28px"] { gap: 20px !important; }
  main [style*="margin-top: 6"], main [style*="margin-top: 7"], main [style*="margin-top: 8"] { margin-top: 36px !important; }
  main [style*="margin-bottom: 6"], main [style*="margin-bottom: 7"], main [style*="margin-bottom: 8"] { margin-bottom: 36px !important; }

  /* lazy embeds reserve desktop heights — shorten the reserve on phones */
  main [data-lazy] { min-height: 300px !important; }

  /* ---- media never overflows ---- */
  main img, main svg, main video { max-width: 100%; }
  h1, h2, h3, h4, p { overflow-wrap: break-word; text-wrap: pretty; }

  /* sticky page-index handles itself (<1200px); belt & suspenders */
  nav[aria-label="Page sections"] { display: none !important; }

  /* mega-menu panel content scrolls if tall */
  header sc-if > div { max-height: 70vh; overflow-y: auto; }

  /* ---- symmetry: one shared gutter for every section's content ---- */
  main > section > [style*="max-width"],
  main > section > div > [style*="max-width"] { padding-left: 20px !important; padding-right: 20px !important; }
  footer > div { padding-left: 20px !important; padding-right: 20px !important; }

  /* comfortable tap targets on links styled as buttons */
  main a[style*="border-radius: 999px"] { min-height: 44px; box-sizing: border-box; align-items: center; }

  /* ---- Residential arming scroller: narration docks to the bottom (above the
     tab bar), house rides high and right so nothing overlaps ---- */
  #ra-sticky { align-items: flex-start !important; }
  #ra-sticky div[style*="rgba(5,7,12,0.94)"] { display: none !important; } /* desktop left scrim */
  #ra-narr {
    position: absolute !important; left: 12px !important; right: 12px !important;
    top: auto !important; bottom: 92px !important; width: auto !important;
    background: rgba(5,7,12,0.9); border: 1px solid rgba(92,184,255,0.22);
    border-radius: 14px; padding: 13px 16px;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  #ra-nk { font-size: 9px !important; margin-bottom: 7px !important; }
  #ra-nt { font-size: 17px !important; margin-bottom: 6px !important; }
  #ra-nb { font-size: 11.5px !important; line-height: 1.55 !important; }
  #ra-stage { width: 128% !important; margin-left: 30vw !important; margin-top: -22vh !important; }
  #ra-cue { bottom: 96px !important; }
  #ra-final { padding: 0 20px 170px !important; box-sizing: border-box; }
}

@media (max-width: 480px) {
  /* phones: 2-up grids that are still cramped drop to 1 col; keep tiny chips 2-up */
  main [style*="minmax(min(100%, 18"],
  main [style*="minmax(min(100%, 19"] { grid-template-columns: 1fr !important; }
}

/* ---- forms: every lead form on the site, phone widths ---- */
@media (max-width: 768px) {
  main form { padding: 22px 18px !important; border-radius: 16px !important; min-width: 0; }
  main form > div[style*="grid"] { grid-template-columns: 1fr !important; gap: 14px !important; }
  main form label { min-width: 0; }
  main form input:not([type="checkbox"]):not([type="radio"]), main form select, main form textarea {
    width: 100% !important; box-sizing: border-box !important; min-height: 50px;
    font-size: 16px !important; /* no iOS zoom-on-focus */
    padding: 13px 15px !important;
  }
  main form textarea { min-height: 120px; }
  main form fieldset { padding: 12px 14px 14px !important; min-width: 0; }
  main form fieldset > div[style*="grid"] { grid-template-columns: 1fr !important; gap: 0 !important; }
  main form fieldset label { min-height: 44px; padding: 4px 0; font-size: 15px !important; }
  main form fieldset input[type="checkbox"] { width: 20px; height: 20px; flex: none; }
  main form button[type="submit"] { width: 100%; min-height: 52px; font-size: 16px !important; }
  /* contact info cards above the form: one column, equal height */
  main section div[style*="grid-template-columns"] > div[style*="border-radius: 18px"][style*="padding: 20px 22px"] { padding: 16px 18px !important; }
  /* Consultation page: desktop has ~400px of hero air before the form; phones don't */
  #contact > div[aria-hidden="true"] { height: 0 !important; }
  #contact div[style*="grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px)"] { padding: 40px 20px 72px !important; gap: 28px !important; }
  #contact div[style*="grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px)"] > div:first-child { gap: 14px !important; }
  #contact h2 { font-size: 32px !important; }
  /* phones: the compact form card already carries the heading and call/email pills, so the intro column
     (h2, blurb, CALL/EMAIL/HOURS cards) above it is redundant. Form starts the section. */
  #contact div[style*="grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px)"] > div:first-child:not(:has(form)) { display: none !important; }
  #contact div[style*="grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px)"] { padding-top: 28px !important; }
  #contact .mq h3.dup { display: block !important; }
}

/* comfortable tap targets for footer and header links on touch widths */
@media (max-width: 768px) {
  footer nav a, header nav a { padding-top: 8px !important; padding-bottom: 8px !important; display: inline-block; }
  footer a { min-height: 44px; display: inline-flex; align-items: center; }
  /* breadcrumbs: tiny caps links become finger-sized rows */
  main nav[aria-label="Breadcrumb"] { min-height: 44px; align-items: center; }
  main nav[aria-label="Breadcrumb"] a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; }
  /* demo bars: Watch / Try it pills */
  main [data-demo-bar] a, main [data-demo-bar] button { min-height: 44px !important; padding-top: 11px !important; padding-bottom: 11px !important; }
  /* contact cards (CALL / EMAIL) and in-copy section links: full-row tap targets */
  main div[style*="border-radius: 18px"] > a[href^="tel:"], main div[style*="border-radius: 18px"] > a[href^="mailto:"] { display: flex !important; align-items: center; min-height: 44px !important; }
  main a[href^="Service-"][style*="font-size: 1"]:not([style*="border-radius"]) { display: inline-flex; align-items: center; min-height: 44px; }
  /* no label under 11px anywhere; keeps letter-spaced caps legible on 390px */
  main [style*="font-size: 9px"], main [style*="font-size: 9.5px"], main [style*="font-size: 10px"], main [style*="font-size: 10.5px"],
  main [style*="font-size: clamp(9px"], main [style*="font-size: clamp(9.5px"], main [style*="font-size: clamp(10px"],
  main [style*="font-size:9px"], main [style*="font-size:9.5px"], main [style*="font-size:10px"], main [style*="font-size:10.5px"] { font-size: 11px !important; }
}

/* Mechanism / demo cards (service pages): at phone widths the 16:10 box with min-height 260px forced a 416px intrinsic
   width inside a 350px column, clipping the demo and its caption. Let the grid children shrink and swap to 4:3,
   which keeps the same ~260px height without overflowing. Desktop is unchanged. */
@media (max-width: 640px) {
  [style*="minmax(min(100%, 520px), 1fr)"] > * { min-width: 0 !important; max-width: 100% !important; box-sizing: border-box; }
  [style*="aspect-ratio: 16 / 10"][style*="min-height: 260px"] { width: 100% !important; max-width: 100% !important; min-width: 0 !important; min-height: 0 !important; aspect-ratio: 4 / 3 !important; box-sizing: border-box; }
}

/* Any grid track or flex child may shrink below its content's intrinsic width. Fixes the "Depth" sections on the
   fire and intrusion pages, where an <image-slot> in an aspect-ratio box forced the grid to 6000px+. */
@media (max-width: 768px) {
  main [style*="display: grid"] > * { min-width: 0; max-width: 100%; }
  main [style*="display: grid"] > * > [style*="aspect-ratio"] { width: 100% !important; max-width: 100% !important; min-width: 0 !important; }
  main image-slot, main iso-device, main ind-demo, main canvas, main video { max-width: 100% !important; min-width: 0 !important; }
  main [style*="display: flex"]:not([style*="nowrap"]) > * { min-width: 0; }
  /* inline text links inside copy get a 44px tap box without changing the line */
  main p a[style*="display: inline-block"], main div > a[style*="display: inline-block"][style*="font-size: 13"] { padding: 12px 0 !important; margin-top: -12px !important; margin-bottom: -12px !important; }
}
