/* ==========================================================================
   Optra — overlays
   Modal surface and its contents: wallet picker, settings, order states.
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: var(--s-4);
}

.modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(122, 18, 66, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity var(--d-3) var(--e-soft);
}

.modal.is-open .modal__scrim { opacity: 1; }

.modal__panel {
  position: relative;
  width: min(100%, 30rem);
  max-height: min(88vh, 46rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
  padding: var(--s-6);
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  /* Opaque enough to read against any part of the field behind it. */
  background: linear-gradient(150deg, #f68b7f, #ef5c9a 62%, #e3409c);
  box-shadow: 0 40px 90px -20px rgba(104, 12, 56, 0.78);
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transition:
    opacity var(--d-3) var(--e-soft),
    transform var(--d-4) var(--e-out);
}

.modal.is-open .modal__panel { opacity: 1; transform: none; }

.modal__panel--sm { width: min(100%, 24rem); }
.modal__panel--lg { width: min(100%, 40rem); }

.modal__close {
  position: absolute;
  top: var(--s-4);
  right: var(--s-4);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-soft);
  color: var(--ink-72);
  transition: color var(--d-2) var(--e-soft), background-color var(--d-2) var(--e-soft);
}

.modal__close:hover { color: var(--ink); background: var(--wash-lift); }
.modal__close svg { width: 15px; height: 15px; }

.modal__head { padding-right: var(--s-7); margin-bottom: var(--s-5); }
.modal__head .meta { margin-bottom: var(--s-2); }

.modal__body > * + * { margin-top: var(--s-4); }

.modal__foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-top: var(--s-6);
}

.modal__foot .btn { flex: 1 1 auto; }

/* --- Wallet picker ------------------------------------------------------ */

.wallet-list { display: grid; gap: var(--s-3); }

.wallet-option {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  width: 100%;
  padding: var(--s-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--line-soft);
  background: var(--wash);
  box-shadow: var(--shadow-lift);
  text-align: left;
  transition:
    background-color var(--d-2) var(--e-soft),
    border-color var(--d-2) var(--e-soft),
    transform var(--d-2) var(--e-out);
}

.wallet-option:hover {
  background: var(--wash-lift);
  border-color: var(--ink-40);
  transform: translateY(-1px);
}

.wallet-option img,
.wallet-option .wallet-option__fallback {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  flex: none;
}

.wallet-option__fallback {
  display: grid;
  place-items: center;
  background: var(--wash-solid);
  font-family: var(--font-display);
  font-weight: 600;
}

.wallet-option__name { font-weight: 600; }
.wallet-option__meta { font-size: var(--t-xs); color: var(--ink-56); }

/* --- Definition rows ---------------------------------------------------- */

.detail-list { display: grid; gap: 0; }

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line-faint);
}

.detail-row:last-child { border-bottom: 0; }

.detail-row__value {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  text-align: right;
  word-break: break-all;
}

/* --- Switch ------------------------------------------------------------- */

.switch-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--line-faint);
}

.switch-row:last-of-type { border-bottom: 0; }

.switch-row__text strong { display: block; font-weight: 600; }
.switch-row__text span { font-size: var(--t-xs); color: var(--ink-56); }

.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 26px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--wash);
  transition: background-color var(--d-2) var(--e-soft), border-color var(--d-2) var(--e-soft);
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform var(--d-2) var(--e-out);
}

.switch[aria-checked="true"] { background: var(--wash-solid); border-color: var(--ink-40); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* --- Order progress ----------------------------------------------------- */

.order-steps { display: grid; gap: var(--s-3); }

.order-step {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--t-sm);
  color: var(--ink-40);
  transition: color var(--d-3) var(--e-soft);
}

.order-step[data-state="active"] { color: var(--ink); }
.order-step[data-state="done"] { color: var(--ink-72); }

.order-step__mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line);
}

.order-step[data-state="done"] .order-step__mark { background: var(--ink); border-color: var(--ink); }
.order-step[data-state="done"] .order-step__mark::after {
  content: "";
  width: 9px; height: 5px;
  border-left: 1.7px solid var(--c-magenta);
  border-bottom: 1.7px solid var(--c-magenta);
  transform: translateY(-1px) rotate(-45deg);
}

/* The only spinner in the system. */
.order-step[data-state="active"] .order-step__mark {
  border-color: var(--ink-40);
  border-top-color: var(--ink);
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .order-step[data-state="active"] .order-step__mark { animation: none; }
}

/* --- Notice ------------------------------------------------------------- */

.notice {
  display: flex;
  gap: var(--s-4);
  padding: var(--s-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--line-soft);
  background: var(--wash);
  box-shadow: var(--shadow-panel);
}

.notice__icon { flex: none; width: 22px; height: 22px; color: var(--ink); }

.notice p { font-size: var(--t-sm); color: var(--ink-88); }
.notice p + p { margin-top: var(--s-2); color: var(--ink-56); }

.modal__panel::-webkit-scrollbar { width: 8px; }
.modal__panel::-webkit-scrollbar-track { background: transparent; }
.modal__panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
