/* ============================================================================
   wa-consent.css — Wizard Academy consent banner + preferences modal
   ----------------------------------------------------------------------------
   Obsidian dark theme tokens used by the rest of the portal
   (#0f1115 page, #1a1e27 surface, amber/yellow accent, slate text).

   STACKING AUDIT (measured in index.html / play.html / the ad + reward modules)
     clean-rail ......................... 45
     ad slot labels / anchor ........... 85
     modal-admin-sanctum (admin) ....... 95
     leaderboard modal ................. 90
     play.html fullscreen overlays .... 999999
     wa-home-ad-gate / wa-ad-gate ... 100200
     toasts (wa-playtime) ............. 99999
   Consent is a legal gate, so it must beat the ad gates and the player
   overlays: 2147483000 (below the browser maximum, above everything above).
   It is appended directly to <body> and is NOT nested inside any animated or
   filtered container, so it creates no new stacking context for the admin
   panel — the admin modals keep their own relative order (95) untouched.
   ============================================================================ */

:root {
  --wa-consent-z: 2147483000;
  --wa-consent-surface: #12161f;
  --wa-consent-surface-2: #1a1e27;
  --wa-consent-border: rgba(251, 191, 36, .28);
  --wa-consent-text: #e2e8f0;
  --wa-consent-muted: #94a3b8;
  --wa-consent-accent: #fbbf24;
  --wa-consent-accent-2: #f59e0b;
  --wa-consent-danger: #64748b;
  --wa-consent-ring: #38bdf8;
}

/* ------------------------------------------------------------------ banner */
#wa-consent-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--wa-consent-z);
  display: none;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  font-family: 'Tajawal', 'Space Grotesk', system-ui, sans-serif;
  color: var(--wa-consent-text);
  pointer-events: none;
}

#wa-consent-banner.is-open {
  display: block;
  /* The fixed strip spans the viewport edge to edge. It must never swallow
     taps meant for the game grid behind it, so only the card itself is
     interactive and the padding around it stays click-through. */
  pointer-events: none;
}

#wa-consent-banner.is-open .wa-consent-inner { pointer-events: auto; }

#wa-consent-banner .wa-consent-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(18, 22, 31, .98), rgba(11, 15, 25, .98));
  border: 1px solid var(--wa-consent-border);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .03),
              0 0 28px rgba(251, 191, 36, .10);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: wa-consent-rise .32s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes wa-consent-rise {
  from { transform: translateY(18px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #wa-consent-banner .wa-consent-inner { animation: none; }
}

#wa-consent-banner .wa-consent-copy { flex: 1 1 320px; min-width: 0; }

#wa-consent-banner .wa-consent-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: .01em;
  color: #fff;
  font-family: 'Cinzel', 'Tajawal', serif;
}

#wa-consent-banner .wa-consent-text {
  margin: 0 0 6px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--wa-consent-muted);
}

#wa-consent-banner .wa-consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.wa-consent-legal {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--wa-consent-muted);
}

.wa-consent-link {
  color: #7dd3fc;
  text-decoration: none;
  border-bottom: 1px dotted rgba(125, 211, 252, .5);
}

.wa-consent-link:hover { color: #bae6fd; }

.wa-consent-dot { opacity: .5; }

/* ------------------------------------------------------------------ buttons */
.wa-consent-btn {
  appearance: none;
  cursor: pointer;
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 12.5px;
  font-weight: 800;
  font-family: inherit;
  line-height: 1;
  border: 1px solid transparent;
  transition: transform .14s ease, box-shadow .18s ease, background .18s ease, filter .18s ease;
  white-space: nowrap;
}

.wa-consent-btn:active { transform: scale(.97); }

.wa-consent-btn-accept {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #0b1220;
  box-shadow: 0 6px 18px rgba(245, 158, 11, .28);
}

.wa-consent-btn-accept:hover { filter: brightness(1.07); }

.wa-consent-btn-reject {
  background: rgba(30, 41, 59, .9);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, .35);
}

.wa-consent-btn-reject:hover { background: rgba(51, 65, 85, .95); color: #fff; }

.wa-consent-btn-ghost {
  background: transparent;
  color: #e2e8f0;
  border-color: rgba(226, 232, 240, .28);
}

.wa-consent-btn-ghost:hover { border-color: var(--wa-consent-accent); color: var(--wa-consent-accent); }

.wa-consent-close {
  position: absolute;
  top: 8px;
  inset-inline-end: 10px;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, .28);
  background: rgba(15, 17, 21, .8);
  color: var(--wa-consent-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.wa-consent-close:hover { color: #fff; border-color: rgba(251, 191, 36, .6); }

#wa-consent-banner .wa-consent-inner { position: relative; }

/* ------------------------------------------------------------ focus states */
.wa-consent-btn:focus-visible,
.wa-consent-close:focus-visible,
.wa-consent-switch:focus-visible,
.wa-consent-link:focus-visible,
#wa-consent-modal:focus-visible {
  outline: 2px solid var(--wa-consent-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, .25);
}

/* Firefox/older WebKit fallback where :focus-visible is unsupported. */
.wa-consent-btn:focus,
.wa-consent-switch:focus { outline: 2px solid var(--wa-consent-ring); outline-offset: 2px; }
.wa-consent-btn:focus:not(:focus-visible),
.wa-consent-switch:focus:not(:focus-visible) { outline: none; }

/* ------------------------------------------------------------------- modal */
#wa-consent-modal {
  position: fixed;
  inset: 0;
  z-index: var(--wa-consent-z);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, .82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: 'Tajawal', 'Space Grotesk', system-ui, sans-serif;
  color: var(--wa-consent-text);
}

#wa-consent-modal.is-open { display: flex; }

#wa-consent-dialog {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: min(86vh, 720px);
  overflow-y: auto;
  padding: 18px 18px 16px;
  border-radius: 20px;
  background: linear-gradient(160deg, #171b24, #0f1115 60%);
  border: 1px solid rgba(251, 191, 36, .22);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .75), 0 0 30px rgba(56, 189, 248, .08);
}

