/* The Klap brand (../klap-site, ../klap-app): ink canvas, paper text, the
   warm --brand highlight for the one primary action, glass cards. This is
   the Klap brand, not a per-merchant theme — one-js's own button is the
   only customizable surface, this page never is. */
@font-face {
  font-family: "Geist";
  src: url("fonts/geist-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("fonts/geist-mono-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #09090b;
  --paper: #f4f4f5;
  --brand: #d9d4cb;
  --brand-hover: #c0bbb2;
  --canvas: var(--ink);
  --surface: #0a0a0a;
  --surface-gradient-top: #141416;
  --surface-soft: rgba(244, 244, 245, 0.03);
  --surface-raised: #161616;
  --border-subtle: #262626;
  --border-glass: rgba(244, 244, 245, 0.1);
  --highlight-100: #d4d4d8;
  --highlight-200: #e4e4e7;
  --highlight-300: var(--paper);
  --focus-ring: var(--brand);
  --pending-400: #f1b733;
  --danger-400: #ff6b6b;
  --danger-500: #ff4d4d;
  --success-400: #4ade80;
  --success-500: #22c55e;
  --text-strong: #d4d4d8;
  --text-subtle: #a1a1aa;
  --overlay-hover: rgba(244, 244, 245, 0.06);
  --font-sans: "Geist", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shadow-panel: inset 0 1px 0 rgba(244, 244, 245, 0.06), inset 0 0 0 1px rgba(244, 244, 245, 0.06),
    0 24px 48px -24px rgba(0, 0, 0, 0.85);
}

* {
  box-sizing: border-box;
}

/* Same scrollbar treatment as klap-app's app/index.html — the Klap
   brand's global scrollbar styling, not a one-off for this page. */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.32);
}

/* No global reset library — this is the entire reset. Browser default
   margins on p/h1-etc. are inconsistent and were leaving elements
   looking "glued together" wherever spacing came from a default margin
   instead of an explicit `gap` — every layout below relies on `gap`,
   never on a tag's own default margin, so it has to be zeroed here. */
h1,
h2,
h3,
p {
  margin: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  min-width: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas);
  padding: 24px;
  font-family: var(--font-sans);
  color: var(--highlight-300);
  caret-color: var(--brand);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background-color: var(--brand);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* The same warm, barely-there ambient glow klap-site's .glow-ambient
   uses — a hint of --brand, never a saturated hue. */
body::before {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: -1;
  background: radial-gradient(45% 40% at 50% 0%, rgba(217, 212, 203, 0.08), transparent 70%),
    radial-gradient(50% 45% at 50% 100%, rgba(244, 244, 245, 0.04), transparent 70%);
  filter: blur(60px);
  animation: drift 24s ease-in-out infinite alternate;
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(2%, -2%, 0) scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  .card,
  .fade-in,
  .pop-in {
    animation: none;
  }
}

