/*
 * Новогодняя гирлянда (New Year Garland 2.1).
 * Основа: https://github.com/bybelov/new-year-garland
 * MIT License, Copyright (c) 2017 Igor — см. LICENSE рядом.
 *
 * Адаптация для rosastronomy.ru:
 *  - полоса живёт под шапкой сайта и не трогает body;
 *  - на планшете/телефоне масштабируется, а не прячется;
 *  - звук включает первый клик (см. script.js), до него ничего не грузится;
 *  - качание шара — CSS-анимация, уважает prefers-reduced-motion.
 */

.ny-garland {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 115px;
    overflow: hidden;
    background: transparent;
    contain: layout paint style;
    z-index: 2;
    /* Сама полоса кликов не перехватывает: иначе она закрывает иконки шапки.
       Интерактивны только верхние части шаров — см. ::before ниже. */
    pointer-events: none;
    --ny-hit-bottom: 41px;
}

/* Полоса на всех ширинах absolute в самом верху, а шапка сдвинута вниз так,
   чтобы её верхняя кромка зашла под ветки: 115px полосы − 40px нахлёста = 75px. */
body.ny-theme .main-header {
    margin-top: 75px;
}

/* В print-макете нет шапки: полоса встаёт в поток и не наезжает на документ. */
.ny-print .ny-garland {
    position: relative;
}

/* Layout без шапки (оплата): на десктопе и планшете main без отступа —
   фоновая картинка идёт под полосу. На телефоне оставляем небольшой отступ. */
@media screen and (max-width: 767.98px) {
    body.ny-no-menu main { margin-top: 43px; }
}

/* Если куки приняты (баннера нет), на десктопе чуть приподнимаем полосу и
   обрезаем её пустой низ: высота 102px = низ самого нижнего шара, поэтому
   после шаров не остаётся пустой полосы, а верх уходит за край экрана на 13px. */
@media screen and (min-width: 1200px) {
    body.ny-no-menu:not(.ny-cookie-visible) .ny-garland {
        top: -13px;
        height: 102px;
    }
}

.ny-garland .b-head-decor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 115px;
    overflow: hidden;
    background: url(balls/b-head-decor_newyear.png) repeat-x 0 0;
    -webkit-transform: scale(1);
    transform: scale(1);
    -webkit-transform-origin: top left;
    transform-origin: top left;
    pointer-events: none;
}

.ny-garland .b-head-decor__inner {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 373px;
    height: 115px;
}

.ny-garland .b-head-decor__inner_n2 { left: 373px; }
.ny-garland .b-head-decor__inner_n3 { left: 746px; }
.ny-garland .b-head-decor__inner_n4 { left: 1119px; }
.ny-garland .b-head-decor__inner_n5 { left: 1492px; }
.ny-garland .b-head-decor__inner_n6 { left: 1865px; }
.ny-garland .b-head-decor__inner_n7 { left: 2238px; }

.ny-garland .b-ball {
    position: absolute;
    pointer-events: none;
    cursor: default;
    touch-action: manipulation;
}

/* Веточки-вставки (b-ball_i*) — только фон, кликать по ним не нужно. */
.ny-garland .b-ball:not([data-note]) {
    pointer-events: none;
    cursor: default;
}

/* Кликабельная зона шара — только выше шапки. Нижний резерв задан в координатах
   полосы (она масштабируется): 41px на десктопе, 42px на планшете, 44px на
   телефоне. Это ровно та полоса, которая наезжает на шапку, — её отдаём меню. */
.ny-garland .b-ball[data-note]::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--ny-hit-bottom, 41px);
    z-index: 1;
    pointer-events: auto;
    cursor: pointer;
}

.ny-garland .b-ball_n1 { top: 0; left: 3px; width: 59px; height: 83px; }
.ny-garland .b-ball_n2 { top: -19px; left: 51px; width: 55px; height: 70px; }
.ny-garland .b-ball_n3 { top: 9px; left: 88px; width: 49px; height: 67px; }
.ny-garland .b-ball_n4 { top: 0; left: 133px; width: 57px; height: 102px; }
.ny-garland .b-ball_n5 { top: 0; left: 166px; width: 49px; height: 57px; }
.ny-garland .b-ball_n6 { top: 6px; left: 200px; width: 54px; height: 70px; }
.ny-garland .b-ball_n7 { top: 0; left: 240px; width: 56px; height: 67px; }
.ny-garland .b-ball_n8 { top: 0; left: 283px; width: 54px; height: 53px; }
.ny-garland .b-ball_n9 { top: 10px; left: 321px; width: 49px; height: 66px; }

