/**
 * Ad Slots CSS
 * Responsive ad placement styles for all ad positions
 */

/* ============================================
   Base Ad Slot Styles
   ============================================ */

.ad-slot {
    margin: 20px auto;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.ad-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50px;
}

/* Banner Ad Styles */
.ad-banner-link {
    display: inline-block;
    line-height: 0;
    transition: opacity 0.3s ease;
}

.ad-banner-link:hover {
    opacity: 0.9;
}

.ad-banner-image {
    max-width: 100%;
    height: auto;
    display: block;
    border: none;
}

/* Empty placeholder for testing (hidden by default) */
.ad-slot-empty {
    display: block; /* force show when debugging placeholders */
    width: 100%;
}

.ad-placeholder {
    background: #f5f5f5;
    border: 2px dashed #ddd;
    padding: 20px;
    border-radius: 4px;
    color: #999;
    font-size: 14px;
}

.ad-label {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============================================
   Header Ad Positions
   ============================================ */

/* ad-header-1: Top banner - below menu/logo */
.ad-slot-ad-header-1 {
    background: #f9f9f9;
    padding: 10px 0;
    margin: 0;
    border-bottom: 1px solid #e5e5e5;
}

/* Inline header container next to logo */
.header-top .header-top-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-top .logo {
    display: flex;
    align-items: center;
}

.header-inline-ad {
    flex: 1 1 auto;
    display: flex;
    justify-content: flex-end;
}

.header-inline-ad .ad-slot-ad-header-1 .ad-wrapper {
    max-width: 720px;
}

.header-inline-ad img.ad-banner-image {
    width: 720px;
    height: 90px;
    object-fit: contain;
}

/* ad-header-2: Bottom leaderboard - below navigation */
.ad-slot-ad-header-2 {
    padding: 5px 0;
    margin: 0 0 20px 0;
    border-bottom: 1px solid #e5e5e5;
}

/* Two banners inline rows */
.ad-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.ad-row .ad-col {
    flex: 0 1 auto;
}

.ad-row-header-2 .ad-slot-ad-header-2 .ad-wrapper,
.ad-row-footer-1 .ad-slot-ad-footer-1 .ad-wrapper {
    max-width: 720px;
}

.ad-row-header-2 img.ad-banner-image,
.ad-row-footer-1 img.ad-banner-image {
    width: 720px;
    height: 90px;
    object-fit: contain;
}

/* ============================================
   Content Ad Positions
   ============================================ */

/* ad-content-top: Above article content */
.ad-slot-ad-content-top {
    margin: 0 0 30px 0;
    padding: 20px 0;
    border-top: 1px solid #e5e5e5;
    border-bottom: 1px solid #e5e5e5;
    background: #fafafa;
}

/* ad-content-mid: Middle of article content */
.ad-slot-ad-content-mid {
    margin: 30px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 4px;
    clear: both;
}

/* ad-content-bottom: Below article content */
.ad-slot-ad-content-bottom {
    margin: 30px 0 0 0;
    padding: 20px 0;
    border-top: 1px solid #e5e5e5;
}

/* ============================================
   Sidebar Ad Positions
   ============================================ */

/* ad-sidebar-top: Top of sidebar */
.ad-slot-ad-sidebar-top {
    margin: 0 0 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
}

/* ad-sidebar-mid: Middle of sidebar */
.ad-slot-ad-sidebar-mid {
    margin: 20px 0;
    padding: 15px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
}

/* ad-sidebar-bottom: Bottom of sidebar */
.ad-slot-ad-sidebar-bottom {
    margin: 20px 0 0 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
}

/* ============================================
   Footer Ad Positions
   ============================================ */

/* ad-footer-1: Footer banner */
.ad-slot-ad-footer-1 {
    margin: 0;
}

.ad-slot-ad-footer-1 .ad-wrapper {
    max-width: 1200px;
    margin: 0 auto;
}

/* ad-text-link: Footer text links */
.ad-slot-ad-text-link {
    background: #f8f9fa;
    padding: 15px 0;
    margin: 0;
    border-top: 1px solid #e5e5e5;
}

.ad-slot-ad-text-link .ad-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    display: block;
    white-space: nowrap;
    text-align: center;
}

.ad-text-link {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    display: inline;
    margin: 3px;
}

.ad-text-link:hover {
    color: #333;
    background: #e9ecef;
    text-decoration: none;
}

/* ============================================
   Mobile Sticky Ad
   ============================================ */

/* ad-sticky-mobile: Sticky bottom on mobile */
.ad-slot-ad-sticky-mobile {
    display: none; /* Hidden by default, shown only on mobile */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    margin: 0;
    padding: 5px 0;
}

/* Close button for sticky mobile ads */
.ad-slot-ad-sticky-mobile .ad-close {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    opacity: 0.7;
    z-index: 1;
}

