/* /converter - Phase 19 rewrite. Markup + behaviour: Views/Converter/Index.cshtml.
   Scoped under .cx-page; tokens from css/ds/tokens.css; shared .tf-tick-up/down for live flashes. */
.cx-page { position: relative; isolation: isolate; color: var(--ds-text); padding: clamp(1rem, 2.4vw, 1.75rem) 0 3rem; }
.cx-page::before { content: ""; position: absolute; inset: 0 0 auto; height: 440px; z-index: -1; pointer-events: none;
  background: radial-gradient(560px 260px at 80% 0%, hsl(199 89% 55% / .14), transparent 70%), radial-gradient(520px 240px at 12% 10%, hsl(45 95% 55% / .11), transparent 70%); }
.cx-page svg, .cx-pop svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cx-wrap { display: flex; flex-direction: column; gap: 1.1rem; }
.cx-muted { color: var(--ds-text-2); font-size: .78rem; font-weight: 600; margin: 0; font-variant-numeric: tabular-nums; }
.cx-h2 { margin: 0 0 .85rem; font-size: clamp(1.02rem, 1.6vw, 1.15rem); font-weight: 900; }
.cx-h3 { margin: 0 0 .7rem; font-size: .95rem; font-weight: 900; }
.cx-page .is-up { color: var(--ds-up-ink); }
.cx-page .is-down { color: var(--ds-down-ink); }

/* ---------- hero ---------- */
.cx-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .5rem; padding: .5rem 0 .25rem; }
.cx-title { margin: 0; font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 1000; line-height: 1.25; }
.cx-sub { margin: 0; max-width: 60ch; color: var(--ds-text-2); font-size: .93rem; line-height: 1.9; font-weight: 600; }
.cx-live { display: inline-flex; align-items: center; gap: .45rem; padding: .28rem .75rem; border-radius: var(--ds-r-pill); font-size: .74rem; font-weight: 800;
  background: var(--ds-surface-2); color: var(--ds-text-2); border: 1px solid var(--ds-line); font-variant-numeric: tabular-nums; }
.cx-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ds-text-3); position: relative; }
.cx-live[data-state="on"] { color: var(--ds-up-ink); background: hsl(152 60% 45% / .1); border-color: hsl(152 60% 45% / .25); }
.cx-live[data-state="on"] i { background: hsl(152 65% 42%); }
.cx-live[data-state="on"] i::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid hsl(152 65% 42% / .5); animation: cx-ping 1.6s ease-out infinite; }
.cx-live[data-state="stale"] { color: hsl(35 90% 40%); background: hsl(40 95% 55% / .12); border-color: hsl(40 95% 55% / .3); }
.cx-live[data-state="stale"] i { background: hsl(38 92% 50%); }
@keyframes cx-ping { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

/* ---------- card ---------- */
.cx-card { position: relative; background: var(--ds-surface-1); border: 1px solid var(--ds-line); border-radius: var(--ds-r-xl); padding: clamp(1rem, 2.4vw, 1.5rem); box-shadow: var(--ds-shadow-1); min-width: 0; }
.cx-wrap > .cx-card:first-of-type { box-shadow: var(--ds-shadow-2); }
.cx-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 1rem; align-items: center; }
.cx-side { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.cx-label { font-size: .76rem; font-weight: 900; color: var(--ds-text-2); }
.cx-field { display: flex; align-items: stretch; gap: .5rem; min-height: 4.25rem; padding: .45rem; border-radius: var(--ds-r-lg); border: 1px solid var(--ds-line); background: var(--ds-surface-2); transition: border-color .15s, box-shadow .15s; }
.cx-field:focus-within { border-color: hsl(199 89% 48% / .55); box-shadow: 0 0 0 4px hsl(199 89% 48% / .12); }
.cx-field--out { background: linear-gradient(135deg, hsl(199 89% 48% / .10), hsl(217 88% 56% / .06)); border-color: hsl(199 89% 48% / .28); }
.cx-amount, .cx-result { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ds-text); font: inherit; font-weight: 1000;
  font-size: clamp(1.35rem, 3vw, 1.9rem); line-height: 1.2; padding: 0 .6rem; font-variant-numeric: tabular-nums; display: flex; align-items: center; }
