/* The swap app (swap/, ui/swap.html). It takes its colours, fonts and themes
   from app.css, so it reads as part of the dashboard wherever it is framed. */

.swap-page { min-height: 100vh; display: flex; flex-direction: column; }
.swap-page .brand { color: inherit; text-decoration: none; }
.brand-txt .brand-name { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.015em; color: var(--fg) !important; margin: 0 !important; }
.swap-main { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 40px var(--gutter) 56px; }
#swap { width: 100%; max-width: 440px; }

/* Framed: the panel alone, on the framing page's own ground. */
.embed, .embed body { background: transparent; }
.embed .top, .embed .foot { display: none; }
/* Tall enough for the wallet's own dialog, which is drawn over the panel and
   would be cut off by a frame fitted to a short one. */
.embed .swap-page { min-height: 640px; }
.embed .swap-main { padding: 0; }
.embed #swap { max-width: none; }

.swap-card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px 18px;
}
.swap-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-height: 32px; }
.swap-head h1 { font-size: 1.0625rem; }
.swap-tools { display: flex; align-items: center; gap: 6px; }

.chip {
  font: inherit; font-family: var(--mono); font-size: .75rem; color: var(--fg-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; cursor: pointer;
}
.chip:hover { color: var(--fg); }
.icon-btn {
  width: 32px; height: 32px; padding: 0; flex: none; display: grid; place-items: center;
  background: none; border: 1px solid var(--line); border-radius: 8px; color: var(--fg-2); cursor: pointer;
}
.icon-btn:hover { color: var(--fg); background: var(--surface-2); }
.icon-btn svg, .swap-flip svg, .token-btn svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- the two sides ---------- */
.swap-field { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 11px 13px 9px; }
.swap-field:focus-within { border-color: var(--line); }
/* The amount's own outline is off (it would be cut by the row); the field
   around it carries the focus ring. */
.swap-field:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.swap-field > label { display: block; font-size: .75rem; color: var(--fg-2); }
.swap-row { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.swap-row input, .swap-row output {
  flex: 1; min-width: 0; font: inherit; font-family: var(--mono); font-size: 1.625rem; font-weight: 500; line-height: 1.3;
  color: var(--fg); background: none; border: 0; padding: 0; outline: none; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
}
.swap-row input::placeholder { color: var(--fg-3); }
.swap-row input:disabled { color: var(--fg-2); }
.swap-row output.pending { color: var(--fg-3); }
.swap-sub { display: flex; justify-content: space-between; gap: 10px; min-height: 1.25rem; margin-top: 1px; font-size: .75rem; color: var(--fg-2); }
.swap-sub > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swap-sub .warn { color: var(--warn); }
.swap-sub .bad { color: var(--bad); }

.token-btn {
  flex: none; display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: .9375rem; font-weight: 600; color: var(--fg);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px 5px 6px; cursor: pointer; max-width: 55%;
}
/* By class: a token without a logo has a letter in a span of its own before
   the symbol. Only the symbol gives way. Whoever deploys a token picks its
   symbol, and a long one must not push the "unlisted" badge out of the button. */
.token-btn .token-name { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.2; }
.token-btn .token-sym { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-btn .badge, .token-btn svg { flex: none; }
/* An unlisted token's button is two lines tall: less round, so they fit. */
.token-btn:has(.badge) { border-radius: 14px; padding-block: 4px; }
.token-btn:hover:not(:disabled) { border-color: var(--fg-3); }
.token-btn:disabled { cursor: default; opacity: .7; }
.token-btn .badge { margin-left: 0; }
.token-btn svg { color: var(--fg-3); width: 14px; height: 14px; }
.logo { border-radius: 50%; flex: none; display: block; object-fit: cover; background: var(--surface-2); }
.logo-letter { display: grid; place-items: center; color: var(--fg-2); font-weight: 600; border: 1px solid var(--line); text-transform: uppercase; }

.swap-flip { display: flex; justify-content: center; height: 8px; position: relative; z-index: 1; }
.swap-flip button {
  width: 32px; height: 32px; margin-top: -12px; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 50%; color: var(--fg-2);
}
.swap-flip button:hover:not(:disabled) { color: var(--fg); }

.link { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.link:hover:not(:disabled) { color: var(--fg); }
.link:disabled { cursor: default; text-decoration: none; }

/* ---------- slippage ---------- */
.swap-slip { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; margin-top: 14px; font-size: .8125rem; color: var(--fg-2); }
.chips { display: flex; gap: 6px; align-items: center; }
.chips button, .chips .custom {
  font: inherit; font-family: var(--mono); font-size: .75rem; color: var(--fg-2); background: none;
  border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; cursor: pointer;
}
.chips button:hover { color: var(--fg); }
.chips button[aria-pressed="true"], .chips .custom.on { color: var(--fg); background: var(--surface-2); border-color: var(--fg-3); }
.chips .custom { display: inline-flex; align-items: center; gap: 2px; cursor: text; padding-block: 3px; }
.chips .custom input { width: 6.2ch; font: inherit; color: var(--fg); background: none; border: 0; outline: none; padding: 0; text-align: right; }
.chips .custom input::placeholder { color: var(--fg-3); }
.chips .custom:not(.on) span { display: none; }
.chips .custom:not(.on) input { text-align: left; }
.chips .custom.bad { border-color: var(--bad); }
.chips .custom:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.swap-hint { flex-basis: 100%; text-align: right; font-size: .75rem; color: var(--bad); }
.swap-hint.warn { color: var(--warn); }

/* ---------- the trade's facts ---------- */
.swap-facts { margin: 12px 0 0; font-size: .8125rem; }
.swap-facts > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 3px 0; }
/* On a narrow panel the label wraps, at its spaces, before the figure breaks. */
.swap-facts dt { color: var(--fg-2); flex: 1 1 0; min-width: min-content; }
.swap-facts dd { margin: 0; text-align: right; font-family: var(--mono); flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
.swap-facts .leg { display: block; font-family: var(--sans); }
.swap-facts dd.warn { color: var(--warn); }

.swap-venues { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.swap-venues h2 { font-size: .75rem; font-weight: 500; color: var(--fg-2); letter-spacing: 0; margin-bottom: 4px; }
.swap-venues table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.swap-venues th { text-align: left; font-weight: 400; color: var(--fg-2); padding: 2px 0; }
/* A heading gives way before a row's name does. */
.swap-venues tbody th { white-space: nowrap; }
.swap-venues td { text-align: right; font-family: var(--mono); padding: 2px 0 2px 10px; color: var(--fg-2); white-space: nowrap; }
.swap-venues thead th { text-align: right; vertical-align: bottom; white-space: normal; font-size: .6875rem; color: var(--fg-2); padding: 0 0 2px 10px; }
/* The network fee is the quiet column: it explains the last one. Quiet by
   its size: small text in the faintest colour is hard to read. */
.swap-venues td:nth-child(3) { font-size: .75rem; }
.swap-venues td:last-child { font-family: var(--sans); }
.swap-venues .ours th, .swap-venues .ours td:nth-child(2) { color: var(--fg); font-weight: 600; }
.swap-venues .ours td:last-child { color: var(--up); font-weight: 500; }
.swap-fee { margin-top: 8px; font-size: .75rem; color: var(--fg-2); line-height: 1.5; }

/* ---------- messages and the action ---------- */
.swap-note { margin-top: 12px; font-size: .8125rem; color: var(--fg-2); line-height: 1.5; }
.swap-note.warn { color: var(--warn); }
.swap-note.bad { color: var(--bad); }
.swap-note.good { color: var(--up); }
.swap-note a { color: inherit; }
/* A trade far under the index price: said in a box of its own above the
   button, and very far under, with the tick that lets it through. The box
   carries the colour and the words are the panel's own: coloured text on a
   tint of itself is too faint to read at this size. */
.swap-alert {
  margin-top: 12px; padding: 9px 12px; border-radius: 9px; font-size: .8125rem; line-height: 1.5; color: var(--fg);
  border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent); border-left: 3px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 9%, transparent);
}
.swap-alert.bad {
  border-color: color-mix(in srgb, var(--bad) 60%, transparent); border-left-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
}
.swap-accept { display: flex; align-items: center; gap: 8px; margin-top: 8px; cursor: pointer; }
.swap-accept input { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--bad); cursor: inherit; }
.swap-accept:has(input:disabled) { color: var(--fg-2); cursor: default; }

.swap-go {
  display: block; width: 100%; margin-top: 14px; font: inherit; font-size: .9375rem; font-weight: 600;
  color: var(--bg); background: var(--fg); border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer;
}
.swap-go:hover:not(:disabled) { opacity: .92; }
.swap-go:disabled { background: var(--surface-2); color: var(--fg-3); border: 1px solid var(--line); cursor: default; }
.swap-fine { margin-top: 10px; font-size: .6875rem; color: var(--fg-2); text-align: center; line-height: 1.5; }

/* ---------- the token picker: over the panel, inside it ---------- */
.picker {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
}
.picker-head { display: flex; gap: 8px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.picker-head input {
  flex: 1; min-width: 0; font: inherit; font-size: .875rem; color: var(--fg); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; outline-offset: 1px;
}
.picker-head input::placeholder { color: var(--fg-3); }
.picker-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; min-height: 0; }
.picker-list button {
  display: flex; align-items: center; gap: 11px; width: 100%; font: inherit; text-align: left; color: var(--fg);
  background: none; border: 0; border-radius: 8px; padding: 7px 10px; cursor: pointer;
}
.picker-list button:hover:not(:disabled) { background: var(--surface-2); }
.picker-list button:disabled { opacity: .45; cursor: default; }
.picker-name { flex: 1; min-width: 0; line-height: 1.3; }
.picker-name b { font-weight: 600; overflow-wrap: anywhere; }
.picker-name small { display: block; color: var(--fg-2); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-name .badge { margin-left: 4px; }
.picker-bal { font-family: var(--mono); font-size: .8125rem; color: var(--fg-2); flex: none; }
.picker-empty { padding: 18px 12px; color: var(--fg-3); font-size: .8125rem; text-align: center; }
/* A short panel (no quote yet) would give the list no room. */
.swap-card:has(.picker) { min-height: 430px; }

@media (max-width: 480px) {
  .swap-venues td, .swap-venues thead th { padding-left: 7px; }
  .swap-main { padding: 18px var(--gutter) 32px; }
  .swap-card { padding: 14px 14px 16px; }
  .swap-row input, .swap-row output { font-size: 1.375rem; }
}
/* The narrowest phones: the row's name wraps after all, and the table's text
   is a size smaller, so the last column stays on the panel. */
@media (max-width: 360px) {
  .swap-venues table { font-size: .75rem; }
  .swap-venues tbody th { white-space: normal; }
  .swap-venues td, .swap-venues thead th { padding-left: 5px; }
  .swap-venues td:nth-child(3) { font-size: .6875rem; }
}