.wa-consent-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.wa-consent-dialog-title {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  color: #fff;
  font-family: 'Cinzel', 'Tajawal', serif;
}

#wa-consent-dialog .wa-consent-close { position: static; flex: 0 0 auto; }

.wa-consent-dialog-desc {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--wa-consent-muted);
}

.wa-consent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 14px;
  background: rgba(26, 30, 39, .75);
  border: 1px solid rgba(255, 255, 255, .06);
}

.wa-consent-row.is-necessary { background: rgba(15, 23, 42, .55); }

.wa-consent-row-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.wa-consent-row-title { font-size: 13px; font-weight: 800; color: #f1f5f9; }

.wa-consent-row-desc { font-size: 11.5px; line-height: 1.6; color: var(--wa-consent-muted); }

.wa-consent-always {
  font-size: 11px;
  font-weight: 800;
  color: #34d399;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, .12);
  border: 1px solid rgba(16, 185, 129, .3);
  white-space: nowrap;
}

/* switch */
.wa-consent-switch {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 96px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, .3);
  background: rgba(15, 17, 21, .9);
  color: var(--wa-consent-muted);
  font-size: 11px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.wa-consent-switch .wa-consent-switch-knob {
  order: -1;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: rgba(100, 116, 139, .45);
  position: relative;
  transition: background .18s ease;
}

.wa-consent-switch .wa-consent-switch-knob::after {
  content: '';
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: transform .18s cubic-bezier(.16, 1, .3, 1), background .18s ease;
}

.wa-consent-switch.is-on { color: #0b1220; border-color: rgba(251, 191, 36, .55); background: rgba(251, 191, 36, .12); }
.wa-consent-switch.is-on .wa-consent-switch-knob { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.wa-consent-switch.is-on .wa-consent-switch-knob::after { transform: translateX(16px); background: #0b1220; }
html[dir="rtl"] .wa-consent-switch.is-on .wa-consent-switch-knob::after { transform: translateX(-16px); }

.wa-consent-dialog-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 12px -18px 0;
  padding: 12px 18px 4px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  background: linear-gradient(180deg, rgba(15, 17, 21, .92), #0f1115 40%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.wa-consent-dialog-foot .wa-consent-actions { justify-content: flex-end; }

/* Lock scroll only while the dialog is open; the banner never does this. */
body.wa-consent-modal-open { overflow: hidden; }

/* ------------------------------------------------------------------- small */
@media (max-width: 640px) {
  #wa-consent-banner { padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); }
  #wa-consent-banner .wa-consent-inner {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 6px 10px;
    padding: 9px 10px;
    border-radius: 14px;
    max-height: none;
    overflow: visible;
  }
  #wa-consent-banner .wa-consent-copy { flex: 1 1 100%; }
  #wa-consent-banner .wa-consent-title {
    font-size: 12px;
    line-height: 1.3;
    margin: 0 0 2px;
    padding-inline-end: 26px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Compact one-row gate (~72px): heading + actions. The long explanation and
     the policy links stay one tap away in "Preferences", so the banner never
     parks over the games grid and eats taps meant for a game card. */
  #wa-consent-banner .wa-consent-text { display: none; }
  #wa-consent-banner .wa-consent-legal { display: none; }
  #wa-consent-banner .wa-consent-actions { width: 100%; flex: 0 0 auto; gap: 6px; }
  #wa-consent-banner .wa-consent-actions .wa-consent-btn {
    flex: 1 1 30%;
    padding: 8px 6px;
    font-size: 11px;
  }
  #wa-consent-dialog { max-height: 88vh; border-radius: 16px; }
  .wa-consent-dialog-foot { flex-direction: column; align-items: stretch; }
  .wa-consent-dialog-foot .wa-consent-actions { width: 100%; }
  .wa-consent-dialog-foot .wa-consent-actions .wa-consent-btn { flex: 1 1 30%; }
}

/* When the mobile anchor ad is visible, lift the banner above it. */
body.wa-has-anchor #wa-consent-banner { padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }

/* ---------------------------------------------------------------- gate hooks
   wa-consent.js mirrors the decision onto <html> as
     data-wa-ads="on|off"  and  data-wa-analytics="on|off"
   so the portal can restyle ad furniture without any JS coupling.
   The rule below only hides containers that would have held a network
   creative; the built-in house cards stay visible unless you opt in.
   ------------------------------------------------------------------------- */
html[data-wa-ads="off"] .wa-ad-slot .wa-ad-network-host { display: none !important; }

/* Opt-in (uncomment to fully hide sponsored furniture for rejected visitors):
   html[data-wa-ads="off"] .wa-infeed-ad,
   html[data-wa-ads="off"] .wa-monetag-banner,
   html[data-wa-ads="off"] #wa-ad-anchor { display: none !important; }
*/
