/* =====================================================================
   LFB · Новогоднее оформление
   Подключается из base_lfb.html только в сезон (см. app/templatetags/festive_tags.py).

   Важно: performance-monitor.js сайта на слабых устройствах ставит
   `* { transform: none !important }`, поэтому всё размещаем через
   left/top/margin, а transform используем только для анимаций.
   ===================================================================== */

/* ---------- Гирлянда под шапкой (canvas рисует lfb-festive.js) ---------- */
.fx-garland {
  position: absolute;
  left: 0;
  top: calc(100% - 3px);
  width: 100%;
  height: 62px;
  pointer-events: none;
  z-index: 2;
  transition: opacity .25s ease;
}
/* шапка уезжает вверх при прокрутке (modern-animations.js): гирлянда вместе с ней */
header[style*="translateY(-100%)"] .fx-garland { opacity: 0; }

/* место под свисающие лампочки: контент начинается ниже гирлянды */
main { padding-top: 24px; }
.hero { padding-top: 34px; }

/* ---------- Логотип: снег на буквах и шапка Санты ---------- */
header .brand,
header .brand a { overflow: visible; }
header .brand a,
.mobile-sidebar-header .brand a { position: relative; }
.fx-logo-snow {
  position: absolute;
  /* SVG шире и выше логотипа: viewBox -40 -110 1140 680 при логотипе 1051x545 */
  left: -3.806%;
  top: -20.183%;
  width: 108.468%;
  height: 124.771%;
  max-width: none;
  pointer-events: none;
  user-select: none;
}

/* на узких экранах .container обнуляет отступ шапки и логотип прилипает к краю:
   даём место шапке Санты */
@media (max-width: 768px) {
  header .header.container { padding-top: 7px; }
}

/* ---------- Снег (canvas) ---------- */
.fx-snow-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 45; /* под шапкой (50), над контентом */
  transition: opacity .6s ease;
}
.fx-snow-canvas.is-off { opacity: 0; }

/* Кнопка «снег вкл/выкл» */
.fx-snow-toggle {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 60;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .9);
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(255, 255, 255, .98), rgba(236, 244, 250, .92) 55%, rgba(214, 229, 240, .9));
  box-shadow:
    0 10px 26px rgba(17, 45, 70, .18),
    0 1px 2px rgba(17, 45, 70, .12),
    inset 0 -2px 6px rgba(120, 160, 195, .18);
  color: #2f6f9e;
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow .25s ease, color .25s ease;
}
.fx-snow-toggle svg { width: 22px; height: 22px; display: block; overflow: visible; }
.fx-snow-toggle .fx-flake { transform-box: fill-box; transform-origin: center; transition: transform .6s cubic-bezier(.34, 1.56, .64, 1); }
.fx-snow-toggle:hover { box-shadow: 0 14px 32px rgba(17, 45, 70, .24), 0 1px 2px rgba(17, 45, 70, .12), inset 0 -2px 6px rgba(120, 160, 195, .18); }
.fx-snow-toggle:hover .fx-flake { transform: rotate(60deg); }
.fx-snow-toggle:focus-visible { outline: 3px solid rgba(47, 111, 158, .45); outline-offset: 3px; }
.fx-snow-toggle .fx-slash { opacity: 0; transition: opacity .2s ease; }
.fx-snow-toggle.is-off { color: #94a3af; }
.fx-snow-toggle.is-off .fx-slash { opacity: 1; }

/* ---------- Снежные шапки и сосульки на карточках (SVG рисует lfb-festive.js) ---------- */
[data-fx-snow] { position: relative; }
.fx-snowcap {
  position: absolute;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(20, 45, 70, .2));
}
.fx-glint {
  fill: #fff;
  transform-box: fill-box;
  transform-origin: center;
  animation: fx-glint 4.5s ease-in-out infinite;
  filter: drop-shadow(0 0 1.5px rgba(140, 200, 255, .9));
}
@keyframes fx-glint {
  0%, 62%, 100% { opacity: 0; transform: scale(.2) rotate(0deg); }
  76%           { opacity: 1; transform: scale(1.15) rotate(45deg); }
}
.fx-drop {
  fill: #fff;
  animation: fx-drop 6s ease-in-out infinite;
}
@keyframes fx-drop {
  0%, 70%, 100% { opacity: .35; }
  80%           { opacity: 1; }
}

/* ---------- Главная: фото с еловой веткой ---------- */
.fx-frame { position: relative; }
/* ветка чуть выходит за край карточки: не даём ей создать горизонтальную прокрутку
   (clip, в отличие от hidden, не ломает position: sticky внутри) */
main { overflow-x: clip; }
.hero { overflow-x: hidden; overflow-x: clip; }
/* морозная дымка по углам фото */
.fx-frame .hero-media::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(62% 48% at 0% 100%, rgba(236, 246, 255, .62), rgba(236, 246, 255, .22) 45%, rgba(236, 246, 255, 0) 72%),
    radial-gradient(58% 46% at 100% 100%, rgba(236, 246, 255, .55), rgba(236, 246, 255, .18) 45%, rgba(236, 246, 255, 0) 72%),
    radial-gradient(40% 30% at 0% 0%, rgba(236, 246, 255, .4), rgba(236, 246, 255, 0) 70%),
    /* лёгкий зимний тон: летнее фото становится «холоднее» */
    linear-gradient(rgba(206, 226, 250, .16), rgba(206, 226, 250, .1));
}

