/* Pokémon TCG Cards Wanted — seller picker.
   Dark-first, mobile-first. No framework. */

:root {
  --bg: #0e1116;
  --bg-raised: #161b23;
  --bg-sunken: #0a0d12;
  --border: #262d38;
  --border-strong: #39424f;
  --text: #e7ecf3;
  --text-muted: #97a3b4;
  --accent: #ffcb3d;
  --accent-ink: #2a1f00;
  --accent-soft: rgba(255, 203, 61, 0.14);
  --danger: #ff6b6b;
  --ok: #4ade80;
  --radius: 12px;
  --radius-sm: 8px;
  --cart-w: 380px;
  --header-h: 60px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa;
    --bg-raised: #ffffff;
    --bg-sunken: #e9edf4;
    --border: #d9e0ea;
    --border-strong: #b9c4d3;
    --text: #16202e;
    --text-muted: #5c6b7f;
    --accent: #f0a500;
    --accent-ink: #ffffff;
    --accent-soft: rgba(240, 165, 0, 0.15);
    --shadow: 0 10px 30px rgba(20, 32, 48, 0.12);
  }
}

*, *::before, *::after { box-sizing: border-box; }

/* Class-based display rules below outrank the UA rule for [hidden], so make
   the attribute win outright. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

body.cart-open { overflow: hidden; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; display: block; }

.wrap {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  min-height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { font-size: 1.5rem; }
.brand-title { margin: 0; font-weight: 700; font-size: 1rem; letter-spacing: .01em; }
.brand-sub { margin: 0; font-size: .78rem; color: var(--text-muted); }

.cart-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 999px;
  padding: 9px 16px; font-size: .92rem; font-weight: 700;
  cursor: pointer;
}
.cart-toggle:hover { filter: brightness(1.06); }

.cart-count {
  background: var(--accent-ink); color: var(--accent);
  border-radius: 999px; min-width: 22px; padding: 1px 7px;
  font-size: .78rem; font-weight: 700; text-align: center;
}

/* ---------- Views ---------- */

main { padding-bottom: 96px; }
.view { padding-top: 22px; }

.notice-area:empty { display: none; }
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--radius);
  padding: 10px 14px; margin-top: 16px;
  font-size: .88rem;
}
.notice button {
  margin-left: auto; background: none; border: 0; cursor: pointer;
  color: inherit; font-size: 1rem; line-height: 1; padding: 2px 4px;
}

/* ---------- Guide ---------- */

.guide {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 24px;
}
.guide p:last-child { margin-bottom: 0; }
.guide-compact { padding: 12px 16px; font-size: .92rem; margin-bottom: 18px; }
.guide-compact p { margin: 0; color: var(--text-muted); }
.guide-compact strong { color: var(--text); }

.guide-steps {
  margin: 0 0 .9em; padding-left: 1.25em;
  display: grid; gap: 4px;
  color: var(--text-muted); font-size: .93rem;
}
.guide-steps strong { color: var(--text); }
.guide-foot { font-size: .86rem; color: var(--text-muted); }

/* ---------- Sets grid ---------- */

.sets-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.set-card {
  display: flex; flex-direction: column; gap: 10px;
  text-align: left; width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  color: inherit; font: inherit; cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.set-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.set-card:disabled { opacity: .45; cursor: not-allowed; }

.set-card-logo {
  height: 54px; width: auto; max-width: 78%;
  object-fit: contain; object-position: left center;
}
.set-card-name { font-weight: 700; font-size: 1.02rem; }
.set-card-series { font-size: .8rem; color: var(--text-muted); }

.set-card-need {
  margin-top: auto; padding-top: 8px;
  font-size: .86rem; font-weight: 700; color: var(--accent);
}
.set-card-need.is-empty { color: var(--text-muted); font-weight: 500; }

.set-card-picked {
  font-size: .8rem; color: var(--ok); font-weight: 600;
}

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

.set-header { margin-bottom: 18px; }
.back-btn {
  background: none; border: 0; color: var(--text-muted);
  font: inherit; font-size: .9rem; cursor: pointer;
  padding: 4px 0; margin-bottom: 10px;
}
.back-btn:hover { color: var(--text); }

.set-header-main { display: flex; align-items: center; gap: 14px; }
.set-logo { height: 52px; width: auto; max-width: 150px; object-fit: contain; }
.set-meta { margin: 0; font-size: .86rem; color: var(--text-muted); }

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.search-field { flex: 1 1 220px; }
.search-field input {
  width: 100%; font: inherit; font-size: .95rem;
  background: var(--bg-sunken); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px;
}
.search-field input::placeholder { color: var(--text-muted); }
.toolbar-status { margin: 0; font-size: .85rem; color: var(--text-muted); }

/* ---------- Cards grid ---------- */

.cards-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
}

@media (min-width: 720px) {
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); }
}

.card-tile {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-raised);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
  transition: border-color .12s ease, transform .12s ease;
}
.card-tile:hover { border-color: var(--border-strong); transform: translateY(-2px); }

