/**
 * Mobile Ad Placements
 * Optimized ad styling for mobile devices
 * Non-intrusive, performant, user-friendly
 */

/* ============================================
   MOBILE AD CONTAINERS
   ============================================ */

/* Mobile Banner Ads */
.mobile-ad-banner {
    position: relative;
    width: 100%;
    min-height: 50px;
    max-height: 100px;
    margin: 16px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    overflow: hidden;
    padding: 8px;
}

/* Mobile Sticky Banner (Bottom) */
.mobile-ad-sticky-bottom {
    position: fixed;
    bottom: calc(60px + env(safe-area-inset-bottom)); /* Above bottom nav */
    left: 0;
    right: 0;
    z-index: 997;
    background: #ffffff;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
    border-top: 1px solid #e5e7eb;
    padding: 8px;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.mobile-ad-sticky-bottom.hidden {
    transform: translateY(100%);
}

.mobile-ad-sticky-bottom .ad-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.mobile-ad-sticky-bottom .ad-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* In-Feed Native Ads */
.mobile-ad-native {
    position: relative;
    background: linear-gradient(135deg, #fafbfc 0%, #f1f3f5 100%);
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.mobile-ad-native::before {
    content: 'Sponsored';
    position: absolute;
    top: 8px;
    left: 12px;
    font-size: 9px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255, 255, 255, 0.9);
    padding: 3px 8px;
    border-radius: 4px;
}

/* In-Content Ads */
.mobile-ad-in-content {
    margin: 24px 0;
    padding: 12px;
    background: #f9fafb;
    border-left: 3px solid #FFB81C;
    border-radius: 4px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-ad-in-content::after {
    content: 'Advertisement';
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 9px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Interstitial Ads (Full-screen) */
.mobile-ad-interstitial {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mobile-ad-interstitial.active {
    display: flex;
}

.mobile-ad-interstitial .ad-container {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    max-width: 90%;
    max-height: 80%;
    overflow: auto;
}

.mobile-ad-interstitial .ad-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 36px;
    height: 36px;
    background: #FFB81C;
    color: #041E42;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    -webkit-tap-highlight-color: transparent;
}

.mobile-ad-interstitial .ad-countdown {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: #ffffff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ad Label */
.mobile-ad-label {
    font-size: 9px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
    text-align: center;
}

/* Ad Placeholder (Before Load) */
.mobile-ad-placeholder {
    position: relative;
    background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    min-height: 50px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-ad-placeholder::after {
    content: 'Loading ad...';
    font-size: 11px;
    color: #9ca3af;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   RESPONSIVE AD SIZING
   ============================================ */

/* Mobile Portrait */
@media (max-width: 767px) and (orientation: portrait) {
    .mobile-ad-banner {
        min-height: 50px;
        max-height: 100px;
    }

    .mobile-ad-sticky-bottom {
        min-height: 50px;
        max-height: 90px;
    }
}

/* Mobile Landscape */
@media (max-width: 767px) and (orientation: landscape) {
    .mobile-ad-sticky-bottom {
        display: none; /* Hide sticky ads in landscape for better content viewing */
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1024px) {
    .mobile-ad-banner {
        max-width: 728px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Desktop - Hide mobile-specific ads */
@media (min-width: 1025px) {
    .mobile-ad-sticky-bottom {
        display: none;
    }

    .mobile-ad-native {
        max-width: 300px;
    }
}

/* ============================================
   AD PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Lazy load ads */
.mobile-ad-lazy {
    visibility: hidden;
}

.mobile-ad-lazy.loaded {
    visibility: visible;
    animation: fadeInAd 0.3s ease-in-out;
}

@keyframes fadeInAd {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Prevent layout shift */
.mobile-ad-container {
    min-height: var(--ad-min-height, 50px);
    position: relative;
}

/* ============================================
   AD ACCESSIBILITY
   ============================================ */

/* Skip ad link for screen readers */
.mobile-ad-skip {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.mobile-ad-skip:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 8px 12px;
    background: #FFB81C;
    color: #041E42;
    font-weight: 600;
    border-radius: 4px;
    z-index: 10;
}

/* ============================================
   DARK MODE
   ============================================ */

@media (prefers-color-scheme: dark) {
    .mobile-ad-banner,
    .mobile-ad-native,
    .mobile-ad-in-content {
        background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
        border-color: #374151;
    }

    .mobile-ad-sticky-bottom {
        background: #1a1a1a;
        border-top-color: #374151;
    }

    .mobile-ad-native::before {
        background: rgba(0, 0, 0, 0.8);
        color: #9ca3af;
    }

    .mobile-ad-placeholder {
        background: linear-gradient(90deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
    }

    .mobile-ad-interstitial .ad-container {
        background: #1a1a1a;
        color: #ffffff;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .mobile-ad-sticky-bottom,
    .mobile-ad-lazy,
    .mobile-ad-placeholder {
        transition: none;
        animation: none;
    }
}

/* ============================================
   PRINT - HIDE ALL ADS
   ============================================ */

@media print {
    .mobile-ad-banner,
    .mobile-ad-sticky-bottom,
    .mobile-ad-native,
    .mobile-ad-in-content,
    .mobile-ad-interstitial {
        display: none !important;
    }
}

/* ============================================
   AD BLOCKER FRIENDLY MESSAGE
   ============================================ */

.mobile-ad-blocker-notice {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.mobile-ad-blocker-notice h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 700;
}

.mobile-ad-blocker-notice p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    opacity: 0.95;
}

.mobile-ad-blocker-notice a {
    color: #ffd700;
    text-decoration: underline;
    font-weight: 600;
}
