/* ==========================================================================
   ADS MOBILE LAYER  (Aurora Design Studios / Aurora Design Systems)
   One shared file that controls phone and tablet layout for every page.
   It is linked last on each page, together with ads-mobile.js.
   Desktop screens wider than 1024px are not affected; touch tablets up to 1366px are.
   ========================================================================== */
@media (max-width: 1024px), (pointer: coarse) and (max-width: 1366px) {
  /* 1. Release the fixed desktop canvas (old pages locked html/body to 1500-1720px) */
  html:not(#ads-m), html:not(#ads-m) body {
    min-width: 0 !important;
    width: auto !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  html:not(#ads-m) body { overflow-wrap: break-word; -webkit-text-size-adjust: 100%; zoom: 1 !important; }
  /* Headings keep whole words; ads-mobile.js shrinks any heading that is too wide */
  html:not(#ads-m) body :where(h1, h2, h3) { overflow-wrap: normal; word-break: normal; }

  /* 2. No layout block may be wider than the screen */
  html:not(#ads-m) body :where(header, main, section, footer, nav, article, aside, div, form,
      figure, ul, ol, dl, p, h1, h2, h3, h4, h5, h6, blockquote, details, fieldset) {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* 3. Media scales down to fit */
  html:not(#ads-m) body :where(img, video, iframe, canvas, object, embed) {
    max-width: 100% !important;
    height: auto;
  }
  html:not(#ads-m) body :where(svg) { max-width: 100% !important; }

  /* 4. Wide tables and code scroll sideways inside their own box */
  html:not(#ads-m) body table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  html:not(#ads-m) body pre { white-space: pre-wrap !important; }

  /* 5. Buttons and links stay tappable */
  html:not(#ads-m) body :where(a, button) { word-break: normal; }
}

@media (max-width: 600px) {
  /* Main site menu: one swipeable row instead of a tall stack of buttons */
  html:not(#ads-m) body .ads-nav {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start !important;
    gap: 8px !important;
    padding-bottom: 4px;
  }
  html:not(#ads-m) body .ads-nav::-webkit-scrollbar { display: none; }
  html:not(#ads-m) body .ads-nav a { flex: 0 0 auto !important; white-space: nowrap; }

  /* Comfortable side margins on phones */
  html:not(#ads-m) body :where(main, section, article) { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
}