.cx-amount:focus, .cx-amount:focus-visible { outline: 0 !important; box-shadow: none !important; border: 0 !important; }
.cx-result { color: hsl(199 89% 38%); overflow-wrap: anywhere; word-break: break-all; }
html.dark-theme .cx-result { color: hsl(199 89% 64%); }
.cx-pick { flex: none; display: inline-flex; align-items: center; gap: .5rem; max-width: 58%; padding: 0 .75rem; min-height: 44px; border-radius: var(--ds-r-md); cursor: pointer;
  border: 1px solid var(--ds-line); background: var(--ds-surface-1); color: var(--ds-text); font: inherit; font-size: .88rem; font-weight: 900; box-shadow: var(--ds-shadow-1); transition: border-color .15s, transform .15s; }
.cx-pick:hover, .cx-pick[aria-expanded="true"] { border-color: hsl(199 89% 48% / .55); }
.cx-pick:focus-visible, .cx-swap:focus-visible, .cx-ghost:focus-visible, .cx-opt:focus-visible, .cx-pairs a:focus-visible, .cx-tile__use:focus-visible, .cx-faq summary:focus-visible { outline: 2px solid hsl(199 89% 48%); outline-offset: 2px; }
.cx-pick__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-pick__chev { width: 16px; height: 16px; flex: none; color: var(--ds-text-2); transition: transform .2s; }
.cx-pick[aria-expanded="true"] .cx-pick__chev { transform: rotate(180deg); }
.cx-ic { width: 26px; height: 26px; flex: none; border-radius: 50%; object-fit: cover; }
.cx-ic--tmn, .cx-ic--txt { display: inline-grid; place-items: center; font-size: .7rem; font-weight: 1000; color: #fff; background: linear-gradient(135deg, hsl(152 60% 40%), hsl(170 70% 36%)); }
.cx-ic--txt { background: var(--ds-surface-2); color: var(--ds-text-2); border: 1px solid var(--ds-line); font-size: .6rem; direction: ltr; }
.cx-quick { display: flex; flex-wrap: wrap; gap: .35rem; }
.cx-quick button { min-height: 32px; padding: .2rem .7rem; border-radius: var(--ds-r-pill); border: 1px solid var(--ds-line); background: transparent; color: var(--ds-text-2); font: inherit; font-size: .76rem; font-weight: 800; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s; }
.cx-quick button:hover { color: var(--ds-text); border-color: hsl(199 89% 48% / .45); background: var(--ds-surface-2); }
.cx-words { min-height: 32px; display: flex; align-items: center; font-size: .8rem; font-weight: 800; color: var(--ds-text-2); padding-inline-start: .25rem; font-variant-numeric: tabular-nums; }
.cx-swap { width: 48px; height: 48px; margin-top: 1.4rem; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, hsl(199 89% 46%), hsl(217 88% 56%)); box-shadow: 0 10px 24px -10px hsl(199 89% 48% / .85); transition: transform .2s cubic-bezier(.34,1.56,.64,1); }
.cx-swap svg { width: 20px; height: 20px; }
.cx-swap:hover { transform: scale(1.07); }
.cx-swap:active { transform: scale(.94); }
.cx-swap.is-spun svg { animation: cx-spin .5s cubic-bezier(.22,1,.36,1); }
@keyframes cx-spin { from { transform: rotate(-180deg); } }

