/* Predefined ad slots. Ads only live in the shared shell, never in games. */

.g-ad-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  width: 100%;
  margin-block: var(--space-3);
  padding: var(--space-2);
  border: 1px solid var(--ad-border);
  border-radius: var(--radius-md);
  background: var(--ad-bg);
}

.g-ad-slot--leaderboard,
.g-ad-slot--rectangle {
  display: none;
}

.g-ad-slot--mobile-banner {
  display: flex;
  margin-top: 0;
}

.g-ad-slot__label {
  color: var(--ad-label-color);
  font-size: var(--font-size-xs);
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.g-ad-slot__container {
  display: flex;
  justify-content: center;
  width: 100%;
  overflow: hidden;
}

.g-ad-slot__container iframe,
.g-ad-slot__container img {
  max-width: 100%;
  border: 0;
}

/* Fixed reservations prevent layout shift while ads load. */
.g-ad-slot--leaderboard .g-ad-slot__container {
  min-height: 90px;
  max-width: 970px;
}

.g-ad-slot--rectangle .g-ad-slot__container {
  min-height: 250px;
  max-width: 300px;
}

.g-ad-slot--mobile-banner .g-ad-slot__container {
  min-height: 50px;
  max-width: 320px;
}

.g-ad-slot--inline .g-ad-slot__container {
  min-height: 250px;
  max-width: 300px;
}

.g-ad-slot--inline {
  margin-block: var(--space-4) 0;
}

.g-ad-slot__close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.g-ad-slot__close:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Empty fill, blocked ads, and errors disappear without error text. */
.g-ad-slot[data-ad-state="empty"],
.g-ad-slot[data-ad-state="error"],
.g-ad-slot[data-ad-enabled="false"] {
  display: none;
}

.g-ad-slot--leaderboard,
.g-ad-slot--mobile-banner {
  width: min(100%, calc(var(--shell-max-width) - var(--space-5) - var(--space-5)));
  margin-inline: auto;
}

.g-ad-slot--leaderboard {
  margin-top: 0;
}

body.is-fullscreen .g-ad-slot--leaderboard,
body.is-fullscreen .g-ad-slot--mobile-banner {
  display: none;
}

/* Ad preference entry point and fallback dialog. */

.g-link-btn {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target-min);
  padding: 0;
  border: 0;
  color: var(--color-text-muted);
  background: transparent;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  touch-action: manipulation;
}

.g-link-btn:hover {
  color: var(--color-text);
}

.g-dialog {
  width: min(100% - var(--space-5), 460px);
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
}

.g-dialog::backdrop {
  background: var(--color-scrim);
}

.g-dialog__body {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-5);
}

.g-dialog__body h2 {
  font-size: var(--font-size-xl);
  letter-spacing: -0.02em;
}

.g-dialog__body p {
  color: var(--color-text-muted);
  line-height: 1.65;
}

.g-dialog__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.g-dialog__actions .g-btn {
  width: 100%;
  min-height: 48px;
}

/* Tablet and desktop: sidebar + footer leaderboard. Mobile: one banner. */
@media (min-width: 480px) {
  .g-dialog__actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .g-dialog__actions .g-btn {
    width: auto;
  }
}

@media (min-width: 768px) {
  .g-ad-slot {
    margin-block: var(--space-4);
  }

  .g-ad-slot--leaderboard,
  .g-ad-slot--rectangle {
    display: flex;
  }

  .g-ad-slot--mobile-banner {
    display: none;
  }

  .g-ad-slot__close {
    top: var(--space-1);
    right: var(--space-1);
    width: var(--ad-close-size);
    height: var(--ad-close-size);
  }
}

/* Phones in landscape are still mobile inventory: one banner at most. */
@media (orientation: landscape) and (max-height: 520px) {
  .g-ad-slot {
    margin-block: var(--space-3);
  }

  .g-ad-slot--leaderboard,
  .g-ad-slot--rectangle {
    display: none;
  }

  .g-ad-slot--mobile-banner {
    display: flex;
  }

  .g-ad-slot__close {
    top: var(--space-2);
    right: var(--space-2);
    width: var(--touch-target-min);
    height: var(--touch-target-min);
  }
}