.fx-corner {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  aspect-ratio: 440 / 300;
}
.fx-corner--hero {
  /* угол карточки в SVG: (398, 62) из 440x300; на широких карточках брендов не больше 380px */
  --fx-cw: min(64%, 380px);
  width: var(--fx-cw);
  right: 0;
  top: 0;
  margin-right: calc(var(--fx-cw) * -42 / 440);
  margin-top: calc(var(--fx-cw) * -62 / 440);
}
.fx-corner-fir {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: auto;
}

/* Ёлочные шары: висят на шнурке под веткой */
.fx-bauble {
  position: absolute;
  z-index: 1;
  display: block;
  transform-origin: 50% 0;
  animation: fx-swing 4.6s ease-in-out infinite;
}
.fx-bauble::before {
  content: "";
  display: block;
  width: 1.3px;
  margin: 0 auto;
  background: linear-gradient(#f4dd98, #b8902f);
  box-shadow: 0 0 1px rgba(80, 55, 10, .35);
}
.fx-bauble img {
  display: block;
  width: 100%;
  height: auto;
  margin-top: -4%;
  filter: drop-shadow(0 10px 10px rgba(10, 25, 18, .35));
}
.fx-bauble--l { width: 16.5%; margin-left: -8.25%; }
.fx-bauble--m { width: 12.5%; margin-left: -6.25%; }
.fx-bauble--s { width: 10%;   margin-left: -5%; }
.fx-bauble--l::before { padding-top: 46%; }
.fx-bauble--m::before { padding-top: 120%; }
.fx-bauble--s::before { padding-top: 62%; }
.fx-bauble:nth-of-type(2) { animation-duration: 5.4s; animation-delay: -1.6s; }
.fx-bauble:nth-of-type(3) { animation-duration: 3.9s; animation-delay: -.8s; }
@keyframes fx-swing {
  0%, 100% { transform: rotate(-3.2deg); }
  50%      { transform: rotate(3.2deg); }
}

/* Тёплые огоньки на ветке */
.fx-light {
  position: absolute;
  z-index: 3;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: radial-gradient(circle, #fffef6 0 24%, #ffe7a8 40%, rgba(255, 194, 92, .6) 58%, rgba(255, 176, 64, 0) 74%);
  box-shadow: 0 0 10px 3px rgba(255, 196, 110, .5);
  animation: fx-twinkle 3.2s ease-in-out infinite;
}
.fx-light:nth-of-type(2n) { animation-duration: 2.6s; animation-delay: -1.1s; }
.fx-light:nth-of-type(3n) { animation-duration: 3.8s; animation-delay: -2.3s; }
@keyframes fx-twinkle {
  0%, 100% { opacity: 1; }
  50%      { opacity: .45; }
}

/* ---------- Футер: веточка на карточке «Need a quote fast?» ---------- */
.footer-b2b .footer-hero { position: relative; }
.fx-corner--footer {
  /* угол карточки в SVG: (398, 62) из 440x300 */
  width: clamp(180px, 24%, 270px);
  right: 0;
  top: 0;
  margin-right: calc(clamp(180px, 24%, 270px) * -30 / 440);
  margin-top: calc(clamp(180px, 24%, 270px) * -62 / 440);
}

/* ---------- Адаптив ---------- */
@media (max-width: 980px) {
  .fx-corner--hero {
    --fx-cw: min(72%, 330px);
    margin-right: calc(var(--fx-cw) * -30 / 440);
  }
  .fx-snow-toggle { left: 12px; bottom: 12px; width: 42px; height: 42px; }
  .hero { padding-top: 30px; }
}

/* Карточки брендов на телефоне: текст начинается у самого верха, отодвигаем его под ветку с шарами */
@media (max-width: 700px) {
  .fx-frame > .bp-hero > .bp-hero-body,
  .fx-frame > .bp-index-hero { padding-top: 96px; }
}

/* Сайт на «слабых» устройствах (по его меркам сюда попадают почти все телефоны)
   ставит всем анимациям 0.1s. Для мерцания это стробоскоп, поэтому возвращаем свои длительности. */
.low-end-device .fx-bauble,
.low-end-optimized .fx-bauble { animation-duration: 4.6s !important; }
.low-end-device .fx-light,
.low-end-optimized .fx-light { animation-duration: 3.2s !important; }
.low-end-device .fx-glint,
.low-end-optimized .fx-glint { animation-duration: 4.5s !important; }
.low-end-device .fx-drop,
.low-end-optimized .fx-drop { animation-duration: 6s !important; }

/* Кто просил меньше движения: всё стоит на месте */
@media (prefers-reduced-motion: reduce) {
  .fx-bauble, .fx-light, .fx-glint, .fx-drop { animation: none !important; }
  .fx-glint { opacity: .8; transform: none; }
  .fx-snow-toggle .fx-flake { transition: none; }
}

@media print {
  .fx-garland, .fx-snow-canvas, .fx-snow-toggle, .fx-logo-snow, .fx-snowcap, .fx-corner { display: none !important; }
  .fx-frame .hero-media::before { display: none; }
}
