/* The deck overview uses the same face artwork as the table, with one readable index at thumbnail size. */
#collection-dialog:has(#collection-gallery.deck-collection:not([hidden])) {
  width: min(46rem, calc(100% - 12px));
}

#collection-dialog #collection-gallery.deck-collection {
  --deck-accent: #dbc18a;
  --deck-muted: #c2c8b6;
  --deck-rule: #495c4d;
  display: grid;
  min-width: 0;
  gap: 12px;
  color: #f2e8d0;
  font-family: "Segoe UI", system-ui, sans-serif;
}

#collection-gallery.deck-collection [hidden] {
  display: none !important;
}

#collection-gallery.deck-collection :is(.deck-overview, .deck-suits, .deck-inspector-container) {
  display: grid;
  min-width: 0;
  gap: 13px;
}

#collection-dialog #collection-gallery .deck-summary,
#collection-dialog #collection-gallery .deck-active-label {
  margin: 0;
  color: var(--deck-muted);
  font-size: 14px;
  line-height: 1.4;
}

#collection-dialog #collection-gallery .deck-summary {
  display: flex;
  align-items: center;
  gap: .55rem;
}
#collection-gallery .deck-total {
  color: #f3dbac;
  white-space: nowrap;
}
#collection-gallery .deck-filter {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-inline-start: auto;
  padding: 4px 0 4px 5px;
  color: #e7e5ce;
  font: 600 13px/1.2 "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}
#collection-gallery .deck-filter input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #e0bd7f;
  cursor: inherit;
}

#collection-gallery.deck-collection .deck-suit-section {
  min-width: 0;
  margin: 0;
  padding: 0;
  --deck-suit-ink: #273331;
}

#collection-gallery.deck-collection :is([data-suit="♥"], [data-suit="♦"]) {
  --deck-suit-ink: #a3333b;
  --deck-suit-accent: #ef9f8e;
}

#collection-dialog #collection-gallery .deck-suit-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 7px;
  color: #ecdbb5;
  font: 650 15px/1.2 "Segoe UI", system-ui, sans-serif;
}

#collection-gallery.deck-collection .deck-suit-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--deck-rule);
}
#collection-gallery .deck-suit-symbol {
  color: var(--deck-suit-accent, #d4dec9);
  font: 700 1.25em/1 Georgia, serif;
}

#collection-gallery.deck-collection .deck-suit-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: start;
  gap: 5px;
}

#collection-dialog #collection-gallery .deck-slot {
  position: relative;
  display: block;
  align-self: start;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 0;
  aspect-ratio: 5 / 7;
  margin: 0;
  padding: 0;
  color: inherit;
  line-height: 1;
  background: transparent;
  border: none;
  border-radius: 3px;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
}

#collection-dialog #collection-gallery .deck-slot > .collection-card-face {
  position: relative;
  inset: auto;
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  aspect-ratio: auto;
  border-radius: 3px;
  pointer-events: none;
}

#collection-dialog #collection-gallery .deck-slot .collection-card-print,
#collection-dialog #collection-gallery .deck-slot .card-art {
  max-width: 100%;
  max-height: 100%;
}

#collection-dialog #collection-gallery .deck-standard-card {
  color: var(--deck-suit-ink, #273331);
  background-color: #eee4cc;
  border: 1px solid #c3b38f;
}

#collection-dialog #collection-gallery .deck-slot:has(.deck-slot-index) .skin-face-preview::before,
#collection-dialog #collection-gallery .deck-slot:has(.deck-slot-index) .skin-face-preview::after {
  content: none;
}

#collection-dialog #collection-gallery .deck-slot-index {
  position: absolute;
  z-index: 2;
  top: 2px;
  left: 2px;
  display: inline-flex;
  align-items: center;
  min-height: 14px;
  padding: 0 2px;
  color: var(--deck-suit-ink, #273331);
  font: 750 clamp(12px, 3vw, 15px)/1.1 Georgia, "Times New Roman", serif;
  letter-spacing: -.04em;
  white-space: nowrap;
  background: #f6ebd1;
  border-radius: 1px;
  pointer-events: none;
}

#collection-dialog #collection-gallery .deck-slot[data-custom="true"] > .collection-card-face {
  outline: 1px solid #c39954;
  outline-offset: -1px;
}

#collection-gallery.deck-collection .deck-slot-index :is(b, i) {
  font: inherit;
}

#collection-gallery.deck-collection .deck-slot-style {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}

#collection-gallery.deck-collection .deck-slot-count {
  position: absolute;
  z-index: 2;
  right: -1px;
  bottom: -1px;
  display: grid;
  min-width: 15px;
  min-height: 14px;
  padding: 0 3px;
  place-items: center;
  color: #fff0c8;
  font: 650 10px/1.1 "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  background: #344539;
  border: 1px solid #b79a66;
  border-radius: 4px 0 3px 0;
  pointer-events: none;
}

#collection-gallery.deck-collection .deck-suit-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

#collection-gallery.deck-collection .deck-legend-row {
  min-width: 0;
}