.cx-foot { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--ds-line-soft); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; }
.cx-rates { display: flex; flex-direction: column; gap: .15rem; font-size: .8rem; font-weight: 600; color: var(--ds-text-2); font-variant-numeric: tabular-nums; }
.cx-rates b { color: var(--ds-text); font-weight: 900; }
.cx-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.cx-ghost { display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: .4rem .85rem; border-radius: var(--ds-r-md); border: 1px solid var(--ds-line); background: transparent; color: var(--ds-text); font: inherit; font-size: .8rem; font-weight: 800; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
.cx-ghost svg { width: 16px; height: 16px; }
.cx-ghost:hover { background: var(--ds-surface-2); }
.cx-ghost.is-done { color: var(--ds-up-ink); border-color: hsl(152 60% 45% / .4); }

/* asset popover (desktop: anchored under the picker; phone: bottom sheet) */
.cx-pop { position: absolute; z-index: 60; width: 320px; max-width: calc(100% - 16px); border-radius: var(--ds-r-lg); border: 1px solid var(--ds-line); background: var(--ds-surface-3); box-shadow: var(--ds-shadow-3); overflow: hidden; animation: cx-pop .2s cubic-bezier(.22,1,.36,1); }
.cx-pop[hidden] { display: none; }
@keyframes cx-pop { from { opacity: 0; transform: translateY(-6px); } }
.cx-pop__search { display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem; border-bottom: 1px solid var(--ds-line); }
.cx-pop__search svg { width: 16px; height: 16px; color: var(--ds-text-2); flex: none; }
.cx-pop__search input { flex: 1; min-width: 0; height: 38px; border: 0; outline: 0 !important; box-shadow: none !important; background: transparent; color: var(--ds-text); font: inherit; font-size: 16px; font-weight: 700; }
.cx-pop__list { max-height: min(340px, 52vh); overflow-y: auto; overscroll-behavior: contain; padding: .35rem; }
.cx-opt { width: 100%; display: flex; align-items: center; gap: .6rem; min-height: 44px; padding: .45rem .6rem; border: 0; border-radius: var(--ds-r-md); background: transparent; color: var(--ds-text); font: inherit; font-size: .88rem; font-weight: 800; cursor: pointer; text-align: start; }
.cx-opt:hover { background: var(--ds-surface-2); }
.cx-opt.is-on { background: hsl(199 89% 48% / .13); color: hsl(199 89% 36%); }
html.dark-theme .cx-opt.is-on { color: hsl(199 89% 66%); }
.cx-opt__name { flex: 1; min-width: 0; }
.cx-opt__px { font-size: .72rem; font-weight: 700; color: var(--ds-text-2); font-variant-numeric: tabular-nums; }
.cx-pop__empty { margin: 0; padding: 1rem; text-align: center; font-size: .8rem; font-weight: 700; color: var(--ds-text-2); }

/* popular pairs */
.cx-pairs { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .4rem; }
.cx-pairs__h { font-size: .76rem; font-weight: 900; color: var(--ds-text-2); margin-inline-end: .25rem; }
.cx-pairs a { display: inline-flex; align-items: center; min-height: 36px; padding: .3rem .8rem; border-radius: var(--ds-r-pill); border: 1px solid var(--ds-line); background: var(--ds-surface-1); color: var(--ds-text); text-decoration: none; font-size: .78rem; font-weight: 800; transition: border-color .15s, transform .15s; }
.cx-pairs a:hover { border-color: hsl(199 89% 48% / .5); transform: translateY(-1px); }

/* live tiles */
.cx-board__head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.cx-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .6rem; }
.cx-tile { position: relative; border-radius: var(--ds-r-lg); border: 1px solid var(--ds-line); background: var(--ds-surface-1); transition: border-color .15s, transform .15s, box-shadow .15s; min-width: 0; }
.cx-tile:hover { border-color: hsl(199 89% 48% / .45); transform: translateY(-1px); box-shadow: var(--ds-shadow-2); }
.cx-tile__use { width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "ic name" "px px" "sub sub"; align-items: center; gap: .35rem .55rem; padding: .8rem .85rem; border: 0; background: transparent; color: var(--ds-text); font: inherit; text-align: start; cursor: pointer; border-radius: inherit; }
.cx-tile__use .cx-ic { grid-area: ic; }
.cx-tile__name { grid-area: name; font-size: .85rem; font-weight: 900; padding-inline-end: 2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-tile__px { grid-area: px; font-size: 1.1rem; font-weight: 1000; font-variant-numeric: tabular-nums; direction: ltr; text-align: end; border-radius: var(--ds-r-xs); }
.cx-tile__sub { grid-area: sub; display: flex; align-items: center; justify-content: space-between; gap: .4rem; font-size: .72rem; color: var(--ds-text-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.cx-delta { font-weight: 900; direction: ltr; }
.cx-tile__link { position: absolute; top: .55rem; inset-inline-end: .55rem; width: 32px; height: 32px; border-radius: var(--ds-r-sm); display: grid; place-items: center; color: var(--ds-text-2); transition: background-color .15s, color .15s; }
.cx-tile__link svg { width: 16px; height: 16px; }
.cx-tile__link:hover { background: var(--ds-surface-2); color: var(--ds-text); }
.cx-sk { display: inline-block; width: 6rem; height: 1rem; border-radius: var(--ds-r-xs); background: linear-gradient(90deg, var(--ds-surface-2), var(--ds-line-soft), var(--ds-surface-2)); background-size: 200% 100%; animation: cx-sk 1.2s linear infinite; vertical-align: middle; }
@keyframes cx-sk { to { background-position: -200% 0; } }
.cx-board__hint { margin-top: .75rem; }

/* content */
.cx-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.cx-steps { list-style: none; counter-reset: s; margin: 0 0 .9rem; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.cx-steps li { counter-increment: s; position: relative; padding-inline-start: 2.5rem; display: flex; flex-direction: column; gap: .15rem; }
.cx-steps li::before { content: counter(s, persian); position: absolute; inset-inline-start: 0; top: .1rem; width: 1.75rem; height: 1.75rem; border-radius: var(--ds-r-sm); display: grid; place-items: center; font-size: .8rem; font-weight: 1000; color: hsl(199 89% 38%); background: hsl(199 89% 48% / .14); }
html.dark-theme .cx-steps li::before { color: hsl(199 89% 66%); }
.cx-steps b { font-size: .9rem; font-weight: 900; }
.cx-steps span { font-size: .84rem; color: var(--ds-text-2); line-height: 1.9; font-weight: 600; }
.cx-note { margin: 0; padding: .7rem .85rem; border-radius: var(--ds-r-md); background: hsl(40 95% 55% / .1); color: var(--ds-text); font-size: .8rem; line-height: 1.9; font-weight: 600; border-inline-start: 3px solid hsl(38 92% 50%); }
.cx-faq { display: flex; flex-direction: column; gap: .5rem; }
.cx-faq details { border: 1px solid var(--ds-line); border-radius: var(--ds-r-lg); overflow: hidden; transition: border-color .15s; }
.cx-faq details[open] { border-color: hsl(199 89% 48% / .4); background: var(--ds-surface-2); }
.cx-faq summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 44px; padding: .75rem .95rem; cursor: pointer; font-size: .88rem; font-weight: 800; }
.cx-faq summary::-webkit-details-marker { display: none; }
.cx-faq summary svg { width: 18px; height: 18px; flex: none; color: var(--ds-text-2); transition: transform .2s; }
.cx-faq details[open] summary svg { transform: rotate(180deg); }
.cx-faq p { margin: 0; padding: 0 .95rem .95rem; color: var(--ds-text-2); font-size: .84rem; line-height: 2; font-weight: 600; }
.cx-links ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.cx-links a { display: inline-flex; align-items: center; min-height: 34px; padding: .3rem .75rem; border-radius: var(--ds-r-pill); background: var(--ds-surface-2); color: var(--ds-text-2); text-decoration: none; font-size: .78rem; font-weight: 800; transition: color .15s; }
.cx-links a:hover { color: var(--ds-text); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .cx-grid { grid-template-columns: 1fr; gap: .6rem; }
  .cx-swap { margin: -.1rem auto; transform: rotate(90deg); }
  .cx-swap:hover { transform: rotate(90deg) scale(1.07); }
  .cx-cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .cx-pick { max-width: 55%; padding: 0 .6rem; font-size: .82rem; }
  .cx-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .cx-tile__use { padding: .7rem; }
  .cx-tile__px { font-size: .98rem; }
  .cx-tile__sub { flex-direction: column; align-items: flex-end; gap: .1rem; }
  .cx-pairs { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -1rem; padding-inline: 1rem; }
  .cx-pairs::-webkit-scrollbar { display: none; }
  .cx-pairs a, .cx-pairs__h { flex: none; white-space: nowrap; }
  .cx-pop { position: fixed; inset: auto 0 0 0 !important; z-index: 1200; width: auto; max-width: none; border-radius: var(--ds-r-xl) var(--ds-r-xl) 0 0; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 0 0 100vmax rgb(2 6 15 / .55), var(--ds-shadow-3); animation-name: cx-sheet; }
  @keyframes cx-sheet { from { transform: translateY(40%); opacity: .4; } }
  .cx-pop__list { max-height: 60vh; }
  .cx-foot { flex-direction: column; align-items: stretch; }
  .cx-actions .cx-ghost { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .cx-live i::after, .cx-sk, .cx-pop, .cx-swap.is-spun svg { animation: none; }
  .cx-tile, .cx-pairs a, .cx-swap { transition: none; }
}
/* phase28 a11y: the search input inside the picker drops its outline, so the wrapper shows focus. */
.cx-pop__search:focus-within { box-shadow: 0 0 0 2px hsl(199 89% 48% / .55); border-radius: var(--ds-r-md); }