.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.card {
  background: linear-gradient(180deg, var(--surface-gradient-top), var(--surface));
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: var(--shadow-panel);
  padding: 25px 20px;
  width: 100%;
  min-width: 280px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* Same entrance klap-checkout's own .card uses. Every screen in the
     flow (identify → verify → wallets → sign → success) mounts a brand
     new .card element rather than mutating one in place, so this single
     rule doubles as the transition between screens, not just first load. */
  animation: card-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Generic entrance for anything that appears in place after the card has
   already settled (a QR/deep-link button replacing the spinner, an error
   line revealed by lib/dom.ts's reveal()) — smaller and quicker than
   card-in since it's a small in-place appearance, not a whole screen. */
.fade-in {
  animation: fade-in 0.25s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* The one payoff moment in the whole flow (sign.ts's showSuccess) —
   deliberately a little bouncier than fade-in, not reused elsewhere. */
.pop-in {
  animation: pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* The Klap One horizontal lockup at the top of every card, always. This
   is deliberate, not incidental: this page is never white-label — the
   payer needs a consistent, recognizable "this is really Klap One asking"
   anchor before OTP/wallet screens. 120px wide is the kit's own minimum
   for the horizontal version. */
.brand {
  display: flex;
  align-items: center;
}

.brand__logo {
  display: block;
  width: 92px;
  height: auto;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand__sandbox-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d0e4ff;
  background: rgba(74, 137, 221, 0.12);
  border: 1px solid rgba(74, 137, 221, 0.6);
  border-radius: 999px;
  padding: 2px 8px;
}

/* Every group of stacked children (a list of rows, a form's fields) gets
   one of these instead of a bare wrapper div — a plain div has no `gap`
   of its own, which is exactly what left wallet rows/menu links/form
   fields touching each other with zero space in between. */
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card__title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--highlight-300);
  margin: 0;
}

.card__subtitle {
  font-size: 13px;
  color: var(--text-subtle);
  margin: 0;
}

.alias-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.alias-row .alias-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alias-row__chevron {
  flex-shrink: 0;
  color: var(--highlight-100);
  font-size: 16px;
}

.alias-row:hover .alias-row__chevron {
  color: var(--brand);
}

.charge-amount {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--highlight-300);
}

.input {
  width: 100%;
  background: var(--surface-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--highlight-300);
  /* 16px, not 15px — iOS Safari auto-zooms the whole page on focus for
     any input under 16px, which is exactly the kind of thing that only
     shows up on a real phone, never in a desktop screenshot. */
  font-size: 16px;
  font-family: inherit;
}

.input::placeholder {
  color: rgba(244, 244, 245, 0.48);
}

.input:focus {
  outline: 1px solid var(--focus-ring);
  outline-offset: -1px;
  border-color: var(--focus-ring);
}

.btn {
  width: 100%;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--brand);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn:not(:disabled):hover {
  background: var(--brand-hover);
}

/* .btn's own `display: flex` above has the same specificity as the [hidden]
   UA-stylesheet rule and loads after it, so it silently wins — setting
   .hidden on a .btn element (see sign.ts's showSuccess) would otherwise
   render it anyway. Found live-testing the real payment flow end to end. */
.btn[hidden] {
  display: none;
}

.btn:disabled {
  background: var(--brand);
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--secondary,
.btn--secondary:disabled {
  background: var(--surface-soft);
  color: var(--highlight-300);
  border: 1px solid var(--border-subtle);
}

.btn--secondary:not(:disabled):hover {
  background: var(--overlay-hover);
  border-color: var(--border-glass);
}

.btn--danger,
.btn--danger:disabled {
  background: transparent;
  color: var(--danger-400);
  border: 1px solid var(--danger-400);
}

.btn--danger:not(:disabled):hover {
  background: rgba(255, 107, 107, 0.1);
}

.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 4px;
}

.tab-button {
  flex: 1;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-subtle);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tab-button--active {
  background: var(--paper);
  color: var(--ink);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Used for both <div> (wallet rows) and <a> (preview menu links) — the
   text-decoration/color resets only matter for the latter. */
.wallet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--highlight-200);
  text-decoration: none;
}

.wallet-row {
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.wallet-row:hover {
  background: var(--overlay-hover);
  border-color: var(--border-glass);
}

.wallet-row__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallet-row__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.wallet-row__star {
  height: 20px;
  width: 20px;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--highlight-300);
  font-size: 13px;
  position: relative;
}

.wallet-row__star-icon {
  height: 18px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.wallet-row__warning {
  color: var(--danger-400);
  font-size: 12px;
  cursor: pointer;
}

.wallet-row__trust {
  height: 20px;
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.wallet-row__trust-dot {
  height: 10px;
  width: 10px;
  border-radius: 999px;
}

.wallet-row__trust[hidden] {
  display: none;
}

.wallet-row__trust--unscored {
  width: auto;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px dashed var(--border-subtle);
  color: var(--text-subtle);
  font-size: 10px;
  font-weight: 300;
  white-space: nowrap;
}

.trust-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.trust-summary[hidden] {
  display: none;
}

.trust-summary__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--text-subtle);
}

.trust-summary__value {
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.trust-summary__track {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: var(--border-subtle);
  overflow: hidden;
}

.trust-summary__fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.wallet-row__type {
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  color: var(--text-subtle);
  font-size: 10px;
  font-weight: 300;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wallet-row__count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  color: var(--highlight-200);
  font-size: 10px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wallet-row__count--empty {
  color: var(--text-subtle);
}

.wallet-address {
  font-family: var(--font-mono);
}

.chain-select {
  position: relative;
}

.chain-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--highlight-300);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.chain-select-trigger__chevron {
  color: var(--text-subtle);
  font-size: 11px;
}

.chain-select-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  background: rgba(17, 17, 19, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  padding: 6px;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chain-select-panel[hidden] {
  display: none;
}

.chain-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--highlight-200);
}

.chain-select-option:hover {
  background: var(--overlay-hover);
}

.chain-select-option__check {
  color: var(--brand);
  font-weight: 700;
  opacity: 0;
}

.chain-select-option.is-selected .chain-select-option__check {
  opacity: 1;
}

.chain-select-option--all {
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
  padding-bottom: 10px;
}

.link-btn {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.coverage-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-subtle);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-panel {
  background: linear-gradient(180deg, var(--surface-gradient-top), var(--surface));
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: var(--shadow-panel);
  padding: 20px;
  width: 100%;
  max-width: 360px;
  max-height: 80vh;
  overflow-y: auto;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-strong);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--focus-ring);
}

