/* Deck building (decks.js). Uses the pixel skin's tokens and button art from skin.css. */

/* ---------- deck tiles: my decks, recommended, deck picker ---------- */
#decks, #deckpick { padding-inline: max(12px, calc((100% - 900px) / 2)); }
.db-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 10px; }
.db-tile { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; text-align: left; padding: 4px; color: var(--cream);
  border-radius: 0; border: 9px solid transparent; border-image: var(--win-dark) 3 fill / 9px / 0 stretch; background: none; }
.db-tile .pic { width: 64px; height: 64px; background: var(--ink) center / cover; box-shadow: var(--frame); display: grid; place-items: center;
  font-size: 36px; color: var(--gold); }
.db-tile .txt { display: grid; gap: 2px; min-width: 0; }
.db-tile b { font-weight: 400; font-size: var(--fs-l, 18px); color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-tile small { font-size: var(--fs-s, 14px); color: var(--dim); }
.db-tile em { font-style: normal; font-size: var(--fs-s, 14px); }
.db-tile em.ok { color: var(--teal); } .db-tile em.bad { color: var(--red); }
.db-tile.new { border-image-source: var(--win-paper); color: var(--ink); }
.db-tile.new b { color: var(--ink); } .db-tile.new small { color: #5a4f3a; }
.db-tile.new .pic { background: var(--ink); }
.db-tile.sel { border-image-source: var(--win-paper); }
.db-tile.sel b { color: var(--ink); } .db-tile.sel small { color: #5a4f3a; } .db-tile.sel em.ok { color: var(--teallo); }
.db-tile.short .pic { filter: saturate(.4) brightness(.7); }
.db-tile:active { transform: translateY(2px); }
.db-h { margin: 6px 0 0; font-weight: 400; font-size: var(--fs-l, 18px); color: var(--gold); text-shadow: 3px 3px 0 var(--ink); }
.db-power { display: grid; gap: 4px; margin-top: 4px; }
.db-power p { margin: 0; font-size: var(--fs-s, 14px); color: var(--dim); line-height: 1.5; }
.db-power b { color: var(--teal); font-weight: 400; }
.db-heroes { display: grid; gap: 8px; text-align: left; }
.db-heroes .hero-pick { grid-template-columns: 64px 1fr; }
.db-heroes .hero-pick img { width: 64px; height: 64px; }
.db-danger { color: var(--red) !important; }
.big-btn.db-danger { color: var(--ink) !important; }
.db-input { width: 100%; box-sizing: border-box; font: 16px var(--pixel); color: var(--ink); background: var(--cream); border: 0; padding: 10px; box-shadow: var(--frame);
  user-select: text; -webkit-user-select: text; resize: none; }
textarea.db-input { word-break: break-all; }

/* ---------- editor ---------- */
#deckedit { padding-bottom: 0; gap: 8px; }
#deckedit .topbar h2 { min-width: 0; }
.db-name { all: unset; cursor: pointer; display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: inherit; color: inherit; }
.db-name i { font-style: normal; font-size: 16px; color: var(--dim); }
.db-hero { display: flex; align-items: center; gap: 8px; font-size: var(--fs-s, 14px); color: var(--dim); }
.db-hero .pic { width: 28px; height: 28px; flex: none; background: center / cover; box-shadow: var(--frame); }
.db-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.db-coll { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding-bottom: 66px; }
.db-filters { display: grid; gap: 6px; }
.db-q { width: 100%; box-sizing: border-box; font: 16px var(--pixel); color: var(--ink); background: var(--cream); border: 0; padding: 8px 10px; box-shadow: var(--frame);
  user-select: text; -webkit-user-select: text; }
.db-q::placeholder { color: #7d7360; }
.db-cost, .db-type { display: flex; gap: 4px; }
.db-cost button, .db-type button { flex: 1; min-width: 0; padding: 6px 0; font-size: var(--fs-s, 14px); color: var(--cream);
  border-radius: 0; border: 6px solid transparent; border-image: var(--btn-dark) 2 fill / 6px / 0 stretch; background: none; }
.db-cost button[aria-pressed="true"], .db-type button[aria-pressed="true"] { border-image-source: var(--btn-paper); color: var(--ink); }
.db-cost button:first-child { flex: 1.6; }
.db-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 6px; align-items: center; }
.db-type button { padding-inline: 2px; }
.db-row select { min-width: 0; width: 100%; font: var(--fs-s, 14px) var(--pixel); color: var(--cream); background: var(--panel); border: 0; padding: 8px 4px; box-shadow: var(--frame); border-radius: 0; }
/* the picked hall: its two playstyles, then how it wins (backlog #84) */
.db-hall { margin: 0; font-size: 12px; line-height: 1.35; color: var(--dim); }
.db-hall b { font-weight: 400; color: var(--gold); margin-right: 8px; }
.db-grid { flex: 1; min-height: 0; padding: 8px 4px 12px; }
.db-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 8px; container-type: inline-size; }
.db-cell { position: relative; display: grid; justify-items: center; }
.db-cards .card { --cw: calc((100cqw - 24px) / 4 - 4px); --ch: calc(var(--cw) * 1.486); cursor: pointer; }
.db-cards .card:active { transform: scale(.96); }
.db-cell.out .card { filter: brightness(.5) saturate(.5); }
.db-q-badge { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); z-index: 2; pointer-events: none;
  background: var(--teal); color: var(--ink); font-size: 13px; padding: 1px 6px; box-shadow: var(--frame); }
.db-cell.out .db-q-badge { background: var(--gold); }
.db-info { position: absolute; top: -6px; right: -2px; z-index: 2; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 0;
  background: var(--ink); color: var(--cream); font: 14px var(--pixel); box-shadow: 0 0 0 2px var(--rim); }
.db-unowned { display: block; margin: 18px auto 70px; font-size: var(--fs-s, 14px); }
.db-none { text-align: center; color: var(--dim); font-size: var(--fs-s, 14px); margin: 16px 0; }

/* deck panel: a bar pinned to the bottom on phones that opens into the deck list */
.db-deck { position: absolute; left: -12px; right: -12px; bottom: 0; z-index: 5; display: flex; flex-direction: column; max-height: 100%;
  background: var(--deep); box-shadow: 0 -3px 0 var(--ink), 0 -6px 0 var(--rim); padding-bottom: env(safe-area-inset-bottom, 0px); }
.db-bar { all: unset; cursor: pointer; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 8px 14px; min-height: 46px; }
.db-bar > b { font-weight: 400; font-size: var(--fs-l, 18px); }
.db-bar > b.ok { color: var(--teal); } .db-bar > b.bad { color: var(--red); }
.db-arrow { color: var(--gold); font-size: var(--fs-s, 14px); }
.db-bar .db-curve { height: 34px; }
.db-bar .db-curve small { display: none; }
.db-curve { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; height: 70px; }
.db-curve > * { all: unset; display: grid; grid-template-rows: 1fr auto auto; justify-items: center; min-width: 0; font-size: 12px; color: var(--dim); }
.db-curve button { cursor: pointer; }
.db-curve .bar { width: 70%; height: 100%; display: flex; align-items: flex-end; background: rgba(11,10,20,.5); }
.db-curve .bar i { display: block; width: 100%; background: var(--gold); box-shadow: inset 0 3px 0 #ffe08a; }
.db-curve small { color: var(--cream); font-size: 12px; min-height: 12px; line-height: 1; }
.db-curve b { font-weight: 400; line-height: 1.2; }
.db-curve .on b { color: var(--teal); } .db-curve .on .bar i { background: var(--teal); box-shadow: inset 0 3px 0 #b4f5dc; }
.db-list { display: none; flex-direction: column; gap: 8px; min-height: 0; flex: 1; padding: 0 14px 12px; }
.db-body.open .db-deck { height: 82%; }
.db-body.open .db-list { display: flex; }
.db-stats { display: flex; justify-content: space-between; font-size: var(--fs-s, 14px); color: var(--dim); }
.db-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.db-acts .ghost-btn { padding: 6px; }
.db-rows { flex: 1; min-height: 0; display: grid; align-content: start; gap: 3px; }
.db-line { all: unset; cursor: pointer; position: relative; display: grid; grid-template-columns: 30px 1fr; align-items: center; height: 34px; overflow: hidden;
  background: var(--panel); box-shadow: inset 0 0 0 2px var(--rimlo); }
.db-line .g { position: relative; z-index: 1; height: 100%; display: grid; place-items: center; background: var(--blue); color: #fff; font-size: 16px; }
.db-line .nm { position: relative; z-index: 1; padding: 0 44px 0 8px; font-size: 15px; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 2px 2px 0 var(--ink); }
.db-line .art { position: absolute; right: 0; top: 0; bottom: 0; width: 55%; background: center 35% / cover; opacity: .55;
  -webkit-mask: linear-gradient(90deg, transparent, #000 70%); mask: linear-gradient(90deg, transparent, #000 70%); }
.db-line .x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); z-index: 1; color: var(--gold); font-size: 15px; text-shadow: 2px 2px 0 var(--ink); }
.db-line.spell { background: #5a1e1c; } .db-line.legend .nm { color: var(--gold); }
.db-line:active { filter: brightness(1.3); }
.db-tip { margin: 0; text-align: center; font-size: 12px; color: var(--dim); line-height: 1.5; }
.db-list .big-btn { padding: 8px; font-size: 18px; }

/* wide screens: collection on the left, deck list always open on the right */
@media (min-width: 900px) {
  #deckedit { padding-inline: max(16px, calc((100% - 1200px) / 2)); }
  .db-body { flex-direction: row; gap: 16px; }
  .db-coll { padding-bottom: 0; }
  .db-cards { grid-template-columns: repeat(6, 1fr); }
  .db-cards .card { --cw: calc((100cqw - 40px) / 6 - 6px); }
  .db-deck, .db-body.open .db-deck { position: static; width: 300px; height: auto; flex: none; box-shadow: none; background: none; }
  .db-bar { cursor: default; padding: 0 0 6px; }
  .db-bar .db-curve, .db-arrow { display: none; }
  .db-list { display: flex; padding: 0; }
}
