/* =======================================================================
   LORECRAFT · THE PLAYER'S CARDS AND DECKS (shared/deck-builder.js)
   The collection of a player and the Deck Builder: the grid of cards on the left (shared/card-browser.css), the deck on the right,
   which stays in view while the grid scrolls; one column on a phone. The deck wears the paint of its Lorecraft (--paint, from
   shared/deck-page.js): the line at its top, the Lorecraft over its own art and the meters. Nothing here reaches into a card
   (shared/card.css): only the box around it (its ring, its lift, its shade).
   ======================================================================= */
.db-body{padding-block:18px 48px}
.db-count{color:var(--muted); font-size:15px; margin:0 0 14px}
.db-head{padding-block:16px; border-bottom:1px solid var(--line)}
.db-head .inner{display:flex; flex-wrap:wrap; gap:12px 16px; align-items:flex-end}
.db-name{display:grid; gap:4px; flex:1 1 260px; max-width:420px}
.db-name input{font:inherit; font-size:18px; padding:8px 10px; border:1px solid var(--line); border-radius:8px; background:var(--surface); color:var(--fg)}
.db-said{color:var(--muted); font-size:14px}
.db-split{display:grid; grid-template-columns:minmax(0,1fr) minmax(300px,380px); gap:28px; align-items:start}