#collection-dialog #collection-gallery .deck-skin-link {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .42em;
  max-width: 100%;
  min-height: 26px;
  padding: 2px 7px 2px 3px;
  color: #eee4c7;
  font: 600 13px/1.25 "Segoe UI", system-ui, sans-serif;
  background: #253a30;
  border: 1px solid #536352;
  border-radius: 5px;
  text-align: start;
}
#collection-gallery .deck-legend-key {
  padding: 2px 4px;
  color: var(--deck-suit-ink);
  font: 700 13px/1 Georgia, serif;
  background: #f3e3bd;
  border-radius: 2px;
}
#collection-gallery .deck-legend-number {
  color: #c1c8b6;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

#collection-gallery .deck-all-standard,
#collection-dialog #collection-gallery .deck-empty-hint {
  color: var(--deck-muted);
  font-size: 13px;
  line-height: 1.4;
}

#collection-dialog #collection-gallery .deck-inspector-title {
  margin: 0;
  color: #f3e0b5;
  font: 700 clamp(20px, 5vw, 27px)/1.15 "Segoe UI", system-ui, sans-serif;
}

#collection-dialog #collection-gallery .deck-active-label {
  padding: 7px 10px;
  color: #e7dbc1;
  background: #23392f;
  border-inline-start: 2px solid #bd9d61;
}

#collection-gallery.deck-collection .deck-inspector-back {
  justify-self: start;
}

#collection-dialog #collection-gallery :is(.deck-inspector-back, .deck-inspect-art,
.deck-apply-variant, .deck-variant-pager button) {
  min-width: 0;
  min-height: 42px;
  padding: 6px 11px;
  color: #f5e3c0;
  font: 650 14px/1.25 "Segoe UI", system-ui, sans-serif;
  text-transform: none;
  background: #253d31;
  border: 1px solid #879070;
  border-radius: 4px;
}

#collection-dialog #collection-gallery .deck-apply-variant {
  color: #322a19;
  background: #e8c98b;
  border-color: #eed7a5;
}

#collection-dialog #collection-gallery button:disabled {
  color: #b0baad;
  background: #29392f;
  border-color: #596756;
  cursor: default;
}

#collection-gallery.deck-collection .deck-variant-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 7px;
}

#collection-dialog #collection-gallery .deck-variant {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 8px 3px;
  color: #f4e7c9;
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.25;
  text-align: center;
  text-transform: none;
  background: #1e3329;
  border: 1px solid #495a49;
  border-radius: 5px;
}

#collection-dialog #collection-gallery .deck-variant > .collection-card-face {
  position: relative;
  display: block;
  width: min(100%, 85px);
  max-width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 2 / 3;
  margin: 0 auto 3px;
  overflow: hidden;
  border-radius: 4px;
}

#collection-dialog #collection-gallery .deck-variant[data-chosen="true"] {
  background: #344438;
  border-color: #d4b776;
}

#collection-gallery.deck-collection .deck-variant[data-active="true"]::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  color: #25392b;
  font: 800 12px/1 system-ui, sans-serif;
  background: #e5c991;
  border: 1px solid #656748;
  border-radius: 50%;
}

#collection-gallery.deck-collection .deck-variant-name {
  color: #fff1cc;
  font-size: 14px;
  font-weight: 650;
  text-wrap: balance;
}

#collection-gallery.deck-collection .deck-variant-meta {
  color: #c5ceb9;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

#collection-gallery.deck-collection .deck-variant-actions {
  position: sticky;
  z-index: 3;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 7px 0 1px;
  background: #192d25;
  border-top: 1px solid var(--deck-rule);
}

#collection-gallery.deck-collection .deck-variant-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--deck-muted);
  font-size: 13px;
}

#collection-dialog #collection-gallery button:focus-visible {
  z-index: 4;
  outline: 2px solid #ffe5a1;
  outline-offset: 2px;
}

@media (hover: hover) {
  #collection-dialog #collection-gallery .deck-slot:hover > .collection-card-face {
    outline: 2px solid #ddc48e;
    outline-offset: -2px;
  }

  #collection-dialog #collection-gallery .deck-variant:hover {
    border-color: #bba571;
  }
  #collection-dialog #collection-gallery .deck-skin-link:hover {
    color: #fff1ca;
    border-color: #c4a874;
  }
}

@media (max-width: 359px) {
  #collection-gallery.deck-collection .deck-suit-grid {
    gap: 4px 3px;
  }

  #collection-gallery.deck-collection .deck-variant-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 640px) {
  #collection-dialog:has(#collection-gallery.deck-collection:not([hidden])) .collection-panel {
    gap: 9px;
    padding: 15px 18px;
  }
  #collection-gallery.deck-collection :is(.deck-overview, .deck-suits) {
    gap: 9px;
  }
  #collection-dialog #collection-gallery .deck-suit-heading {
    margin-bottom: 5px;
  }
  #collection-gallery.deck-collection .deck-suit-grid {
    grid-template-columns: repeat(13, minmax(0, 1fr));
  }
}
