/* ============================================================
   /v2/css/v3-modal.css
   Custom V3 modal + toast styles — pairs with /v2/js/v3-modal.js
   and /v2/js/v3-toast.js to replace Bootstrap modal + bootbox +
   bootstrap-notify.

   Shared across search-v2, mydomains, app, ... — page-specific
   skins (className passed via show()) layer on top.

   z-index hierarchy:
     V3Modal overlay     : 2147483640
     V3Toast container   : 2147483641
     Kit overlay (XWK)   : 2147483647  (always wins)
   ============================================================ */

/* ===================== V3 MODAL OVERLAY ===================== */
.v3-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483640;
    padding: 16px;
    opacity: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    transition: opacity 240ms ease;
    font-family: var(--v3-sans, system-ui, sans-serif);
    color: var(--v3-ink, #e8eef6);
}

.v3-modal-overlay.is-shown { opacity: 1; }
.v3-modal-overlay.is-hiding { opacity: 0; }

/* ===================== V3 MODAL DIALOG ===================== */
.v3-modal-dialog {
    background: var(--v3-glass-bg-strong, rgba(18, 22, 30, 0.96));
    border: 1px solid var(--v3-line, rgba(255, 255, 255, 0.08));
    border-radius: var(--v3-radius-lg, 16px);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.55),
        0 1px 0 rgba(255, 255, 255, 0.04) inset;
    color: var(--v3-ink, #e8eef6);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    transform: translateY(12px) scale(0.97);
    transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.v3-modal-overlay.is-shown .v3-modal-dialog {
    transform: translateY(0) scale(1);
}

.v3-modal-overlay.is-hiding .v3-modal-dialog {
    transform: translateY(-4px) scale(0.99);
}

/* Size variants */
.v3-modal-size-sm .v3-modal-dialog { max-width: 400px; }
.v3-modal-size-md .v3-modal-dialog { max-width: 520px; }
.v3-modal-size-lg .v3-modal-dialog { max-width: 720px; }
.v3-modal-size-xl .v3-modal-dialog { max-width: 880px; }

/* ===================== HEADER ===================== */
.v3-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex: 0 0 auto;
}

.v3-modal-title {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--v3-mono, 'JetBrains Mono', monospace);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v3-modal-close {
    flex: 0 0 auto;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.5);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: -4px -8px -4px 0;
    transition: background 160ms ease, color 160ms ease;
}

.v3-modal-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.95);
}

.v3-modal-close:focus-visible {
    outline: 2px solid var(--v3-accent, #45c2f5);
    outline-offset: 2px;
}

/* ===================== BODY ===================== */
.v3-modal-body {
    padding: 22px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    line-height: 1.5;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.78);
}

.v3-modal-body > *:first-child { margin-top: 0; }
.v3-modal-body > *:last-child { margin-bottom: 0; }

