/*
 * Decks: the list of decks, a deck's page (header with statistics and the mana curve, card
 * groups, side boxes, pull list) and the editor. Loaded after cards.css, whose pips and chips it uses.
 */

/* ---------- List of decks ---------- */

.deck-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 8px; }
.deck-tile { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; color: var(--text); background: var(--surface-glass); border: 1px solid var(--border); border-left: 3px solid var(--accent2); border-radius: 10px; transition: transform 0.2s, border-color 0.2s; }
.deck-tile:hover { transform: translateY(-2px); border-color: rgba(124, 58, 237, 0.6); }
.deck-tile-name { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 15px; font-weight: 700; }
.deck-tile-style { min-height: 1.2em; font-size: 12px; color: var(--muted); }
.deck-tile-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.st { padding: 1px 8px; font-family: var(--mono); font-size: 10px; font-style: normal; color: var(--muted); border: 1px solid var(--border); border-radius: 99px; }
.st.ok { color: var(--accent3); background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.5); }
.st.buy { color: var(--warn); background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.5); }

/* ---------- Actions above a deck ---------- */

.deck-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 22px 0 14px; }
.deck-count { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.deck-count.warn, .rule { color: var(--warn); }
.rule { margin-top: 8px; font-family: var(--mono); font-size: 11px; }
.share-link { margin: 0 0 14px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.post-action { display: inline-flex; }
.post-action button.chip { font-size: 11px; }
.post-action button.chip.danger { color: var(--danger); border-color: rgba(239, 68, 68, 0.5); }
.post-action button.round { width: 26px; height: 26px; font-size: 13px; line-height: 1; color: var(--dim); background: var(--surface2); border: 1px solid var(--border); border-radius: 99px; cursor: pointer; }
.post-action button.round:hover { color: var(--accent); border-color: var(--accent); }
.post-action button.round.on { color: var(--warn); border-color: rgba(245, 158, 11, 0.6); }
.post-action button.round.danger:hover { color: var(--danger); border-color: var(--danger); }
.danger-zone { max-width: 900px; margin-top: 24px; font-size: 13px; color: var(--muted); }
.danger-zone summary { cursor: pointer; }
.danger-zone p { margin: 8px 0; }

/* ---------- Header ---------- */

.dhead { position: relative; display: grid; grid-template-columns: 1fr minmax(260px, 380px); gap: 24px; align-items: end; margin-bottom: 18px; padding: 22px 24px; overflow: hidden; background: var(--surface-glass); border: 1px solid var(--border); border-radius: 12px; }
.dhead::before { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 3px; background: linear-gradient(var(--accent), var(--accent2)); }
.dstyle { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.dhead h1 { margin: 6px 0 10px; font-size: clamp(24px, 3.4vw, 36px); line-height: 1.15; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); }
.stats b { font-family: var(--mono); font-size: 15px; color: var(--text); }
.flag { display: inline-block; margin-top: 12px; padding: 4px 12px; font-family: var(--mono); font-size: 12px; font-weight: 700; border: 1px solid; border-radius: 99px; }
.flag.ok { color: var(--accent3); background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.5); }
.flag.buy { color: var(--warn); background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.5); }

