/**
 * CS2Bet Advertisement Styles
 * Responsive advertisement display with full-height skyscrapers,
 * mobile top banner, sidebar 1:1, and in-content banners.
 */

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

.cs2bet-ad {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.cs2bet-ad-link {
    display: block;
    line-height: 0;
    transition: opacity 0.2s;
}

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

.cs2bet-ad-img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Mobile/Desktop image switching */
.cs2bet-ad-desktop {
    display: block;
}

.cs2bet-ad-mobile {
    display: none;
}

@media (max-width: 767px) {
    .cs2bet-ad-desktop {
        display: none;
    }

    .cs2bet-ad-mobile {
        display: block;
    }
}

/* ============================================
   Skyscraper Ads — Full Viewport Height (Desktop)
   ============================================ */

/* Skyscraper offset = header + subheader sticky stack.
   JS sets --sky-top on scroll for pixel-perfect positioning. */
:root {
    --sky-top: calc(var(--header-h, 96px) + var(--subheader-h, 48px));
}

.cs2bet-skyscrapers-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 100;
}

.cs2bet-skyscraper {
    position: fixed;
    top: calc(var(--sky-top) + 12px);
    bottom: 12px;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* Anchor to content edges — never overlap the 1240px container.
   Left skyscraper sits to the left of content, right sits to the right. */
.cs2bet-skyscraper-left {
    right: calc(50% + var(--container, 1240px) / 2 + 30px);
    left: 8px;
}

.cs2bet-skyscraper-right {
    left: calc(50% + var(--container, 1240px) / 2 + 30px);
    right: 8px;
}

.skyscraper-item {
    background: transparent;
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.skyscraper-item .cs2bet-ad-link {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* 320x1200 native aspect ratio — always show full image, never crop.
   Height fills available space, width auto-scales from aspect ratio. */
.skyscraper-item img.cs2bet-ad-desktop {
    max-height: 100%;
    width: auto;
    aspect-ratio: 320 / 1200;
    object-fit: contain;
    border-radius: 8px;
}

.cs2bet-skyscraper-right .skyscraper-item img.cs2bet-ad-desktop {
    /* identical styling */
}

/* Hide skyscrapers when there's not enough room outside the content area.
   Each side needs at least ~120px for a visible skyscraper.
   1240px container + 40px padding + 2×30px gap + 2×120px min ad = 1580px.
   Use 1580px breakpoint — below this, show mobile top banner instead. */
@media (max-width: 1579px) {
    .cs2bet-skyscrapers-container {
        display: none;
    }
}

/* ============================================
   Mobile Top Banner (Skyscraper Fallback)
   Shows on mobile/tablet as horizontal banner
   at the top of every page.
   ============================================ */

/* Mobile top banner — only rendered on <1580px */
.cs2bet-mobile-top-banner {
    display: none;
    width: 100%;
    background: var(--bg-card, #0d0d14);
    border-bottom: 1px solid var(--border, #1a1a2e);
    overflow: hidden;
}
.cs2bet-mobile-top-banner .mobile-top-ad {
    width: 100%;
}
.cs2bet-mobile-top-banner .cs2bet-ad-link {
    display: block;
    width: 100%;
}
.cs2bet-mobile-top-banner .cs2bet-mobile-banner-img {
    display: block;
    width: 100%;
    max-height: 140px;
    object-fit: cover;
    object-position: center;
}

/* Show mobile banner when desktop skyscrapers are hidden */
@media (max-width: 1579px) {
    .cs2bet-mobile-top-banner {
        display: block;
    }
}

/* ============================================
   Banner Ads (Full App Width)
   Used on predictions, news, and between content
   ============================================ */

.cs2bet-banner-container {
    text-align: center;
    padding: 15px;
    background: var(--bg-card, #0d0d14);
}

.cs2bet-banner-banner_top {
    margin-top: 0;
}

.cs2bet-banner-banner_middle {
    margin: 20px 0;
}

.cs2bet-banner-banner_bottom {
    margin-bottom: 0;
}

.cs2bet-banner-container .cs2bet-ad-img {
    max-width: 728px;
    width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 4px;
}

/* Full-width in-feed banner (predictions, news) */
.cs2bet-banner-infeed {
    width: 100%;
    margin: 24px 0;
    padding: 12px 0;
    background: transparent;
    text-align: center;
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}

.cs2bet-banner-infeed .cs2bet-ad-img.cs2bet-ad-desktop {
    max-width: 100%;
    width: 100%;
    height: auto;
    border-radius: var(--radius-md, 8px);
}

/* Mobile: show 1:1 square instead of wide banner */
@media (max-width: 767px) {
    .cs2bet-banner-container {
        padding: 10px;
    }

    .cs2bet-banner-container .cs2bet-ad-img {
        max-width: 100%;
    }

    .cs2bet-banner-infeed .cs2bet-ad-img.cs2bet-ad-mobile {
        max-width: 300px;
        margin: 0 auto;
        border-radius: var(--radius-md, 8px);
    }
}

/* ============================================
   Sidebar Ads (1:1 Square Format)
   ============================================ */

.cs2bet-sidebar-ads {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 15px 0;
}

.sidebar-ad-item {
    background: var(--bg-card, #1a1a2e);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}

.sidebar-ad-item img {
    width: 100%;
    max-width: 300px;
    height: auto;
    display: block;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

/* Sticky sidebar ad */
.cs2bet-sidebar-ads.sticky {
    position: sticky;
    top: 20px;
}

/* Mobile: sidebar ads stay 1:1 square centered */
@media (max-width: 767px) {
    .cs2bet-sidebar-ads {
        align-items: center;
    }

    .sidebar-ad-item {
        max-width: 300px;
        width: 100%;
    }
}

/* ============================================
   In-Content Ads
   ============================================ */

.cs2bet-in-content-ad {
    margin: 30px 0;
    text-align: center;
    clear: both;
}

.cs2bet-in-content-ad .cs2bet-ad-img {
    max-width: 728px;
    width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 4px;
}

@media (max-width: 767px) {
    .cs2bet-in-content-ad {
        margin: 20px -15px;
    }

    .cs2bet-in-content-ad .cs2bet-ad-img {
        border-radius: 0;
    }
}

/* ============================================
   Ad Labels (Optional)
   ============================================ */

.cs2bet-ad-label {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.6);
    color: #999;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 1;
}

/* ============================================
   Loading States
   ============================================ */

.cs2bet-ad.loading {
    min-height: 100px;
    background: linear-gradient(90deg, #1a1a2e 25%, #242442 50%, #1a1a2e 75%);
    background-size: 200% 100%;
    animation: cs2bet-ad-shimmer 1.5s infinite;
}

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

/* ============================================
   Dark Theme Compatibility
   ============================================ */

.cs2bet-ad {
    color: #fff;
}

.cs2bet-banner-container,
.sidebar-ad-item {
    background: var(--bg-card, #0d0d14);
}

/* ============================================
   Animation Effects
   ============================================ */

.cs2bet-ad {
    opacity: 0;
    animation: cs2bet-ad-fadein 0.3s ease forwards;
}

@keyframes cs2bet-ad-fadein {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@media print {
    .cs2bet-ad,
    .cs2bet-skyscrapers-container,
    .cs2bet-mobile-top-banner,
    .cs2bet-banner-container,
    .cs2bet-sidebar-ads,
    .cs2bet-in-content-ad {
        display: none !important;
    }
}

/* ============================================
   High Contrast / Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .cs2bet-ad {
        animation: none;
        opacity: 1;
    }

    .cs2bet-ad.loading {
        animation: none;
    }
}

/* ============================================
   Specific Ad Size Classes
   ============================================ */

/* Skyscraper: 320x1200 aspect ratio, contained (never cropped) */
.cs2bet-ad-skyscraper_left img,
.cs2bet-ad-skyscraper_right img {
    aspect-ratio: 320 / 1200;
    object-fit: contain;
}

/* Leaderboard: 728x90 */
.cs2bet-ad-banner_top img,
.cs2bet-ad-banner_middle img,
.cs2bet-ad-banner_bottom img,
.cs2bet-ad-in_content img {
    max-width: 728px;
}

/* Medium Rectangle: 300x250 (1:1 in sidebar) */
.cs2bet-ad-sidebar img {
    max-width: 300px;
}
