/* ============================================================
   RUNO — banner_top.css (шаблон edu2)
   Баннер из ИБ107 (banner_top) выводится НАД новой шапкой
   .r42-global-header (см. local/templates/edu2/header.php).
   Образец: bitrix/templates/runo-mob/css/banner_top.css.

   Задача: баннер закреплён вверху вьюпорта (position: fixed),
   шапка .r42-global-header (position: sticky, top: 0, z-index: 1200
   в common.css) начинается ПОД баннером и не перекрывает его.

   Высота баннера — 60px (см. требование шаблона). Она вынесена
   в CSS-переменную --r42-banner-top-height, чтобы при необходимости
   менять её в одном месте.
   ============================================================ */

:root {
    --r42-banner-top-height: 60px;
    /* Выше шапки: в common.css у .r42-global-header z-index: 1200. */
    --r42-banner-top-z-index: 1300;
}

/* Скрываем кнопку закрытия виджета обратного отсчёта (как в runo-mob). */
.eapps-countdown-timer .eapps-countdown-timer-bar-close {
    display: none !important;
}

/* ------------------------------------------------------------
   1. Контейнер баннера над шапкой.
   В header.php используется класс .r42-banner-top1, при этом
   исторически в CSS был .r42-banner-top — поддерживаем оба.
   Контейнер фиксируем, чтобы он не уезжал при прокрутке.
   ------------------------------------------------------------ */
.r42-banner-top1,
.r42-banner-top {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: var(--r42-banner-top-height) !important;
    min-height: var(--r42-banner-top-height) !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    z-index: var(--r42-banner-top-z-index) !important;
}

/* ------------------------------------------------------------
   2. Сам виджет Elfsight.
   Elfsight может вставлять root-элемент как прямым потомком body,
   так и внутрь .r42-banner-top1. Фиксируем оба варианта.
   ------------------------------------------------------------ */
body > .eapps-countdown-timer,
.eapps-countdown-timer-position-top-bar-static {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: var(--r42-banner-top-height) !important;
    min-height: var(--r42-banner-top-height) !important;
    max-height: var(--r42-banner-top-height) !important;
    overflow: hidden !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    z-index: var(--r42-banner-top-z-index) !important;
}

/* Прямые потомки контейнера (виджет обратного отсчёта и т.п.) — ровно 60px. */
.r42-banner-top1 > *,
.r42-banner-top > * {
    height: var(--r42-banner-top-height) !important;
    min-height: var(--r42-banner-top-height) !important;
    max-height: var(--r42-banner-top-height) !important;
    box-sizing: border-box !important;
}

/* Внутренние элементы виджета — ровно 60px на всех разрешениях. */
.r42-banner-top1 .eapps-countdown-timer,
.r42-banner-top1 .eapps-countdown-timer-inner,
.r42-banner-top .eapps-countdown-timer,
.r42-banner-top .eapps-countdown-timer-inner,
body > .eapps-countdown-timer .eapps-countdown-timer-inner,
.eapps-countdown-timer-position-top-bar-static .eapps-countdown-timer-inner {
    height: var(--r42-banner-top-height) !important;
    min-height: var(--r42-banner-top-height) !important;
    max-height: var(--r42-banner-top-height) !important;
    box-sizing: border-box !important;
}

/* ------------------------------------------------------------
   3. Шапка сайта.
   В common.css: .r42-global-header { position: sticky; top: 0;
   z-index: 1200; }. Сдвигаем sticky-шапку вниз на высоту баннера
   и резервируем это место в потоке через margin-top, чтобы шапка
   начиналась строго ПОД баннером и не перекрывалась им.
   Селектор body > .r42-global-header имеет большую специфичность,
   чем .r42-global-header, и banner_top.css подключается после
   common.css — правило гарантированно применяется.
   ------------------------------------------------------------ */
body > .r42-global-header {
    top: var(--r42-banner-top-height) !important;
    margin-top: var(--r42-banner-top-height) !important;
}

/* ------------------------------------------------------------
   4. Закрытие баннера.
   Кнопка .eapps-countdown-timer-bar-close скрыта (см. п.1),
   поэтому штатного закрытия нет. Тем не менее, если Elfsight
   скроет/удалит root-элемент (display:none / hidden), снимаем
   отступ у шапки через :has(). Это best-effort: если виджет
   удаляется из DOM полностью, CSS не может отреагировать на
   удаление (см. ограничения в отчёте).
   ------------------------------------------------------------ */
body:has(.eapps-countdown-timer[style*="display: none"]) > .r42-global-header,
body:has(.eapps-countdown-timer[hidden]) > .r42-global-header {
    top: 0 !important;
    margin-top: 0 !important;
}

/* Убираем подчёркивание ссылки виджета при наведении (как в runo-mob). */
a.eapps-countdown-timer-inner:hover {
    border-bottom: 0;
}

/* ============================================================
   5. Локальный баннер-таймер (ИБ116).
   Разметка: local/templates/edu2/header.php (.r42-banner-local),
   отсчёт: local/templates/edu2/js/banner_top.js.
   Цвета/размеры/фон приходят из свойств ИБ116 через CSS-переменные
   --r42-banner-* (см. inline style контейнера).
   ============================================================ */
.r42-banner-local {
    background-color: var(--r42-banner-bg-color, transparent);
    background-image: var(--r42-banner-bg-desktop, none);
    background-size: auto 100%;
    background-position: center;
    background-repeat: no-repeat;
    color: #000;
}

.r42-banner-local__inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.r42-banner-local__link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.r42-banner-local__link:hover {
    border-bottom: 0;
}

.r42-banner-local__text {
    font-size: 18px;
    line-height: 1.2;
    white-space: nowrap;
}

.r42-banner-local__timer {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.r42-banner-local__unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.r42-banner-local__value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: 3px 6px;
    border-radius: 3px;
    background-color: var(--r42-banner-timer-bg, #000);
    color: var(--r42-banner-timer-color, #fff);
    font-size: var(--r42-banner-timer-size, 18px);
    line-height: 1.2;
    font-weight: 700;
    box-sizing: border-box;
}

.r42-banner-local__label {
    font-size: 11px;
    line-height: 1.1;
    color: #000;
}

.r42-banner-local__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 32px;
    border-radius: 2px;
    background-color: var(--r42-banner-btn-bg, #000);
    color: var(--r42-banner-btn-color, #fff);
    font-size: var(--r42-banner-btn-size, 12px);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.r42-banner-local__btn:hover {
    opacity: .9;
}

@media (max-width: 1199px) {
    /* На мобильных баннер выше: текст сверху, таймер под ним, всё по центру. */
    :root {
        --r42-banner-top-height: 90px;
    }

    .r42-banner-local {
        background-image: var(--r42-banner-bg-mobile, var(--r42-banner-bg-desktop, none));
    }

    .r42-banner-local__inner {
        flex-direction: column;
        gap: 4px;
        padding: 6px 10px;
    }

    .r42-banner-local__link {
        flex-direction: column;
        gap: 4px;
    }

    .r42-banner-local__text,
    .r42-banner-local__text * {
        font-size: 13px !important;
        line-height: 1.15 !important;
    }

    .r42-banner-local__text {
        white-space: normal;
        text-align: center;
    }

    .r42-banner-local__timer {
        gap: 6px;
    }

    .r42-banner-local__value {
        min-width: 26px;
        font-size: 14px;
    }

    .r42-banner-local__label {
        font-size: 9px;
    }

    /* На мобильных кнопка скрыта — весь баннер кликабелен (BANNER_LINK). */
    .r42-banner-local__btn {
        display: none;
    }
}
