/* ==========================================================================
   ACME AUCTIONS — Magic: The Gathering collection
   Extends css/styles.css. Card cells are cropped from binder-page scans.
   ========================================================================== */

.mtg-intro { padding: 56px 0 24px; }
.mtg-intro .inner,
.mtg-controls .inner,
.mtg-results .inner { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

.mtg-intro h1 { font-size: clamp(2rem, 4vw, 3rem); margin-bottom: 12px; }
.mtg-intro p { max-width: var(--narrow); color: var(--gray-700); }

/* --- Stats --- */
.mtg-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  margin-top: 24px;
}
.mtg-stat .num {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1;
  color: var(--charcoal);
  display: block;
}
.mtg-stat .label {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gray-500);
}

/* --- Controls --- */
.mtg-controls {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  /* Safari leaves stale pixels behind this bar as the grid scrolls under it,
     painting ghost copies of the selects. Giving it its own compositing layer
     is what stops that; the isolation keeps the layer self-contained. */
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  isolation: isolate;
}
/* one row that wraps as a whole, so controls never end up overlapping */
.mtg-controls .inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 14px;
  padding-bottom: 14px;
}

.mtg-search {
  flex: 1 1 220px;
  min-width: 170px;
  max-width: 340px;
  padding: 9px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--white);
}
.mtg-search:focus { outline: none; border-color: var(--charcoal); }

.mtg-select {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--gray-300);
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 0.84rem;
  color: var(--ink);
  background: var(--white);
  cursor: pointer;
  /* the platform arrow renders at wildly different widths — draw our own */
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--gray-500) 50%),
                    linear-gradient(135deg, var(--gray-500) 50%, transparent 50%);
  background-position: calc(100% - 16px) 51%, calc(100% - 11px) 51%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.mtg-select:focus { outline: none; border-color: var(--charcoal); }
/* each control paints as its own box, so a repaint cannot bleed across them.
   deliberately not a transform: that upsets where Safari anchors the native
   select popup */
.mtg-search, .mtg-select, .mtg-viewtoggle { position: relative; z-index: 1; }

.mtg-viewtoggle {
  flex: 0 0 auto;
  display: flex;
  border: 1px solid var(--gray-300);
  border-radius: 2px;
  overflow: hidden;
}
.mtg-viewtoggle button {
  height: 38px;
  padding: 0 18px;
  border: 0;
  background: var(--white);
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gray-700);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.mtg-viewtoggle button + button { border-left: 1px solid var(--gray-300); }
.mtg-viewtoggle button[aria-pressed="true"] { background: var(--charcoal); color: var(--white); }

.mtg-count {
  flex: 0 0 auto;
  margin-left: auto;
  padding-left: 12px;
  font-size: 0.78rem;
  color: var(--gray-500);
  white-space: nowrap;
}

/* --- Results --- */
.mtg-results { padding: 32px 0 80px; min-height: 40vh; }

.mtg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 28px 20px;
}

/* equal-height tiles: a card with two rows of tags must not push its price out
   of line with its neighbours */
.mtg-grid { align-items: stretch; }
.mtg-card {
  text-align: left;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* The crop window: a card-shaped viewport onto the binder scan */
.mtg-crop {
  position: relative;
  overflow: hidden;
  aspect-ratio: 63 / 88;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.mtg-crop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mtg-card:hover .mtg-crop { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16); }
.mtg-card:focus-visible .mtg-crop { outline: 2px solid var(--rust); outline-offset: 3px; }

.mtg-foil::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, rgba(255,255,255,0) 35%, rgba(255,255,255,0.55) 50%, rgba(255,255,255,0) 65%);
  pointer-events: none;
}