.curve .clbl { margin-bottom: 8px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.bars { display: block; width: 100%; height: 90px; }
.bars rect { fill: var(--accent); }
.bar-row { display: grid; grid-template-columns: repeat(8, 1fr); font-family: var(--mono); font-size: 11px; text-align: center; color: var(--text); }
.bar-row span { min-height: 1.4em; }
.bar-row.mv { margin-top: 4px; font-size: 10px; color: var(--muted); }

/* ---------- Lists and boxes ---------- */

.dgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.lists { columns: 2; column-gap: 18px; }
/* .grp alone is the filter bar's group (cards.css); a deck's card group is one inside .lists. */
.lists .grp, .box { margin-bottom: 16px; padding: 12px 14px; background: var(--surface-glass); border: 1px solid var(--border); border-radius: 10px; }
.lists .grp { break-inside: avoid; }
.box { padding: 14px 16px; }
.lists .grp h2, .box h2, .box h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.box h3 { margin-top: 14px; color: var(--violet); }
.lists .grp h2 span, .box h3 span { color: var(--muted); }
.box p { font-size: 14px; color: var(--dim); }
.box .hint { margin-bottom: 8px; font-size: 12.5px; color: var(--muted); }

.dl { list-style: none; }
.dl li { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 6px; padding: 3px 0; font-size: 13.5px; border-bottom: 1px solid rgba(31, 45, 69, 0.5); }
.dl li:last-child { border-bottom: 0; }
.dl .q { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.dl .nm { color: var(--text); border: none; }
.dl .nm:hover { color: var(--accent); }
.dl li.short .nm { color: var(--warn); }
.dl .warn { grid-column: 2 / -1; font-family: var(--mono); font-size: 10px; color: var(--warn); }
.dl .mc .pip { width: 15px; height: 15px; font-size: 9px; }
.dl .adds { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 4px; }
.dl.found .q { color: var(--accent3); }
.dl.recs .q { color: var(--warn); }
.dl .reason { display: flex; flex: 1 1 260px; gap: 6px; }
.dl .reason input:not([type=hidden]) { flex: 1; min-width: 0; padding: 4px 10px; font: inherit; font-size: 12.5px; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 99px; outline: none; }
.dl .reason input:focus { border-color: var(--accent); }

.keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.keys a { border: none; }
.keys img { display: block; width: 100%; height: auto; aspect-ratio: 488 / 680; background: var(--surface2); border-radius: 6px; transition: transform 0.2s; }
.keys img:hover { transform: translateY(-3px) scale(1.03); }
.tips, .buy { list-style: none; }
.tips li { position: relative; margin-bottom: 7px; padding-left: 16px; font-size: 13.5px; color: var(--dim); }
.tips li::before { content: '›'; position: absolute; left: 2px; font-family: var(--mono); color: var(--accent); }
.buy li { padding: 7px 0; font-size: 13.5px; border-bottom: 1px solid rgba(31, 45, 69, 0.6); }
.buy li:last-child { border-bottom: 0; }
.buy li a { font-weight: 600; color: var(--text); border: none; }
.buy li div { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.buy .price { float: right; font-family: var(--mono); font-size: 11px; color: var(--accent3); }
.shop { border-color: rgba(245, 158, 11, 0.4); }
.shop h2 { color: var(--warn); }
.shop .sq { display: inline-block; min-width: 24px; font-family: var(--mono); font-weight: 700; color: var(--warn); }

.pull ul { list-style: none; columns: 3; column-gap: 18px; }
.pull li { padding: 2px 0; font-size: 13px; break-inside: avoid; color: var(--dim); }
.pull .set { display: inline-block; min-width: 64px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.pull input { accent-color: var(--accent); }

/* ---------- Shopping list ---------- */

.sums { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 14px; margin: 0 0 14px; }
.sum { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; font-size: 12.5px; color: var(--muted); background: var(--surface-glass); border: 1px solid var(--border); border-radius: 10px; }
.sum.active { border-color: rgba(0, 212, 255, 0.55); background: rgba(0, 212, 255, 0.06); }
.sum-title { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.sum b { font-family: var(--mono); font-size: 20px; color: var(--text); }
.cards td.buy-n { font-family: var(--mono); font-weight: 700; color: var(--warn); }
.cards td.nm .tip { margin-left: 4px; color: var(--warn); }
.cards td.nm .why { font-size: 11.5px; font-weight: 400; color: var(--muted); }
.cards td.cr { font-size: 12px; white-space: nowrap; }
.cards td.cr .stock { margin-left: 6px; font-family: var(--mono); font-size: 10px; color: var(--accent3); }
.cards td.cr .stock.low { color: var(--warn); }
.cards td.cr .other { margin-left: 6px; font-family: var(--mono); font-size: 10px; color: var(--muted); }
.cards td .use { display: inline-block; margin-right: 8px; white-space: nowrap; }
.shop-note { margin: 8px 0 16px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.box.export textarea { width: 100%; padding: 10px 12px; font-family: var(--mono); font-size: 12px; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; resize: vertical; }

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

/* ---------- Editor ---------- */

.deck-edit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.deck-edit .bar { margin-bottom: 10px; padding: 8px 10px; }
.chip.check { display: inline-flex; align-items: center; gap: 6px; }
.chip.check input { accent-color: var(--accent); }
.account-card textarea { width: 100%; padding: 10px 12px; font: inherit; color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; outline: none; resize: vertical; }
.account-card textarea:focus { border-color: var(--accent); }

@media (max-width: 1100px) {
  .dgrid, .deck-edit { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .dhead { grid-template-columns: 1fr; }
  .lists { columns: 1; }
  .pull ul { columns: 2; }
}

@media (max-width: 520px) {
  .pull ul { columns: 1; }
  .keys { grid-template-columns: repeat(3, 1fr); }
}

/* Printing a deck page prints the pull list only. */
@media print {
  body { color: #000; background: #fff; }
  body::before, .deck-actions, .share-link, .dhead, .dgrid, .danger-zone { display: none; }
  .box.pull { padding: 0; background: #fff; border: none; }
  .pull li, .pull .set, .pull h2 { color: #000; }
  .pull .hint { display: none; }
  .pull ul { columns: 2; }
}
.deck-history { max-width: 900px; margin: 24px 0; font-size: 13px; }
.deck-history summary { font-family: var(--mono); color: var(--dim); cursor: pointer; }
.deck-history-save { display: flex; gap: 8px; margin: 12px 0; }
.deck-history-save input { flex: 1 1 auto; padding: 6px 10px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.deck-history-list { margin: 0; padding: 0; list-style: none; }
.deck-history-list li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border); }
.deck-history-list .when { font-family: var(--mono); color: var(--dim); }
.deck-history-list .kind { padding: 0 8px; font-family: var(--mono); font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 99px; }
.deck-history-list .kind.saved { color: var(--accent3); border-color: var(--accent3); }
.deck-history-list .count { color: var(--muted); }
.deck-history-list .what { flex: 1 1 12ch; color: var(--text); overflow-wrap: anywhere; }
/* An editable row is two lines: the name keeps the whole width, and under it the buttons stand at
   the left and the mana cost at the right, wherever the name wraps. */
.dl li:has(.dl-adjust) .q { grid-row: 1; }
.dl li:has(.dl-adjust) .nm { grid-row: 1; grid-column: 2 / -1; }
.dl li:has(.dl-adjust) .dl-adjust { grid-row: 2; grid-column: 2; }
.dl li:has(.dl-adjust) .mc { grid-row: 2; grid-column: 3; justify-self: end; }
.dl-adjust { display: inline-flex; gap: 4px; }
.dl-adjust .post-action button.round { width: 20px; height: 20px; font-size: 12px; }
.deck-hand { margin: 0 0 16px; padding: 10px 14px; font-size: 13px; background: var(--surface-glass, rgba(17, 24, 39, 0.5)); border: 1px solid var(--border); border-radius: 10px; }
.deck-hand > summary { font-family: var(--mono); color: var(--dim); cursor: pointer; }
.deck-hand .bar { margin: 12px 0 8px; }
.deck-words { display: grid; gap: 10px; max-width: 640px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.deck-words label { display: grid; gap: 4px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.deck-words input, .deck-words select, .deck-words textarea { padding: 7px 10px; font: inherit; font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.deck-words .btn { justify-self: start; }
