.winter-garland {
  display: none;
}

/* При поле от 60 px рядом с колонкой Neo хватает места для целых ламп */
@media screen and (min-width: 1520px) and (forced-colors: none) {
  .winter-garland {
    --gutter: calc((100vw - 1400px) / 2);
    --strand-width: min(calc(var(--gutter) / 2), 170px);
    /* Стекло и провод занимают около 54% ширины растра, остальное приходится на ореол */
    --photo-width: calc(var(--strand-width) * 1.86);
    /* В фотографии шириной 670 px семь ламп с шагом 440 px */
    --lamp-step: calc(var(--photo-width) * 440 / 670);
    --tile-height: calc(7 * var(--lamp-step));
    --tile-size: auto var(--tile-height);
    --tile-repeat: no-repeat round;
    --tile-position: center;
    --inset: calc((var(--gutter) - var(--strand-width)) / 2);
    position: fixed;
    inset-block: 0;
    left: var(--inset);
    width: var(--strand-width);
    display: block;
    pointer-events: none;
    user-select: none;
    z-index: 2;
    transform-origin: center top;
  }

  @supports (height: round(nearest, 12px, 5px)) {
    .winter-garland {
      /* Половина остатка в каждом конце, до четверти шага от середины свободного провода */
      --edge-offset: calc((100vh - round(nearest, 100vh, var(--lamp-step))) / 2);
      --tile-position: center var(--edge-offset);
      --tile-size: 100% var(--tile-height);
      --tile-repeat: repeat-y;
    }
  }

  .winter-garland--right {
    left: auto;
    right: var(--inset);
  }

  .winter-garland__lights {
    position: absolute;
    inset-block: 0;
    left: 50%;
    width: var(--photo-width);
    transform: translateX(-50%);
  }

  .winter-garland--right .winter-garland__lights {
    transform: translateX(-50%) rotate(180deg);
  }

  .winter-garland__lights::before,
  .winter-garland__lights::after {
    position: absolute;
    inset: 0;
    background: url("../img/girland.webp?v=5") var(--tile-position) / var(--tile-size) var(--tile-repeat);
  }

  .winter-garland__lights::before {
    content: "";
  }
}

@media screen and (min-width: 1520px) and (forced-colors: none) and (prefers-reduced-motion: no-preference) {
  .winter-garland {
    animation: neo-strand-sway 9s ease-in-out infinite alternate;
  }

  /* Даже в высоком окне свободный конец отклоняется максимум на 8 px */
  @media (min-height: 1528px) {
    .winter-garland {
      animation-name: neo-strand-sway-tall;
    }
  }

  .winter-garland--right {
    animation-duration: 10.5s;
    animation-delay: -5s;
  }

  .winter-garland__lights::before {
    animation: neo-lamp-breathe 5.6s ease-in-out infinite alternate;
  }

  /* Второй слой подсвечивает группы ламп в другой фазе, маска повторяется в шаг рисунка */
  .winter-garland__lights::after {
    content: "";
    mask: repeating-linear-gradient(to bottom, transparent 0 3%, #000 5% 9%, transparent 11% 28.5714%)
      var(--tile-position) / 100% var(--tile-height) var(--tile-repeat);
    filter: brightness(1.28);
    animation: neo-lamp-glow 4.3s -2.5s ease-in-out infinite alternate;
  }

  .winter-garland--right .winter-garland__lights::before {
    animation-delay: -3.4s;
  }

  .winter-garland--right .winter-garland__lights::after {
    animation-delay: -6s;
  }
}

@keyframes neo-strand-sway {
  from { transform: skewX(-.30deg); }
  to { transform: skewX(.30deg); }
}

@keyframes neo-strand-sway-tall {
  from { transform: translateX(-8px); }
  to { transform: translateX(8px); }
}

@keyframes neo-lamp-breathe {
  from { opacity: .78; }
  to { opacity: .98; }
}

@keyframes neo-lamp-glow {
  from { opacity: .06; }
  to { opacity: .82; }
}