.mtg-meta { padding-top: 10px; flex: 1; display: flex; flex-direction: column; }
.mtg-name { font-family: var(--font-display); font-size: 0.98rem; line-height: 1.3; color: var(--charcoal); }
.mtg-card .mtg-name { min-height: 2.6em; }
.mtg-sub { font-size: 0.76rem; color: var(--gray-500); margin-top: 3px; }
.mtg-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; min-height: 22px; }
.mtg-tag {
  font-size: 0.62rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 3px 7px;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  border-radius: 2px;
}
.mtg-tag.rare { border-color: #b8860b; color: #8a6508; }
.mtg-tag.mythic { border-color: var(--rust); color: var(--rust-dark); }
.mtg-tag.foil { border-color: var(--charcoal); color: var(--charcoal); }
/* prices sit on one line across the row, whatever the tags above them did */
.mtg-est { font-size: 0.8rem; color: var(--charcoal); margin-top: auto; padding-top: 8px; font-weight: 600; }

/* --- Binder view --- */
.mtg-binder { display: grid; gap: 56px; }
.mtg-binder-page h2 { font-size: 1.3rem; margin-bottom: 4px; }
.mtg-binder-page .mtg-sub { margin-bottom: 16px; }
.mtg-binder-scan { border: 1px solid var(--gray-200); border-radius: 4px; overflow: hidden; cursor: zoom-in; }
.mtg-binder-list {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 24px;
  font-size: 0.85rem;
  color: var(--gray-700);
}
.mtg-binder-list span { color: var(--gray-400); margin-right: 8px; }

/* --- Empty state --- */
.mtg-empty {
  border: 1px dashed var(--gray-300);
  padding: 56px 32px;
  text-align: center;
  color: var(--gray-500);
}
.mtg-empty h2 { font-size: 1.4rem; margin-bottom: 10px; color: var(--charcoal); }

/* --- Detail overlay --- */
.mtg-detail {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}
.mtg-detail.active { display: flex; }
.mtg-detail-inner {
  background: var(--white);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.mtg-detail-img { background: var(--gray-100); display: flex; align-items: center; justify-content: center; padding: 24px; }
.mtg-detail-img .mtg-crop { width: 100%; border: 0; box-shadow: 0 8px 30px rgba(0,0,0,0.2); }
.mtg-detail-body { padding: 32px; }
.mtg-detail-body h2 { font-size: 1.7rem; margin-bottom: 6px; }
.mtg-detail-body dl { margin-top: 18px; display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 0.88rem; }
.mtg-detail-body dt { color: var(--gray-500); text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.1em; padding-top: 3px; }
.mtg-detail-body dd { color: var(--ink); }
.mtg-detail-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: 0;
  color: var(--white);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}
.mtg-detail-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  color: var(--white);
  font-size: 2.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 12px 18px;
}
.mtg-detail-prev { left: 8px; }
.mtg-detail-next { right: 8px; }

@media (max-width: 860px) {
  .mtg-search { max-width: none; flex-basis: 100%; order: -1; }
  .mtg-count { margin-left: 0; }
}

@media (max-width: 720px) {
  .mtg-detail-inner { grid-template-columns: 1fr; }
  .mtg-stats { gap: 28px; }
  .mtg-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 22px 14px; }
}

/* --- Sets: the folder view --- */
.mtg-setgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 34px 24px;
}
.mtg-setcard { text-align: left; border: 0; background: none; padding: 0; cursor: pointer; font-family: inherit; }
.mtg-setcover { position: relative; }
/* the stacked-cards edge that makes a set read as a folder */
.mtg-setcover::before,
.mtg-setcover::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: var(--white);
  transition: transform 0.25s var(--ease);
}
.mtg-setcover::before { transform: translate(10px, 10px); }
.mtg-setcover::after { transform: translate(5px, 5px); }
.mtg-setcover .mtg-crop { position: relative; z-index: 1; }
.mtg-setcard:hover .mtg-setcover::before { transform: translate(14px, 14px); }
.mtg-setcard:hover .mtg-setcover::after { transform: translate(7px, 7px); }
.mtg-setcard:hover .mtg-crop { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0,0,0,0.16); }
.mtg-setcard:focus-visible .mtg-crop { outline: 2px solid var(--rust); outline-offset: 3px; }
.mtg-setcount { font-size: 0.78rem; color: var(--gray-700); margin-top: 6px; }

.mtg-back {
  border: 0;
  background: none;
  padding: 0 0 4px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gray-500);
  cursor: pointer;
}
.mtg-back:hover { color: var(--rust); }
.mtg-sectionhead { font-size: 1.6rem; margin: 4px 0 24px; }

.mtg-tag.warn { border-color: var(--rust); color: var(--rust-dark); }

/* --- Binder view: front and back, side by side --- */
.mtg-scanpair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
}
.mtg-scanpair figure { margin: 0; }
.mtg-scanpair img { border: 1px solid var(--gray-200); border-radius: 4px; }
.mtg-scanpair figcaption {
  font-size: 0.7rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--gray-500);
  padding-top: 8px;
}

.mtg-pockettable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 0.85rem;
}
.mtg-pockettable th {
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--gray-500);
  font-weight: 600;
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--gray-300);
}
.mtg-pockettable td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--gray-200); vertical-align: top; }
.mtg-pockettable td:first-child { color: var(--gray-400); width: 60px; }
.mtg-pockettable em { color: var(--gray-500); font-style: normal; font-size: 0.8rem; }
.mtg-muted { color: var(--gray-400); }

.mtg-detail-link { margin-top: 18px; font-size: 0.85rem; }
.mtg-detail-link a { color: var(--rust); }
.mtg-detail-note { margin-top: 14px; font-size: 0.75rem; color: var(--gray-500); }

@media (max-width: 720px) {
  .mtg-scanpair { grid-template-columns: 1fr; }
  .mtg-setgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 16px; }
}

/* Binder view with a single scan per page: scan left, pocket list right */
.mtg-scanpair.mtg-single { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; }
.mtg-scanpair.mtg-single .mtg-pockettable { margin-top: 0; }
.mtg-scanpair.mtg-single figure img { cursor: zoom-in; }
@media (max-width: 900px) {
  .mtg-scanpair.mtg-single { grid-template-columns: 1fr; }
}


.mtg-card:hover .mtg-card:hover 


