/* Новогоднее оформление: гирлянда под шапкой и лёгкий снег.
   Включается флагом $winterThemeEnabled в inc/config_additional.php.
   Только тема meat74ru, узкие экраны и reduced-motion не затрагиваются. */

#ny-garland {
    position: absolute;  /* верхняя полоса 30px над шапкой и сайдбаром, уезжает с прокруткой */
    top: 0;
    left: 0;
    right: 0;
    height: 30px;
    z-index: 1000;
    pointer-events: none;
    overflow: hidden;
    background: var(--card-color, #0d0d11);   /* тот же фон, что у шапки и бокового меню */
    border-bottom: 1px solid var(--header-bottom-color, rgba(255, 255, 255, .04));
    box-sizing: border-box;
}
#ny-garland svg { position: absolute; left: 0; top: 0; }

/* ---------- Режимы подсветки (класс на #ny-garland ставит ny.js) ----------
   --i — номер лампочки, --q — случайное число 0..1 */

/* 1. Радуга: цвет бежит волной по всей гирлянде */
#ny-garland.m-rainbow .b { --c: #ff2d4f; --c2: #b3123a; animation: ny-hue 5s linear calc(var(--i) * -.07s) infinite; }
@keyframes ny-hue { to { filter: hue-rotate(360deg); } }

/* 2. Бегущий огонь: светит только «пачка» лампочек, остальные приглушены */
#ny-garland.m-chase .b { opacity: .6; animation: ny-run 2.4s linear calc(var(--i) * -.04s) infinite; }
@keyframes ny-run { 0%, 30% { opacity: 1; } 55%, 100% { opacity: .6; } }

/* 3. Дыхание: вся гирлянда плавно гаснет и разгорается */
#ny-garland.m-breathe .b { animation: ny-breathe 3.4s ease-in-out infinite; }
@keyframes ny-breathe { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }

/* 4. Искры: лампочки вспыхивают в случайном порядке */
#ny-garland.m-sparkle .b { opacity: .65; animation: ny-spark calc(1.4s + var(--q) * 2.6s) ease-out calc(var(--q) * -4s) infinite; }
@keyframes ny-spark { 0%, 70%, 100% { opacity: .65; } 78% { opacity: 1; } 90% { opacity: .8; } }

/* 5. Через одну: чётные и нечётные горят по очереди */
#ny-garland.m-alt .b { animation: ny-alt 1.4s steps(1, end) infinite; }
#ny-garland.m-alt .b:nth-of-type(even) { animation-delay: -.7s; }
@keyframes ny-alt { 0% { opacity: 1; } 50% { opacity: .55; } }

/* 6. Комета: яркая «голова» с затухающим хвостом бежит слева направо */
#ny-garland.m-comet .b { opacity: .6; animation: ny-comet 3s linear calc(var(--i) * -.035s) infinite; }
@keyframes ny-comet { 0% { opacity: 1; } 35% { opacity: .85; } 60%, 100% { opacity: .6; } }

/* Лампочка: цоколь (::before), стекло (само i), ореол (::after) */
#ny-garland .b {
    position: absolute;
    width: 8px;
    height: 12px;
    margin: 1px 0 0 -4px;
    border-radius: 50% 50% 55% 55% / 35% 35% 65% 65%;
    background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.7) 0 8%, var(--c) 30%, var(--c) 70%, var(--c2) 100%);
    transform-origin: 50% -2px;
    transform: rotate(var(--r, 0deg));
}
#ny-garland .b::before {
    content: "";
    position: absolute;
    left: 50%; top: -4px;
    width: 3px; height: 4px;
    margin-left: -1.5px;
    border-radius: 1px;
    background: #1a1e38;
}

#ny-garland .t1 { --c: #ff3b5c; --c2: #c4163a; }   /* красный */
#ny-garland .t2 { --c: #2ee59d; --c2: #12a56c; }   /* зелёный */
#ny-garland .t3 { --c: #3d8bff; --c2: #1b55d1; }   /* синий */
#ny-garland .t4 { --c: #ffd23f; --c2: #e0991a; }   /* жёлтый */
#ny-garland .t5 { --c: #b45cff; --c2: #7a24d6; }   /* фиолетовый */

/* Волна: каждая следующая лампочка загорается чуть позже предыдущей */

#ny-snow {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    #ny-garland .b { animation: none !important; opacity: .9; }
}
@media (max-width: 1000px) {
    #ny-garland { display: none; }
}

#ny-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-left: 8px;
    padding: 0;
    box-sizing: border-box;
    border-radius: 9px;
    background: #16161c;
    border: 1px solid rgba(255, 255, 255, .08);
    color: var(--accent, #5f65dc);
    cursor: pointer;
    transition: border-color .2s, color .2s;
}
#ny-toggle svg { width: 17px; height: 17px; }
#ny-toggle:hover { border-color: rgba(255, 255, 255, .2); }
#ny-toggle.is-off { color: #5d5d68; }
@media (max-width: 1000px) { #ny-toggle { display: none; } }

/* Фон: узор из новогодних и контровских значков (ёлка, подарок, шапка, прицел, граната, снежинки) */
html body {
    background-image: url("/templates/meat74ru/img/ny/pattern.svg");
    background-size: 170px 255px;
    background-repeat: repeat;
}
@media (max-width: 1000px) { html body { background-image: none; } }


/* Сдвиг всего, что прибито к верху окна, на высоту полосы */
@media (min-width: 1001px) {
    html.ny-on body { padding-top: 30px; }
    html.ny-on .left-menu,
    html.ny-on #siteChat,
    html.ny-on #siteChatRail { top: var(--ny-off, 30px); }
}
@media (max-width: 1000px) { #ny-garland { display: none; } }

/* Холст с подсветкой значков фона: под всем контентом, поверх статичного узора */
#ny-bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
@media (max-width: 1000px) { #ny-bg { display: none; } }

/* Лампочки реагируют на наведение: полоса пропускает клики, сами лампочки ловят мышь */
#ny-garland .b { pointer-events: auto; transition: transform .12s ease-out; }
#ny-garland .b.ny-hit { transform: rotate(var(--r, 0deg)) scale(1.45); }

/* Когда узор рисует canvas (он же подсвечивает значки), CSS-фон не нужен */
html.ny-bgc body { background-image: none; }

/* Новый год выключен: узор не рисуем, сдвигов нет */
html.ny-off body { background-image: none; padding-top: 0; }
