/* The Trade screen and the offer builder (js/trade.js). */

/* ---------- boxes ---------- */
.trade-panel { padding: 18px 20px; border-radius: 12px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.trade-plain { display: flex; align-items: center; justify-content: space-between; gap: 14px 24px; flex-wrap: wrap; color: #e6d7c2; line-height: 1.45; }
.trade-plain p { flex: 1 1 280px; max-width: 62ch; }
#trade > .trade-plain { margin-top: 26px; }
.trade-row { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.trade-label { display: block; margin-bottom: 8px; font-weight: 700; color: var(--gilt-hi); }
.trade-input {
  font: inherit; font-size: 1.1rem; color: var(--ink); background: var(--cream); flex: 1 1 150px; min-width: 0; width: 100%;
  padding: .58em .75em .52em; border: 0; border-radius: 8px; box-shadow: inset 0 2px 5px rgba(27, 21, 18, .28);
}
.trade-input::placeholder { color: #94836f; }
.trade-input:focus-visible { outline: 3px solid var(--gilt-hi); outline-offset: 2px; }
.trade-msg { margin-top: 18px; color: var(--gilt-hi); font-weight: 700; line-height: 1.4; text-shadow: 0 1px 3px rgba(10, 3, 4, .8); }
.trade-msg + .trade-top { margin-top: 14px; }
.trade-join .trade-msg { margin-top: 0; }
.trade-msg.is-bad { color: #ffb3a6; }

/* ---------- your code, and adding a friend ---------- */
.trade-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; margin-top: 26px; }
.trade-me, .trade-add, .trade-join { display: flex; flex-direction: column; gap: 12px; }
.trade-join h2 { margin: 0; }
.trade-join .trade-label, .trade-add .trade-label { margin-bottom: -4px; }
#trade > .trade-join { margin-top: 26px; max-width: 560px; }
.trade-code { display: flex; flex-direction: column; gap: 2px; }
.trade-code strong { font-size: clamp(2.1rem, 9vw, 2.8rem); line-height: 1; letter-spacing: .08em; color: var(--gilt-hi); font-variant-numeric: tabular-nums; }
.trade-add .note, .trade-me .note { font-size: .92rem; line-height: 1.4; }

/* ---------- offers and friends ---------- */
.trade-cols { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 0 28px; align-items: start; }
.trade-cols section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.trade-cols h2 { margin: 36px 0 2px; }
@container (max-width: 840px) {
  .trade-cols { grid-template-columns: minmax(0, 1fr); }
  /* On a narrow screen whatever is waiting for an answer comes before your code. */
  #trade { display: flex; flex-direction: column; }
  #trade > .trade-msg { order: -2; }
  #trade > .trade-cols:has(.offer.is-in, .friend.is-in) { order: -1; }
  #trade > .trade-cols:has(.offer.is-in, .friend.is-in) h2:first-child { margin-top: 22px; }
}

.offer { display: flex; flex-direction: column; gap: 14px; }
.offer.is-in { box-shadow: inset 0 0 0 1px rgba(245, 223, 157, .55); }
.offer-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; }
.offer-head strong { font-size: 1.12rem; }
.offer-head .note { font-size: .88rem; }
.offer-body { display: flex; align-items: flex-start; gap: 10px; }
.offer-side { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.offer-cap { font-size: .9rem; font-weight: 700; color: var(--muted); }
.offer-cards { --cw: clamp(58px, 16.5vw, 88px); display: flex; gap: 8px; flex-wrap: wrap; }
.offer-card { margin: 0; width: var(--cw); display: flex; flex-direction: column; gap: 5px; }
.offer-card .card { cursor: default; }
.offer-card figcaption, .tb-name { font-size: .74rem; line-height: 1.15; text-align: center; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.offer-none { color: var(--muted); font-size: .95rem; line-height: 1.35; padding: 6px 0; }
.offer-swap { flex: none; width: 26px; margin-top: 46px; color: var(--gilt); }
.offer-swap svg { display: block; width: 100%; }
.offer-actions { display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap; }
.offer-actions .note { font-size: .9rem; line-height: 1.35; }

.friend { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.friend.is-in { box-shadow: inset 0 0 0 1px rgba(245, 223, 157, .55); }
.friend-face { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 1.25rem; line-height: 1; color: var(--gilt-hi); background: var(--panel-hi); box-shadow: inset 0 0 0 1px rgba(217, 180, 90, .6); }
.friend-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.friend-who strong { font-size: 1.08rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-who .note { font-size: .86rem; }
.friend-does { flex: none; display: flex; align-items: center; gap: 14px; }
.friend-does .btn { font-size: .98rem; }
.friend-does .link { font-size: .9rem; color: var(--muted); }
.friend-does .link:hover { color: #fff; }

.trade-log { list-style: none; margin: 10px 0 0; padding: 0; color: #e6d7c2; line-height: 1.4; text-shadow: 0 1px 3px rgba(10, 3, 4, .8); }
.trade-log li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.trade-log strong { color: var(--cream); }
.trade-log .note { display: block; font-size: .84rem; }

/* ---------- putting an offer together ---------- */
#trade-build { align-items: stretch; }
.tb-head { flex: none; display: flex; align-items: center; gap: 18px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.tb-head h2 { margin: 0; font-size: clamp(1.25rem, 5vw, 1.6rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-wait { margin: auto; padding: 0 20px; color: var(--muted); text-align: center; }
.tb-tabs { display: none; flex: none; padding: 8px 12px 0; gap: 6px; }
.tb-tab { flex: 1; padding: 9px 6px 8px; border-radius: 8px 8px 0 0; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-tab.on { color: var(--gilt-hi); font-weight: 700; background: rgba(243, 234, 216, .06); border-bottom-color: var(--gilt); }
.tb-panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
.tb-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.tb-pane + .tb-pane { border-left: 1px solid var(--line); }
.tb-pane-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; padding: 14px 20px 8px; }
.tb-pane-head h3 { margin: 0; font-size: 1.15rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-chips { display: flex; gap: 6px; }
.tb-chip { padding: .34em .8em .28em; border-radius: 8px; font-size: .9rem; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.tb-chip.on { color: var(--gilt-hi); font-weight: 700; background: var(--panel-hi); box-shadow: inset 0 0 0 1px rgba(217, 180, 90, .55); }
.tb-grid {
  --cw: clamp(76px, 20vw, 104px); flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; justify-items: center;
  grid-template-columns: repeat(auto-fill, minmax(var(--cw), 1fr)); gap: 16px 10px; padding: 10px 20px 22px; overscroll-behavior: contain;
}
.tb-tile { width: var(--cw); display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tb-tile .card { transition: transform .2s var(--ease); }
.tb-tile:not(:disabled):hover .card { transform: translateY(-.35em); }
.tb-tile.is-out { opacity: .32; cursor: default; }
.tb-tag { font-size: .7rem; font-weight: 700; line-height: 1; color: var(--gilt-hi); }
.tb-empty { grid-column: 1 / -1; padding: 30px 0; text-align: center; }
.tb-tray {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 14px 34px; flex-wrap: wrap;
  padding: 14px 20px max(14px, env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line);
}
.tb-piles { display: flex; align-items: flex-end; gap: 12px; }
.tb-piles .offer-swap { margin: 0 0 22px; width: 22px; }
.tb-pile { display: flex; flex-direction: column; gap: 7px; }
.tb-slots { --cw: clamp(44px, 12.5vw, 62px); display: flex; gap: 7px; }
.tb-slot { width: var(--cw); aspect-ratio: 5 / 7; border-radius: calc(var(--cw) / 16 * .9); border: 1.5px dashed rgba(217, 180, 90, .5); background: rgba(10, 4, 5, .4); }
.tb-slot.is-full { border: 0; background: none; }
/* too small for print: only the art, the price and the metal */
.tb-slot .card-tier, .tb-slot .card-ver { display: none; }
.tb-slot .card-price { font-size: max(2em, 10px); }
.tb-slot .card-info { padding-bottom: .5em; }
@media (max-width: 560px) { /* on a phone the two sides of an offer stack */
  .offer-body { flex-direction: column; gap: 6px; }
  .offer-body .offer-swap { margin: 2px 0 0 26px; transform: rotate(90deg); }
  .offer-cards { --cw: clamp(70px, 22vw, 88px); }
}
.tb-send { display: flex; flex-direction: column; align-items: center; gap: 9px; max-width: 330px; text-align: center; }
.tb-send .note { font-size: .88rem; line-height: 1.35; min-height: 2.7em; }
@media (max-width: 760px) {
  .tb-tabs { display: flex; }
  .tb-panes { grid-template-columns: 1fr; }
  .tb-pane { display: none; border: 0 !important; }
  .tb-pane.on { display: flex; }
  .tb-pane-head h3 { display: none; }
  .tb-pane-head { justify-content: flex-end; padding: 10px 14px 6px; }
  .tb-grid { padding: 8px 14px 18px; }
  .tb-tray { padding-left: 12px; padding-right: 12px; gap: 10px; }
  .tb-send { flex-direction: row; max-width: none; width: 100%; text-align: left; }
  .tb-send .note { flex: 1; min-height: 0; }
  .tb-send .btn-big { flex: none; font-size: 1.05rem; padding: .7em 1.1em .64em; }
}
