/* === Evara auth mobile branch — v1. =========================================
   SERVED AS PLATFORM CSS. `LiveSiteHead` links this file LAST on every
   public-render surface, so it ships with the deploy and needs nobody to
   remember anything.

   It is ALSO appendable to websites.global_css by
   scripts/marketing/ship-auth-mobile-css.ts (and by
   scripts/marketing/ship-global-auth-css.ts, which always re-appends it so a
   desktop re-ship can never drop the mobile branch). That path is now
   belt-and-braces, not the delivery mechanism.

   WHY THE LINK EXISTS — measured 2026-09-05
   -----------------------------------------
   This file was written on 2026-09-05 and the ship script was never run. On
   the live https://evara.build/login served by prod sha 2a73037 the marker on
   line 1 of this file appeared **0 times** in the delivered HTML, so every
   rule below was inert and the phone layout was exactly as broken as it was
   before the file existed. A CSS fix whose only delivery path is a hand-run
   DB script is a to-do, not a fix.

   WHY THIS FILE EXISTS
   --------------------
   Measured 2026-09-05 against the LIVE https://evara.build/login with the
   ExactQA runner (POST 127.0.0.1:9000/layout-audit) and against the page's own
   inline global_css:

     * The auth block in websites.global_css is 58,692 chars and contains
       ZERO @media rules. The only two @media rules in the whole 66,728-char
       global_css sit at offsets 7576 / 7697 — BEFORE the auth marker at 8036 —
       and belong to the footer. The auth design is desktop-only by
       construction, and it is 633 declarations of !important deep, so nothing
       downstream can soften it.

     * That produces FOUR nested padded boxes. On a 390px viewport the
       horizontal padding alone is:

         [data-element-id="el-signin-columns"]  padding 32px 20px   ->  40px
         .el--login-form   (outer ghost)        padding 60px 22px   ->  44px
         .el-login-form--card                   padding 36px 44px   ->  88px
         .el-login-form__surface (renderer)     padding 28px 24px   ->  48px
                                                              total -> 220px

       ExactQA measured the resulting content column directly:
       button.el-login-form__submit had client_width 144px inside a 390px
       viewport while its own text needed scroll_width 316px (delta 172px,
       reported as text_truncation/accidental_clip). At 361px the same button
       was 115px wide.

     * The segmented rows are pinned to a fixed height and clipped:
       .el-login-form__tabs / .el-login-form__mode-tabs carry
       "height: 48px !important; overflow: hidden !important", and every
       segment inside carries "flex: 1 1 0 !important; height: 34px !important;
       max-height: 34px !important; padding: 0 12px !important". ExactQA
       measured each method tab at 40.67px wide / 34px tall at 390px and
       30.33px wide at 359px — which is why "Login link / Password / Passkey"
       renders as "ogin lir / asswor / asske" in the owner's screenshot. A
       centred flex item clips on BOTH sides, and text-overflow never applies
       to a flex container, so no ellipsis appears either.

     * .el-login-form__form is "display: grid; grid-template-columns:
       repeat(2, minmax(0, 1fr))" unconditionally — a two-column form inside a
       144px column.

   WHAT THIS BRANCH DOES
   ---------------------
   It does not restyle anything. It only (a) collapses the padding stack from
   220px to 104px per 390px viewport, (b) un-pins the segmented rows so labels
   wrap instead of being clipped and every segment is a >= 44px tap target,
   (c) forces the form grid to one column, (d) stops long strings (the
   recipient email on the magic-link screen) from spilling past the card, and
   (e) adds safe-area insets. Everything in that branch is inside
   @media (max-width: 480px), so it cannot reach desktop.

   One block sits OUTSIDE that media query — the segmented-row floor directly
   below — because the clipping it fixes was measured at 768 and 1440 too. It
   is the only such block and a guard keeps it that way.

   SPECIFICITY, and why it is not optional — MEASURED 2026-09-05
   -------------------------------------------------------------
   Every selector below is the desktop selector it overrides with `html:root `
   spliced onto the front (`html body ...` becomes `html:root body ...`; a
   `:root ` PREFIX would never match, because html is not a descendant of
   itself). That adds exactly one class-level unit, so each rule outranks the
   desktop rule it is aimed at and nothing else.

   This used to rely on source order instead, on the theory that the block is
   appended last. That theory is false for the served copy. Read back through
   `document.styleSheets` on the live page with the floor injected at the exact
   position LiveSiteHead emits it:

     sheet 36  /css/leaflet.css          <- last platform stylesheet
     sheet 37  the injected floor
     sheet 38  <style data-custom-css="site">   <- the tenant blob

   React hoists the tenant <style> BELOW every platform <link> during
   hydration, so an equally-specific !important copy loses no matter where the
   link is emitted. Specificity is order-independent; source order is not.

   Do not "simplify" the long html:root body [data-element-id$="-form"]...
   selector — everything after `html:root ` must stay a byte-for-byte copy of
   the desktop rule or the override silently stops working.
   ========================================================================== */

