/* MINOMO — Merchant Lead Capture wizard + sheet CTA (contract §4).
 * Namespaced .ml-* — independent of minomo.css (.m-*) and mina.css (.mn-*)
 * so it renders identically on followed.html (no mina.css loaded there)
 * and app.html/explore.html (mina.css present). Built ONLY on the shared
 * minomo-2026.css custom properties (--text, --card, --hairline, --orange,
 * --space-*), which are loaded on all three host pages — with hardcoded
 * fallbacks in case of load-order edge cases.
 */

body.ml-open { overflow: hidden; }

/* ---------- Entry point A — followed.html "+" sheet CTA row ---------- */
.ml-sheet-cta {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 10px 4px 2px;
    border: none;
    background: transparent;
    color: var(--text-3, #86868B);
    font-family: 'Manrope', sans-serif;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.ml-sheet-cta:active { opacity: 0.7; }
.ml-sheet-cta[hidden] { display: none; }

/* ---------- Wizard overlay + modal ---------- */
.ml-overlay {
    position: fixed;
    /* Keyboard-aware bounds (UAT fix 2026-07-23): on mobile — and
       especially inside the MINA/Capacitor webview — the soft keyboard
       shrinks the VISUAL viewport but NOT the layout viewport, so a plain
       `inset:0` (100% height) leaves this flex-end-aligned sheet anchored
       to the full-screen bottom, i.e. BEHIND the keyboard, hiding the just
       -focused input (step 1 name / step 4 phone). merchant-lead-wizard.js
       mirrors window.visualViewport height/offsetTop onto --ml-vvh/--ml-kb
       while the wizard is open (resize/scroll listeners) so the sheet's
       flex-end bottom always sits above the keyboard. Falls back to the
       original 100%/0px full-screen behaviour wherever visualViewport is
       unsupported or before JS has run. */
    /* UAT fix v2 (2026-07-23): keep the overlay a full-screen FIXED box (iOS
       WKWebView mishandles resizing a fixed element's top/height during the
       keyboard) and instead pad the bottom by the keyboard height (--ml-kb,
       set from visualViewport by merchant-lead-wizard.js) so the flex-end
       sheet rises above the keyboard. --ml-kb unset (desktop/no-keyboard) = 0. */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-sizing: border-box;
    padding-bottom: var(--ml-kb, 0px);
    /* Above MINA (--mn-z-toast: 990) and above legacy .m-modal-overlay/
       .m-add-page-modal (1100/9999) — the wizard can be opened from either
       surface and must always sit on top. */
    z-index: 10500;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    /* Anchor the sheet to the TOP (UAT-3 2026-07-23): the visualViewport-based
       lift works on iOS but NOT on this Android WebView (resize event doesn't
       fire / keyboard not reported), leaving a bottom-anchored sheet fully
       behind the keyboard. Top-anchoring puts the focused field in the upper
       part of the screen, above where any soft keyboard appears — robust on
       both platforms with no keyboard detection and no native rebuild. */
    align-items: flex-start;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}
.ml-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.ml-modal {
    width: 100%;
    max-width: 480px;
    /* Top-anchored card: sits just below the status bar, grows downward with
       its content and scrolls internally if a step is tall. Since the field
       lives in the upper part, the keyboard (bottom) never covers it. */
    margin-top: calc(env(safe-area-inset-top, 0px) + 10px);
    max-height: calc(100% - 20px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-elev, #0a0a0a);
    border-radius: 20px;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateY(-20px);
    transition: transform 280ms cubic-bezier(.16, 1, .3, 1);
    font-family: 'Manrope', sans-serif;
    color: var(--text, #F5F5F7);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
.ml-overlay.show .ml-modal { transform: translateY(0); }

/* When the keyboard-aware overlay bounds above are active (--ml-vvh set by
   JS), cap the sheet to the actual visible area instead of the layout
   viewport's 88vh so it never asks for more room than is on-screen above
   the keyboard — overflow keeps scrolling internally (.ml-modal already
   has overflow-y:auto). No-op / desktop / no-keyboard: --ml-vvh unset,
   this rule doesn't change anything since it only applies with the class. */
.ml-overlay.ml-vv-active .ml-modal {
    max-height: calc(var(--ml-vvh, 88vh) - 24px);
}

.ml-modal-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}
.ml-back, .ml-close {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text, #F5F5F7);
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
}
.ml-back svg, .ml-close svg { width: 18px; height: 18px; }
.ml-back[hidden] { display: none; }

.ml-progress {
    flex: 1;
    display: flex;
    justify-content: center;
    gap: 8px;
}
.ml-progress[hidden] { visibility: hidden; }
.ml-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--hairline-strong, rgba(255, 255, 255, .12));
    transition: background 180ms ease, transform 180ms ease;
}
.ml-dot-active { background: var(--orange, #F58220); transform: scale(1.3); }
.ml-dot-done { background: var(--orange-soft, #F89D43); }

.ml-body { min-height: 220px; }

.ml-intro {
    font-size: 14px;
    color: var(--text-2, #C7C7CC);
    margin: 0 0 8px;
}
.ml-title {
    font-family: 'Space Grotesk', 'Manrope', sans-serif;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 20px;
    line-height: 1.3;
}
.ml-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2, #C7C7CC);
    margin-bottom: 8px;
}
.ml-input {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--hairline-strong, rgba(255, 255, 255, .12));
    background: var(--card, #141416);
    color: var(--text, #F5F5F7);
    font-size: 16px; /* iOS Safari: prevents input-focus zoom */
    font-family: inherit;
}
.ml-input:focus {
    outline: none;
    border-color: var(--orange-soft, #F89D43);
    box-shadow: 0 0 0 3px var(--orange-glow, rgba(245, 130, 32, .30));
}

.ml-btn-primary, .ml-btn-secondary {
    border: none;
    border-radius: 14px;
    padding: 15px 20px;
    font-family: 'Manrope', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 120ms ease, opacity 120ms ease;
}
.ml-btn-block { width: 100%; }
.ml-btn-primary {
    background: linear-gradient(135deg, var(--orange, #F58220), var(--orange-hot, #FF7B1F));
    color: #fff;
    margin-top: 28px;
}
.ml-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.ml-btn-primary:active:not(:disabled) { transform: scale(0.97); }
.ml-btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--orange-glow, rgba(245, 130, 32, .30));
}
.ml-btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text, #F5F5F7);
    margin-top: 20px;
}
.ml-btn-secondary:active { transform: scale(0.97); }

/* ---------- Step 2 — category chip grid (13 enabled groups) ---------- */
.ml-chip-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.ml-chip {
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 16px;
    background: var(--card, #141416);
    border: 1px solid var(--hairline, rgba(255, 255, 255, .07));
    color: var(--text, #F5F5F7);
    cursor: pointer;
    min-height: 44px; /* WCAG 2.1 AA — 2.5.5 minimum target size */
}
.ml-chip[aria-checked="true"] {
    background: var(--orange-tint, rgba(245, 130, 32, .12));
    border-color: var(--orange-soft, #F89D43);
}
.ml-chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--orange-glow, rgba(245, 130, 32, .30));
}
.ml-chip-icon { font-size: 24px; line-height: 1; }
.ml-chip-label { font-size: 12px; font-weight: 600; text-align: center; line-height: 1.2; }

.ml-cat-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 32px 0;
    color: var(--text-3, #86868B);
    font-size: 14px;
}

/* ---------- Step 3 — intent rows (bigger tap targets than a 3-col grid) ---------- */
.ml-chip-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ml-chip-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 56px;
    padding: 14px 18px;
    border-radius: 14px;
    background: var(--card, #141416);
    border: 1px solid var(--hairline, rgba(255, 255, 255, .07));
    color: var(--text, #F5F5F7);
    font-size: 16px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.ml-chip-row[aria-checked="true"] {
    background: var(--orange-tint, rgba(245, 130, 32, .12));
    border-color: var(--orange-soft, #F89D43);
}
.ml-chip-row:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--orange-glow, rgba(245, 130, 32, .30));
}
.ml-chip-row-icon { font-size: 22px; }

/* ---------- Step 4 — contact + consent ---------- */
.ml-phone-row {
    display: flex;
    gap: 8px;
}
.ml-dial-select {
    flex: 0 0 112px;
    padding: 14px 8px;
    border-radius: 14px;
    border: 1px solid var(--hairline-strong, rgba(255, 255, 255, .12));
    background: var(--card, #141416);
    color: var(--text, #F5F5F7);
    font-size: 15px;
    font-family: inherit;
}
.ml-phone-input { flex: 1; }
.ml-field-error {
    color: var(--danger, #FF3B30);
    font-size: 13px;
    margin-top: 6px;
}
.ml-email-row {
    margin: 18px 0 0;
    font-size: 13px;
    color: var(--text-3, #86868B);
}

.ml-consent-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 22px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
}
.ml-checkbox {
    /* WCAG 2.1 AA — large custom checkbox, never pre-checked (contract §4.3) */
    appearance: none;
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 7px;
    border: 2px solid var(--hairline-strong, rgba(255, 255, 255, .12));
    background: var(--card, #141416);
    position: relative;
    cursor: pointer;
    margin-top: 1px;
}
.ml-checkbox:checked {
    background: var(--orange, #F58220);
    border-color: var(--orange, #F58220);
}
.ml-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.ml-checkbox:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--orange-glow, rgba(245, 130, 32, .30));
}
.ml-consent-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-2, #C7C7CC);
}
.ml-consent-text a { color: var(--orange-soft, #F89D43); }

.ml-banner {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 59, 48, 0.10);
    border: 1px solid rgba(255, 59, 48, 0.30);
    font-size: 13px;
    color: var(--text, #F5F5F7);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.ml-banner[hidden] { display: none; }
.ml-banner-retry {
    border: none;
    background: rgba(255, 255, 255, 0.10);
    color: var(--text, #F5F5F7);
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}

/* ---------- Result screens (success / already_merchant / lead_already_exists) ---------- */
.ml-step-result {
    text-align: center;
    padding: 20px 0 8px;
}
.ml-result-icon { font-size: 44px; margin-bottom: 12px; }
.ml-result-body {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-2, #C7C7CC);
    margin: 0 0 8px;
}

@media (prefers-reduced-motion: reduce) {
    .ml-overlay, .ml-modal, .ml-dot, .ml-btn-primary, .ml-btn-secondary {
        transition: none !important;
    }
}
