/**
 * Mobile tap-target enforcement — Phase 5 of the UX sweep.
 *
 * WCAG 2.5.5 + Apple HIG both recommend interactive elements be at
 * least 44×44 CSS pixels on touch surfaces. iOS Safari also fails
 * pointer events when targets are smaller than ~30px due to scroll
 * coalescing. This file bumps any too-small touch target to the
 * minimum without touching its visual size on desktop.
 *
 * Strategy: apply only on coarse pointers (touch devices) AND viewports
 * the user is likely operating with a finger, never on hover-capable
 * desktops. Dense data-table action buttons are exempt explicitly —
 * an ops listing with 8 action icons per row would blow up otherwise.
 */

@media (pointer: coarse) and (max-width: 991.98px) {

    /* Primary CTA classes used across the public site + modals. */
    .btn,
    .pm-submit,
    .pm-close,
    .ce-btn,
    .hero-cta-primary,
    .hero-cta-secondary,
    .cta-btn,
    .newsletter-btn,
    .footer-quick-btn,
    .tr-success__cta,
    .reg-inline-success__cta,
    .ih-inline-success__cta,
    a.nav-link-item {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
    }

    /* Icon-only buttons: ensure the *box* hits 44×44 even if the icon is small. */
    .pm-close,
    .back-to-top,
    .sticky-dismiss,
    .tr-dropzone__remove,
    .ih-stepper__btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Form fields too — typing is the secondary touch target.
       44px aligns with the WCAG 2.5.5 guidance and prevents zoom-on-focus
       on iOS by also bumping font-size to 16px below. */
    input.form-control:not([type=hidden]):not([type=file]),
    input.pm-input,
    select.form-control,
    select.pm-select,
    textarea.form-control,
    textarea.pm-textarea {
        min-height: 44px;
    }

    /* iOS Safari zooms on focus when the input's font-size is <16px.
       Lock the public form inputs to ≥16px on touch. */
    .pm-input,
    .pm-select,
    .pm-textarea,
    .form-control:not(.form-control-sm),
    .newsletter-input {
        font-size: max(16px, 0.95rem);
    }

    /* Stretch primary footer buttons in modals to full width — small
       phone screens cramp the side-by-side trust message + button. */
    .pm-footer .pm-submit,
    #in-house-footer .pm-submit {
        flex: 1 1 100%;
    }
}

/* ── Density-aware exemptions ────────────────────────────────────────
   The dashboard list-views (DataTables, leads-table) deliberately pack
   8-12 action icons per row. Forcing 44×44 would explode their layouts
   and is unnecessary because the rows themselves are wider than touch
   guidance assumes.
   We keep the hit-area generous via padding instead of a hard min-size.
   ──────────────────────────────────────────────────────────────────── */
@media (pointer: coarse) and (max-width: 991.98px) {
    .leads-action-btn {
        min-height: 36px; min-width: 36px;
        padding: 0.45rem;
    }
    /* Pagination chips can stay compact — they sit alone on the row. */
    .page-link {
        min-height: 36px; min-width: 36px;
        padding: 0.45rem 0.7rem;
    }
}

/* ── Sufficient spacing between adjacent touch targets ───────────── */
@media (pointer: coarse) and (max-width: 991.98px) {
    .leads-actions-group { gap: 6px; }
    .pm-footer           { gap: 0.6rem; flex-wrap: wrap; }
    .form-submit-area    { gap: 0.6rem; flex-wrap: wrap; }
}
