/* ALZAN M2 old-page safe layout — 30 Nov 2026 (Maher5).
   CSS only. Charcoal / ivory inherited; no new colours.
   Solution 1: stack the AI launcher in the WhatsApp corner
   (logical inline-start: EN left, AR right) and use a smaller
   start-edge / bottom reserve than the previous both-corners offset.
   Does not edit alzan-whatsapp.js or alzan-assistant.css.
   Does not include page-transition (M2a) rules. */

/* —— 1. FAB stack (max-width 639 = 390 / 412) ———————————— */
@media (max-width: 639px) {
  #alzan-wa {
    inset-inline-start: 16px !important;
    inset-inline-end: auto !important;
    /* New shells (no React tab bar): sit in the true corner. */
    bottom: max(16px, env(safe-area-inset-bottom, 0px)) !important;
  }

  #alzan-va {
    inset-inline-start: 16px !important;
    inset-inline-end: auto !important;
    /* AI stacked above the 52×52 WA button, 10px gap. */
    bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + 52px + 10px) !important;
  }

  /* Panel must open inward from the start edge, not off-canvas. */
  #alzan-va .alzva-panel {
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
  }

  /* Old React shells: keep the stack just above the fixed 4-tab bar
     (nav.fixed.inset-x-3, bottom 12px, height ~62px). 82px is a
     slightly smaller reserve than the live JS 96px. */
  body:has(nav.fixed.inset-x-3) #alzan-wa {
    bottom: calc(12px + 62px + 8px + env(safe-area-inset-bottom, 0px)) !important;
  }
  body:has(nav.fixed.inset-x-3) #alzan-va {
    bottom: calc(12px + 62px + 8px + env(safe-area-inset-bottom, 0px) + 52px + 10px) !important;
  }

  /* Smaller safe offset: only the start edge (16 + 52), not both
     corners. Margin (not padding) so the hit-box itself clears
     Criterion 2a. */
  main#main .ctas,
  main#main .phero .ctas,
  main#main .phero-copy .ctas {
    margin-inline-start: 68px;
    max-width: calc(100% - 68px);
    box-sizing: border-box;
  }

  main#main-content h1,
  main#main-content h2,
  main#main-content .lead,
  main#main-content a.inline-flex[class*="justify-center"],
  main#main-content a[class*="min-h-[52px]"],
  main#main-content a[class*="min-h-16"],
  main#main-content a[class*="min-h-20"],
  main#main-content a.flex[href^="#"],
  main#main-content a[href^="tel:"],
  main#main-content button[class*="min-h-16"],
  main#main-content button[class*="min-h-20"],
  main#main-content button[type="submit"] {
    margin-inline-start: 68px;
    max-width: calc(100% - 68px);
    box-sizing: border-box;
  }

  /* Bottom padding: clear the stacked pair when the page is stopped
     at the end. New shells already have ~120px; bump slightly.
     React shells need more only when the AI launcher is present. */
  main#main {
    padding-bottom: 140px;
  }
  main#main-content {
    padding-bottom: 120px;
  }
  body:has(#alzan-va) main#main-content {
    padding-bottom: 220px;
  }


  /* Contact / quote forms: a 2-up chip row and the submit button were
     measuring ~10–15px past the 390 viewport (C2c fully-in-view). */
  #main-content form {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  #main-content form button {
    max-width: 100%;
    box-sizing: border-box;
  }
  /* —— 2. EN contact 37–39px overflow ————————————————
     Offending node: .space-y-10.alz-in (and sibling .scroll-mt-28.alz-in)
     in a 358px grid cell, used width 412.6px, left 16 → past the 390
     viewport. Cause: grid/flex item min-width:auto plus a long
     unwrapped email / location row, not an image. */
  /* .alz-in is only attached when the M1 bridge runs (not under
     prefers-reduced-motion). Target the same nodes without that class. */
  #main-content .space-y-10,
  #main-content .scroll-mt-28,
  #main-content .space-y-10 .group.flex,
  #main-content .scroll-mt-28 .group.flex {
    min-width: 0;
    max-width: 100%;
    width: auto;
    box-sizing: border-box;
    overflow-wrap: anywhere;
  }
}


/* ≥640: live WA stays labelled on the physical left in EN (and often
   in AR too, via left:24px in the WA stylesheet). Do not move the
   desktop AI launcher. A start-edge (EN) reserve of 196px matches the
   Wave-1 labelled-FAB gutter (24 + ~162 + gap) so first-viewport TOC
   / tel links on short legal and contact pages clear Criterion 2a. */
@media (min-width: 640px) {
  html:not([dir="rtl"]) main#main-content a.flex[href^="#"],
  html:not([dir="rtl"]) main#main-content a[href^="tel:"],
  html:not([dir="rtl"]) main#main-content a.group[href^="tel:"],
  html:not([dir="rtl"]) main#main-content button[type="submit"] {
    margin-inline-start: 196px;
    max-width: calc(100% - 196px);
    box-sizing: border-box;
  }
}

/* Other 390 overflow (measured, not restyled):
   - products 387px: SPAN.alz-glint already clipped by article.pcard
     { overflow: hidden }. Decorative motion, not page scroll.
   - brands 522px: snap-start brand-chip BUTTONS inside
     div.flex.snap-x.overflow-x-auto (intended rail).
   - projects 411px: min-w-max filter BUTTONS inside
     div.flex.overflow-x-auto (intended rail).
   - surface-gallery 1093px: #material-brand-rail snap-start buttons
     with small brand-logo IMGs, overflow-x: auto (intended shelf).
     Noted for maher4: do not hide the logos; the rail already scrolls.
   - technical-library 267px: TABLE 640px inside
     div.alzan-tech-table-scroll { overflow-x: auto }.
   None of these are hidden or width-clipped by this file. */
