/* Public card shop. Self-contained — shares nothing with the admin app.css. */

:root {
  --bg:      #f6f7f9;
  --card:    #ffffff;
  --line:    #e3e6ea;
  --ink:     #14171c;
  --ink2:    #5c6470;
  --ink3:    #8a929e;
  --accent:  #1f6feb;
  --good:    #0f7b46;
  --goodbg:  #e8f5ee;
  --foil:    #7b3fe4;
  --foilbg:  #f1eaff;
  /* Availability pill and quantity picker share these so they read as one
     control group: the number you can have, and the number you want. */
  --chip:     #e6eaf0;
  --chipline: #c3ccd8;
  --radius:  10px;
  --shadow:  0 1px 2px rgba(16,20,28,.06), 0 1px 8px rgba(16,20,28,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:     #0f1216;
    --card:   #171b21;
    --line:   #262c35;
    --ink:    #e8ebef;
    --ink2:   #9aa3b0;
    --ink3:   #6d7684;
    --accent: #58a6ff;
    --good:   #3fb27f;
    --goodbg: #10291e;
    --foil:   #b18cff;
    --foilbg: #201a33;
    --chip:     #242b35;
    --chipline: #414b59;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */

/* Title, search and filters ride along as one sticky block. z-index sits above
   the rows so scrolled cards pass underneath rather than through. */
header.site {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 0 10px;
  margin-bottom: 16px;
  box-shadow: 0 1px 12px rgba(16,20,28,.05);
}

.titlerow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.titlebox { min-width: 0; }
h1 { margin: 0; font-size: 20px; letter-spacing: -.015em; }
.sub { margin: 2px 0 0; color: var(--ink2); font-size: 12px; }

/* ---------- login indicator ---------- */

.authbox { display: flex; align-items: center; gap: 8px; margin: 0; }
.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink2);
  background: var(--bg);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill.on { color: var(--good); background: var(--goodbg); border-color: transparent; }

/* ---------- running total ---------- */

.picked {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-left: auto;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.picked.any { border-color: var(--accent); }
.pk { color: var(--ink2); font-size: 13px; }
.pv {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.picked.any .pv { color: var(--accent); }

/* ---------- search + filters ---------- */

.searchrow { display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px; }
.searchbox { flex: 1; min-width: 0; }
.filttoggle { display: none; }          /* mobile only — see the media query */
.fcount {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.searchbox input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;              /* 16px stops iOS zooming on focus */
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.searchbox input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.fbtn {
  appearance: none;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.fbtn:hover { border-color: var(--ink3); }
select.fbtn { padding-right: 26px; }

.seg {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.segbtn {
  appearance: none;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink2);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
}
.segbtn:last-child { border-right: 0; }
.segbtn:hover { color: var(--ink); }
.segbtn.on { background: var(--accent); color: #fff; }

.link {
  appearance: none;
  background: none;
  border: 0;
  padding: 6px 4px;
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
}
.link:hover { text-decoration: underline; }
.muted { color: var(--ink3); font-size: 12px; }

/* ---------- set dropdown ---------- */

.dropdown { position: relative; }
.dropdown .panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(16,20,28,.16);
  padding: 10px;
}
.dropdown .panel input[type=search] {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.panelactions { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; }
.options { max-height: 300px; overflow-y: auto; }
.opt {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.opt:hover { background: var(--bg); }
.opt input { margin: 0; accent-color: var(--accent); }
.oname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ocount { color: var(--ink3); font-size: 12px; font-variant-numeric: tabular-nums; }
.caret { color: var(--ink3); font-size: 11px; }

/* ---------- results ---------- */

.resultbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 2px 10px;
  color: var(--ink2);
  font-size: 13px;
}

.rows { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;   /* thumb · info · prices · controls */
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.thumb {
  width: 44px;
  aspect-ratio: 488 / 680;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--line);
}
.thumb.ph {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink3);
  font-size: 15px;
}

/* Grid columns default to min-width:auto, meaning this one refuses to shrink
   below its longest word and pushes the price column off-screen instead. */
.info { min-width: 0; }
.cname { font-weight: 600; letter-spacing: -.005em; }

/* Set names collide constantly — four different Wasteland printings — and the
   full name is already on the line below. The code disambiguates at a glance. */
.setcode {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink3);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: 1px;
}
.cmeta { color: var(--ink2); font-size: 13px; margin-top: 2px; }
.cmeta .dot { color: var(--ink3); margin: 0 5px; }

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  vertical-align: 1px;
}
.tag.foil { background: var(--foilbg); color: var(--foil); }
.tag.rl   { background: var(--goodbg); color: var(--good); }

/* ---------- availability + quantity, deliberately one visual group ---------- */

.rows.authed .row { grid-template-columns: 44px 1fr auto auto auto; }

.controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;   /* pulls the pill toward the price */
  gap: 8px;
}

/* The shared look: how many exist, next to how many you want. */
.avail, .qty {
  border: 2px solid var(--chipline);
  background: var(--chip);
  border-radius: 8px;
}
.avail {
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink2);
  white-space: nowrap;
}

.qty {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
}
.qbtn {
  appearance: none;
  width: 28px;
  height: 28px;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  color: var(--ink2);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.qbtn:hover:not([disabled]) { background: var(--card); color: var(--ink); }
.qbtn[disabled] { opacity: .3; cursor: default; }
.qn {
  min-width: 24px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink3);           /* zero stays faded */
}
.row.picked-row { border-color: var(--accent); }
.row.picked-row .qn { color: var(--ink); }   /* anything above zero reads solid */

/* Reserves the widest total the column will ever show, so rows do not jitter
   sideways as quantities change. */
.linetotal {
  min-width: 74px;
  text-align: right;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink3);
}
.row.picked-row .linetotal { color: var(--ink); }

