/* CCG Data — static site styles */

:root {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --ink: #1e1c18;
  --muted: #6d6861;
  --line: #ded9d0;
  --line-strong: #c4bdb2;
  --accent: #7a3e2f;
  --accent-ink: #ffffff;
  --accent-soft: #f0e4df;
  --ok: #2f6b45;
  --warn: #8a5b16;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 28, 24, .06), 0 8px 24px rgba(30, 28, 24, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --panel: #201f1c;
    --ink: #eae6de;
    --muted: #a29b90;
    --line: #35322d;
    --line-strong: #4a463f;
    --accent: #e0a38f;
    --accent-ink: #23120d;
    --accent-soft: #33221c;
    --ok: #8fce9f;
    --warn: #e0b978;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1em; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

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

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 58px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.site-nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 11px;
  border-radius: 7px;
  font-size: .92rem;
  font-weight: 550;
}

.site-nav a:hover { color: var(--ink); background: var(--bg); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }

main { padding: 28px 0 72px; }

/* ---------- misc ---------- */

.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tiny { font-size: .78rem; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }

.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.crumbs span { margin: 0 6px; opacity: .6; }

.page-head { margin-bottom: 22px; }
.page-head .lede { color: var(--muted); max-width: 70ch; }
.page-head .meta { color: var(--muted); font-size: .9rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.stack > * + * { margin-top: 16px; }

.stats { display: flex; gap: 26px; flex-wrap: wrap; }
.stat { min-width: 92px; }
.stat b { display: block; font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: .82rem; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
}
.chip.ok { color: var(--ok); border-color: currentColor; }
.chip.warn { color: var(--warn); border-color: currentColor; }

/* ---------- controls ---------- */

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.controls input[type="search"],
.controls input[type="text"],
.controls select,
.panel input[type="text"],
.panel input[type="search"],
.panel select {
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}

.controls input[type="search"] { flex: 1 1 240px; }
.controls select { max-width: 220px; }

input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.94); color: var(--accent-ink); }
.btn.danger:hover { border-color: #b3352b; color: #b3352b; }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.count { color: var(--muted); font-size: .86rem; margin-left: auto; }

/* ---------- game grid ---------- */

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

.game-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color .12s, transform .12s;
}

.game-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.game-card h3 { margin: 0; font-size: 1rem; }
.game-card .sub { color: var(--muted); font-size: .82rem; }
.game-card .counts { color: var(--muted); font-size: .8rem; margin-top: auto; display: flex; gap: 12px; }
.game-card .counts b { color: var(--ink); font-weight: 650; }

.bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .imaged { background: var(--accent); }
.bar .documented { background: var(--ok); }

/* ---------- tables ---------- */

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  max-width: 100%;
}

table { width: 100%; border-collapse: collapse; font-size: .9rem; }

thead th {
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel);
  border-bottom: 1px solid var(--line-strong);
  padding: 10px 12px;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--ink); }
thead th .arrow { opacity: .45; margin-left: 4px; font-size: .8em; }
thead th[aria-sort="ascending"] .arrow,
thead th[aria-sort="descending"] .arrow { opacity: 1; }

tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.item-row { cursor: pointer; }
tbody tr.item-row:hover td { background: var(--accent-soft); }

td.name { font-weight: 600; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.pager .btn { min-width: 38px; justify-content: center; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 44px 20px;
}

tbody tr.group-row td {
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding-top: 12px;
  padding-bottom: 6px;
}

tbody tr.group-row:first-child td { border-top: 0; }

/* ---------- dialog ---------- */

dialog {
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  max-width: min(860px, 94vw);
  width: 100%;
  max-height: 88vh;
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(20, 18, 15, .45); backdrop-filter: blur(2px); }

.dialog-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}

.dialog-head h2 { margin: 0 0 4px; }
.dialog-head .sub { color: var(--muted); font-size: .86rem; }

.dialog-close {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.dialog-close:hover { color: var(--ink); background: var(--bg); }

.dialog-body { padding: 18px 20px 22px; }

.images { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.images figure { margin: 0; flex: 1 1 240px; max-width: 100%; }
.images img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  display: block;
}
.images figcaption { font-size: .78rem; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; gap: 8px; }

.attrs { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: 0; border-top: 1px solid var(--line); }
.attrs dt {
  color: var(--muted);
  font-size: .82rem;
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--line);
  word-break: break-word;
}
.attrs dd {
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: .9rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  bottom: 0;
}

.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--panel); }
.qty button { border: 0; background: transparent; color: var(--ink); font-size: 1rem; width: 32px; height: 34px; cursor: pointer; }
.qty button:hover { background: var(--accent-soft); }
.qty input { width: 44px; border: 0; text-align: center; font: inherit; font-size: .9rem; background: transparent; color: var(--ink); -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 550;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 100;
  max-width: 90vw;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- search ---------- */

.search-box { display: flex; gap: 10px; margin-bottom: 18px; }
.search-box input { flex: 1; font-size: 1.05rem; padding: 13px 15px; }

.result-group { margin-bottom: 22px; }
.result-group h3 { display: flex; align-items: baseline; gap: 10px; }
.result-group h3 .small { font-weight: 400; }

.result-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.result-list li { border-bottom: 1px solid var(--line); }
.result-list li:last-child { border-bottom: 0; }
.result-list a { display: flex; gap: 12px; padding: 9px 13px; text-decoration: none; color: inherit; align-items: baseline; }
.result-list a:hover { background: var(--accent-soft); }
.result-list .n { font-weight: 600; }
.result-list .s { margin-left: auto; color: var(--muted); font-size: .82rem; text-align: right; }

/* ---------- collection / decks ---------- */

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .count { margin-left: auto; }

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

.deck-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.deck-card h3 { margin: 0; }
.deck-card .sub { color: var(--muted); font-size: .82rem; }
.deck-card .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.dialog-form { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; }
.field label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.field input, .field textarea, .field select {
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
.field textarea { min-height: 70px; resize: vertical; }

.file-drop {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
  padding: 22px 0 40px;
}

.site-footer .wrap { display: flex; gap: 16px; flex-wrap: wrap; }

@media (max-width: 620px) {
  .wrap { padding: 0 14px; }
  .site-header .wrap { min-height: 52px; gap: 6px; }
  .site-nav { width: 100%; margin-left: 0; overflow-x: auto; flex-wrap: nowrap; }
  .site-nav a { padding: 6px 9px; font-size: .86rem; }
  .stats { gap: 18px; }
  .attrs { grid-template-columns: 1fr; }
  .attrs dt { border-bottom: 0; padding-bottom: 0; }
  .attrs dd { padding-top: 2px; }
  thead th, tbody td { padding: 8px 9px; }
}

@media print {
  .site-header, .site-nav, .site-footer, .controls, .pager, .dialog-actions { display: none !important; }
  .table-wrap { border: 0; }
}

/* Unverified / missing image states */
.need-image-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: .68rem;
  letter-spacing: .02em;
  white-space: nowrap;
  vertical-align: 1px;
}

.need-image-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 210px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  background: var(--panel);
  text-align: center;
}
