/* ===========================================================================
   MTG Custom Cards: "The Spoiler". Laid out like an official set gallery:
   a tile per set, a sticky tool bar, then the cards in colour order under
   mana headers. Cards tilt toward the pointer and rares and up catch a foil
   glare (mtg.js). The cards themselves come from [wam_mtg_spoiler].
   =========================================================================== */

.wp-site-blocks:has(> .wam-page.wam-mtg) { background: #101018; }
.wam-page.wam-mtg {
  --sp-panel: #171824;
  --sp-panel-2: #1e2030;
  --sp-faint: rgba(255, 255, 255, 0.56);
  --sp-ember: #f08a3c;
  position: relative;
  isolation: isolate;
  background: radial-gradient(900px 460px at 50% -10%, rgba(240, 138, 60, 0.22), transparent 70%), #101018;
  padding-bottom: clamp(64px, 8vw, 100px);
  color: var(--wam-white);
}
.wam-mtg .wp-block-group > * { margin-block: 0; }
.wam-mtg p { margin: 0; }
.wam-mtg-wrap { max-width: 1240px; margin-inline: auto; padding-inline: 24px; display: grid; gap: 22px; }

.wam-mtg-hero { display: grid; gap: 6px; padding-top: clamp(44px, 6vw, 60px); animation: wam-rise 0.8s var(--wam-ease) both; }
.wam-mtg .wam-mtg-eyebrow { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.wam-mtg .wam-mtg-eyebrow a { color: var(--sp-ember); text-decoration: none; }
.wam-mtg .wam-mtg-eyebrow a:hover { text-decoration: underline; }
.wam-mtg .wam-mtg-h1 { margin: 0; color: var(--wam-white); font: 800 clamp(2.2rem, 5vw, 3.4rem)/1.05 var(--wam-font); letter-spacing: -0.01em; text-wrap: balance; }
.wam-mtg .wam-mtg-lede { color: var(--wam-faded); }
.wam-mtg .wam-mtg-disclaim { color: var(--sp-faint); font-size: 0.82rem; font-style: italic; }

/* Buttons here are drawn from scratch; the theme's button look stays out. */
.wam-sp button, .wam-sp-modal button { margin: 0; font-family: var(--wam-font); line-height: 1.2; letter-spacing: normal; text-transform: none; }
.wam-sp button:focus-visible, .wam-sp input:focus-visible, .wam-sp-modal button:focus-visible { outline: 2px solid var(--wam-gold); outline-offset: 3px; }
.wam-sp { display: grid; gap: 18px; }
.wam-sp [hidden] { display: none !important; }
.wam-sp .screen-reader-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wam-sp .ms-cost, .wam-sp-modal .ms-cost { font-size: 0.95em; }

/* Set tiles */
.wam-sp-sets { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.wam-sp .wam-sp-set {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 4px 16px;
  align-items: center;
  padding: 18px;
  border: 0;
  border-radius: 20px;
  background: var(--sp-panel);
  box-shadow: inset 0 0 0 1px var(--wam-line);
  color: var(--wam-white);
  text-align: left;
  cursor: pointer;
  transition: transform 0.3s var(--wam-spring), box-shadow 0.2s ease;
}
.wam-sp .wam-sp-set:hover { transform: translateY(-3px); }
.wam-sp .wam-sp-set[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--sp-ember), 0 18px 40px rgba(240, 138, 60, 0.18); }
.wam-sp-set > img, .wam-sp-set-ph { grid-row: span 2; width: 60px; height: 60px; object-fit: contain; border-radius: 14px; }
.wam-sp-set-ph { background: rgba(255, 255, 255, 0.06); }
.wam-sp-set b { font-size: 1.12rem; font-weight: 800; line-height: 1.2; }
.wam-sp-set small { color: var(--sp-faint); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.wam-sp-pie { grid-column: 1 / -1; display: flex; height: 8px; margin-top: 8px; border-radius: 99px; overflow: hidden; background: rgba(255, 255, 255, 0.06); }
.wam-sp-pie i { display: block; height: 100%; }

/* Tools */
.wam-sp-tools {
  position: sticky;
  top: 82px;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(23, 24, 36, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px var(--wam-line), 0 14px 30px rgba(0, 0, 0, 0.35);
}
.wam-sp-search { flex: 1 1 240px; display: block; }
.wam-sp .wam-sp-search input[type="search"] { width: 100%; height: auto; box-shadow: none; padding: 10px 13px; border: 1px solid var(--wam-line); border-radius: 12px; background: #0f0f16; color: var(--wam-white); font: 400 0.95rem/1.3 var(--wam-font); }
.wam-sp .wam-sp-search input::placeholder { color: var(--sp-faint); }
.wam-sp-pips, .wam-sp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wam-sp .wam-sp-pip {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px var(--wam-line);
  color: var(--wam-white);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s ease, transform 0.2s var(--wam-spring), box-shadow 0.2s ease;
}
.wam-sp .wam-sp-pip .ms { font-size: 1.15rem; }
.wam-sp .wam-sp-pip:hover { opacity: 0.85; }
.wam-sp .wam-sp-pip[aria-pressed="true"] { opacity: 1; transform: translateY(-2px); box-shadow: inset 0 0 0 2px var(--wam-gold); }
.wam-sp .wam-sp-chip { padding: 7px 13px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 0 0 1px var(--wam-line); color: var(--wam-faded); font-size: 0.84rem; font-weight: 600; cursor: pointer; }
.wam-sp .wam-sp-chip:hover { color: var(--wam-white); }
.wam-sp .wam-sp-chip[aria-pressed="true"] { background: var(--sp-ember); color: #1a0d00; box-shadow: none; }
.wam-sp .wam-sp-count { color: var(--sp-faint); font-size: 0.84rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.wam-sp .wam-sp-count:empty { display: none; }

/* The gallery */
.wam-sp-sections { display: grid; gap: 30px; }
.wam-sp-sec { display: grid; gap: 12px; }
.wam-sp .wam-sp-sec-title { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--wam-white); font: 800 1.35rem/1.2 var(--wam-font); }
.wam-sp .wam-sp-sec-title .ms { font-size: 1.3rem; }
.wam-sp .wam-sp-sec-title small { color: var(--sp-faint); font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.wam-sp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 16px; perspective: 900px; }
.wam-sp-img { position: relative; display: block; width: 100%; aspect-ratio: 375 / 523; border-radius: 4.6% / 3.3%; overflow: hidden; background: #22232f; }
.wam-sp-img img { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; }
.wam-sp .wam-sp-card {
  --rx: 0deg;
  --ry: 0deg;
  --gx: 50%;
  --gy: 50%;
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 4.6% / 3.3%;
  background: none;
  cursor: pointer;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.35s var(--wam-ease);
}
.wam-sp .wam-sp-card:hover { z-index: 2; transition-duration: 0.08s; }
.wam-sp-card .wam-sp-img { box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45); transition: box-shadow 0.3s ease; }
.wam-sp-card:hover .wam-sp-img { box-shadow: 0 22px 44px rgba(0, 0, 0, 0.6); }
.wam-sp-glare { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity 0.3s ease; background: radial-gradient(circle at var(--gx) var(--gy), rgba(255, 255, 255, 0.35), transparent 45%); }
.wam-sp-card.is-foil .wam-sp-glare {
  background: radial-gradient(circle at var(--gx) var(--gy), rgba(255, 255, 255, 0.4), transparent 40%), linear-gradient(115deg, transparent 20%, rgba(255, 0, 170, 0.22) 35%, rgba(0, 220, 255, 0.22) 50%, rgba(255, 230, 0, 0.22) 65%, transparent 80%);
  background-size: 100% 100%, 200% 200%;
  background-position: center, var(--gx) var(--gy);
  mix-blend-mode: color-dodge;
}
.wam-sp-card:hover .wam-sp-glare, .wam-sp-card:focus-visible .wam-sp-glare { opacity: 1; }
.wam-sp-faces { position: absolute; top: 8px; right: 8px; padding: 3px 8px; border-radius: 99px; background: rgba(0, 0, 0, 0.72); color: var(--wam-white); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; }
.wam-sp .wam-sp-empty { padding: 30px; border-radius: 16px; background: var(--sp-panel); color: var(--sp-faint); text-align: center; }

/* The card, opened (appended to body by mtg.js) */
.wam-sp-modal {
  --sp-panel: #171824;
  --sp-panel-2: #1e2030;
  --sp-faint: rgba(255, 255, 255, 0.56);
  --sp-ember: #f08a3c;
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 6, 10, 0.88);
  backdrop-filter: blur(6px);
  color: var(--wam-white);
  font-family: var(--wam-font);
}
.wam-sp-modal[hidden] { display: none; }
html.wam-sp-locked { overflow: hidden; }
.wam-sp-modal-in { position: relative; width: min(980px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 24px; border-radius: 24px; background: var(--sp-panel); box-shadow: inset 0 0 0 1px var(--wam-line), 0 40px 80px rgba(0, 0, 0, 0.6); animation: wam-sp-pop 0.35s var(--wam-spring) both; }
@keyframes wam-sp-pop { from { transform: scale(0.94); } }
.wam-sp-modal .wam-sp-x { position: absolute; top: 14px; right: 14px; z-index: 2; width: 40px; height: 40px; padding: 0; border: 1px solid var(--wam-line); border-radius: 50%; background: var(--sp-panel-2); color: var(--wam-white); font-size: 1.3rem; cursor: pointer; }
.wam-sp-modal .wam-sp-x:hover { background: #2a2c3e; }
.wam-sp-modal-body { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 26px; }
.wam-sp-flip { perspective: 1200px; align-self: start; }
.wam-sp-flip-in { position: relative; transition: transform 0.7s var(--wam-ease); transform-style: preserve-3d; }
.wam-sp-flip.is-b .wam-sp-flip-in { transform: rotateY(180deg); }
.wam-sp-side { backface-visibility: hidden; }
.wam-sp-side.is-back { position: absolute; inset: 0; transform: rotateY(180deg); }
.wam-sp-side .wam-sp-img { box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5); }
.wam-sp-dt { display: grid; gap: 12px; align-content: start; min-width: 0; }
/* The header row keeps clear of the close button. */
.wam-sp-dt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding-right: 52px; }
.wam-sp-modal .wam-sp-dt-name { margin: 0; color: var(--wam-white); font: 800 1.5rem/1.15 var(--wam-font); text-wrap: balance; }
.wam-sp-dt-cost { white-space: nowrap; font-size: 1.1rem; }
.wam-sp-modal .wam-sp-dt-type { margin: 0; padding: 7px 11px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); font-size: 0.92rem; font-weight: 600; }
.wam-sp-dt-oracle { color: var(--wam-faded); font-size: 0.94rem; line-height: 1.6; }
.wam-sp-dt-flavor { padding-left: 12px; border-left: 2px solid var(--wam-line); color: var(--sp-faint); font-size: 0.9rem; font-style: italic; }
.wam-sp-dt-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; color: var(--sp-faint); font-size: 0.82rem; }
.wam-sp-dt-set, .wam-sp-dt-rar { display: inline-flex; align-items: center; gap: 7px; }
.wam-sp-dt-set img { width: 20px; height: 20px; object-fit: contain; }
.wam-sp-dt-rar { text-transform: capitalize; }
.wam-sp-rar { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #c9c9d1; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35); }
.wam-sp-rar.is-uncommon { background: #a8c3d6; }
.wam-sp-rar.is-rare { background: #e6c15a; }
.wam-sp-rar.is-mythic { background: #f0703a; }
.wam-sp-rar.is-special { background: #c08cf0; }
.wam-sp-dt-pt { margin-left: auto; padding: 4px 12px; border-radius: 10px; background: var(--wam-white); color: #111; font-size: 0.95rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.wam-sp-dt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 4px; }
.wam-sp-dt-label { color: var(--sp-faint); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.wam-sp-modal .wam-sp-btn { padding: 8px 16px; border: 0; border-radius: 999px; background: var(--sp-ember); color: #1a0d00; font-size: 0.82rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; cursor: pointer; }
.wam-sp-modal .wam-sp-btn.is-ghost { background: rgba(255, 255, 255, 0.08); color: var(--wam-white); letter-spacing: normal; text-transform: none; }
.wam-sp-modal .wam-sp-btn.is-ghost[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--sp-ember); }

@media (max-width: 720px) {
  .wam-sp-modal { padding: 10px; }
  .wam-sp-modal-in { padding: 18px; max-height: calc(100vh - 20px); }
  .wam-sp-modal-body { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .wam-sp-flip { width: min(280px, 78%); margin-inline: auto; }
  .wam-sp-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .wam-sp-tools { top: 70px; }
}
@media (max-width: 640px) { .wam-mtg-wrap { padding-inline: 16px; } }
@media (prefers-reduced-motion: reduce) {
  .wam-mtg *, .wam-mtg *::before, .wam-mtg *::after, .wam-sp-modal * { animation: none !important; transition-duration: 0.01ms !important; }
  .wam-sp .wam-sp-card { transform: none; }
}