.ny-garland .b-ball_n1 .b-ball__i { background: url(balls/b-ball_n1.png) no-repeat; }
.ny-garland .b-ball_n2 .b-ball__i { background: url(balls/b-ball_n2.png) no-repeat; }
.ny-garland .b-ball_n3 .b-ball__i { background: url(balls/b-ball_n3.png) no-repeat; }
.ny-garland .b-ball_n4 .b-ball__i { background: url(balls/b-ball_n4.png) no-repeat; }
.ny-garland .b-ball_n5 .b-ball__i { background: url(balls/b-ball_n5.png) no-repeat; }
.ny-garland .b-ball_n6 .b-ball__i { background: url(balls/b-ball_n6.png) no-repeat; }
.ny-garland .b-ball_n7 .b-ball__i { background: url(balls/b-ball_n7.png) no-repeat; }
.ny-garland .b-ball_n8 .b-ball__i { background: url(balls/b-ball_n8.png) no-repeat; }
.ny-garland .b-ball_n9 .b-ball__i { background: url(balls/b-ball_n9.png) no-repeat; }

.ny-garland .b-ball_i1 { top: 0; left: 0; width: 25px; height: 71px; background: url(balls/b-ball_i1.png) no-repeat; }
.ny-garland .b-ball_i2 { top: 0; left: 25px; width: 61px; height: 27px; background: url(balls/b-ball_i2.png) no-repeat; }
.ny-garland .b-ball_i3 { top: 0; left: 176px; width: 29px; height: 31px; background: url(balls/b-ball_i3.png) no-repeat; }
.ny-garland .b-ball_i4 { top: 0; left: 205px; width: 50px; height: 51px; background: url(balls/b-ball_i4.png) no-repeat; }
.ny-garland .b-ball_i5 { top: 0; left: 289px; width: 78px; height: 28px; background: url(balls/b-ball_i5.png) no-repeat; }
.ny-garland .b-ball_i6 { top: 0; left: 367px; width: 6px; height: 69px; background: url(balls/b-ball_i6.png) no-repeat; }

.ny-garland .b-ball__i {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-transform-origin: 50% 0;
    transform-origin: 50% 0;
    -webkit-transition: -webkit-transform .3s ease-in-out;
    transition: transform .3s ease-in-out;
    pointer-events: none;
}

@keyframes ny-garland-swing {
    0%   { transform: rotate(0deg); }
    20%  { transform: rotate(-9deg); }
    45%  { transform: rotate(9deg); }
    70%  { transform: rotate(-4deg); }
    100% { transform: rotate(0deg); }
}

.ny-garland .b-ball.is-swinging .b-ball__i {
    -webkit-animation: ny-garland-swing 1.05s ease-in-out;
    animation: ny-garland-swing 1.05s ease-in-out;
    will-change: transform;
}

