/* Purchases page. .ithumb is purchases.js itemThumb() (also used by Overview); promote both with it to core.js / base.css */

/* item thumbnail: fixed box, soft rarity-tinted glow, neutral when there's no image */
.ithumb {
  --rar: #5d626a;
  position: relative; flex: none; display: grid; place-items: center;
  width: var(--thumb, 40px); height: var(--thumb, 40px); border-radius: 8px; overflow: hidden;
  background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--rar) 26%, transparent) 0%, transparent 70%), var(--surface-2);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--rar) 55%, transparent);
}
.ithumb img { width: 88%; height: 88%; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); animation: fade .3s ease-out both; }

/* ---------- best buys: horizontal strip of wide cards, image left ---------- */
.bb-wrap { min-width: 0; }
.bb-strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: 284px; gap: 12px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: thin;
  padding-bottom: 6px; -webkit-overflow-scrolling: touch;
}
.bb-strip > .card { padding: 14px; }
.bb {
  position: relative; display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 10px 12px 10px 10px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  color: inherit; font: inherit; text-align: left; cursor: pointer; scroll-snap-align: start;
  transition: border-color .15s, background .15s, transform .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.bb:hover { border-color: #353a40; background: var(--surface-2); transform: translateY(-2px); }
.bb:active { transform: translateY(0) scale(.98); }
.bb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bb-rank { position: absolute; top: 6px; left: 6px; padding: 0 6px; border-radius: 999px; background: rgba(14, 15, 17, .78); color: var(--muted); font-size: 11px; line-height: 17px; }
.bb-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.bb-saved { color: var(--pos); font-size: 16px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.bb-saved small { color: var(--faint); font-size: 11.5px; font-weight: 400; letter-spacing: 0; }
.bb-item {
  font-size: 13px; line-height: 1.3; overflow-wrap: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bb-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- toolbar: search, then type chips · date chips (+ custom dates) · Steam ID ---------- */
.ptools { display: grid; gap: 12px; scroll-margin-top: calc(var(--top-h) + 12px); }
.ptools, .ptools .fs-body { grid-template-columns: minmax(0, 1fr); }
.ptools-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; min-width: 0; }
.ptools .search { flex: 1 1 260px; }
.ptools .clear { flex: none; }
.pdates { display: flex; align-items: center; gap: 8px; animation: fade .2s ease-out both; }
.pdates input { width: 140px; padding: 4px 10px; }
.pdates .dash { color: var(--faint); }
.fchips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.fchip {
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); background: transparent;
  color: var(--muted); font: 500 12.5px/20px inherit; font-family: inherit; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s; -webkit-tap-highlight-color: transparent;
}
.fchip:hover { color: var(--text); background: var(--surface-2); }
.fchip[aria-pressed="true"] { color: var(--accent); background: rgba(138, 180, 255, .1); border-color: rgba(138, 180, 255, .35); }
.fchip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.acc-box { position: relative; display: flex; flex-direction: column; flex: 0 0 190px; margin-left: auto; }
.acc-box .pacct { width: 100%; padding: 4px 10px; font-size: 13px; }
.acc-hint { position: absolute; top: 100%; left: 2px; margin-top: 3px; color: var(--warn); font-size: 11.5px; white-space: nowrap; }

/* ---------- summary strip ---------- */
.psum {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 28px;
  padding: 11px 20px; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, .012);
  font-variant-numeric: tabular-nums; animation: fade .25s ease-out both;
}
.psum-i { display: flex; align-items: baseline; gap: 8px; }
.psum-i span { color: var(--muted); font-size: 12.5px; }
.psum-i b { font-weight: 600; }

/* ---------- table ---------- */
.purch .icell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.purch td.item { white-space: normal; text-overflow: clip; }
/* whole words, two lines at most */
.purch .iname {
  min-width: 0; overflow-wrap: break-word; word-break: normal; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.copy {
  padding: 2px 6px; margin: -2px -6px; border: 0; border-radius: 6px; background: transparent; color: inherit;
  cursor: copy; transition: background .15s, color .15s;
}
.copy:hover { background: var(--surface-2); color: var(--accent); }
.copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }

@media (min-width: 721px) {
  .purch td { padding-top: 9px; padding-bottom: 9px; }
}

@media (max-width: 720px) {
  .bb-strip { grid-auto-columns: 276px; gap: 10px; margin-right: calc(-1 * max(16px, env(safe-area-inset-right))); padding-right: 16px; }
  .ptools-row { gap: 12px; }
  .ptools .search { flex: 1 1 0; }
  .fchip { min-height: 36px; padding: 6px 14px; }
  .pdates, .acc-box { flex: 1 1 100%; margin-left: 0; min-width: 0; }
  .pdates input { flex: 1 1 0; width: auto; min-width: 0; }
  .acc-box .pacct { font-size: 16px; }
  .acc-hint { position: static; margin-top: 4px; }
  .psum { padding: 12px 16px; gap: 8px 18px; }
  .psum-i { flex: 1 1 40%; flex-direction: column; gap: 0; }
  .purch .icell .ithumb { --thumb: 44px !important; }
  /* compact row (base .dt-x): Paid under the name, Exp. ROI always at the right edge */
  .purch .table-wrap tr[aria-expanded] { align-items: center; row-gap: 2px; }
  .purch .table-wrap tr[aria-expanded] > td.item ~ td.pri { margin-left: 56px; font-weight: 500; }
  .purch .table-wrap tr[aria-expanded] > td.item ~ td.pri:last-child { margin-left: auto; }
  .purch .table-wrap tr[aria-expanded="true"] > td:not(.pri) { margin-top: 8px; }
  .copy { min-height: 30px; margin: -5px 0; padding-left: 0; }
}
