/*
 * Card lists and the card detail: filter bar, table, rarity badges, mana pips.
 * Used by the public database and by the pages of a signed-in user.
 */

/* ---------- Chosen sets ---------- */

.sets { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 14px; }
.setb { display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 8px; color: var(--muted); background: var(--surface-glass); border: 1px solid var(--border); border-radius: 99px; }
.setb:hover { color: var(--text); }
.setb .code { padding: 2px 8px; font-family: var(--mono); font-size: 12px; font-weight: 700; border: 1px solid var(--border); border-radius: 99px; }
.setb.on { color: var(--text); background: rgba(0, 212, 255, 0.08); border-color: rgba(0, 212, 255, 0.55); }
.setb.on .code { color: var(--bg); background: var(--accent); border-color: var(--accent); }

/* ---------- Filter bar ---------- */

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 12px; padding: 12px 14px; background: var(--surface-glass); border: 1px solid var(--border); border-radius: 10px; }
.bar .grp { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.bar .lbl { margin-right: 3px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.bar input[type=search] { flex: 1 1 260px; min-width: 0; padding: 7px 14px; font-family: var(--mono); font-size: 13px; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 99px; outline: none; }
.bar input[type=search]:focus { border-color: var(--accent); }

.chip { padding: 3px 10px; font-family: var(--mono); font-size: 11px; line-height: 1.5; color: var(--muted); background: var(--surface2); border: 1px solid var(--border); border-radius: 99px; cursor: pointer; }
.chip:hover { color: var(--text); border-color: var(--border); }
.chip.on { color: var(--accent); background: rgba(0, 212, 255, 0.08); border-color: rgba(0, 212, 255, 0.5); }
.chip.pipchip { display: inline-flex; padding: 2px 4px; }
.chip.pipchip.on { background: transparent; box-shadow: 0 0 0 2px var(--accent); }
.chip.reset { border-style: dashed; }

.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.notice { max-width: 900px; padding: 16px 20px; color: var(--dim); background: var(--surface-glass); border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: 10px; }

/* ---------- Table ---------- */

.tbl-wrap { overflow: auto; background: rgba(17, 24, 39, 0.75); border: 1px solid var(--border); border-radius: 10px; }
table.cards { width: 100%; font-size: 13px; border-collapse: separate; border-spacing: 0; }
.cards th { padding: 9px 10px; font-family: var(--mono); font-size: 10px; font-weight: 400; letter-spacing: 0.1em; text-align: left; text-transform: uppercase; white-space: nowrap; color: var(--muted); background: var(--surface2); border-bottom: 1px solid var(--border); }
.cards th a { color: inherit; border: none; }
.cards th a:hover { color: var(--text); }
.cards th.sorted, .cards th.sorted a { color: var(--accent); }
.cards th.sorted a::after { content: ' ▲'; }
.cards th.sorted.desc a::after { content: ' ▼'; }
.cards th.num, .cards td.num { text-align: right; }
.cards td { padding: 7px 10px; vertical-align: middle; color: var(--dim); border-bottom: 1px solid var(--border); }
.cards tbody tr { transition: background 0.15s; }
.cards tbody tr:hover td { background: rgba(0, 212, 255, 0.05); }
.cards td.nm { min-width: 170px; font-weight: 600; }
.cards td.nm a { color: var(--text); border: none; }
.cards td.nm a:hover { color: var(--accent); }
.cards td.nm .alt { margin-left: 6px; font-family: var(--mono); font-size: 9.5px; font-weight: 400; color: var(--muted); }
.cards td.type { min-width: 170px; }
.cards td.kw { max-width: 240px; font-size: 12px; color: var(--muted); }
.cards td.set { font-family: var(--mono); font-size: 11px; white-space: nowrap; color: var(--muted); }
.empty { padding: 40px; font-family: var(--mono); text-align: center; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0 0; font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* ---------- Ownership ---------- */

.cards tr.owned td.nm::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 7px; vertical-align: 2px; background: var(--accent3); border-radius: 50%; }
.cards td.own b { color: var(--accent3); }
.cards td.own .foil { margin-left: 4px; font-size: 10px; color: var(--violet); }

.own-box { margin-top: 14px; padding: 14px 16px; background: rgba(7, 13, 23, 0.7); border: 1px solid var(--border); border-left: 3px solid var(--accent3); border-radius: 10px; }
.own-box h2 { margin-bottom: 8px; font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.own-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; }
.own-row form { display: flex; align-items: center; gap: 8px; }
.own-finish { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.own-qty { min-width: 28px; font-family: var(--mono); font-size: 16px; text-align: center; color: var(--muted); }
.own-qty.has { color: var(--accent3); }
.own-row button { width: 30px; height: 30px; font-size: 16px; line-height: 1; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 99px; cursor: pointer; }
.own-row button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.own-row button:disabled { opacity: 0.35; cursor: not-allowed; }
.own-else, .own-invite { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------- Notes and tags ---------- */

.tag { display: inline-block; margin: 1px 3px 1px 0; padding: 0 8px; font-family: var(--mono); font-size: 10px; white-space: nowrap; color: var(--violet); background: rgba(124, 58, 237, 0.08); border: 1px solid rgba(124, 58, 237, 0.5); border-radius: 99px; }
.note-dot { margin-left: 4px; font-size: 12px; color: var(--warn); }
.cards td.tg { min-width: 90px; }
.note-box { border-left-color: var(--accent2); }
.note-box label { display: block; margin: 8px 0 4px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.note-box textarea, .note-box input:not([type=hidden]) { width: 100%; padding: 8px 10px; font: inherit; font-size: 13px; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; outline: none; resize: vertical; }
.note-box textarea:focus, .note-box input:focus { border-color: var(--violet); }
.note-box .suggest { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.note-box .suggest .tag { cursor: pointer; opacity: 0.75; }
.note-box .suggest .tag:hover { opacity: 1; }
.note-box button[type=submit] { margin-top: 10px; }

/* ---------- Rarity ---------- */

.rar { padding: 1px 7px; font-family: var(--mono); font-size: 10px; font-weight: 700; border: 1px solid; border-radius: 99px; }
.rar.c { color: #cbd5e1; border-color: #475569; }
.rar.u { color: #bfd2e6; background: rgba(127, 155, 184, 0.12); border-color: #7f9bb8; }
.rar.r { color: #f3cf6b; background: rgba(184, 145, 46, 0.12); border-color: #b8912e; }
.rar.m { color: #ff8a4c; background: rgba(196, 80, 27, 0.14); border-color: #c4501b; }
.rar.s, .rar.b { color: var(--violet); border-color: var(--accent2); }

/* ---------- Mana pips ---------- */

.cost { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; white-space: nowrap; }
.cost-sep { color: var(--muted); }
.pip { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 17px; height: 17px; margin: 0 1px; font-family: var(--mono); font-size: 10px; font-weight: 700; line-height: 1; vertical-align: middle; color: #111; background: #c9ced6; border-radius: 50%; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.3); }
.pip.W { background: var(--mW); }
.pip.U { color: #fff; background: var(--mU); }
.pip.B { color: #fff; background: var(--mB); }
.pip.R { color: #fff; background: var(--mR); }
.pip.G { color: #fff; background: var(--mG); }
.pip.C { background: var(--mC); }
.pip.T { font-size: 11px; }
.pip.lg { width: 22px; height: 22px; font-size: 12px; }

/* A hybrid symbol is two halves; the a-… class colours the first, b-… the second. */
.pip.hy { --h1: #9aa3ad; --h2: #9aa3ad; font-size: 8px; color: #fff; background: linear-gradient(135deg, var(--h1) 50%, var(--h2) 50%); }
.pip.a-W { --h1: var(--mW); }
.pip.a-U { --h1: var(--mU); }
.pip.a-B { --h1: var(--mB); }
.pip.a-R { --h1: var(--mR); }
.pip.a-G { --h1: var(--mG); }
.pip.a-C { --h1: var(--mC); }
.pip.b-W { --h2: var(--mW); }
.pip.b-U { --h2: var(--mU); }
.pip.b-B { --h2: var(--mB); }
.pip.b-R { --h2: var(--mR); }
.pip.b-G { --h2: var(--mG); }
.pip.b-C { --h2: var(--mC); }
.pip.b-P { --h2: #111; }

/* ---------- Hover preview (positioned by js/card-list.js) ---------- */

.card-preview { position: fixed; z-index: 50; display: none; width: 244px; border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); pointer-events: none; }
.card-preview.show { display: block; }

/* ---------- Card detail ---------- */

.card-detail { display: grid; grid-template-columns: 340px 1fr; gap: 28px; max-width: 1040px; margin: 28px auto 0; padding: 26px; background: rgba(17, 24, 39, 0.97); border: 1px solid var(--border); border-radius: 14px; }
.imgs a { border: none; }
.imgs img { display: block; width: 100%; height: auto; margin-bottom: 10px; aspect-ratio: 488 / 680; background: var(--surface2); border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.imgs .imgnote { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.d-name { font-size: 24px; line-height: 1.2; }
.d-cost { margin: 8px 0 2px; }
.d-type { margin: 6px 0 14px; font-family: var(--mono); font-size: 13px; color: var(--accent); }
.d-text { padding: 14px 16px; font-size: 14.5px; line-height: 1.65; white-space: pre-line; color: var(--text); background: rgba(7, 13, 23, 0.7); border: 1px solid var(--border); border-radius: 10px; }
.d-text .rem { font-style: italic; color: var(--muted); }
.d-flavor { margin-top: 10px; font-size: 13.5px; font-style: italic; white-space: pre-line; color: var(--muted); }
.d-pt { margin-top: 10px; font-family: var(--mono); font-size: 16px; font-weight: 700; }
.d-face { margin-top: 14px; }
.d-face h2 { margin-bottom: 6px; font-family: var(--mono); font-size: 13px; color: var(--violet); }
.d-face .d-type { margin: 0 0 8px; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 5px 14px; margin-top: 18px; font-size: 13px; }
.kv dt { padding-top: 3px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.kv dd { color: var(--dim); }
.kv .approx { font-size: 11px; color: var(--muted); }
.kw-link { margin-right: 8px; font-family: var(--mono); font-size: 11px; }
.printings a { display: inline-block; margin: 0 10px 2px 0; font-family: var(--mono); font-size: 11px; white-space: nowrap; }

@media (max-width: 860px) {
  .card-detail { grid-template-columns: 1fr; padding: 20px 18px; }
  .imgs { width: 100%; max-width: 320px; margin: 0 auto; }
  .cards .hide-m { display: none; }
}

@media (max-width: 560px) {
  .kv { grid-template-columns: 1fr; }
}

/* The personal boxes of a card sit under it. */
/* Copies owned and plans share a row; the note takes the whole width below them.
   Boxes that stand side by side are as tall as the tallest (the grid's default stretch). */
.d-mine { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.d-mine .note-box { grid-column: 1 / -1; }
.d-mine .own-box { margin-top: 0; }
.modal .card-detail { max-width: none; margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }
.grp.locked .chip { opacity: 0.7; border-style: dashed; }
tr.chosen td { background: rgba(0, 212, 255, 0.05); }
@media (max-width: 760px) { .d-mine { grid-template-columns: 1fr; } }
a.use.short, .use.short { color: var(--warn); }
.bar input.kw-add { width: 13rem; padding: 3px 10px; font-size: 12px; }
.plans-box { border-left-color: var(--warn); }
.plans-box .plans-next { margin-top: 16px; }
.plans-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
/* The deck's name gets the whole width; the zone and the button share the next row. */
.plans-add select.plans-deck { flex: 1 0 100%; }
.plans-add select { min-width: 0; flex: 1; padding: 6px 8px; font: inherit; font-size: 13px; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; }
.plans-done { margin-top: 10px; padding: 8px 12px; font-size: 13px; }
.plans-box .rule { margin-top: 6px; font-size: 12px; color: var(--warn); }
td.wish-qty { white-space: nowrap; }
td.wish-qty b { display: inline-block; min-width: 2ch; text-align: center; }
.shop-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.shop-line small { color: var(--muted); }
.shop-line .shop-pending { color: var(--warn); }
td.cr .shop-pending { margin-right: 6px; color: var(--warn); }