/* ---------- the pool: every card, a ring on the ones in this deck, the ones the player hasn't got in grey ---------- */
.db-pool .grid{grid-template-columns:repeat(auto-fill, minmax(min(190px,100%),1fr)); gap:26px 16px}   /* beside the deck: smaller cards, more of them */
.db-pool .grid.both{grid-template-columns:repeat(auto-fill, minmax(min(380px,100%),1fr))}
.db-pool .item[data-id]{cursor:pointer}
.db-pool .cap b{font-size:15px}
.db-pool .cap small{font-size:12.5px}
.db-pool .faces > .card-box{border-radius:4.71% / 3.37%; transition:transform .16s ease, box-shadow .16s ease, filter .16s ease, opacity .16s ease}
.db-pool .item:hover .faces > .card-box{transform:translateY(-4px); box-shadow:0 14px 28px rgb(0 0 0 / .35)}
.db-pool .item.in-deck .faces > .card-box{box-shadow:0 0 0 3px var(--ok, #2f7d4a), 0 8px 22px color-mix(in srgb, var(--ok, #2f7d4a) 30%, transparent)}
.db-pool .item.chosen .faces > .card-box{box-shadow:0 0 0 3px var(--accent), 0 0 26px color-mix(in srgb, var(--accent) 50%, transparent)}
.db-pool .item.spent .faces > .card-box{opacity:.6}
.db-pool .item.unowned{cursor:not-allowed}
.db-pool .item.unowned .faces > .card-box{filter:grayscale(1) brightness(.7); opacity:.75}
.db-pool .item.unowned:hover .faces > .card-box{transform:none; box-shadow:none; filter:grayscale(.5) brightness(.85)}
.db-pool .item.spent .qty{background:var(--muted)}
/* whether they have it and the decks that hold it; with more than one, all of them in the tooltip */
.db-in{position:relative; display:flex; flex-wrap:wrap; gap:4px; margin-top:5px}
.db-chip{max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding:2px 9px; border:1px solid var(--line); border-radius:999px;
  background:var(--chip); color:var(--fg); font:600 12px/1.45 var(--sans)}
.db-chip.here{border-color:color-mix(in srgb, var(--ok, #2f7d4a) 60%, var(--line)); background:color-mix(in srgb, var(--ok, #2f7d4a) 20%, var(--surface))}
.db-chip.none{border-style:dashed; background:transparent; color:var(--muted)}
.db-in[data-tip]{cursor:help}
.db-in[data-tip]::after{content:attr(data-tip); position:absolute; left:0; bottom:calc(100% + 8px); z-index:6; width:max-content; max-width:min(280px, 80vw);
  padding:9px 12px; border-radius:10px; background:var(--fg); color:var(--bg); font:500 13px/1.5 var(--sans); white-space:pre-line;
  box-shadow:0 10px 28px rgb(0 0 0 / .4); opacity:0; translate:0 4px; pointer-events:none; transition:opacity .12s, translate .12s}
.db-in[data-tip]:hover::after{opacity:1; translate:0 0}

/* ---------- the deck ---------- */
.db-deck{position:sticky; top:calc(var(--site-h, 0px) + 12px); max-height:calc(100vh - var(--site-h, 0px) - 24px); overflow:auto; overscroll-behavior:contain;
  padding:0 16px 16px; border:1px solid var(--line); border-radius:14px; background:var(--surface); box-shadow:0 10px 30px rgb(0 0 0 / .18); scrollbar-width:thin}
.db-deck::before{content:""; display:block; height:4px; margin:0 -16px; background:var(--paint, var(--line))}
.db-deck-head{display:flex; justify-content:space-between; align-items:baseline; gap:8px; padding-top:12px}
.db-deck-head h2{font-size:22px; margin:0}
.db-deck-head small{font:600 14px var(--sans); color:var(--muted); font-variant-numeric:tabular-nums}
/* the Lorecraft, big, over its own art */
.db-stage{position:relative; isolation:isolate; overflow:hidden; display:grid; place-items:center; margin:10px -16px 12px; padding:18px 16px 20px}
.db-stage-art{position:absolute; inset:0; z-index:-2; width:100%; height:100%; object-fit:cover; filter:blur(16px) saturate(1.2); transform:scale(1.2); opacity:.6}
.db-stage::after{content:""; position:absolute; inset:0; z-index:-1; background:linear-gradient(180deg, color-mix(in srgb, var(--surface) 20%, transparent), var(--surface) 96%)}
.db-lc{width:min(300px, 90%); filter:drop-shadow(0 12px 22px rgb(0 0 0 / .5))}
.db-stage.none{min-height:120px; margin-top:12px; border-block:1px dashed var(--line)}
.db-stage.none p{max-width:240px; margin:0; color:var(--muted); font-size:14px; text-align:center}
/* how far the books and the Reserve are */
.db-meters{display:grid; grid-template-columns:1fr 1fr; gap:10px 14px}
.db-meters:empty{display:none}
.db-meter{display:grid; grid-template-columns:minmax(0,1fr) auto; gap:4px 6px; font:600 12.5px/1.2 var(--sans)}
.db-meter span{overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.db-meter b{color:var(--muted); font-weight:600; font-variant-numeric:tabular-nums}
.db-meter small{grid-column:1 / -1; color:var(--muted); font:500 12px/1.3 var(--sans)}
.db-meter i{grid-column:1 / -1; position:relative; height:6px; border-radius:999px; background:var(--chip); overflow:hidden}
.db-meter i::after{content:""; position:absolute; inset:0 auto 0 0; width:calc(var(--p) * 100%); border-radius:inherit; background:var(--paint, var(--accent)); transition:width .2s}
.db-meter.full b{color:var(--ok, #2f7d4a)}
.db-meter.over b{color:var(--hurt, #c62a1c)}
.db-meter.over i::after{background:var(--hurt, #c62a1c)}
/* what the rules say is missing, then what is done: small, right under the Lorecraft */
.db-rules{list-style:none; display:grid; gap:3px; margin:12px 0 4px; padding:9px 11px; border-radius:10px; background:var(--chip); font-size:12.5px; line-height:1.35}
.db-rules:empty{display:none}
.db-rules li{display:grid; grid-template-columns:1.3em minmax(0,1fr)}
.db-rules li::before{font-weight:700}
.db-rules .bad::before{content:"✕"; color:var(--hurt, #c62a1c)}
.db-rules .good{color:var(--muted)}
.db-rules .good::before{content:"✓"; color:var(--ok, #2f7d4a)}
/* the parts, and a line for each card: its colors at the edge, its copies, its name, its cost and its art fading in */
.db-part h3{display:flex; justify-content:space-between; font:700 15px/1.2 var(--sans); margin:18px 0 6px; padding-bottom:5px; border-bottom:1px solid var(--line)}
.db-part h3 span{color:var(--muted); font-variant-numeric:tabular-nums}
.db-line{position:relative; isolation:isolate; overflow:hidden; display:flex; align-items:center; gap:8px; width:100%; min-height:34px; margin-top:3px; padding:5px 8px 5px 12px;
  border:1px solid var(--line); border-radius:8px; background:var(--bg); color:inherit; font:inherit; font-size:14px; text-align:left; cursor:pointer;
  transition:border-color .12s, transform .12s}
.db-line::before{content:""; position:absolute; inset:0 auto 0 0; width:4px; background:var(--tint)}
.db-line-art{position:absolute; inset:0 0 0 auto; z-index:-1; width:62%; height:100%; object-fit:cover; object-position:center 30%; opacity:.55;
  -webkit-mask-image:linear-gradient(90deg, transparent, #000 75%); mask-image:linear-gradient(90deg, transparent, #000 75%)}
.db-line .db-n{min-width:2.2em; color:var(--muted); font-weight:700; font-variant-numeric:tabular-nums}
.db-line .db-nm{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:600; text-shadow:0 0 6px var(--bg), 0 0 2px var(--bg)}
/* its cost as the card prints it, each amount beside its resource (25/11/2026: a number alone read as a second count) */
.db-line .db-cost{display:flex; align-items:center; gap:7px; padding:3px 7px; border-radius:999px; background:color-mix(in srgb, var(--bg) 80%, transparent); border:1px solid var(--line)}
.db-res{display:inline-flex; align-items:center; gap:3px; font:700 12.5px/1 var(--sans); font-variant-numeric:tabular-nums}
.db-res .token{--size:18px}
.db-line:hover, .db-line:focus-visible{border-color:var(--hurt, #c62a1c); outline:none; transform:translateX(-2px)}
.db-line.over{border-color:var(--hurt, #c62a1c)}
.db-line.over .db-n{color:var(--hurt, #c62a1c)}
.db-empty{color:var(--muted); font-size:14px; margin:4px 0}
@media (max-width:900px){
  .db-split{grid-template-columns:minmax(0,1fr)}
  .db-deck{position:static; max-height:none}
}
@media (prefers-reduced-motion: reduce){
  .db-pool .faces > .card-box, .db-line, .db-meter i::after, .db-in[data-tip]::after{transition:none}
  .db-pool .item:hover .faces > .card-box{transform:none}
}