.status[data-tone="success"] .status-dot {
  background: var(--success-400);
}

.status[data-tone="danger"] .status-dot {
  background: var(--danger-400);
}

.error-text {
  font-size: 13px;
  color: var(--danger-400);
  margin: 0;
}

.spinner {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}

.confirmation-progress {
  width: min(340px, 100%);
  display: grid;
  gap: 12px;
  text-align: center;
}

.confirmation-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.confirmation-step {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.confirmation-step__bar {
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--border-subtle);
}

.confirmation-step__fill {
  position: relative;
  width: 0;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-hover), var(--brand));
  transition: width 1s linear;
}

.confirmation-step[data-state="active"] .confirmation-step__fill {
  box-shadow: 0 0 8px 0 rgba(217, 212, 203, 0.35);
}

.confirmation-step[data-state="active"] .confirmation-step__fill::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: confirmation-progress-shimmer 1.6s ease-in-out infinite;
}

.confirmation-step[data-state="done"] .confirmation-step__fill {
  transition-duration: 0.4s;
}

.confirmation-step__label {
  overflow: hidden;
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.6;
}

.confirmation-step[data-state="active"] .confirmation-step__label {
  color: var(--text-strong);
  opacity: 1;
}

.confirmation-step[data-state="done"] .confirmation-step__label {
  color: var(--paper);
  opacity: 1;
}

.charge-fee-breakdown {
  color: var(--text-subtle);
  font-size: 12px;
}

.confirmation-progress__delay {
  color: var(--text-subtle);
  font-size: 12px;
}

@keyframes confirmation-progress-shimmer {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .confirmation-step__fill {
    transition: none;
  }

  .confirmation-step[data-state="active"] .confirmation-step__fill::after {
    animation: none;
  }
}

.charge-fee-breakdown {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.qr-frame {
  width: min(300px, 100%);
  margin: 0 auto;
  background: #ffffff;
  border-radius: 10px;
  overflow: hidden;
}

.qr-placeholder {
  width: min(300px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 10px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  animation: qr-placeholder-pulse 1.6s ease-in-out infinite;
}

@keyframes qr-placeholder-pulse {
  0%,
  100% {
    background-color: var(--surface-soft);
  }
  50% {
    background-color: var(--border-subtle);
  }
}

.qr-content {
  display: grid;
  gap: 8px;
  padding-bottom: 10px;
}

.qr-content img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

.qr-content .btn {
  width: calc(100% - 20px);
  margin: 0 auto;
}

.qr-content .btn--secondary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.qr-content .btn--secondary:hover {
  background: var(--surface-raised);
  border-color: var(--surface-raised);
}

.wallet-action-panel {
  min-height: 112px;
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.wallet-action-panel--progress {
  min-height: 132px;
  padding: 0 20px;
}

.footer {
  font-size: 11px;
  color: var(--text-subtle);
  text-align: center;
}

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