/* Wizard Academy — reserved ad containers, lazy skeleton states and in-feed cards.
   Every slot declares its final dimensions here before any network script runs. */

[data-wa-ad] {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(135deg, #0b1220 0%, #070b14 100%);
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  contain: layout paint;
  isolation: isolate;
}

[data-wa-ad]:not(.wa-ad-live) > * {
  visibility: hidden !important;
}

[data-wa-ad]:not(.wa-ad-live)::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(100deg, #0a111d 20%, #16233a 40%, #0a111d 60%);
  background-size: 220% 100%;
  animation: waAdShimmer 1.5s linear infinite;
  opacity: 0.85;
}

[data-wa-ad]:not(.wa-ad-live)::after {
  content: attr(data-ad-label);
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: rgba(148, 163, 184, 0.95);
  text-transform: uppercase;
  pointer-events: none;
}

@keyframes waAdShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -20% 0; }
}

.wa-ad-live {
  animation: none;
}

.wa-ad-network > :not(.wa-ad-network-host) {
  display: none !important;
}

.wa-ad-network-host {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.wa-ad-network-host ins,
.wa-ad-network-host iframe {
  max-width: 100%;
}

/* ---------- Home leaderboards ---------- */
#wa-home-top-ad,
#home-middle-ad-slot,
#wa-home-bottom-ad {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin: 16px auto;
}

@media (max-width: 767px) {
  #wa-home-top-ad,
  #home-middle-ad-slot,
  #wa-home-bottom-ad {
    max-width: 320px;
    min-height: 50px;
    margin: 12px auto;
  }
  #wa-home-bottom-ad {
    min-height: 100px;
  }
}

/* ---------- Monetag in-page leaderboard slots ----------
   Measured on the live site: the container paints at 1139x78 (house creative,
   content-sized), wa-ads-manager.js then writes its reserved box inline, and a
   few seconds later the network drops an 800x162 creative into it on desktop.
   Each of those three boxes moved everything below the slot, which is the whole
   of the all-games and shop CLS readings (0.0667 live on the top slot alone).

   The three sources must agree, so this block mirrors wa-ads-config.js exactly:
   800x162 desktop and the configured mobile boxes. The inline style the
   manager writes is identical, so the box never changes size or position and
   the grid, Load More and the footer stay where they are. */
.wa-monetag-banner {
  width: 100%;
  max-width: 800px;
  margin: 14px auto;
  flex: 0 0 auto;
}

#wa-home-top-ad,
#home-middle-ad-slot,
#wa-home-bottom-ad,
#wa-ag-top-ad,
#wa-ag-bottom-ad,
#wa-shop-top-ad,
#wa-shop-bottom-ad,
.wa-monetag-banner {
  min-height: 162px;
}

/* The house creative is a single anchor; it now has to fill the reserved box
   instead of defining it. */
.wa-monetag-banner > a {
  flex: 1 1 auto;
  min-width: 0;
}

/* The box is pinned, not merely floored. Measured on the shop page: the network
   briefly wrote a 1052x234 block into the container — and inline sizes on the
   container itself — so the slot grew with it and everything below jumped twice
   (0.0208 + 0.0522). `!important` here beats whatever the network sets inline,
   and `contain: size` makes the box independent of its contents, so a creative
   can only ever be laid out inside the reservation; it can never move the page. */
#wa-home-top-ad,
#home-middle-ad-slot,
#wa-home-bottom-ad,
#wa-ag-top-ad,
#wa-ag-bottom-ad,
#wa-shop-top-ad,
#wa-shop-bottom-ad,
.wa-monetag-banner {
  height: 162px !important;
  max-width: 800px !important;
  contain: layout paint size !important;
}

/* Mobile mirrors the per-slot mobile boxes in wa-ads-config.js: 320 wide,
   50 tall for the top slots and 100 tall for the bottom ones. */
@media (max-width: 767px) {
  #wa-home-top-ad,
  #home-middle-ad-slot,
  #wa-ag-top-ad,
  #wa-shop-top-ad,
  .wa-monetag-banner {
    height: 50px !important;
    min-height: 50px !important;
    max-width: 320px !important;
    margin: 10px auto;
  }

  #wa-home-bottom-ad,
  #wa-ag-bottom-ad,
  #wa-shop-bottom-ad {
    height: 100px !important;
    min-height: 100px !important;
    max-width: 320px !important;
  }
}