/* ===================== FOOTER / ACTIONS ===================== */
.v3-modal-footer {
    display: flex;
    gap: 10px;
    padding: 14px 22px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    justify-content: flex-end;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.v3-modal-action {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 18px;
    border-radius: 999px;
    font-family: var(--v3-mono, 'JetBrains Mono', monospace);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1;
    cursor: pointer;
    border: 1px solid transparent;
    transition:
        background 180ms ease,
        border-color 180ms ease,
        color 180ms ease,
        transform 180ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 180ms ease;
    text-decoration: none !important;
    white-space: nowrap;
}

/* Unified modal primary action — flat cyan tint instead of the
   saturated gradient + cyan halo we used to ship.  Audit (#9):
     • no box-shadow (the halo looked like an error glow on dark)
     • no translateY hover (jump felt jittery during rapid clicks)
   Hover keeps a subtle brightness bump via bg + border so the
   button still feels responsive without dancing under the cursor. */
.v3-modal-action-primary {
    background: linear-gradient(135deg,
        var(--v3-accent, #25aae1),
        var(--v3-accent-soft, #5dc8f0));
    color: #050608;
    /* Try Again / Verify Again in error modals get the same cyan halo
       as Register Now so the recovery action stays the loudest signal. */
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.22) inset,
        0 0 24px rgba(37, 170, 225, 0.32),
        0 6px 18px -6px rgba(37, 170, 225, 0.40);
    transition: filter .14s var(--v3-ease, ease),
                box-shadow .18s var(--v3-ease, ease);
}

.v3-modal-action-primary:hover {
    filter: brightness(1.08);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.30) inset,
        0 0 36px rgba(37, 170, 225, 0.48),
        0 8px 22px -6px rgba(37, 170, 225, 0.55);
}

.v3-modal-action-primary:active {
    filter: brightness(0.96);
}

.v3-modal-action-secondary {
    background: transparent;
    color: rgba(255, 255, 255, 0.74);
    border-color: rgba(255, 255, 255, 0.14);
}

.v3-modal-action-secondary:hover {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.22);
}

.v3-modal-action:focus-visible {
    outline: 2px solid var(--v3-accent, #45c2f5);
    outline-offset: 2px;
}

.v3-modal-action:disabled {
    opacity: 0.65;
    cursor: wait;
}

/* ===================== BODY LOCK ===================== */
body.v3-modal-open {
    overflow: hidden;
}

/* ===================== MOBILE (bottom sheet) ===================== */
@media (max-width: 560px) {
    .v3-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .v3-modal-dialog,
    .v3-modal-size-sm .v3-modal-dialog,
    .v3-modal-size-md .v3-modal-dialog,
    .v3-modal-size-lg .v3-modal-dialog,
    .v3-modal-size-xl .v3-modal-dialog {
        width: 100%;
        max-width: 100% !important;
        /* Pass 4 — reserve 64px top gap so the bottom-sheet modal never
           rises into the status bar / browser address pill area on
           iPhone Pro Max.  Was hugging the very top edge before,
           making the close button visually overlap with the floating
           browser controls.                                           */
        max-height: calc(100vh - 64px - env(safe-area-inset-top, 12px));
        margin-top: 64px;
        border-radius: 16px 16px 0 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        transform: translateY(100%);
    }
    .v3-modal-overlay.is-shown .v3-modal-dialog {
        transform: translateY(0);
    }
    .v3-modal-overlay.is-hiding .v3-modal-dialog {
        transform: translateY(20%);
    }
    .v3-modal-footer {
        padding-bottom: calc(18px + env(safe-area-inset-bottom, 0));
    }
    /* Issue #6 fix — make the close button unmissable on mobile:
       bigger hit area (44×44 WCAG 2.5.5), brighter color, higher
       z-index so any modal body content with position: absolute
       can't sit on top of it.                                       */
    .v3-modal-header {
        position: sticky;
        top: 0;
        background: var(--v3-glass-bg-strong, rgba(18, 22, 30, 0.96));
        z-index: 5;
        padding: 16px 18px;
    }
    .v3-modal-close {
        width: 44px;
        height: 44px;
        font-size: 28px;
        color: rgba(255, 255, 255, 0.75);
        background: rgba(255, 255, 255, 0.06);
        margin: 0;
        /* Pass 4 — bump z-index so the button doesn't sit under the
           floating wallet-connect pill in the page header after a tap
           lifts focus (was triggering stuck hover/active state).      */
        position: relative;
        z-index: 10;
    }
    .v3-modal-close:hover,
    .v3-modal-close:focus-visible {
        background: rgba(255, 255, 255, 0.12);
        color: #fff;
    }
}

/* ===================== REDUCED MOTION ===================== */
@media (prefers-reduced-motion: reduce) {
    .v3-modal-overlay,
    .v3-modal-dialog,
    .v3-modal-action {
        transition: none !important;
    }
}

/* ============================================================
   V3 TOAST
   ============================================================ */
.v3-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2147483641;
    pointer-events: none;
    max-width: 420px;
    font-family: var(--v3-sans, system-ui, sans-serif);
}

.v3-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--v3-glass-bg-strong, rgba(18, 22, 30, 0.97));
    border: 1px solid var(--v3-line, rgba(255, 255, 255, 0.10));
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    color: var(--v3-ink, #e8eef6);
    min-width: 280px;
    max-width: 420px;
    font-size: 12.5px;
    line-height: 1.4;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(20px);
    transition:
        opacity 220ms ease,
        transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.v3-toast.is-shown {
    opacity: 1;
    transform: translateX(0);
}

.v3-toast.is-hiding {
    opacity: 0;
    transform: translateX(20px);
}

.v3-toast-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 12px;
}

.v3-toast-content {
    flex: 1 1 auto;
    min-width: 0;
    color: rgba(255, 255, 255, 0.92);
}

.v3-toast-content .small,
.v3-toast-content small {
    font-size: 12.5px;
}

.v3-toast-close {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 auto;
    background: transparent;
    border: 0;
    color: rgba(255, 255, 