/* Mini-exchanger: one stylesheet for every partner site; colours come from /theme.css (tenant config). */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --ok: #0f7a4a;
  --ok-bg: color-mix(in srgb, var(--ok) 12%, var(--surface));
  --bad: #b42318;
  --bad-bg: color-mix(in srgb, var(--bad) 10%, var(--surface));
  --warn: #8a5a00;
  --warn-bg: color-mix(in srgb, #f5a524 16%, var(--surface));
  --field: color-mix(in srgb, var(--text) 4%, var(--surface));
  /* Muted text on --field blocks: the tenant's muted is checked against surface and bg only (OnlySwap #64748b gave 4.4:1 here). */
  --muted-on-field: color-mix(in srgb, var(--muted) 78%, var(--text));
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 8px 24px rgb(0 0 0 / 0.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --ok: #4ade80;
  --bad: #ff8a80;
  --warn: #f5c451;
  --warn-bg: color-mix(in srgb, #f5a524 14%, var(--surface));
  --field: color-mix(in srgb, var(--text) 6%, var(--surface));
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 30px rgb(0 0 0 / 0.35);
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}
a { color: var(--accent); }
[data-theme="dark"] a { color: color-mix(in srgb, var(--accent) 70%, var(--text)); }
h1, h2 { line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; }
code { font-family: var(--mono); }

.mx-wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.mx-muted { color: var(--muted); margin: 0; }
.mx-note { color: var(--muted); font-size: 0.85rem; margin: 6px 0 0; }
.mx-fine { color: var(--muted); font-size: 0.82rem; margin: 12px 0 0; text-align: center; }

/* header */
.mx-head { border-bottom: 1px solid var(--border); background: var(--surface); }
.mx-head__row { display: flex; align-items: center; gap: 20px; min-height: 64px; flex-wrap: wrap; }
.mx-logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
[data-theme="dark"] .mx-logo { color: var(--text); }
.mx-logo__img { width: 36px; height: 36px; object-fit: contain; }
.mx-logo__mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 800;
}
.mx-nav { display: flex; gap: 4px; margin-left: auto; }
.mx-nav a, .mx-langs a {
  color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 500; font-size: 0.95rem;
}
.mx-nav a:hover, .mx-langs a:hover { color: var(--text); background: var(--field); }
.mx-nav a[aria-current="page"] { color: var(--text); background: var(--field); }
.mx-langs { display: flex; gap: 2px; }
.mx-langs a { padding: 6px 9px; font-size: 0.85rem; }
.mx-langs a[aria-current="true"] { color: var(--text); font-weight: 700; }

/* layout */
.mx-main { flex: 1; padding-top: 36px; padding-bottom: 56px; }
.mx-hero { max-width: 640px; margin-bottom: 24px; }
.mx-lead { color: var(--muted); font-size: 1.05rem; margin: 0; }
.mx-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.mx-side { display: grid; gap: 24px; }
.mx-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}

/* form */
.mx-field { margin-bottom: 18px; }
.mx-label { display: block; font-weight: 600; font-size: 0.9rem; margin: 0 0 8px; }
.mx-amount {
  display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px);
  background: var(--field); overflow: hidden;
}
.mx-amount:focus-within, .mx-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.mx-amount__input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: 600 1.4rem/1.2 var(--font);
  padding: 16px; outline: none;
}
.mx-amount__input::placeholder, .mx-input::placeholder { color: var(--muted); opacity: 0.8; }
.mx-asset {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 0 36px 0 14px; min-width: 150px;
  border-left: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.mx-asset::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg);
}
.mx-asset__badge {
  width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 0.85rem;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--text);
}
.mx-asset__text { display: flex; flex-direction: column; line-height: 1.15; }
.mx-asset__text b { font-size: 1rem; }
.mx-asset__text small { color: var(--muted); font-size: 0.78rem; }
.mx-asset select {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px;
}
.mx-asset:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
.mx-swap-row { display: flex; justify-content: center; margin: -6px 0 6px; }
.mx-swap {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow);
}
.mx-swap:hover { border-color: var(--accent); color: var(--accent); }
.mx-input {
  width: 100%; border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px); background: var(--field); color: var(--text);
  font: 500 0.98rem/1.4 var(--mono); padding: 14px 16px; outline: none;
}