/* ---------- Game player page ---------- */
#wa-ad-top {
  width: 100%;
  max-width: 970px;
  min-height: 90px;
  margin: 10px auto;
}

#wa-ad-side-left,
#wa-ad-side-right {
  display: none !important;
}

@media (min-width: 1280px) {
  #wa-ad-side-left,
  #wa-ad-side-right {
    display: flex !important;
    position: sticky;
    top: 84px;
    align-self: flex-start;
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    height: 600px;
    min-height: 600px;
    max-height: 600px;
    flex: 0 0 160px;
  }
}

.game-theater {
  align-items: flex-start;
}

#wa-ad-mid {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin: 16px auto;
}

#wa-ad-native {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin: 16px auto;
}

#wa-ad-bottom {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin: 16px auto;
}

@media (max-width: 767px) {
  #wa-ad-top,
  #wa-ad-mid,
  #wa-ad-bottom {
    max-width: 320px;
    min-height: 100px;
    margin: 16px auto;
  }
  #wa-ad-native {
    max-width: 300px;
    min-height: 250px;
    margin: 16px auto;
  }
}

/* ---------- Mobile sticky anchor ---------- */
#wa-ad-anchor {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 85;
  width: 320px;
  max-width: calc(100vw - 20px);
  height: 50px;
  min-height: 50px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

@media (max-width: 767px) {
  #wa-ad-anchor {
    display: flex;
    /* Clear the fixed mobile navigation (60px + safe area) instead of sitting
       on top of its buttons. */
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }
  body.wa-has-anchor {
    padding-bottom: 132px;
  }
}

@media (min-width: 768px) {
  #wa-ad-anchor {
    display: none !important;
  }
}

.wa-anchor-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  padding: 4px 30px 4px 10px;
  color: #e2e8f0;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
}

.wa-anchor-link .wa-anchor-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.wa-anchor-link .wa-anchor-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-anchor-link .wa-anchor-cta {
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 6px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.wa-anchor-close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 6;
  /* 44px touch target per WCAG 2.5.5; the visual × stays small via padding. */
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(2, 6, 23, 0.85);
  color: #94a3b8;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 13px;
}

.wa-anchor-close:hover {
  color: #fff;
  background: rgba(220, 38, 38, 0.85);
}

/* ---------- In-grid native ad card ---------- */
#browser-games-grid > .wa-infeed-ad,
#wa-ag-grid > .wa-infeed-ad {
  display: block !important;
  position: relative;
  overflow: hidden;
  cursor: default;
  background: linear-gradient(160deg, #0d1728 0%, #0a0f1a 100%) !important;
  border: 1px solid rgba(168, 85, 247, 0.3) !important;
}

.wa-infeed-ad:not(.wa-ad-live)::before,
.wa-infeed-ad:not(.wa-ad-live)::after {
  display: none;
}

#browser-games-grid > .wa-infeed-ad,
#wa-ag-grid > .wa-infeed-ad:not(.wa-ad-live) > .wa-infeed-skel {
  visibility: visible !important;
}

.wa-infeed-inner {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  text-align: left;
}

.wa-infeed-label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 7px;
  letter-spacing: 0.18em;
  color: #94a3b8;
  opacity: 0.75;
}

.wa-infeed-icon {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.4));
}

.wa-infeed-title {
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  color: #f8fafc;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wa-infeed-sub {
  font-size: 10px;
  line-height: 1.3;
  color: #94a3b8;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wa-infeed-cta {
  margin-top: 4px;
  padding: 5px 9px;
  border-radius: 7px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.wa-infeed-skel {
  position: absolute;
  inset: 10px;
  z-index: 1;
  border-radius: 10px;
  background: linear-gradient(100deg, #0c1422 20%, #1a2740 40%, #0c1422 60%);
  background-size: 220% 100%;
  animation: waAdShimmer 1.5s linear infinite;
}

#browser-games-grid > .wa-infeed-ad,
#wa-ag-grid > .wa-infeed-ad.wa-ad-live .wa-infeed-skel {
  display: none;
}

@media (max-width: 640px) {
  .wa-infeed-inner {
    padding: 9px;
    gap: 4px;
  }
  .wa-infeed-icon {
    font-size: 20px;
  }
  .wa-infeed-title {
    font-size: 10px;
  }
  .wa-infeed-sub {
    display: none;
  }
  .wa-infeed-cta {
    font-size: 8px;
    padding: 4px 7px;
  }
}