/* Кнопка звука: до первого клика это подсказка «включить», после — выключатель. */
.ny-garland .ny-sound {
    position: absolute;
    right: 12px;
    bottom: 10px;
    z-index: 3;
    display: -webkit-inline-box;
    display: -ms-inline-flexbox;
    display: inline-flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid rgba(24, 35, 52, .18);
    border-radius: 999px;
    background: rgba(255, 255, 255, .94);
    color: #182334;
    font: 600 12px/1 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    white-space: nowrap;
    cursor: pointer;
    -webkit-box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.ny-garland .ny-sound[hidden] { display: none; }
.ny-garland .ny-sound:hover { background: #fff; }
.ny-garland .ny-sound:focus-visible {
    outline: 2px solid #182334;
    outline-offset: 2px;
}

.ny-garland .ny-sound__icon {
    width: 16px;
    height: 16px;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    fill: currentColor;
}

.ny-garland .ny-sound__wave,
.ny-garland .ny-sound__slash {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.ny-garland .ny-sound[aria-pressed="false"] .ny-sound__wave { display: none; }
.ny-garland .ny-sound[aria-pressed="true"] .ny-sound__slash { display: none; }

@media (max-width: 1199.98px) {
    .ny-garland { height: 92px; --ny-hit-bottom: 42px; }
    body.ny-theme .main-header { margin-top: 60px; } /* 92 − 32 нахлёста */
    .ny-garland .b-head-decor {
        width: 125%;
        -webkit-transform: scale(.8);
        transform: scale(.8);
    }
}

@media (max-width: 767.98px) {
    .ny-garland { height: 67px; --ny-hit-bottom: 44px; }
    body.ny-theme .main-header { margin-top: 43px; } /* 67 − 24 нахлёста: меню заметно под гирляндой */
    .ny-garland .b-head-decor {
        width: 172.4138%; /* 100 / 0.58 */
        -webkit-transform: scale(.58);
        transform: scale(.58);
    }

    .ny-garland .ny-sound {
        right: 8px;
        bottom: 6px;
        padding: 5px 8px;
        font-size: 11px;
    }
}

@media (max-width: 359.98px) {
    .ny-garland .ny-sound { padding: 6px; border-radius: 50%; }
    .ny-garland .ny-sound__label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ny-garland .b-ball__i { transition: none; }
    .ny-garland .b-ball.is-swinging .b-ball__i { animation: none; }
}

/* WebP-версии тех же картинок: современные браузеры берут .webp,
   старые — .png из правил выше. Отдельные файлы, ничего не ломается. */
.ny-garland .b-head-decor {
    background-image: image-set(
        url(balls/b-head-decor_newyear.webp) type("image/webp"),
        url(balls/b-head-decor_newyear.png) type("image/png")
    );
}
.ny-garland .b-ball_n1 .b-ball__i {
    background-image: image-set(
        url(balls/b-ball_n1.webp) type("image/webp"),
        url(balls/b-ball_n1.png) type("image/png")
    );
}
.ny-garland .b-ball_n2 .b-ball__i {
    background-image: image-set(
        url(balls/b-ball_n2.webp) type("image/webp"),
        url(balls/b-ball_n2.png) type("image/png")
    );
}
.ny-garland .b-ball_n3 .b-ball__i {
    background-image: image-set(
        url(balls/b-ball_n3.webp) type("image/webp"),
        url(balls/b-ball_n3.png) type("image/png")
    );
}
.ny-garland .b-ball_n4 .b-ball__i {
    background-image: image-set(
        url(balls/b-ball_n4.webp) type("image/webp"),
        url(balls/b-ball_n4.png) type("image/png")
    );
}
.ny-garland .b-ball_n5 .b-ball__i {
    background-image: image-set(
        url(balls/b-ball_n5.webp) type("image/webp"),
        url(balls/b-ball_n5.png) type("image/png")
    );
}
.ny-garland .b-ball_n6 .b-ball__i {
    background-image: image-set(
        url(balls/b-ball_n6.webp) type("image/webp"),
        url(balls/b-ball_n6.png) type("image/png")
    );
}
.ny-garland .b-ball_n7 .b-ball__i {
    background-image: image-set(
        url(balls/b-ball_n7.webp) type("image/webp"),
        url(balls/b-ball_n7.png) type("image/png")
    );
}
.ny-garland .b-ball_n8 .b-ball__i {
    background-image: image-set(
        url(balls/b-ball_n8.webp) type("image/webp"),
        url(balls/b-ball_n8.png) type("image/png")
    );
}
.ny-garland .b-ball_n9 .b-ball__i {
    background-image: image-set(
        url(balls/b-ball_n9.webp) type("image/webp"),
        url(balls/b-ball_n9.png) type("image/png")
    );
}
.ny-garland .b-ball_i1 {
    background-image: image-set(
        url(balls/b-ball_i1.webp) type("image/webp"),
        url(balls/b-ball_i1.png) type("image/png")
    );
}
.ny-garland .b-ball_i2 {
    background-image: image-set(
        url(balls/b-ball_i2.webp) type("image/webp"),
        url(balls/b-ball_i2.png) type("image/png")
    );
}
.ny-garland .b-ball_i3 {
    background-image: image-set(
        url(balls/b-ball_i3.webp) type("image/webp"),
        url(balls/b-ball_i3.png) type("image/png")
    );
}
.ny-garland .b-ball_i4 {
    background-image: image-set(
        url(balls/b-ball_i4.webp) type("image/webp"),
        url(balls/b-ball_i4.png) type("image/png")
    );
}
.ny-garland .b-ball_i5 {
    background-image: image-set(
        url(balls/b-ball_i5.webp) type("image/webp"),
        url(balls/b-ball_i5.png) type("image/png")
    );
}
.ny-garland .b-ball_i6 {
    background-image: image-set(
        url(balls/b-ball_i6.webp) type("image/webp"),
        url(balls/b-ball_i6.png) type("image/png")
    );
}

/* Пока куки-баннер виден, полоса стоит над ним, а баннер — под ней:
   JS переносит полосу в поток перед баннером и убирает отступы шапки/контента. */
body.ny-cookie-visible .ny-garland { position: relative; }
body.ny-cookie-visible .main-header { margin-top: 0; }
body.ny-cookie-visible.ny-no-menu main { margin-top: 0; }