/* === AT EVERY WIDTH: a segmented row may not clip its own labels. ==========
   This is the ONLY block in this file outside the phone media query, and it is
   deliberately narrow: it un-pins the two segmented rows and nothing else.
   segmentedRowFloor is the guard that keeps it that way
   (loginFormMobileLayout.test.tsx).

   MEASURED 2026-09-05 on the live page through the ExactQA runner
   (POST 127.0.0.1:9000/browser-action, getBoundingClientRect per selector):

     390x844   .el-login-form__tabs  h=48  overflow hidden  flex-wrap WRAP
               3 x .el-login-form__tab @ 130px in a 142px row -> 3 wrapped
               rows of 34px, rows 2 and 3 entirely inside the clipped region
     768x1024  same row, "Passkey" alone on a 2nd row at y-offset 38px
     1440x900  identical to 768 (the card is a fixed 394px)

   So the Passkey tab was invisible at EVERY measured width, not only on a
   phone. The desktop tenant block pins the row
   ("height/min-height/max-height: 48px !important; overflow: hidden
   !important") and each segment ("height/min-height/max-height: 34px
   !important"), and 28f29bc52 gave the row "flex-wrap: wrap" — a wrapped row
   inside a fixed-height clipped box hides whatever wrapped.

   The phone branch below already fixes this under 480px. Un-pinning the row
   height at all widths is what stops a wrapped segment from disappearing on a
   tablet or a desktop. Segment MIN-height stays at the desktop 34px here; the
   phone branch raises it to 44px for tap targets, which is why this block has
   to come FIRST — two !important declarations of equal specificity are decided
   by source order, and putting this last silently capped the phone at 34px
   (measured on the fixture before the blocks were swapped). */
