/* Swappy: the split screen.
   The top field is what you pay, the bottom field is what you receive. Swappy, the swap sign with a face, sits on the seam:
   tap it to switch the two tokens; its face and its words are the status.
   One typeface, Bricolage Grotesque, served from this site (fonts/), SIL Open Font License 1.1. */
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/BricolageGrotesque.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  color-scheme: light;
  --sun: #FFC21A; --sea: #2A2FE0; --ink: #14143A; --foam: #DCDDFB; --line: #5B60EA; --white: #FFFFFF; --red: #B3261E;
  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --gut: max(22px, calc(50% - 214px));      /* one 428px column, centred on wide screens */
}
*, *::before, *::after { box-sizing: border-box; }
html { background: linear-gradient(var(--sun) 0 50%, var(--sea) 50% 100%) fixed; -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); overflow-x: hidden; font: 400 16px/22px var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, output { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-appearance: none; appearance: none; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.get :focus-visible { outline-color: var(--white); }
.get .warn :focus-visible { outline-color: var(--sea); }

.app { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }

/* ---------- Top field: what you pay ---------- */
.pay { display: flex; flex-direction: column; min-height: min(41vh, 360px); padding: max(20px, env(safe-area-inset-top)) var(--gut) 64px; background: var(--sun); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wm { font: 800 28px/44px var(--font); letter-spacing: -.03em; text-transform: lowercase; }
.chips { flex: 1; display: flex; justify-content: flex-end; gap: 6px; min-width: 0; }
.chip { height: 44px; padding: 0 12px; border: 2px solid var(--ink); border-radius: 22px; background: transparent; color: var(--ink);
  font: 600 14px/1 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#walletBtn, #sheetX { flex: none; }
.chip.acc { background: var(--ink); color: var(--white); }
.note { margin-top: 8px; font-size: 13px; line-height: 18px; }
.grow { flex: 1; min-height: 20px; }

.lbl { font: 600 16px/22px var(--font); }
.legrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#amt, #out { display: block; flex: 1; min-width: 0; padding: 0; border: 0; border-radius: 0; background: none; outline: none; color: inherit;
  font-weight: 800; overflow: hidden; white-space: nowrap; }
#amt { font-size: clamp(44px, 16.4vw, 64px); line-height: 1.19; letter-spacing: -.045em; caret-color: var(--sea); }
#amt::placeholder { color: var(--ink); opacity: .35; }
#amt:focus-visible { box-shadow: 0 3px 0 var(--ink); }
#out { font-size: clamp(34px, 11.3vw, 44px); line-height: 1.32; letter-spacing: -.04em; }
#out.dim { color: #A9ACF5; }
.tok { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 48px; max-width: 46vw; padding: 0 16px 0 8px; border: 0; border-radius: 24px;
  font: 700 18px/1 var(--font); white-space: nowrap; overflow: hidden; }
.tok::before { content: attr(data-i); flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; }
.pay .tok { background: var(--ink); color: var(--white); }
.pay .tok::before { background: var(--sun); color: var(--ink); }
.get .tok { background: var(--white); color: var(--ink); }
.get .tok::before { background: var(--sea); color: var(--white); }
.side { display: flex; align-items: baseline; gap: 10px; min-height: 22px; font-size: 15px; line-height: 22px; }
.side span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side button { flex: none; margin: -11px -6px; padding: 11px 6px; border: 0; background: none; color: var(--ink); font: 600 15px/22px var(--font); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- The seam: Swappy and what it says ---------- */
.seam { position: relative; z-index: 2; height: 0; }
.pal { position: absolute; left: var(--gut); top: -48px; width: 96px; height: 96px; padding: 0; border: 0; border-radius: 50%; background: none; }
.pal svg { display: block; width: 96px; height: 96px; transition: transform .2s var(--ease); animation: pop .6s var(--ease) both; }
.pal:active svg { transform: scale(.93); }
.arms { transform-origin: 48px 48px; transform: rotate(calc(var(--t, 0) * 360deg)); transition: transform .7s var(--ease); }
.pal[data-mood="busy"] .arms { animation: turn 1.6s linear infinite; }
.face { display: none; }
.pal[data-mood="calm"] .calm, .pal[data-mood="busy"] .calm, .pal[data-mood="alarm"] .alarm, .pal[data-mood="happy"] .happy, .pal[data-mood="flat"] .flat, .pal[data-mood="sleep"] .sleep { display: inline; }
.say { position: absolute; left: calc(var(--gut) + 108px); top: 0; transform: translateY(-50%); max-width: calc(100% - var(--gut) - var(--gut) - 108px); min-height: 44px; padding: 11px 18px;
  border-radius: 22px; background: var(--white); color: var(--ink); font: 600 16px/22px var(--font); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes turn { to { transform: rotate(360deg); } }

/* ---------- Bottom field: what you receive ---------- */
.get { flex: 1; display: flex; flex-direction: column; padding: 58px var(--gut) max(20px, env(safe-area-inset-bottom)); background: var(--sea); color: var(--white); }
.get .side { margin-bottom: 16px; color: var(--foam); }

.tip, .warn { display: flex; flex-wrap: wrap; gap: 12px 8px; margin-bottom: 16px; padding: 16px; border-radius: 20px; font-size: 15px; line-height: 21px; }
.warn { display: none; background: var(--white); color: var(--ink); }
.warn.on { display: flex; }
.tip { border: 2px solid var(--line); color: var(--foam); }
.tip[hidden] { display: none; }
.tip button, .warn button { flex: 1 1 130px; min-height: 46px; padding: 0 12px; border-radius: 23px; font: 700 15px/1 var(--font); }
.warn button { border: 2px solid var(--ink); background: var(--ink); color: var(--white); }
.warn button + button { background: var(--white); color: var(--ink); }
.tip button { border: 2px solid var(--white); background: var(--white); color: var(--ink); }
.tip button + button { background: transparent; color: var(--white); }

.rows { margin-bottom: 16px; font-size: 15px; line-height: 22px; border-bottom: 1px solid var(--line); }
.rows li { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-top: 1px solid var(--line); }
.rows span { flex: none; color: var(--foam); }
.rows b { min-width: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.rows b.bad { color: var(--sun); font-weight: 700; }
.rows b button { margin: -11px -6px; padding: 11px 6px; border: 0; background: none; color: var(--white); font: 600 15px/22px var(--font); text-align: right; text-decoration: underline; text-underline-offset: 3px; }
.rows b button[disabled] { text-decoration: none; cursor: default; }

.cta { min-height: 60px; padding: 8px 20px; border: 2px solid var(--sun); border-radius: 30px; background: var(--sun); color: var(--ink);
  font: 800 clamp(17px, 4.9vw, 21px)/1.2 var(--font); letter-spacing: -.01em; transition: transform .2s var(--ease), background-color .2s ease, color .2s ease; }
.cta:active { transform: scale(.985); }
.cta.ghost { background: transparent; color: var(--sun); }
.cta[disabled] { border-color: var(--line); background: var(--line); color: var(--white); cursor: default; }
.msg { margin-top: 12px; font-size: 15px; line-height: 21px; color: var(--foam); overflow-wrap: anywhere; }
.msg:empty { display: none; }
.msg.bad { color: var(--sun); font-weight: 600; } .msg.good { color: var(--white); font-weight: 600; }
.msg button { margin: 6px 0 0 8px; min-height: 32px; padding: 0 12px; border: 2px solid var(--white); border-radius: 16px; background: none; color: var(--white); font: 600 13px/1 var(--font); }
.fine { margin-top: 14px; font-size: 13px; line-height: 18px; color: var(--foam); }

/* ---------- Sheet: network and token pickers ---------- */
.sheet { position: fixed; z-index: 10; left: 0; top: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; justify-content: center; background: rgba(20, 20, 58, .62); }
.sheet[hidden] { display: none; }
.sheet-in { width: 100%; max-width: 472px; max-height: 82vh; display: flex; flex-direction: column; gap: 12px; padding: 20px 22px max(20px, env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0; background: var(--white); color: var(--ink); animation: rise .4s var(--ease); }
@keyframes rise { from { transform: translateY(40px); } to { transform: none; } }
.sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-h h2 { font: 800 22px/28px var(--font); letter-spacing: -.02em; }
#q { width: 100%; min-height: 48px; padding: 0 18px; border: 2px solid var(--ink); border-radius: 24px; background: var(--white); color: var(--ink); font-size: 16px; outline: none; }
#q::placeholder { color: #55557A; }
#q:focus { box-shadow: 0 0 0 2px var(--sun); }
#list { overflow-y: auto; display: flex; flex-direction: column; }
#list button { width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; min-height: 52px; padding: 12px 0; border: 0; border-bottom: 1px solid #E3E3EF; background: none; color: var(--ink); text-align: left; }
#list b { font-weight: 700; font-size: 17px; }
#list button > span { color: #55557A; font-size: 13px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list li.wide button { flex-direction: column; align-items: flex-start; gap: 2px; }
#list li.wide button > span { white-space: normal; text-align: left; font-size: 14px; line-height: 19px; }
#list small { display: block; margin-top: 2px; font-size: 12px; color: #55557A; }
#list .unv small { color: var(--red); }
#list .cur b::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: var(--sea); }
#list .none { padding: 16px 0; color: #55557A; font-size: 15px; }

@media (min-width: 900px) {
  .sheet { align-items: center; }
  .sheet-in { border-radius: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .pal svg, .sheet-in, .pal[data-mood="busy"] .arms { animation: none; }
  .arms, .cta, .pal svg { transition: none; }
}

/* WalletConnect panel and the reminder to open the wallet app */
#wcBox { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
#wcBox[hidden], #list[hidden], #wcGo[hidden] { display: none; }
#wcSay { font-size: 15px; line-height: 21px; color: var(--ink); }
#wcQr { align-self: center; width: min(264px, 70vw); height: auto; border: 2px solid var(--ink); border-radius: 20px; image-rendering: pixelated; }
#wcQr[hidden] { display: none; }
#wcGo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wc-a { display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 26px; background: var(--ink); color: var(--white); font: 700 15px/1.2 var(--font); text-align: center; text-decoration: none; }
.wc-a.quiet { background: transparent; color: var(--ink); }
.wc-a[hidden] { display: none; }
.nudge { margin-top: 12px; padding: 14px 16px; border: 2px solid var(--white); border-radius: 20px; font-size: 15px; line-height: 21px; color: var(--white); font-weight: 600; }
.nudge[hidden] { display: none; }
.nudge a { color: var(--sun); font-weight: 700; text-underline-offset: 3px; }
.nudge a[hidden] { display: none; }
