/**
 * Shared frontend compatibility and accessibility layer.
 * Kept intentionally small and scoped to Ads Affiliates components.
 * @since 1.2.0-beta34
 */
:where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"][role="region"], .mlaf-popup, .mlaf-comp-popup-overlay),
:where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"][role="region"], .mlaf-popup, .mlaf-comp-popup-overlay) * {
    box-sizing: border-box;
}

:where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"][role="region"]) {
    max-inline-size: 100%;
    min-inline-size: 0;
    overflow-wrap: anywhere;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

:where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"][role="region"]) img {
    max-inline-size: 100%;
    block-size: auto;
}

:where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"][role="region"], .mlaf-popup, .mlaf-comp-popup-overlay)
:where(a, button, [role="button"]):focus-visible {
    outline: 3px solid #2563eb !important;
    outline-offset: 3px !important;
}

:where(.mlaf-template-custom, .mlaf-comparative-wrap, [class*="mlaf-comp-"][role="region"])
:where(a[class*="btn"], a[class*="cta"], button[class*="btn"], button[class*="cta"]),
:where(.mlaf-popup, .mlaf-comp-popup-overlay)
:where(a[class*="cta"], button, [role="button"]) {
    min-block-size: 44px;
    max-inline-size: 100%;
    touch-action: manipulation;
}

.mlaf-popup-container,
.mlaf-comp-popup-container {
    max-block-size: calc(var(--mlaf-visual-viewport-height, 100vh) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-block-size: calc(var(--mlaf-visual-viewport-height, 100dvh) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overscroll-behavior: contain;
}

@media (max-width: 480px) {
    :where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"][role="region"]) {
        margin-inline: 0 !important;
    }

    :where(.mlaf-template-custom, .mlaf-comparative-wrap, [class*="mlaf-comp-"][role="region"])
    :where(a[class*="btn"], a[class*="cta"], button[class*="btn"], button[class*="cta"]) {
        inline-size: 100%;
        white-space: normal;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    :where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"], .mlaf-popup, .mlaf-comp-popup-overlay),
    :where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"], .mlaf-popup, .mlaf-comp-popup-overlay) *,
    :where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"], .mlaf-popup, .mlaf-comp-popup-overlay) *::before,
    :where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"], .mlaf-popup, .mlaf-comp-popup-overlay) *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: more) {
    :where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"][role="region"])
    :where(a[class*="btn"], a[class*="cta"], button[class*="btn"], button[class*="cta"]) {
        border: 2px solid currentColor !important;
        font-weight: 800 !important;
    }
}

@media (forced-colors: active) {
    :where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"], .mlaf-popup, .mlaf-comp-popup-overlay) {
        forced-color-adjust: auto;
    }

    :where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"], .mlaf-popup, .mlaf-comp-popup-overlay)
    :where(a, button, [role="button"]) {
        border: 1px solid ButtonText !important;
    }
}

@media print {
    .mlaf-popup,
    .mlaf-comp-popup-overlay {
        display: none !important;
    }

    :where(.mlaf-ad-wrapper, .mlaf-comparative-wrap, [class*="mlaf-comp-"][role="region"]) {
        break-inside: avoid;
        box-shadow: none !important;
    }
}