html:root .el-login-form__mode-tabs,
html:root .el-login-form__tabs {
  flex-wrap: wrap !important;
  row-gap: 4px !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

html:root body [data-element-id$="-form"][data-element-id^="el-"] button.el-login-form__mode-tab,
html:root body [data-element-id$="-form"][data-element-id^="el-"] button.el-login-form__mode-tab--active,
html:root body [data-element-id$="-form"][data-element-id^="el-"] button.el-login-form__tab,
html:root body [data-element-id$="-form"][data-element-id^="el-"] button.el-login-form__tab--active,
html:root .el-login-form__mode-tab,
html:root .el-login-form__mode-tab--active,
html:root .el-login-form__tab,
html:root .el-login-form__tab--active {
  /* flex:1 1 0 is the declaration that shrinks a segment below its own label. */
  flex: 1 1 auto !important;
  min-width: fit-content !important;
  height: auto !important;
  min-height: 34px !important;
  max-height: none !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  overflow-wrap: break-word !important;
}

@media (max-width: 480px) {
  /* --- 1. The padding stack: 220px -> 104px per side pair at 390px. ------- */
  html:root [data-element-id="el-signin-columns"],
  html:root [data-element-id="el-signup-columns"] {
    /* align-items:center + min-height:100dvh vertically centres a card that is
       taller than the phone, which pushes the heading off the top of the
       screen (owner screenshot 0c816ecb starts mid-card). Start at the top and
       let the page scroll instead. */
    align-items: flex-start !important;
    min-height: 100dvh !important;
    padding-top: 20px !important;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
    padding-left: calc(12px + env(safe-area-inset-left, 0px)) !important;
    padding-right: calc(12px + env(safe-area-inset-right, 0px)) !important;
  }

  /* The desktop design floats the SYSTEM ONLINE pill in the 60px gap above the
     card by taking .el-login-form__eyebrow-row out of flow
     ("position: absolute; top: 12px" anchored to this wrapper). On a phone the
     pill lands on top of the logo — visible in the owner's screenshot
     4cea9d59 and reproduced in the before/after fixture capture. Absolute
     positioning is the wrong tool at this width: put the pill back in the
     normal flow, stacked above the logo, and the 60px reservation it needed
     disappears with it. */
  html:root .el-login-form__eyebrow-row {
    position: static !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin: 0 auto 10px !important;
    padding-bottom: 0 !important;
  }

  html:root .el--login-form,
  html:root .el--signup-form {
    max-width: 100% !important;
    /* No pill gap to reserve any more, so this is just breathing room. */
    padding: 12px 10px !important;
  }

  /* 96px of logo plus a 96px-tall glow is a third of a phone screen. */
  html:root .el-login-form__logo,
  html:root .el-login-form img[alt*="logo" i] {
    width: 64px !important;
    height: 64px !important;
    margin: 0 auto 14px !important;
  }

  html:root .el-login-form--card,
  html:root .el-signup-form--card {
    padding: 22px 16px 24px !important;
  }

  html:root .el-login-form__surface {
    padding: 18px 14px !important;
  }

  /* --- 2. Segmented rows: unpin the height, let labels wrap, 44px targets. */
  html:root .el-login-form__mode-tabs,
  html:root .el-login-form__tabs {
    flex-wrap: wrap !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    row-gap: 4px !important;
  }

  html:root body [data-element-id$="-form"][data-element-id^="el-"] button.el-login-form__mode-tab,
  html:root body [data-element-id$="-form"][data-element-id^="el-"] button.el-login-form__mode-tab--active,
  html:root body [data-element-id$="-form"][data-element-id^="el-"] button.el-login-form__tab,
  html:root body [data-element-id$="-form"][data-element-id^="el-"] button.el-login-form__tab--active,
  html:root .el-login-form__mode-tab,
  html:root .el-login-form__mode-tab--active,
  html:root .el-login-form__tab,
  html:root .el-login-form__tab--active {
    /* flex:1 1 0 is what shrinks a segment below its own label. Content width
       plus wrapping is the only layout that cannot truncate. */
    flex: 1 1 auto !important;
    min-width: fit-content !important;
    height: auto !important;
    min-height: 44px !important;
    max-height: none !important;
    padding: 8px 10px !important;
    line-height: 1.2 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: break-word !important;
  }

  /* --- 3. One column. A two-column grid inside a phone card is not a grid. */
  html:root .el-login-form__form,
  html:root .el-signup-form__form {
    grid-template-columns: 1fr !important;
  }

  /* --- 4. Long unbroken strings must not leave the card. The magic-link
     screen prints the recipient address verbatim; in the owner's screenshot
     "Mhoskins@viatechsystems.com" runs past the card's right edge. --------- */
  html:root .el-login-form__magic-sent-email,
  html:root .el-login-form__magic-sent-body,
  html:root .el-login-form__magic-sent-title,
  html:root .el-login-form__description,
  html:root .el-login-form__error,
  html:root .el-login-form__success {
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }

  /* --- 5. Tap targets + no iOS zoom-on-focus (needs >= 16px). ------------- */
  html:root .el-login-form__input {
    font-size: 16px !important;
    min-height: 44px !important;
  }

  html:root .el-login-form__submit,
  html:root .el-login-form__method-button,
  html:root .el-login-form__magic-reset {
    min-height: 48px !important;
    white-space: normal !important;
  }

  /* --- 6. Nothing in the auth column may exceed the viewport. ------------- */
  html:root [data-element-id="el-signin-columns"] *,
  html:root [data-element-id="el-signup-columns"] * {
    max-width: 100% !important;
  }
}