.ad-slot-ad-sticky-mobile .ad-close:hover {
    opacity: 1;
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* Desktop Large (1200px+) */
@media (min-width: 1200px) {
    .ad-slot-ad-header-1,
    .ad-slot-ad-header-2 {
        min-height: 90px; /* Leaderboard 720x90 */
        width: 720px;
    }
    
    .ad-slot-ad-sidebar-top,
    .ad-slot-ad-sidebar-mid,
    .ad-slot-ad-sidebar-bottom {
        min-height: 250px; /* Medium Rectangle 300x250 */
    }
}

/* Desktop (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .ad-slot-ad-header-1 .ad-wrapper,
    .ad-slot-ad-header-2 .ad-wrapper {
        max-width: 720px; /* Leaderboard */
    }
    
    .ad-slot-ad-sidebar-top,
    .ad-slot-ad-sidebar-mid,
    .ad-slot-ad-sidebar-bottom {
        min-height: 250px; /* Medium Rectangle */
    }
}

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .ad-slot-ad-header-1,
    .ad-slot-ad-header-2 {
        padding: 5px 10px;
    }
    
    .ad-slot-ad-header-1 .ad-wrapper,
    .ad-slot-ad-header-2 .ad-wrapper {
        max-width: 720px;
    }
    
    /* Sidebar ads in single column on tablet */
    .ad-slot-ad-sidebar-top,
    .ad-slot-ad-sidebar-mid,
    .ad-slot-ad-sidebar-bottom {
        margin: 10px auto;
        max-width: 728px;
    }
    
    .ad-slot-ad-content-mid {
        margin: 10px auto;
        max-width: 728px;
    }
}

/* Mobile (up to 767px) */
@media (max-width: 767px) {
    .ad-slot {
        margin: 0px auto;
    }
    
    /* Hide ad-header-1 on mobile */
    .ad-slot-ad-header-1,
    .header-inline-ad {
        display: none !important;
    }
    
    .ad-slot-ad-header-2 {
        min-height: auto;
    }
    
    .ad-slot-ad-header-1 .ad-wrapper,
    .ad-slot-ad-header-2 .ad-wrapper {
        max-width: 320px; /* Mobile banner */
    }
    .header-inline-ad img.ad-banner-image,
    .ad-row-header-2 img.ad-banner-image,
    .ad-row-footer-1 img.ad-banner-image {
        width: 320px;
        height: auto;
    }
    .ad-row {
        flex-direction: column;
    }
    
    /* Content ads adjust to mobile */
    .ad-slot-ad-content-top,
    .ad-slot-ad-content-mid,
    .ad-slot-ad-content-bottom {
        margin: 5px 0;
        padding: 5px 10px;
    }
    
    .ad-slot-ad-content-top .ad-wrapper,
    .ad-slot-ad-content-mid .ad-wrapper,
    .ad-slot-ad-content-bottom .ad-wrapper {
        max-width: 300px;
    }
    
    /* Sidebar ads full width on mobile */
    .ad-slot-ad-sidebar-top,
    .ad-slot-ad-sidebar-mid,
    .ad-slot-ad-sidebar-bottom {
        margin: 15px 0;
        padding: 10px;
    }
    
    .ad-slot-ad-sidebar-top .ad-wrapper,
    .ad-slot-ad-sidebar-mid .ad-wrapper,
    .ad-slot-ad-sidebar-bottom .ad-wrapper {
        max-width: 300px;
    }
    
    /* Footer ad mobile optimized */
    .ad-slot-ad-footer-1 {
        padding: 0px 0;
    }
    
    .ad-slot-ad-footer-1 .ad-wrapper {
        max-width: 320px;
    }
    
    /* Text link ads mobile optimized */
    .ad-slot-ad-text-link {
        padding: 10px 0;
    }
    
    .ad-slot-ad-text-link .ad-wrapper {
        max-width: 100%;
        padding: 0 15px;
        white-space: nowrap;
    }
    
    .ad-text-link {
        font-size: 13px;
        margin: 3px;
    }
    
    /* Show sticky mobile ad on mobile only */
    .ad-slot-ad-sticky-mobile {
        display: block;
    }
    
    /* Add bottom padding to body when sticky ad is present */
    body.has-sticky-ad {
        padding-bottom: 60px;
    }
}

/* Extra Small Mobile (up to 480px) */
@media (max-width: 480px) {
    
    .ad-slot-ad-header-1 .ad-wrapper,
    .ad-slot-ad-header-2 .ad-wrapper,
    .ad-slot-ad-footer-1 .ad-wrapper {
        max-width: 300px; /* Smaller mobile banner */
    }
    
    .ad-slot-ad-content-top,
    .ad-slot-ad-content-mid,
    .ad-slot-ad-content-bottom {
        padding: 10px 5px;
    }
}

/* ============================================
   Legacy Support (Backward Compatibility)
   ============================================ */

.ad-slot-sidebar-top {
    composes: ad-slot-ad-sidebar-top;
}

.ad-slot-footer-banner {
    composes: ad-slot-ad-footer-1;
}

.ad-slot-in-article {
    composes: ad-slot-ad-content-mid;
}

/* ============================================
   Accessibility & UX Improvements
   ============================================ */

/* Label for ad content */
.ad-slot::before {
    content: '';
    display: block;
    height: 0;
    overflow: hidden;
}

.ad-slot[data-ad-position]::before {
    content: attr(data-ad-position);
    display: none; /* Hidden, but useful for debugging */
}

/* Prevent layout shift */
.ad-slot {
    transition: all 0.3s ease;
}

/* Loading state */
.ad-slot.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Error state */
.ad-slot.error {
    display: none;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .ad-slot,
    .ad-slot-ad-sticky-mobile {
        display: none !important;
    }
}


/* Desktop override to force-hide sticky mobile ad (wins over vendor inline styles) */
@media (min-width: 769px) {
    .ad-slot-ad-sticky-mobile {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}
