/* ============================================================================
   Vibe Dashboard v2 — shared modal primitive (design-upgrade row C47)
   One backdrop + one panel for every dashboard modal. Reads styles/vibe-tokens.css
   only — never hardcode hex here. Consumers: src/dashboard/code-overwrite.jsx
   (signing overlay). Pending adoption: tasks.jsx / network.jsx (S4),
   login.jsx wallet chooser (S7); legacy duplicate styles/dashboard.css:1290-1341
   (S8 closes it).

   API
   ---
   .v2-modal-backdrop            fixed, full-viewport scrim (--v-scrim + blur 4px),
                                 grid-centred, z-index 80, fades in.
   .v2-modal-backdrop.is-local   absolute — covers only the nearest positioned
                                 ancestor (a card), z-index 5, inherits its radius.
   .v2-modal                     the panel: --v-surface, --v-border, --v-r-modal,
                                 28px padding, min(520px, 100%), lifts in.
   .v2-modal.is-plain            no panel chrome — centred text straight on the
                                 scrim (the signing overlay).
   .v2-modal.is-sheet            ≤640px: bottom sheet on --v-sheet, top radius only.
   .v2-modal-close               32px round icon button, top-right of the panel.
   .v2-modal-kicker / -title / -body / -actions   panel typography + button row.

   Conventions (the CSS cannot do these — every consumer must)
   ----------------------------------------------------------
   • root element: role="dialog" aria-modal="true" aria-labelledby=<title id>
     (an in-flight status overlay uses role="alertdialog" aria-live="assertive").
   • Escape closes/cancels: add a keydown listener while open, remove on close.
   • Focus: use window.V2ModalTrap(active, panelRef) (a React hook, defined in
     src/core/modal-trap.jsx) — it focuses the first control (or the
     panel, tabIndex=-1), cycles Tab / Shift+Tab inside the panel, sets `inert`
     on everything outside the panel's ancestor chain, and restores focus to
     the opener on close.
   • Background clicks on .v2-modal-backdrop close a dismissable modal; a modal
     that guards an in-flight action (signing) offers an explicit Cancel instead.
   • Reduced motion: the entry animations are disabled below.
   ============================================================================ */

@keyframes v2ModalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes v2ModalUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.v2-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--v-scrim);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: v2ModalFade .2s ease;
}
.v2-modal-backdrop.is-local {
  position: absolute;
  z-index: 5;
  border-radius: inherit;
}

.v2-modal {
  position: relative;
  width: min(520px, 100%);
  box-sizing: border-box;
  padding: 28px;
  border-radius: var(--v-r-modal);
  border: 1px solid var(--v-border);
  background: var(--v-surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .5);
  color: var(--v-text);
  animation: v2ModalUp .25s ease;
}
.v2-modal.is-plain {
  width: auto;
  max-width: 360px;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  text-align: center;
}

.v2-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--v-border);
  border-radius: var(--v-r-pill);
  background: color-mix(in srgb, white 4%, transparent);
  color: var(--v-text-2);
  font: inherit;
  cursor: pointer;
}
.v2-modal-close:hover { color: var(--v-text); border-color: color-mix(in srgb, white 25%, transparent); }
.v2-modal-close:focus-visible { outline: 2px solid var(--v-blue); outline-offset: 2px; }

.v2-modal-kicker {
  font-family: var(--v-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--v-link);
}
.v2-modal-title {
  margin: 8px 36px 8px 0;
  font-family: var(--v-font-nav);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--v-heading);
}
.v2-modal-body {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--v-text-2);
}
.v2-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

@media (max-width: 640px) {
  .v2-modal-backdrop:not(.is-local) { align-items: end; padding: 0; }
  .v2-modal.is-sheet {
    width: 100%;
    max-width: none;
    border-radius: var(--v-r-modal) var(--v-r-modal) 0 0;
    border-bottom: 0;
    background: var(--v-sheet);
    padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .v2-modal-backdrop, .v2-modal { animation: none; }
}