.mx-quote {
  border: 1px dashed var(--border); border-radius: calc(var(--radius) - 4px); padding: 14px 16px; margin: 4px 0 16px; min-height: 56px;
}
.mx-quote__row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; padding: 2px 0; }
.mx-quote__row b { text-align: right; }
.mx-quote__get { font-size: 1.15rem; }
.mx-quote__row--small { font-size: 0.88rem; margin-top: 4px; }
.mx-timer { color: var(--muted); font-variant-numeric: tabular-nums; }
.mx-timer.is-over { color: var(--bad); font-weight: 600; }
.mx-loading::after { content: ""; display: inline-block; width: 1em; animation: mx-dots 1.2s steps(4) infinite; overflow: hidden; vertical-align: bottom; }
@keyframes mx-dots { from { width: 0; } to { width: 1em; } }

/* "Exchange via a DEX" consent: before the button, required. */
.mx-check { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px); font-size: 0.88rem; line-height: 1.45; color: var(--text); cursor: pointer; }
.mx-check input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); cursor: pointer; }
.mx-check a { color: var(--accent); font-weight: 600; }
[data-theme="dark"] .mx-check a { color: color-mix(in srgb, var(--accent) 70%, var(--text)); }
.mx-check.is-invalid { border-color: var(--bad); background: var(--bad-bg); }

.mx-error {
  background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; font-size: 0.92rem;
}
[data-theme="dark"] .mx-error { color: var(--text); border-left: 3px solid var(--bad); }

.mx-btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 0; border-radius: calc(var(--radius) - 4px);
  background: var(--accent); color: var(--accent-text); font: 700 1rem/1 var(--font); padding: 16px 22px; cursor: pointer; text-decoration: none;
}
[data-theme="dark"] a.mx-btn { color: var(--accent-text); }
.mx-btn:hover { filter: brightness(1.06); }
.mx-btn:disabled { background: var(--field); color: color-mix(in srgb, var(--muted) 75%, var(--text)); box-shadow: inset 0 0 0 1px var(--border); cursor: not-allowed; filter: none; }
.mx-btn--wide { width: 100%; font-size: 1.05rem; }
.mx-link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
[data-theme="dark"] .mx-link { color: color-mix(in srgb, var(--accent) 70%, var(--text)); }
.mx-link:hover { text-decoration: underline; }

/* side */
.mx-how ol { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; color: var(--text); }
.mx-recent ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mx-recent li { display: flex; flex-direction: column; }
.mx-recent a { font-weight: 600; text-decoration: none; }
.mx-recent small { color: var(--muted); }

/* order */
.mx-order { max-width: 760px; margin: 0 auto; }
.mx-order__head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mx-order__head h1 { margin: 0; font-size: clamp(1.3rem, 1.1rem + 1vw, 1.8rem); word-break: break-all; }
.mx-pill { padding: 5px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 700; background: var(--field); color: var(--text); }
.mx-pill--completed { background: var(--ok-bg); color: var(--ok); }
.mx-pill--error, .mx-pill--cancelled { background: var(--bad-bg); color: var(--bad); }
.mx-pill--awaiting_deposit, .mx-pill--processing, .mx-pill--quoting { background: var(--warn-bg); color: var(--warn); }
.mx-live { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.88rem; margin: 8px 0 20px; min-height: 1.4em; }
.mx-live.is-off { color: var(--bad); }
.mx-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: mx-pulse 1.6s ease-in-out infinite; }
.mx-live.is-off .mx-dot { background: var(--bad); animation: none; }
@keyframes mx-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.mx-stages { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; counter-reset: st; }
.mx-stages li { display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 0.85rem; line-height: 1.25; }
.mx-stage__dot { height: 6px; border-radius: 3px; background: var(--border); }
.mx-stages li.is-done { color: var(--text); }
.mx-stages li.is-done .mx-stage__dot { background: var(--ok); }
.mx-stages li.is-now { color: var(--text); font-weight: 700; }
.mx-stages li.is-now .mx-stage__dot { background: var(--accent); animation: mx-pulse 1.6s ease-in-out infinite; }
.mx-stages li.is-bad { color: var(--bad); font-weight: 700; }
.mx-stages li.is-bad .mx-stage__dot { background: var(--bad); }

