/* Maximize — Story Full ad popup */

.mx-story-ad {
  --mx-story-bg: #0f0f0f;
  --mx-story-text: #ffffff;
  --mx-story-cta-bg: #ffffff;
  --mx-story-cta-text: #111111;
  --mx-story-overlay: #000000;
  position: fixed;
  inset: 0;
  z-index: var(--mx-z-modal, 950);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  font-family: var(--mx-font-body, "Segoe UI", Tahoma, sans-serif);
  touch-action: none;
}

.mx-story-ad.is-open {
  opacity: 1;
  pointer-events: auto;
}

.mx-story-ad.is-out {
  opacity: 0;
}

.mx-story-ad__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--mx-story-overlay) calc(var(--mx-story-overlay-opacity, 55) * 1%), transparent);
  backdrop-filter: blur(2px);
  transition: opacity 0.2s ease, background 0.2s ease;
}

.mx-story-ad.is-dragging .mx-story-ad__backdrop {
  opacity: 0.35;
}

.mx-story-ad__dialog {
  position: relative;
  z-index: 1;
  width: 90vw;
  height: 90dvh;
  height: 90vh;
  max-width: 90vw;
  max-height: 90dvh;
  background: var(--mx-story-bg);
  color: var(--mx-story-text);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  box-shadow: none;
  transform: translate3d(0, 0, 0);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
  border-radius: 12px;
}

.mx-story-ad.is-dragging .mx-story-ad__dialog {
  transition: none;
}

.mx-story-ad.is-swipe-out .mx-story-ad__dialog {
  transform: translate3d(0, 110%, 0) !important;
  transition: transform 0.28s cubic-bezier(0.4, 0, 1, 1);
}

.mx-story-ad__close {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px));
  inset-inline-end: 12px;
  z-index: 4;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: var(--mx-story-text);
  cursor: pointer;
  padding: 0;
}

.mx-story-ad__close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.mx-story-ad__badge {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px));
  inset-inline-start: 14px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.mx-story-ad__bars {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  inset-inline: 14px 52px;
  display: flex;
  gap: 4px;
  z-index: 3;
}

.mx-story-ad__badge ~ .mx-story-ad__bars {
  top: calc(48px + env(safe-area-inset-top, 0px));
}

.mx-story-ad__bar {
  flex: 1;
  height: 2.5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  overflow: hidden;
}

.mx-story-ad__bar i {
  display: block;
  height: 100%;
  width: 0;
  background: #fff;
  transform-origin: left center;
}

[dir="rtl"] .mx-story-ad__bar i {
  transform-origin: right center;
}

@keyframes mx-story-bar-fill {
  from { width: 0; }
  to { width: 100%; }
}

.mx-story-ad__bar.is-done i {
  width: 100%;
  animation: none !important;
}

.mx-story-ad.is-paused .mx-story-ad__bar.is-on i {
  animation-play-state: paused !important;
}

.mx-story-ad__media {
  flex: 1;
  min-height: 0;
  background: #1a1a1a;
  position: relative;
}

.mx-story-ad__slide {
  position: absolute;
  inset: 0;
  margin: 0;
}

.mx-story-ad__slide[hidden] {
  display: none !important;
}

.mx-story-ad__hit {
  position: absolute;
  top: 56px;
  bottom: 150px;
  width: 42%;
  z-index: 2;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.mx-story-ad__hit--prev {
  inset-inline-start: 0;
}

.mx-story-ad__hit--next {
  inset-inline-end: 0;
  width: 58%;
}

.mx-story-ad__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.mx-story-ad__placeholder {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 280px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.18), transparent 45%),
    linear-gradient(160deg, #243028, #121212);
}

.mx-story-ad__copy {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 3;
  padding: 28px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  pointer-events: none;
}

.mx-story-ad__copy .mx-story-ad__cta {
  pointer-events: auto;
}

.mx-story-ad__title {
    margin: 0 0 8px;
    font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--mx-story-text);
}

.mx-story-ad__text {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--mx-story-text);
  opacity: 0.88;
}

.mx-story-ad__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--mx-story-cta-bg);
  color: var(--mx-story-cta-text);
  font-weight: 500;
  text-decoration: none;
}

.mx-story-ad__cta:hover {
  filter: brightness(1.06);
}

html.has-mx-story-ad,
body.has-mx-story-ad {
  overflow: hidden;
  overscroll-behavior: none;
}

/* Desktop: narrower 9:16 card */
@media (min-width: 768px) {
  .mx-story-ad {
    padding: 24px;
  }

  .mx-story-ad__dialog {
    width: min(380px, 42vw, calc((100dvh - 48px) * 9 / 16));
    height: min(calc(380px * 16 / 9), calc(100dvh - 48px));
    max-height: calc(100dvh - 48px);
    aspect-ratio: 9 / 16;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  }

  .mx-story-ad__badge ~ .mx-story-ad__bars {
    top: calc(14px + env(safe-area-inset-top, 0px));
    inset-inline: 72px 52px;
  }

  .mx-story-ad__badge {
    top: calc(14px + env(safe-area-inset-top, 0px));
  }

  .mx-story-ad__close {
    top: calc(14px + env(safe-area-inset-top, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .mx-story-ad,
  .mx-story-ad__dialog,
  .mx-story-ad__backdrop,
  .mx-story-ad__bar i {
    transition: none !important;
    animation: none !important;
  }
}