.card-tile[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.card-thumb-wrap {
  position: relative;
  aspect-ratio: 245 / 342;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.card-thumb { width: 100%; height: 100%; object-fit: contain; }

.card-check {
  position: absolute; inset-inline-end: 6px; inset-block-start: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-size: .85rem; font-weight: 800;
  opacity: 0; transform: scale(.6);
  transition: opacity .12s ease, transform .12s ease;
}
.card-tile[aria-pressed="true"] .card-check { opacity: 1; transform: scale(1); }

.card-qty {
  position: absolute; inset-inline-start: 6px; inset-block-start: 6px;
  background: rgba(0, 0, 0, .72); color: #fff;
  border-radius: 999px; padding: 2px 8px;
  font-size: .72rem; font-weight: 700;
}

.card-num { font-size: .74rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.card-name {
  font-size: .84rem; font-weight: 600; line-height: 1.3;
  overflow-wrap: anywhere;
}
.card-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }

.badge {
  font-size: .68rem; font-weight: 700; letter-spacing: .02em;
  border-radius: 999px; padding: 2px 8px;
  border: 1px solid var(--border-strong); color: var(--text-muted);
}
.badge-variant-normal { border-color: var(--border-strong); }
.badge-variant-reverse-holofoil { border-color: #7c9cff; color: #9db4ff; }
.badge-variant-holofoil { border-color: #d78bff; color: #dda6ff; }
.badge-rarity { border-style: dashed; }

.empty-state {
  text-align: center; color: var(--text-muted);
  padding: 28px 12px; font-size: .92rem;
}

/* ---------- Cart ---------- */

.cart-scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .55);
}

.cart {
  position: fixed; z-index: 50;
  top: 0; right: 0; bottom: 0;
  width: min(var(--cart-w), 100vw);
  display: flex; flex-direction: column;
  background: var(--bg-raised);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(101%);
  transition: transform .22s ease;
  visibility: hidden;
}
.cart.is-open { transform: none; visibility: visible; }

@media (prefers-reduced-motion: reduce) {
  .cart { transition: none; }
}

.cart-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cart-head h2 { margin: 0; }

.icon-btn {
  background: none; border: 0; color: var(--text-muted);
  font-size: 1.05rem; cursor: pointer; padding: 6px 8px; border-radius: var(--radius-sm);
}
.icon-btn:hover { color: var(--text); background: var(--bg-sunken); }

.cart-body {
  flex: 1; overflow-y: auto;
  padding: 14px 16px;
  -webkit-overflow-scrolling: touch;
}

.cart-guide {
  font-size: .86rem; color: var(--text-muted);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 14px;
}
.cart-guide strong { color: var(--text); }

.cart-set-group { margin-bottom: 18px; }
.cart-set-name {
  font-size: .74rem; font-weight: 800; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-muted);
  padding-bottom: 6px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.cart-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px; align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: 0; }

.cart-thumb {
  width: 42px; aspect-ratio: 245 / 342; object-fit: contain;
  background: var(--bg-sunken); border-radius: 4px;
}
.cart-item-main { min-width: 0; }
.cart-item-num { font-size: .72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cart-item-name { font-size: .85rem; font-weight: 600; overflow-wrap: anywhere; }
.cart-item-variant { font-size: .72rem; color: var(--text-muted); }

.price-field {
  display: flex; align-items: center; gap: 4px;
  margin-top: 6px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  max-width: 148px;
}
.price-field.is-invalid { border-color: var(--danger); }
.price-prefix { font-size: .8rem; color: var(--text-muted); }
.price-field input {
  width: 100%; min-width: 0;
  background: none; border: 0; color: var(--text);
  font: inherit; font-size: .88rem; padding: 2px 0;
  font-variant-numeric: tabular-nums;
}
.price-field input:focus { outline: none; }
.price-field input::-webkit-outer-spin-button,
.price-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.cart-item-remove {
  background: none; border: 0; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; padding: 4px 6px; border-radius: 6px;
}
.cart-item-remove:hover { color: var(--danger); background: var(--bg-sunken); }

.cart-foot {
  border-top: 1px solid var(--border);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--bg-raised);
}
.cart-total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px; font-size: .95rem;
}
.cart-total strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }

.cart-warning {
  margin: 0 0 10px; font-size: .82rem; color: var(--danger);
}

.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 11px 16px;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost {
  background: none; color: var(--text-muted); border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-block { display: block; width: 100%; }
.btn-small { padding: 8px 14px; font-size: .85rem; margin-top: 8px; }

.checkout-output {
  width: 100%; resize: vertical;
  background: var(--bg-sunken); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px;
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* Wrap for reading; the copied value keeps its real newlines either way. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.checkout-actions { display: flex; gap: 8px; margin-top: 12px; }
.checkout-actions .btn { flex: 1; }
.copy-status { margin: 10px 0 0; font-size: .84rem; color: var(--ok); min-height: 1.2em; }

/* ---------- Desktop: cart docks beside content ---------- */

@media (min-width: 1080px) {
  body.cart-open { overflow: auto; }
  body.cart-open .cart-scrim { display: none; }
  body.cart-open main,
  body.cart-open .site-header .wrap { padding-right: calc(var(--cart-w) + 16px); }
}