.prices { text-align: right; white-space: nowrap; }

/* "85% of FtF" rides to the left of the ask, on the same baseline. */
.saleline {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 7px;
}
.pct {
  color: var(--ink3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.sale {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
/* "5 for $0.01" is a phrase, not a figure, and at the full price size it
   crowds the row and reads as though it were a big number. Slightly smaller
   and in the muted ink keeps the price column's rhythm intact. */
.sale.bulk {
  font-size: 15px;
  color: var(--ink2);
  white-space: nowrap;
}
.retail {
  color: var(--ink3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

/* 28% of listings have no F2F quote and so carry no ask. A bare em-dash there
   reads as a bug; this reads as a state. */
.noprice {
  color: var(--ink3);
  font-size: 13px;
  font-style: italic;
}

.empty, .loading {
  text-align: center;
  padding: 44px 16px;
  color: var(--ink2);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.more { text-align: center; margin: 18px 0; }
.btn {
  appearance: none;
  padding: 10px 20px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { border-color: var(--ink3); }
.btn[disabled] { opacity: .5; cursor: default; }

.foot {
  margin: 28px 0 40px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink2);
  font-size: 13px;
}

@media (max-width: 560px) {
  .row { grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; padding: 9px 11px; }
  .row > .controls { grid-column: 2 / -1; }

  /* "85% of FtF" moves above the price rather than beside it — inline, the
     pair is ~130px wide and shoves the whole price column past the viewport
     edge on a 375px screen. */
  .saleline { display: block; }
  .pct { display: block; margin-bottom: 1px; }
  .thumb { width: 38px; }
  .cmeta { font-size: 12px; }
  .sale { font-size: 16px; }
  .filters { gap: 6px; }

  /* The sticky block is competing with the card list for a small screen, so
     it sheds everything that is not the title, the running total and the
     controls. */
  header.site { padding: 10px 0 8px; }
  h1 { font-size: 17px; }
  .sub { display: none; }
  .titlerow { gap: 8px; margin-bottom: 8px; }
  .picked { padding: 3px 9px; gap: 7px; }
  .pv { font-size: 14px; }
  .pk { font-size: 12px; }

  /* The filters collapse behind a toggle here: on a phone they were three
     wrapped rows of chips permanently occupying a third of the screen. Hidden
     with display:none rather than overflow/height so the set dropdown's
     absolutely positioned panel is never clipped when it IS open. */
  .searchrow { margin-bottom: 0; }
  .searchbox input { padding: 9px 12px; }
  .fbtn, .segbtn { padding: 6px 9px; font-size: 13px; }
  select.fbtn { padding-right: 22px; }

  .filttoggle { display: inline-flex; align-items: center; white-space: nowrap; }
  .filters { display: none; padding-top: 10px; }
  header.site.filters-open .filters { display: flex; }

  /* Controls and line total drop to a second line rather than crushing the
     card name into two characters. */
  .rows.authed .row {
    grid-template-columns: 38px 1fr auto;
    grid-template-areas:
      "thumb info     price"
      "thumb controls total";
    row-gap: 8px;
  }
  .rows.authed .row > .thumb     { grid-area: thumb; align-self: start; }
  .rows.authed .row > .info      { grid-area: info; }
  .rows.authed .row > .prices    { grid-area: price; }
  .rows.authed .row > .controls  { grid-area: controls; justify-content: flex-start; }
  .rows.authed .row > .linetotal { grid-area: total; }
}
