/* decks.html: your decks (a gallery of deck boxes) and the builder (the card pool on the left, the deck on the
   right; on phones the deck is a sheet at the bottom). */

/* ---------------------------------------------------------------- gallery */
.gallery { max-width: 1240px; margin: 0 auto; padding: 26px 22px 40px; }
.ghead { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.ghead h1 { font-size: 28px; }
.ghead.sub { margin: 34px 0 14px; }
.ghead.sub h2 { font-size: 19px; }
.decks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.deckbox { position: relative; display: flex; flex-direction: column; min-height: 222px; border-radius: 16px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 14px 34px rgba(0, 0, 0, .35); cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s; color: var(--text); font: inherit; text-align: left; padding: 0; }
.deckbox:hover, .deckbox:focus-visible { transform: translateY(-3px); border-color: rgba(240, 180, 60, .45); box-shadow: 0 20px 40px rgba(0, 0, 0, .45); outline: none; }
.deckbox .cover { height: 132px; background: #222 center 24% / 118% auto no-repeat; position: relative; }
.deckbox .cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(17, 20, 22, .95)); }
.deckbox .dinfo { display: grid; gap: 3px; padding: 0 14px; margin-top: -26px; position: relative; }
.deckbox .dinfo b { font-size: 16px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deckbox .dmeta { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.deckbox .dmeta .ms { font-size: 11px; }
.deckbox .dmeta .bad { color: var(--bad); }
.deckbox .dactions { display: flex; gap: 6px; padding: 10px 14px 14px; margin-top: auto; opacity: 0; transition: opacity .15s; }
.deckbox:hover .dactions, .deckbox:focus-within .dactions { opacity: 1; }
@media (hover: none) { .deckbox .dactions { opacity: 1; } }
.deckbox.new { align-items: center; justify-content: center; gap: 6px; border-style: dashed; border-color: var(--line2); background: rgba(17, 20, 22, .55); }
.deckbox.new .plus { font-size: 44px; line-height: 1; color: var(--gold); font-weight: 300; }
.deckbox.starter .cover { filter: saturate(.9); }

/* ---------------------------------------------------------------- builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 350px; grid-template-rows: auto minmax(0, 1fr); height: calc(100vh - 57px); height: calc(100dvh - 57px); }
.bhead { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: rgba(12, 14, 15, .7); backdrop-filter: blur(8px); min-width: 0; }
.deckname { font-family: Cinzel, Georgia, serif; font-weight: 700; font-size: 21px; background: transparent !important; border-color: transparent !important; padding: 4px 8px !important; min-width: 120px; width: min(420px, 36vw); }
.deckname:hover { border-color: var(--line2) !important; }
.deckname:focus { border-color: rgba(240, 180, 60, .7) !important; background: rgba(0, 0, 0, .3) !important; }
.deckname[readonly] { cursor: default; }
.legal { padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.legal.ok { background: rgba(90, 210, 138, .13); color: var(--good); }
.legal.short { background: rgba(240, 180, 60, .13); color: var(--gold); }
.legal.bad { background: rgba(255, 107, 94, .14); color: var(--bad); }
.saved { font-size: 12.5px; white-space: nowrap; }
.b.disabled { opacity: .5; }
.menu { position: relative; }
.menulist { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; display: grid; min-width: 190px; padding: 6px; border-radius: 12px; background: #1b1e20; border: 1px solid var(--line2); box-shadow: 0 16px 40px rgba(0, 0, 0, .55); }
.menulist button { text-align: left; padding: 9px 12px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; cursor: pointer; }
.menulist button:hover { background: var(--panel2); }
.menulist .danger { color: var(--bad); }

/* the card pool */
.collection { position: relative; overflow-y: auto; min-width: 0; padding: 0 18px 20px; scrollbar-gutter: stable; }
.filters { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; padding: 12px 0 12px; margin: 0 -2px 6px; background: linear-gradient(180deg, rgba(10, 11, 12, .96) 80%, rgba(10, 11, 12, 0)); }
.search { position: relative; flex: 1 1 240px; }
.search input { width: 100%; padding-right: 34px; }
.search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); }
kbd { display: inline-block; min-width: 18px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line2); background: rgba(255, 255, 255, .06); font: 600 11px/1.4 ui-monospace, Menlo, monospace; color: var(--muted); text-align: center; }
.chips { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); }
.chips button { display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 700 13px/1 inherit; cursor: pointer; transition: background .12s, box-shadow .12s, opacity .12s; }
.chips button:hover { background: var(--panel2); color: var(--text); }
.chips button.on { background: rgba(240, 180, 60, .18); color: var(--gold); box-shadow: inset 0 0 0 1.5px rgba(240, 180, 60, .7); }
.chips.colors button .ms { font-size: 15px; }
.chips.colors:has(button.on) button:not(.on) { opacity: .55; }
.chips button.multi { font-family: Cinzel, Georgia, serif; background: linear-gradient(135deg, var(--W), var(--U) 25%, var(--B) 50%, var(--R) 75%, var(--G)); color: #222; width: 22px; min-width: 22px; height: 22px; margin: 4px; border-radius: 50%; font-size: 11px; }
.chips button.multi.on { box-shadow: 0 0 0 2px var(--gold); }
.filters select { min-height: 36px; padding: 6px 10px; }
label.check.small { font-size: 13px; }
.count { font-size: 12.5px; white-space: nowrap; }

.grid { --tile: 158px; display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); gap: 14px 12px; }
.grid[data-size="s"] { --tile: 112px; gap: 10px 8px; }
.grid[data-size="l"] { --tile: 215px; gap: 18px 14px; }
.grid[data-size="s"] .tile .hov button { width: 26px; height: 26px; font-size: 15px; }
.grid[data-size="s"] .tile .qty { min-width: 24px; height: 24px; font-size: 12px; top: -6px; right: -6px; }
.grid .sect { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 8px; margin: 10px 2px -4px; font: 700 12px/1 -apple-system, system-ui, sans-serif; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 7px; }
.grid .sect:first-child { margin-top: 0; }
.grid .sect span { font-weight: 600; letter-spacing: 0; color: rgba(154, 166, 161, .7); }
.chips.sizes button { min-width: 26px; font-size: 12px; }
.tile { position: relative; aspect-ratio: 488 / 680; border-radius: 4.6% / 3.4%; cursor: pointer; transition: transform .14s ease, box-shadow .14s, filter .14s; box-shadow: 0 6px 16px rgba(0, 0, 0, .45); user-select: none; }
.tile img { width: 100%; height: 100%; display: block; border-radius: inherit; }
.tile:hover { transform: translateY(-4px) scale(1.025); box-shadow: 0 14px 28px rgba(0, 0, 0, .6); z-index: 2; }
.tile:active { transform: translateY(-1px) scale(1.01); }
.tile.in { box-shadow: 0 0 0 2.5px var(--gold), 0 8px 20px rgba(0, 0, 0, .5); }
.tile.max img { filter: saturate(.55) brightness(.8); }
.tile .qty { position: absolute; top: -8px; right: -8px; min-width: 30px; height: 30px; padding: 0 7px; display: grid; place-items: center; border-radius: 15px; background: linear-gradient(#ffc94a, var(--gold2)); color: #2a1a00; font-weight: 900; font-size: 14px; box-shadow: 0 3px 8px rgba(0, 0, 0, .5), 0 0 0 2px #1a1300; }
.tile .qty:empty { display: none; }
.tile .hov { position: absolute; left: 6%; right: 6%; bottom: 5%; display: flex; justify-content: space-between; gap: 6px; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; }
.tile:hover .hov { opacity: 1; transform: none; }
@media (hover: none) { .tile .hov { opacity: 1; transform: none; } }
.tile .hov button { width: 34px; height: 34px; border-radius: 50%; border: 0; font: 900 19px/1 inherit; cursor: pointer; background: rgba(15, 16, 17, .88); color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
.tile .hov button.plus { background: linear-gradient(#ffc94a, var(--gold2)); color: #2a1a00; }
.tile .hov button.zoomb { font-size: 15px; }
.tile .hov button:hover { transform: scale(1.1); }
.grid .none { grid-column: 1 / -1; padding: 40px; text-align: center; color: var(--muted); }
.hint { font-size: 12.5px; margin: 20px 2px 0; }
.collection.dropping { outline: 2px dashed rgba(255, 107, 94, .45); outline-offset: -8px; }
.collection.over { background: rgba(255, 107, 94, .06); }

/* the whole deck as cards: columns by mana value, cards overlapping so their names show */
.stacks { padding: 14px 0 20px; }
.shead { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.shead h3 { font-family: Cinzel, Georgia, serif; font-size: 20px; }
.scols { display: grid; grid-template-columns: repeat(var(--n, 8), minmax(96px, 158px)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 10px; }
.scol { min-width: 0; }
.scol h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; white-space: nowrap; }
.scol h4 span { color: var(--text); letter-spacing: 0; }
.spile { display: flex; flex-direction: column; }
/* each card overlaps the next so its name bar shows: a card is 1.393 widths tall; -103% of the width leaves ~0.36 */
.scard { position: relative; width: 100%; aspect-ratio: 488 / 680; margin-bottom: -103%; border-radius: 7px; cursor: pointer; transition: transform .14s, margin .14s; }
.scard:last-child { margin-bottom: 0; }
.scard img { width: 100%; height: 100%; display: block; border-radius: inherit; box-shadow: 0 -2px 10px rgba(0, 0, 0, .55); }
.scard:hover { transform: translateX(6px); z-index: 5; }
.scard:hover:not(:last-child) { margin-bottom: -40%; }
.scard .x { position: absolute; top: 7px; right: 8px; padding: 1px 7px; border-radius: 9px; background: rgba(0, 0, 0, .8); color: var(--gold); font-weight: 900; font-size: 12.5px; box-shadow: 0 0 0 1px rgba(240, 180, 60, .5); }
.stacks .none { padding: 50px; text-align: center; color: var(--muted); }

/* the deck */
.dtabs { display: flex; gap: 4px; padding: 10px 12px 0; }
.dtabs button { flex: 1; padding: 7px 8px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); font: 600 12.5px/1.2 inherit; cursor: pointer; }
.dtabs button.on { background: rgba(240, 180, 60, .12); color: var(--gold); border-color: rgba(240, 180, 60, .4); }
.dtabs button:hover:not(.on) { color: var(--text); background: var(--panel2); }
.deckpane { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: rgba(13, 15, 16, .9); transition: background .15s, box-shadow .15s; }
.deckpane.dropping { box-shadow: inset 0 0 0 2px rgba(240, 180, 60, .5); }
.deckpane.over { background: rgba(40, 32, 14, .95); }
.dsum { display: none; }
.stats { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.curve { display: flex; align-items: flex-end; gap: 6px; height: 74px; }
.curve .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.curve .bar i { display: block; width: 100%; min-height: 2px; border-radius: 4px 4px 2px 2px; background: linear-gradient(180deg, #ffd05a, #c98506); transition: height .25s ease; }
.curve .bar .n { font-size: 11px; font-weight: 800; color: var(--text); min-height: 13px; }
.curve .bar .l { font-size: 11px; color: var(--muted); }
.split { display: grid; gap: 6px; font-size: 12.5px; }
.pipline { display: flex; gap: 10px; flex-wrap: wrap; }
.pipline span { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.pipline .ms { font-size: 12px; }
.typeline { display: flex; gap: 12px; color: var(--muted); flex-wrap: wrap; }
.typeline b { color: var(--text); }
.typeline .warn b, .typeline .warn { color: var(--gold); }

.list { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }
.grp h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 12px 6px 6px; display: flex; justify-content: space-between; }
.drow { position: relative; display: flex; align-items: center; gap: 8px; height: 36px; margin: 3px 0; padding: 0 8px 0 4px; border-radius: 9px; cursor: pointer; overflow: hidden; background: linear-gradient(90deg, rgba(16, 18, 19, .97) 38%, rgba(16, 18, 19, .45)), var(--art) right 0 top 26% / 62% auto no-repeat, #1a1d1f; border: 1px solid rgba(255, 255, 255, .06); transition: border-color .12s, transform .12s; }
.drow:hover { border-color: rgba(240, 180, 60, .5); }
.drow.over { border-color: rgba(255, 107, 94, .7); }
.drow .k { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: rgba(240, 180, 60, .16); color: var(--gold); font-weight: 900; font-size: 13.5px; }
.drow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13.5px; text-shadow: 0 1px 3px #000; }
.drow .cost { flex: none; display: flex; gap: 1px; }
.drow .cost .ms { font-size: 11.5px; }
.drow .rb { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: flex; gap: 4px; opacity: 0; transition: opacity .1s; }
.drow:hover .rb { opacity: 1; }
.drow:hover .cost { opacity: 0; }
.drow .rb button, .bl button { width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .75); color: #fff; font: 900 16px/1 inherit; cursor: pointer; box-shadow: 0 0 0 1px var(--line2); }
.drow .rb button:hover, .bl button:hover { background: var(--gold2); color: #1a1300; }
.list .empty { display: grid; gap: 8px; padding: 30px 14px; text-align: center; color: var(--muted); }
.list .empty b { color: var(--text); font-size: 15px; }

.basics { padding: 10px 14px 14px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.basics h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.basics h3 .muted { text-transform: none; letter-spacing: 0; }
.blands { display: flex; gap: 8px; flex-wrap: wrap; }
.bl { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); }
.bl .ms { font-size: 14px; }
.bl b { min-width: 18px; text-align: center; }

/* hover preview, zoom, import */
.preview { position: fixed; z-index: 40; width: 270px; pointer-events: none; opacity: 0; transform: translateX(8px); transition: opacity .12s, transform .12s; }
.preview.show { opacity: 1; transform: none; }
.preview img { width: 100%; border-radius: 13px; box-shadow: 0 20px 50px rgba(0, 0, 0, .7); }
dialog { color: var(--text); background: #16191b; border: 1px solid var(--line2); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .7); padding: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.zoomdlg[open] { display: grid; grid-template-columns: auto minmax(0, 320px); gap: 22px; padding: 22px; max-width: min(760px, 94vw); }
.zoomdlg img { width: min(340px, 42vw); border-radius: 16px; box-shadow: 0 16px 40px rgba(0, 0, 0, .6); }
.zoomdlg .ztext { display: flex; flex-direction: column; gap: 8px; }
.zoomdlg .ztext h2 { font-size: 20px; }
.zoomdlg .ztext p { margin: 0; line-height: 1.45; }
.zoomdlg .ztext .ms { font-size: 12px; }
.zoomdlg .inthe { margin-top: auto !important; color: var(--gold); font-weight: 700; }
.zoomdlg .row { display: flex; gap: 8px; flex-wrap: wrap; }
.zoomdlg form { grid-column: 1 / -1; justify-self: end; margin: 0; }
.importdlg form { display: grid; gap: 10px; padding: 22px; width: min(520px, 92vw); }
.importdlg textarea { font-family: ui-monospace, Menlo, monospace; font-size: 13px; resize: vertical; }
.importdlg .row { display: flex; gap: 8px; }
.flyer { position: fixed; z-index: 90; pointer-events: none; border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .6); transform-origin: center; }

/* ---------------------------------------------------------------- narrow screens: the deck becomes a bottom sheet */
@media (max-width: 900px) {
  .builder { grid-template-columns: 1fr; height: auto; min-height: calc(100dvh - 57px); }
  /* header: [← name] then [state · undo · more · play] */
  .bhead { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .bhead #backBtn { order: 0; }
  .deckname { order: 1; flex: 1 1 calc(100% - 60px); width: auto; font-size: 18px; }
  .bhead .legal { order: 2; flex: 1 1 auto; max-width: none; }
  .bhead .grow { display: none; }
  .bhead .saved { display: none; }
  .bhead #undoBtn, .bhead .menu, .bhead #playBtn, .bhead #testBtn { order: 3; }
  .collection { overflow: visible; padding: 0 12px 110px; }
  /* filters: the search, then one line of chips that scrolls sideways */
  .filters { top: 56px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-top: 8px; display: grid; grid-template-columns: repeat(7, max-content); gap: 8px; }
  .filters::-webkit-scrollbar { display: none; }
  .filters .search { grid-column: 1 / -1; position: sticky; left: 0; width: calc(100vw - 24px); }
  .filters .count, .filters #clearFilters { display: none !important; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px 8px; }
  .tile .qty { min-width: 24px; height: 24px; font-size: 12px; top: -6px; right: -6px; }
  .tile .hov { bottom: 3%; }
  .tile .hov button { width: 26px; height: 26px; font-size: 15px; opacity: .92; }
  .tile .hov .zoomb { display: none; }
  .hint { display: none; }
  .deckpane > .stats { order: 3; } .deckpane > .list { order: 4; } .deckpane > .basics { order: 5; }
  .deckpane { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; height: 64px; border-left: 0; border-top: 1px solid var(--line2); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, .6); transition: height .25s ease; overflow: hidden; }
  .deckpane { background: #101213; }
  .deckpane.open { height: min(78dvh, 640px); }
  .dtabs { order: 2; }
  .dsum { order: 1; display: flex; align-items: center; gap: 8px; flex: none; height: 64px; padding: 0 18px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; }
  .dsum b { font-size: 22px; font-family: Cinzel, Georgia, serif; }
  .dsum .ok { color: var(--good); font-weight: 700; }
  .dsum .short { color: var(--gold); font-weight: 700; }
  .dsum .chev { transition: transform .2s; }
  .deckpane.open .dsum .chev { transform: rotate(180deg); }
  .preview { display: none; }
  .zoomdlg[open] { grid-template-columns: 1fr; justify-items: center; }
  .zoomdlg img { width: min(300px, 80vw); }
}
