/* The decks page: the list of decks and the deck builder. Shared colours and controls are in theme.css. */
.page.wide { max-width: none; padding: 14px 14px 0; }
section + section { margin-top: 20px; }

/* ----- The list of decks ----- */
#list { max-width: 1400px; margin: 0 auto; padding-bottom: 50px; }
.decklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; padding: 16px; }
.decktile { background: var(--raised); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column; transition: border-color .12s, transform .12s; }
.decktile:hover { border-color: var(--gold); transform: translateY(-2px); }
.decktile .cover-art { height: 132px; border-radius: 0; background-size: 135%; background-position: center 24%; cursor: pointer; position: relative; }
.decktile .cover-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(36, 50, 71, 0) 55%, var(--raised)); }
.decktile .cover-art .badge { position: absolute; top: 10px; right: 10px; z-index: 1; backdrop-filter: blur(4px); }
.decktile .cover-art .badge.green { background: rgba(14, 40, 26, .85); }
.decktile .cover-art .badge.red { background: rgba(52, 16, 18, .88); }
.decktile .cover-art .badge.gold { background: rgba(48, 36, 10, .88); }
.format-what { margin: 0; padding: 12px 16px 0; }
.decktile .desc { margin: 0; font-size: 13px; line-height: 1.4; }
.decktile .info { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.decktile h3 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.decktile .sub { color: var(--muted); font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.decktile .sub.byline { min-height: 24px; }
.decktile .sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.decktile .sub label.check { margin: 0; flex: none; }
.decktile .row { margin-top: auto; padding-top: 6px; }
.decktile .row button { flex: 1; justify-content: center; }
.decktile .row button.peek, .decktile .row button.vote { flex: none; }
.decktile .sub a { font-weight: 600; }
.decktile[hidden] { display: none; }
/* The builder fills the window, so the footer is left to the list. */
body:has(#editor:not([hidden])) .sitefoot { display: none; }
#detail-text { padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; }

/* ----- The builder: card on the left, deck in the middle, search on the right ----- */
#editor { display: grid; grid-template-columns: 330px minmax(0, 1fr) 440px; gap: 12px; height: calc(100vh - 56px - 14px); padding-bottom: 12px; }
#editor > .panel { display: flex; flex-direction: column; min-height: 0; }
.scroll { overflow-y: auto; min-height: 0; flex: 1; }
.head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.head .row { flex-wrap: wrap; }
.grow { flex: 1; }

/* Left: the selected card */
#detail-empty { padding: 60px 20px; text-align: center; color: var(--muted); }
#detail-name { font-size: 20px; font-weight: 650; }
.stepper { display: grid; grid-template-columns: 64px 1fr 64px; border: 1px solid var(--hover); border-radius: 8px; overflow: hidden; }
.stepper button { border-radius: 0; justify-content: center; background: var(--bg); }
.stepper button:hover { background: var(--hover); }
.stepper span { display: flex; align-items: center; justify-content: center; border-left: 1px solid var(--hover);
  border-right: 1px solid var(--hover); font-variant-numeric: tabular-nums; }
.stepper b { margin-right: 5px; }
#detail-art { display: grid; grid-template-columns: 26px 1fr 26px; align-items: center; padding: 12px 6px 4px; }
#detail-art button { padding: 0; height: 60px; justify-content: center; background: transparent; color: var(--muted); font-size: 22px; }
#detail-art button:hover { color: var(--text); background: var(--raised); }
#detail-art button:disabled { visibility: hidden; }
#detail-facts { padding: 6px 16px 14px; display: flex; flex-direction: column; gap: 8px; }
.heart { font-size: 18px; padding: 6px 10px; line-height: 1; }
.heart.on { color: #ff6b81; }

/* Middle: the deck */
#cover { width: 74px; height: 46px; padding: 0; border-radius: 6px; overflow: hidden; background: var(--bg) center 22% / 170% no-repeat;
  border: 1px solid var(--hover); position: relative; }
#cover:hover { border-color: var(--gold); }
#cover-menu { position: absolute; z-index: 30; top: 62px; left: 12px; padding: 12px; width: 420px; display: flex; flex-wrap: wrap; gap: 8px; box-shadow: 0 14px 40px rgba(0,0,0,.6); }
#cover-menu b { flex-basis: 100%; }
#cover-menu button { width: 74px; height: 46px; padding: 0; justify-content: center; font-size: 13px; border-radius: 6px; background: var(--bg) center 22% / 170% no-repeat; border: 1px solid var(--hover); }
#cover-menu button.on, #cover-menu button:hover { border-color: var(--gold); }
#tag-menu { position: absolute; z-index: 30; padding: 12px; width: min(520px, calc(100vw - 40px)); box-shadow: 0 14px 40px rgba(0,0,0,.6); }
#tag-menu .hint { flex-basis: 100%; font-size: 12px; color: var(--muted); }
#tags.on { border-color: var(--gold); }
#deck-name { font-size: 17px; font-weight: 650; }
.counter { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.counter.ok { color: var(--green); }
.counter.over { color: var(--orange); }
#deck-body { padding: 12px 14px 20px; }
/* The table's own colours for a drag: blue where a card may be dropped, pink where it will be taken away. */
#deck-body.over { outline: 2px dashed #5ce1ff; outline-offset: -6px; background: rgba(92, 225, 255, .05); }
#search-panel.over { outline: 2px dashed #ff5fb7; outline-offset: -6px; }
#search-panel.over::after { content: "Drop here to remove one copy"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(14, 19, 27, .82); color: #ff5fb7; font-weight: 650; font-size: 17px; border-radius: var(--radius); pointer-events: none; }
#search-panel { position: relative; }
.group { margin: 10px 0 8px; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.group:first-child { margin-top: 0; }
.group span { color: var(--text); margin-left: 6px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--deck-card, 112px), 1fr)); gap: 9px; }
.sizes button { padding: 5px 10px; font-size: 12px; }
.tile { position: relative; border-radius: 6px; cursor: pointer; user-select: none; }
.tile img { display: block; width: 100%; aspect-ratio: 245 / 342; border-radius: 4.2% / 3%; background: var(--raised); }
.tile.sel img { outline: 2px solid var(--cyan); outline-offset: 1px; }
/* A card that isn't legal in the deck's format: kept, marked, and the deck can't be played until it goes. */
.tile.illegal img { outline: 2px solid var(--red); outline-offset: 1px; opacity: .75; }
.tile.illegal .n { background: var(--red); color: #fff; }
.lines .line.illegal .name { color: var(--red); }
.group.illegal { color: var(--red); }
/* Import: which printing a line meant. Each ambiguous line gets a row of the printings to pick from. */
.choices { max-height: min(60vh, 520px); overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding-right: 4px; }
.choices .choice h3 { margin: 0 0 8px; font-size: 14px; font-weight: 650; }
.choices .choice h3 span { color: var(--muted); font-weight: 400; margin-left: 8px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.choices .options { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.choices .option { display: flex; flex-direction: column; gap: 5px; padding: 6px; border-radius: 8px; border: 1px solid var(--hover); background: var(--bg); cursor: pointer; text-align: center; }
.choices .option:hover { border-color: var(--muted); }
.choices .option.sel { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.choices .option img { display: block; width: 100%; aspect-ratio: 245 / 342; border-radius: 4.2% / 3%; background: var(--raised); }
.choices .option .where { font-size: 12px; color: var(--muted); line-height: 1.25; }
.choices .option .where b { display: block; color: var(--text); font-weight: 600; }
/* The count and its - and + scale with the card (cqw is a hundredth of the tile's width), so they read
   as clearly on a small search result as on a large deck card. */
.tile { container-type: inline-size; }
.tile .n { position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%); width: 34cqw; height: 34cqw; border-radius: 50%;
  background: var(--gold); color: var(--dark); font-weight: 800; font-size: 21cqw; line-height: 1; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--dark); box-shadow: 0 2px 8px rgba(0,0,0,.65); pointer-events: none; font-variant-numeric: tabular-nums; }
.tile .pm { position: absolute; bottom: 12%; width: 26cqw; height: 26cqw; padding: 0; border-radius: 50%;
  background: var(--dark); border: 2px solid var(--gold); display: none; font-size: 0; box-shadow: 0 2px 6px rgba(0,0,0,.6); }
.tile .pm:hover { background: var(--hover); }
.tile .pm.minus { left: 3%; }
.tile .pm.plus { right: 3%; }
/* The signs are drawn as bars, because a typed minus or plus never sits in the middle of a circle. */
.tile .pm::before, .tile .pm.plus::after { content: ""; position: absolute; left: 50%; top: 50%; background: var(--gold); border-radius: 1px; transform: translate(-50%, -50%); }
.tile .pm::before { width: 50%; height: 12%; }
.tile .pm.plus::after { width: 12%; height: 50%; }
.tile:hover .pm { display: inline-flex; }
.tile.full img { opacity: .4; }
.lines .line { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.lines .line:hover, .lines .line.sel { background: rgba(46, 64, 90, .45); }
.line .q { width: 20px; text-align: right; font-weight: 700; }
.line .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line .set { color: var(--muted); font-size: 12px; }
.line button { padding: 0; width: 24px; height: 24px; justify-content: center; border-radius: 6px; }

/* Right: search */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; font-size: 13px; font-weight: 600; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--hover); }
.chip:hover { color: var(--text); background: var(--bg); border-color: var(--muted); }
.chip.on { background: var(--gold); color: var(--dark); border-color: var(--gold); }
.filter-label { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 4px 0 -2px; }
#filters { display: flex; flex-direction: column; gap: 8px; }
#results { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--result-card, 92px), 1fr)); gap: 8px; padding: 12px 14px; }
.small-select { width: auto; padding: 5px 8px; font-size: 13px; }
#active { font-size: 13px; }

/* Deck statistics */
.stat-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
table.stat { width: 100%; border-collapse: collapse; font-size: 14px; }
table.stat th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 4px 0 6px; border-bottom: 1px solid var(--line); }
table.stat td { padding: 5px 0; }
table.stat td.num, table.stat th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.stat tr.total td { border-top: 1px solid var(--line); font-weight: 700; }
table.stat .set { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* The import/export and statistics dialogs are wider than the site's default. */
dialog.text { width: min(620px, calc(100vw - 32px)); }
dialog.stats { width: min(760px, calc(100vw - 32px)); }
#list-filter { width: 220px; }
/* The tabs that pick a panel exist only when the panels stack (below). */
.pane-tabs { display: none; }

@media (max-width: 1150px) { #editor { grid-template-columns: 280px minmax(0, 1fr) 340px; } }

/* On a touch screen there is no hover, so the − and + on a card are always there. */
@media (hover: none) { .tile .pm { display: inline-flex; } }

/* ----- Phones and small tablets: the list's head wraps, the builder's panels stack behind tabs ----- */
@media (max-width: 768px) {
  .page.wide { padding: 10px 10px 0; }
  #list .panel-head { flex-wrap: wrap; padding: 8px 10px 10px !important; gap: 8px; }
  #list .panel-head .spacer { display: none; }
  #list-tabs { width: 100%; }
  #list-tabs button { flex: 1; }
  #list-format { flex: 1; min-width: 0; }
  #list-filter { width: 100%; }
  #import-new, #new { flex: 1; justify-content: center; }
  .decklist { padding: 10px; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  #stats-dialog .stat-cols { grid-template-columns: 1fr; }
  #cover-menu { width: min(420px, calc(100vw - 40px)); left: 8px; }
  .choices .options { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .tile .pm { width: 30cqw; height: 30cqw; }
}

@media (max-width: 899px) {
  #editor { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 0;
    height: calc(100vh - 56px - 10px); height: calc(100dvh - 56px - 10px); padding-bottom: 8px; }
  .pane-tabs { display: flex; margin-bottom: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .pane-tabs button { flex: 1; justify-content: center; }
  /* One panel at a time, the one the tabs name. */
  #editor > .panel { display: none; }
  #editor[data-pane="deck"] > #deck-panel, #editor[data-pane="search"] > #search-panel, #editor[data-pane="card"] > #detail-panel { display: flex; }
  #detail-art { grid-template-columns: 40px 1fr 40px; }
  #detail-art img { max-width: 300px; margin: 0 auto; }
  #detail-art button { height: 80px; }
  .head { padding: 10px; gap: 8px; }
  #problem { flex-basis: 100%; }
  #deck-name { min-width: 120px !important; }
  .stepper { grid-template-columns: 72px 1fr 72px; }
  .stepper button { min-height: 44px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(var(--deck-card, 96px), 1fr)); }
  #results { grid-template-columns: repeat(auto-fill, minmax(var(--result-card, 84px), 1fr)); padding: 10px; }
  #deck-body { padding: 10px 10px 16px; }
  .line button { width: 36px; height: 36px; }
  .lines .line { padding: 4px 4px; }
}
