/* Deck builder + collection browser. */

.deckbuilder {
  display: grid;
  grid-template-columns: 250px 1fr 300px;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "bar     bar    bar"
    "filters grid   deck";
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1c1729 0%, transparent 70%),
    var(--bg-0);
}

/* ---- Top bar ---- */
.db-bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-1);
  border-bottom: 1px solid var(--bg-3);
  flex-wrap: wrap;
}

.db-valid {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
}
.db-valid.ok { color: var(--ok); border-color: var(--ok); background: rgba(111,206,143,.10); }
.db-valid.bad { color: var(--bad); border-color: var(--bad); background: rgba(227,103,95,.10); }

/* ---- Filters ---- */
.db-filters {
  grid-area: filters;
  background: var(--bg-1);
  border-right: 1px solid var(--bg-3);
  padding: var(--sp-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.db-preview {
  width: 100%;
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-2);
}
.db-preview svg {
  width: 100%;
  height: auto;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-card);
}
.db-preview-empty {
  aspect-ratio: var(--card-ratio);
  display: grid;
  place-items: center;
  text-align: center;
  padding: var(--sp-4);
  border: 1px dashed var(--bg-3);
  border-radius: var(--r-lg);
  color: var(--ink-3);
  font-size: 12px;
}
.db-preview-meta { margin-top: 6px; color: var(--ink-2); text-align: center; }

.db-types { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.db-type {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: var(--bg-inset);
  border: 1px solid var(--bg-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  opacity: .5;
  transition: all var(--t-fast) var(--ease-out);
}
.db-type:hover { opacity: .85; background: var(--bg-2); }
.db-type[aria-pressed="true"] {
  opacity: 1;
  border-color: currentColor;
  background: var(--bg-3);
}

/* ---- Collection grid ---- */
.db-grid-wrap { grid-area: grid; overflow-y: auto; padding: var(--sp-3); }

.db-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
  gap: var(--sp-3);
  align-content: start;
}

.db-card {
  position: relative;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out),
              filter var(--t-fast) var(--ease-out);
}
.db-card svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
}
.db-card:hover { transform: translateY(-4px) scale(1.03); z-index: 3; }
.db-card:hover svg { box-shadow: var(--sh-lift); }

.db-card.locked { filter: grayscale(.9) brightness(.42); }
.db-card.locked:hover { filter: grayscale(.7) brightness(.6); }
.db-card.maxed svg { outline: 2px solid var(--brass-1); outline-offset: -2px; }

.db-card-foot {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  justify-content: center;
  padding: 4px;
  pointer-events: none;
}
.db-count {
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: rgba(8,6,12,.9);
  border: 1px solid var(--bg-3);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.db-count.has { color: var(--brass-0); border-color: var(--brass-2); }
.db-count i { font-style: normal; opacity: .55; font-weight: 400; }
.db-lock {
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: rgba(8,6,12,.9);
  border: 1px solid var(--bg-3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-3);
}

.db-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--sp-7);
  color: var(--ink-3);
  font-size: 13px;
}

/* ---- Deck column ---- */
.db-deck {
  grid-area: deck;
  background: var(--bg-1);
  border-left: 1px solid var(--bg-3);
  overflow-y: auto;
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.db-pile { margin-bottom: var(--sp-3); }
.db-pile h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--sp-2);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--bg-3);
}
.db-pile h3 .ok { color: var(--ok); font-variant-numeric: tabular-nums; }
.db-pile h3 .warn { color: var(--warn); font-variant-numeric: tabular-nums; }

.db-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 5px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12px;
  transition: background var(--t-fast) var(--ease-out);
}
.db-row:hover { background: var(--bg-3); }
.db-row:hover .db-row-n::after { content: ' −'; color: var(--bad); }
.db-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.db-row-name { flex: 1 1 auto; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.db-row-kind { flex: 0 0 auto; }
.db-row-n { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--brass-0); }

/* ---- Stats ---- */
.db-stats { border-top: 1px solid var(--bg-3); padding-top: var(--sp-3); }

.db-bar-row {
  display: grid;
  grid-template-columns: 68px 1fr 22px;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  margin-bottom: 3px;
}
.db-bar-label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.db-bar-track { height: 6px; background: var(--bg-inset); border-radius: var(--r-pill);
  overflow: hidden; }
.db-bar-track i { display: block; height: 100%; border-radius: inherit;
  transition: width var(--t-med) var(--ease-out); }
.db-bar-n { text-align: right; color: var(--ink-1); font-variant-numeric: tabular-nums; }

.db-curve { display: flex; align-items: flex-end; gap: 4px; height: 60px; }
.db-curve-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: 3px;
}
.db-curve-col i {
  display: block;
  width: 100%;
  background: linear-gradient(180deg, var(--brass-0), var(--brass-2));
  border-radius: 3px 3px 0 0;
  min-height: 3px;
}
.db-curve-col span { font-size: 9px; color: var(--ink-3); }

/* ---- Narrow ---- */
@media (max-width: 1250px) {
  .deckbuilder { grid-template-columns: 210px 1fr 260px; }
  .db-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}
@media (max-width: 1000px) {
  .deckbuilder { grid-template-columns: 1fr 250px; grid-template-areas: "bar bar" "grid deck"; }
  .db-filters { display: none; }
}

/* Every rarity tier the player owns of one card — promotions are otherwise invisible here. */
.db-tiers { display: inline-flex; gap: 6px; text-transform: uppercase; letter-spacing: .08em; }
.db-tiers [data-r="common"]    { color: #8b9096; }
.db-tiers [data-r="uncommon"]  { color: #5797d3; }
.db-tiers [data-r="rare"]      { color: #a56be0; }
.db-tiers [data-r="epic"]      { color: #e0625a; }
.db-tiers [data-r="legendary"] { color: #e8bd63; }
.db-tiers [data-r="secret"]    { color: #f2f7ff; }
