/* ===========================================================================
   trades.css — trade offers (trades.js): proposing one from a profile, and
   the Trades page (#/trades) with each offer, its two sides and its messages.
   =========================================================================== */

.view-trades {
  height: calc(100vh - 52px - var(--pfbar-h, 0px));
  height: calc(100dvh - 52px - var(--pfbar-h, 0px));
  overflow-y: auto; overflow-x: hidden;
  background: var(--bg);
}
body.has-bottomnav .view-trades { padding-bottom: var(--bottomnav-h, 0px); }

.trd { max-width: 860px; margin: 0 auto; padding: clamp(18px, 3vw, 34px) clamp(16px, 4vw, 32px) 40px; }
.trd-wait { margin: 18vh 0 0; text-align: center; color: var(--ink-3); }
.trd-title { margin: 0; font-size: 26px; font-weight: 750; letter-spacing: -0.02em; }
.trd-sub { margin: 4px 0 0; color: var(--ink-3); font-size: 14px; }
.trd-sec { margin-top: 24px; }
.trd-h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 17px; }
.trd-count { padding: 1px 8px; border-radius: 999px; font-size: 12px; color: var(--ink-3); background: var(--bg-3); }
.trd-empty { margin: 0; color: var(--ink-3); font-size: 14px; }
.trd-list { display: flex; flex-direction: column; gap: 12px; }

.trd-card {
  display: flex; flex-direction: column; gap: 12px; padding: 16px;
  border-radius: calc(var(--radius) + 4px); background: var(--bg-2); border: 1px solid var(--line-soft, var(--line));
}
.trd-card.is-declined, .trd-card.is-withdrawn { opacity: .7; }
.trd-card-head { display: flex; align-items: center; gap: 12px; }
.trd-avatar {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; object-fit: cover;
  font-weight: 750; color: #fff; background: linear-gradient(145deg, #3b82f6, #1e3a8a);
}
.trd-card-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.trd-card-title b { font-size: 15px; }
.trd-card-title span { font-size: 12.5px; color: var(--ink-3); }
.trd-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.trd-side h3 { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.trd-things { display: flex; flex-direction: column; gap: 6px; }
.trd-none { margin: 0; font-size: 13px; color: var(--ink-3); }
.trd-thing { display: flex; align-items: center; gap: 10px; min-width: 0; }
.trd-thing.is-pick { padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line-soft, var(--line)); cursor: pointer; }
.trd-thing.is-pick:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.trd-thing input { flex: none; width: 17px; height: 17px; accent-color: var(--accent); }
.trd-pic {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; overflow: hidden;
  background: var(--bg-3); color: var(--ink-3); font-weight: 700;
}
.trd-pic.is-card { height: auto; aspect-ratio: var(--card-ratio, .714); border-radius: 4px; }
.trd-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.trd-thing-text { display: flex; flex-direction: column; min-width: 0; }
.trd-thing-text b, .trd-thing-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trd-thing-text b { font-size: 13.5px; }
.trd-thing-text span { font-size: 12px; color: var(--ink-3); }

.trd-msgs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.trd-msg {
  align-self: flex-start; max-width: 80%; padding: 8px 12px; border-radius: 14px 14px 14px 4px;
  font-size: 14px; line-height: 1.4; background: var(--bg-3); white-space: pre-line; overflow-wrap: anywhere;
}
.trd-msg.is-mine { align-self: flex-end; border-radius: 14px 14px 4px 14px; color: var(--accent-ink); background: var(--accent-fill, var(--accent)); }
.trd-write { display: flex; gap: 8px; }
.trd-say { flex: 1; min-width: 0; }
.trd-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.trd-actions:empty { display: none; }
.trd-hint { font-size: 12.5px; color: var(--ink-3); }

/* the propose dialog */
.modal.modal-trade { width: min(760px, 100%); }
.trd-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.trd-col h3 { margin: 0 0 8px; font-size: 13px; }
.trd-picks { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.trd-note { resize: vertical; font: inherit; }
@media (max-width: 640px) {
  .trd-sides, .trd-cols { grid-template-columns: minmax(0, 1fr); }
  .trd-picks { max-height: none; }
}

/* the profile page's Propose a trade */
.pf-match { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.pf-match p { margin: 0; flex: 1 1 240px; }
.pf-match.is-plain { color: var(--ink-2); background: var(--home-glass); border-color: var(--home-glass-line); }