/* --- Admin: delete a card from the live site --- */
.mtg-admin {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.mtg-admin button {
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 2px;
  cursor: pointer;
  background: var(--white);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
/* unobtrusive until it is needed */
.mtg-admin-unlock { border: 1px solid var(--gray-300); color: var(--gray-500); }
.mtg-admin-unlock:hover { border-color: var(--gray-700); color: var(--gray-700); }
/* destructive, and dressed as such */
.mtg-admin-delete { border: 1px solid var(--rust); color: var(--rust); }
.mtg-admin-delete:hover:not(:disabled) { background: var(--rust); color: var(--white); }
.mtg-admin-delete:disabled { opacity: 0.5; cursor: default; }
.mtg-admin-msg { font-size: 0.78rem; color: var(--rust-dark); }

/* Sealed product is photographed, not scanned, and is not card-shaped —
   show the whole item instead of cropping it to a card's proportions. */
.mtg-crop.sealed { background: var(--gray-100); }
.mtg-crop.sealed img { object-fit: contain; }

/* --- Set completion and missing cards --- */
.mtg-progress {
  height: 3px;
  background: var(--gray-200);
  margin-top: 8px;
  border-radius: 2px;
  overflow: hidden;
}
.mtg-progress span { display: block; height: 100%; background: var(--charcoal); }

.mtg-missing-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  font-size: 0.82rem;
  color: var(--gray-700);
  cursor: pointer;
}
.mtg-missing-toggle input { cursor: pointer; }

/* A gap is not a card. It is drawn flat and grey so it never reads as something
   owned, and it carries no price at all — these are absent from the totals. */
.mtg-gap { cursor: default; }
.mtg-gap-art {
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    45deg, var(--gray-100), var(--gray-100) 8px, var(--white) 8px, var(--white) 16px);
  border: 1px dashed var(--gray-300);
}
.mtg-gap-art span {
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  color: var(--gray-400);
  font-weight: 600;
}
.mtg-gap .mtg-name { color: var(--gray-500); }
.mtg-gap:hover .mtg-crop { transform: none; box-shadow: none; }
.mtg-tag.gap { border-color: var(--gray-300); color: var(--gray-400); }

/* Some sealed items are photographed in landscape — a pack lying beside its
   contents. Let those keep their own proportions rather than being forced into
   a card-shaped frame. */
.mtg-crop.wide { aspect-ratio: 4 / 3; }

/* --- Paging --- */
.mtg-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 40px 0 8px;
  padding-top: 24px;
  border-top: 1px solid var(--gray-200);
}
.mtg-pagebtn {
  padding: 9px 16px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gray-700);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.mtg-pagebtn:hover:not(:disabled) { background: var(--charcoal); color: var(--white); }
.mtg-pagebtn:disabled { opacity: 0.4; cursor: default; }
.mtg-pagepos {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink);
}
.mtg-pageof {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gray-500);
}
@media (max-width: 520px) {
  .mtg-pager { gap: 12px; }
  .mtg-pagebtn { padding: 8px 11px; letter-spacing: 0.05em; }
}

/* --- Wholesale view --- */
.mtg-wholesale-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 24px;
  margin: 0 0 24px;
  padding: 18px 22px;
  background: var(--charcoal);
  color: var(--white);
  border-radius: 3px;
}
.mtg-ws-total { display: flex; flex-direction: column; }
.mtg-ws-total .num { font-family: var(--font-display); font-size: 1.9rem; line-height: 1; font-weight: 700; }
.mtg-ws-total .label { margin-top: 4px; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.7; }
.mtg-ws-side { font-size: 0.9rem; opacity: 0.85; }
.mtg-ws-tiers { margin-left: auto; font-size: 0.74rem; letter-spacing: 0.02em; opacity: 0.6; }
@media (max-width: 560px) { .mtg-ws-tiers { margin-left: 0; flex-basis: 100%; } }

/* two prices on a card: wholesale leads, retail sits under it */
.mtg-est-ws { display: flex; flex-direction: column; line-height: 1.25; }
.mtg-est-ws .ws { color: var(--rust, #b8471f); font-weight: 700; }
.mtg-est-ws .rt { font-size: 0.72rem; font-weight: 400; color: var(--gray-500); text-transform: none; letter-spacing: 0; }

/* --- Find it on eBay (affiliate) --- */
.mtg-cell { display: flex; flex-direction: column; height: 100%; }
.mtg-cell .mtg-card { flex: 1 1 auto; }
.mtg-ebay {
  display: block;
  margin-top: 8px;
  padding: 7px 10px;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--charcoal);
  background: var(--gray-100, #f2efe9);
  border: 1px solid var(--gray-300, #cfc9bb);
  border-radius: 2px;
  text-decoration: none;
  transition: background 0.15s var(--ease, ease), color 0.15s var(--ease, ease);
}
.mtg-ebay:hover { background: var(--charcoal); color: var(--white); border-color: var(--charcoal); }

/* affiliate disclosure bar */
.mtg-affiliate {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--gray-600, #6b6b6b);
  background: var(--gray-100, #f2efe9);
  border: 1px solid var(--gray-200, #e3ddd0);
  border-radius: 3px;
  padding: 12px 16px;
  margin: 14px 0 0;
}