.mx-deposit {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: start; padding: 20px;
  border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px); background: var(--field); margin-bottom: 20px;
}
.mx-deposit .mx-label { margin-top: 12px; }
.mx-deposit .mx-label:first-child { margin-top: 0; }
.mx-deposit__amount { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.mx-copyline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mx-addr { font-size: 0.95rem; word-break: break-all; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; color: var(--text); }
.mx-copyline--addr .mx-addr { flex: 1; min-width: 0; }
.mx-copy {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 12px; font: 600 0.85rem var(--font); cursor: pointer;
}
.mx-copy:hover { border-color: var(--accent); }
.mx-copy.is-done { border-color: var(--ok); color: var(--ok); }
.mx-qr { width: 200px; height: 200px; border-radius: 10px; background: #fff; padding: 6px; border: 1px solid var(--border); }
.mx-warn { background: var(--warn-bg); color: var(--text); border-left: 3px solid var(--warn); border-radius: 8px; padding: 10px 12px; font-size: 0.88rem; margin: 14px 0 0; }

.mx-banner { border-radius: calc(var(--radius) - 4px); padding: 16px 18px; background: var(--field); margin-bottom: 20px; }
.mx-deposit .mx-muted, .mx-deposit .mx-note, .mx-banner .mx-muted, .mx-banner .mx-note { color: var(--muted-on-field); }
.mx-banner p { margin: 4px 0 0; }
.mx-banner--ok { background: var(--ok-bg); }
.mx-banner--ok b { color: var(--ok); font-size: 1.1rem; }
.mx-banner--bad { background: var(--bad-bg); border-left: 3px solid var(--bad); }

.mx-sum { margin: 0 0 16px; border-top: 1px solid var(--border); }
.mx-sum__row { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.mx-sum dt { color: var(--muted); }
.mx-sum dd { margin: 0; font-weight: 600; word-break: break-word; }
.mx-sum dd small { color: var(--muted); font-weight: 400; }
.mx-sum .mx-addr { display: inline-block; font-weight: 500; }

/* documents */
.mx-doc { max-width: 760px; margin: 0 auto; }
.mx-doc h2 { margin-top: 24px; }
.mx-doc p { margin: 0 0 12px; }
.mx-faq { border-bottom: 1px solid var(--border); padding: 14px 0; }
.mx-faq summary { font-weight: 600; cursor: pointer; }
.mx-faq p { margin: 10px 0 0; color: var(--text); }

/* footer */
.mx-foot { border-top: 1px solid var(--border); background: var(--surface); padding: 28px 0; font-size: 0.92rem; }
.mx-foot__row { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.mx-foot p { margin: 0 0 4px; }
.mx-foot__name { font-weight: 700; }
.mx-foot__text { color: var(--muted); }
.mx-foot__label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }

@media (max-width: 860px) {
  .mx-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .mx-wrap { padding: 0 14px; }
  .mx-head__row { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .mx-nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .mx-langs { margin-left: auto; }
  .mx-main { padding-top: 20px; }
  .mx-card { padding: 18px; }
  .mx-asset { min-width: 128px; padding: 0 30px 0 10px; }
  .mx-amount__input { font-size: 1.2rem; padding: 14px 12px; }
  .mx-stages { grid-template-columns: 1fr; gap: 10px; }
  .mx-stages li { flex-direction: row; align-items: center; }
  .mx-stage__dot { width: 22px; flex: none; }
  .mx-deposit { grid-template-columns: 1fr; padding: 16px; }
  .mx-qr { justify-self: center; }
  .mx-sum__row { grid-template-columns: 1fr; gap: 2px; }
  .mx-addr { font-size: 0.8rem; padding: 7px 8px; }
  .mx-input { font-size: 0.9rem; }
}
@media (prefers-reduced-motion: reduce) {
  .mx-dot, .mx-stages li.is-now .mx-stage__dot, .mx-loading::after { animation: none; }
}

/* Exchange paused (API unavailable): replaces the form until the API answers again. */
.mx-paused { padding: 8px 4px; }
.mx-paused h2 { font-size: 1.25rem; }
.mx-paused p { margin: 8px 0 0; }
.mx-paused::before {
  content: ""; display: block; width: 40px; height: 40px; margin-bottom: 14px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, #f5a524 55%, var(--surface));
  background: linear-gradient(90deg, transparent 13px, var(--warn) 13px 17px, transparent 17px 23px, var(--warn) 23px 27px, transparent 27px)
    center / 100% 14px no-repeat, var(--warn-bg);
}
