/**
 * Стили для рекламных блоков Яндекс РСЯ
 * Оптимизировано для темы GS
 */

/* ===================================
   БАЗОВЫЕ СТИЛИ ДЛЯ ВСЕХ РЕКЛАМНЫХ БЛОКОВ
   =================================== */

.yandex-ad-block {
    margin: 20px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: transparent;
}

.yandex-ad-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    pointer-events: none;
    z-index: 1;
}

/* Метка "Реклама" */
.yandex-ad-label {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: block;
    font-weight: 500;
}

/* ===================================
   ПОЗИЦИИ РЕКЛАМНЫХ БЛОКОВ
   =================================== */

/* Реклама в шапке (горизонтальный баннер) */
.ad-header {
    margin: 0 0 20px;
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ad-header .yandex-ad-block {
    margin: 0;
}

/* Реклама в сайдбаре */
.ad-sidebar {
    margin: 20px 0;
    padding: 16px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Реклама между постами в ленте */
.ad-feed {
    margin: 40px 0;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

/* Реклама в конце поста */
.ad-post-end {
    margin: 40px 0 20px;
    padding: 24px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
}

/* Реклама в футере */
.ad-footer {
    margin: 20px 0;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    text-align: center;
}

/* ===================================
   РАЗМЕРЫ БЛОКОВ
   =================================== */

/* Стандартные размеры РСЯ */
.ad-240x400 { width: 240px; height: 400px; margin: 0 auto; }
.ad-300x250 { width: 300px; height: 250px; margin: 0 auto; }
.ad-300x600 { width: 300px; height: 600px; margin: 0 auto; }
.ad-320x100 { width: 320px; height: 100px; margin: 0 auto; }
.ad-728x90 { width: 728px; height: 90px; margin: 0 auto; }
.ad-970x250 { width: 970px; height: 250px; margin: 0 auto; }

/* Адаптивные блоки */
.ad-adaptive {
    width: 100%;
    min-height: 200px;
}

/* Специальные размеры */
.ad-100\% {
    width: 100%;
    height: auto;
    min-height: 150px;
}

.ad-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.8);
    display: none;
}

.ad-interscroller {
    width: 100%;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.ad-floor {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 150px;
    z-index: 1000;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

/* ===================================
   ТЕМНАЯ ТЕМА
   =================================== */

body.dark-theme .ad-header,
body.dark-theme .ad-sidebar,
body.dark-theme .ad-feed,
body.dark-theme .ad-post-end,
body.dark-theme .ad-footer {
    background: var(--dark-bg-secondary);
    border-color: var(--dark-border-color);
}

body.dark-theme .yandex-ad-label {
    color: var(--dark-text-tertiary);
}

/* ===================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   =================================== */

@media (max-width: 768px) {
    .ad-header,
    .ad-sidebar,
    .ad-feed,
    .ad-post-end {
        margin: 16px 0;
        padding: 16px;
        border-radius: 8px;
    }
    
    /* Скрываем большие баннеры на мобильных */
    .ad-728x90,
    .ad-970x250 {
        display: none;
    }
    
    /* Мобильные блоки показываем только на мобильных */
    .ad-mobile-header,
    .ad-mobile-footer-1,
    .ad-mobile-footer-2,
    .ad-mobile-middle-1,
    .ad-mobile-middle-2 {
        display: block;
        margin: 10px 0;
        padding: 8px;
        background: var(--bg-secondary);
        border-radius: 6px;
        text-align: center;
    }
    
    /* Специальные стили для мобильных позиций */
    .ad-mobile-header {
        position: sticky;
        top: 0;
        z-index: 100;
        margin-bottom: 20px;
    }
    
    .ad-mobile-footer-1,
    .ad-mobile-footer-2 {
        margin-top: 20px;
    }
    
    /* Адаптивные размеры для мобильных */
    .ad-300x250,
    .ad-300x600 {
        width: 100%;
        max-width: 300px;
        height: auto;
        min-height: 200px;
    }
    
    .ad-240x400 {
        width: 100%;
        max-width: 240px;
        height: auto;
        min-height: 300px;
    }
    
    .ad-320x100 {
        width: 100%;
        max-width: 320px;
        height: 100px;
    }
    
    /* Floor Ad на мобильных */
    .ad-floor {
        max-height: 100px;
        padding: 8px;
    }
}

/* Скрываем мобильные блоки на десктопе */
@media (min-width: 769px) {
    .ad-mobile-header,
    .ad-mobile-footer-1,
    .ad-mobile-footer-2,
    .ad-mobile-middle-1,
    .ad-mobile-middle-2 {
        display: none;
    }
}

@media (max-width: 480px) {
    .ad-sidebar {
        margin: 12px -16px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .yandex-ad-block {
        margin: 12px 0;
    }
}

/* ===================================
   СПЕЦИАЛЬНЫЕ ЭФФЕКТЫ
   =================================== */

/* Плавное появление рекламы */
.yandex-ad-block {
    opacity: 0;
    animation: fadeInAd 0.5s ease-in-out 0.2s forwards;
}

@keyframes fadeInAd {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hover эффект для интерактивности */
.yandex-ad-block:hover {
    transform: translateY(-1px);
    transition: transform 0.2s ease;
}

/* ===================================
   БЛОКИРОВЩИКИ РЕКЛАМЫ
   =================================== */

/* Запасной контент, если реклама заблокирована */
.ad-fallback {
    display: none;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.ad-blocked .ad-fallback {
    display: block;
}

.ad-blocked .yandex-ad-block {
    display: none;
}

/* ===================================
   LAZY LOADING
   =================================== */

.yandex-ad-block[data-lazy="true"] {
    min-height: 200px;
    background: var(--bg-secondary);
    position: relative;
}

.yandex-ad-block[data-lazy="true"]::before {
    content: "Загрузка рекламы...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-tertiary);
    font-size: 12px;
}