/* ==========================================================================
   ОБЩИЕ СТИЛИ (DESKTOP & GLOBAL)
   ========================================================================== */
.close.small {
  width: 28px;
  height: 28px;
  position: relative;
  cursor: pointer;
}

.close.small:before {
  content: '';
  position: absolute;
  top: 7px;
  left: 7px;
  width: 14px;
  height: 14px;
  background: url("../../img/gallery.png") right -469px no-repeat;
  opacity: .7;
}

.close.small:hover:before {
  opacity: 1;
}

.text-notice {
  padding-bottom: 1.25rem;
}

body.popup-no-scroll {
  overflow: hidden;
}

.popup {
  background: var(--popup-mask-background-color);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1006;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.popup.removing {
  opacity: 0;
}

.popup > div {
  display: flex;
  background: rgba(0, 0, 0, 0.1);
  padding: 5px;
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 5px;
}

.popup > div > div {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  max-height: 100%;
  min-height: 100%;
  background: var(--content-background-color);
  padding: 1.25rem;
  border-radius: 5px;
}

.popup > div > div div.caption {
  flex: 0 0 auto;
  color: #2b2b2b;
  font-size: 1.143em;
  font-weight: bold;
  margin-top: -5px;
  padding: 0 1.875rem 1.25rem 0;
}

/* Расположение крестика для десктопа */
.popup > div > div div.caption .close {
  right: 16px !important;
  left: auto !important;
  top: 25px !important;
  position: absolute !important;
  z-index: 9999 !important;
}

.popup > div > div div.body {
  flex: 1 1 0%;
  overflow-y: auto;
}

/* ==========================================================================
   MOBILE NATIVE BOTTOM SHEET (СМАРТФОНЫ)
   ========================================================================== */
@media screen and (max-width: 767px) {
  .popup {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    background: rgba(0, 0, 0, 0.45) !important;
    touch-action: none; /* ЖЕСТКИЙ БЛОК: Задний фон сайта больше не будет двигаться при свайпах */
  }

  /* Позиционирование шторки внизу экрана */
  .popup > div {
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    background: none !important;
    border-radius: 30px 30px 0 0 !important;    transform: translateY(100%);
    animation: slideUpSheet .26s cubic-bezier(.2,.8,.2,1) forwards;
    transition: transform .26s cubic-bezier(.2,.8,.2,1);
    will-change: transform;
    -webkit-tap-highlight-color: transparent;
    touch-action: none; /* Блокируем системный скролл страницы на обертке */
  }

  /* Класс для плавной работы Drag-n-Drop (когда палец касается шторки) */
  .popup > div.dragging {
    transition: none !important;
  }

  .popup.removing > div {
    transform: translateY(100%) !important;
    transition: transform .26s cubic-bezier(.2,.8,.2,1) !important;
  }

  .popup > div > div {
    width: 100% !important;
    border-radius: 18px 18px 0 0 !important;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom)) 16px !important;
    min-height: auto !important;
    max-height: 99vh !important;
    box-shadow: 0 -18px 48px rgba(17,24,39,.25);
    overflow: visible !important;
  }

  /* Разрешаем скроллить ТОЛЬКО внутренний контейнер шторки */
  .popup > div > div div.body {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y; /* Разрешает ТОЛЬКО вертикальную прокрутку контента */
  }

  /* Полоска-ручка сверху */
  .sheet-handle {
    width: 42px;
    height: 4px;
    background: #E5E7EB;
    border-radius: 999px;
    margin: 4px auto 16px auto;
    display: block !important;
    cursor: grab;
    touch-action: none !important; /* Блокирует прокрутку страницы при перетаскивании за ручку */
  }

  .popup > div > div div.caption {
    font-size: 1.15em !important;
    font-weight: 700 !important;
    text-align: center;
    padding: 0 40px 12px 0 !important;
    margin-top: 0 !important;
    border-bottom: 1px solid #E5E7EB;
    margin-bottom: 16px;
    color: #111827 !important;
    width: 100%;
    position: relative;
    touch-action: none !important; /* Блокирует прокрутку страницы при перетаскивании за шапку */
  }

  /* Крестик в углу шторки */
  .popup > div > div div.caption .close,
  .close.small {
    top: -4px !important;
    right: 0px !important;
    left: auto !important;
    position: absolute !important;
  }
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}