/*
 * Всплывающие окна (js/popup.js) — вид окон Fancybox 5, которыми
 * пользовался прежний сайт: тёмное затемнение, белое окно формы
 * с крестиком над правым верхним углом, фото и видео на всю высоту,
 * стрелки по бокам и счётчик слева вверху. Классы — те же, что
 * у Fancybox, поэтому правила старого main.css для них работают.
 */
html.with-fancybox {
  overflow: hidden;
}

.fancybox__container {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  color: #f8f8f8;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.fancybox__backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(24, 24, 27, 0.98);
  animation: pd-fade-in 0.2s ease;
}

.fancybox__toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  padding: 8px;
  pointer-events: none;
}

.fancybox__toolbar__column {
  display: flex;
  align-items: center;
  pointer-events: auto;
}

.fancybox__counter {
  padding: 0 10px;
  font-size: 17px;
  line-height: 1;
  color: rgba(248, 248, 248, 0.9);
  font-variant-numeric: tabular-nums;
}

.fancybox__carousel {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.fancybox__viewport,
.fancybox__track {
  display: flex;
  width: 100%;
  height: 100%;
}

.fancybox__slide {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 64px 8px;
  overflow: auto;
  overscroll-behavior: contain;
}

.fancybox__slide::before,
.fancybox__slide::after {
  content: "";
  flex: 0 0 0;
  margin: auto;
}

.fancybox__content {
  position: relative;
  z-index: 20;
  align-self: center;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  margin: 0;
  padding: 2rem;
  color: #374151;
  background: #fff;
  cursor: default;
  animation: pd-zoom-in 0.25s ease;
}

.fancybox__slide.has-image .fancybox__content {
  padding: 0;
  background: transparent;
  max-height: 100%;
}

.fancybox__image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 128px);
  object-fit: contain;
}

.fancybox__slide.has-iframe .fancybox__content {
  width: calc(100% - 120px);
  height: 90%;
  padding: 0;
  background: #000;
}

.fancybox__iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

.f-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 4px;
  color: rgba(248, 248, 248, 0.9);
  background: rgba(24, 24, 27, 0.65);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.f-button:hover {
  color: #fff;
  background: rgba(70, 70, 73, 0.65);
}

.f-button svg {
  width: 22px;
  height: 22px;
  pointer-events: none;
}

/* Крестик формы — над окном справа, как у Fancybox для блока со страницы. */
.fancybox__content > .f-button.is-close-btn {
  position: absolute;
  top: -38px;
  right: 0;
  width: 34px;
  height: 34px;
  background: transparent;
  opacity: 0.75;
}

.fancybox__content > .f-button.is-close-btn:hover {
  opacity: 1;
}

.fancybox__nav .f-button.is-arrow {
  position: absolute;
  top: 50%;
  z-index: 30;
  width: 50px;
  height: 50px;
  margin-top: -25px;
  border-radius: 50%;
}

.fancybox__nav .is-prev {
  left: 15px;
}

.fancybox__nav .is-next {
  right: 15px;
}

@media (max-width: 767px) {
  .fancybox__slide {
    padding: 48px 4px;
  }

  .fancybox__slide.has-iframe .fancybox__content {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .fancybox__nav .f-button.is-arrow {
    width: 40px;
    height: 40px;
    margin-top: -20px;
  }

  .fancybox__nav .is-prev {
    left: 4px;
  }

  .fancybox__nav .is-next {
    right: 4px;
  }
}

@keyframes pd-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pd-zoom-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .fancybox__backdrop,
  .fancybox__content {
    animation: none;
  }
}
