/* assets/css/mobile-forms.css
   ---------------------------------------------------------------------------
   Shared mobile form hygiene for the public/auth pages (login, sign-up,
   register, 2FA, company form, MC submission, submit task...).

   Two problems were measured on every one of those pages at 390px:

   1. Inputs rendered at 13.3-14px. Safari on iOS zooms the whole viewport when
      a field smaller than 16px receives focus, so tapping any field threw the
      page out of alignment and the user had to pinch back. 16px is the
      threshold, not a preference.
   2. Controls were 37-43px tall (register.html: 20px), below the 44px comfortable
      touch target.

   Scoped entirely to `max-width: 767px` - desktop is untouched. `!important` is
   used only on font-size, where it has to beat each page's own element/class
   rules; everything else wins on specificity alone.
   --------------------------------------------------------------------------- */

/* ===========================================================================
   NOT mobile-only - this one applies at every width.

   These pages link style.css for tokens and shared components, and style.css
   configures BODY for the app shell:

       body { display: flex; height: 100vh; overflow: hidden; }

   On a standalone auth/form page that is fatal. The document is locked to the
   viewport height with overflow clipped, so a card taller than the screen gets
   no scrollbar and the rest of it is simply unreachable. Measured on
   mc_submission.html at 844x390 (a phone held sideways): a 591px card in a
   390px viewport, max scrollY = 0, submit button permanently off-screen.

   Give the document its natural height back. `display` is deliberately left
   alone so the existing centring still works.

   Excluded: pages that really are the app shell. They contain .app-container
   and depend on the 100vh body with inner scrolling. On a browser without :has() the rule
   is dropped and behaviour is unchanged, never worse.
   =========================================================================== */
body:not(:has(.app-container)) {
    height: auto;
    min-height: 100%;
    overflow: visible;
}

@media (max-width: 767px) {

    /* --- 1. Never let iOS zoom on focus --- */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
    select,
    textarea {
        font-size: 16px !important;
        min-height: 44px;
        box-sizing: border-box;
        max-width: 100%;
    }

    textarea { min-height: 104px; }

    /* --- 2. Comfortable pressable areas --- */
    button,
    input[type="submit"],
    input[type="button"],
    input[type="reset"],
    .btn,
    a.btn {
        min-height: 44px;
    }

    /* Icon-only controls (password reveal, close, stepper arrows) are usually
       the smallest things on these pages. */
    button:empty,
    button > svg:only-child,
    button > i:only-child {
        min-width: 44px;
    }

    /* --- 3. Checkbox / radio rows --- */
    /* The control itself stays visually small; the ROW it sits in becomes the
       target, which is what a thumb actually hits. */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 20px;
        min-height: 20px;
    }
    label:has(> input[type="checkbox"]),
    label:has(> input[type="radio"]) {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        min-height: 44px;
    }

    /* --- 4. Nothing on a form page may exceed the viewport --- */
    form { max-width: 100%; }
    form img,
    form table,
    form pre { max-width: 100%; }

    /* --- 5. Standalone action / navigation links ---
       On these pages the measured heights were 16-21px, and on
       account_suspended.php the only two actions on the whole page ("Log Out",
       "Return to Login") were 16px tall.

       Inline links sitting inside a sentence are deliberately NOT included:
       WCAG 2.5.5 exempts inline text, and forcing them to 44px would break the
       line box they live in. */
    .back-button { min-width: 44px; justify-content: center; }

    /* The brand lockup doubles as the "home" link on these pages and was
       21-38px tall. :has() is unsupported on older Safari, where this simply
       does not apply - the link keeps working, it just stays short. */
    a:has(> .sz-brand),
    a:has(> .brand) {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .mc-link,
    .footer-link,
    .muted-link,
    .action-link,
    .support-link,
    .footer-credit a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* --- 6. Keyboard focus is visible on every control --- */
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible,
    button:focus-visible,
    a:focus-visible {
        outline: 2px solid var(--sz-accent);
        outline-offset: 2px;
    }
}
