/*---------------------------------------
    Закреплённая шапка + кнопка и окно «Где купить»
-----------------------------------------*/

/* --- шапка --- */

.custom-navbar {
  transition: box-shadow .3s ease;
}

.custom-navbar.top-nav-collapse {
  box-shadow: 0 4px 18px rgba(38, 57, 73, .14);
}

/* кнопка «Где купить» в меню */

.custom-navbar .nav li.nav-buy,
.custom-navbar .nav li.nav-buy:hover,
.custom-navbar .nav li.nav-buy:focus {
  background: transparent;
}

.custom-navbar .nav li.nav-buy > a::after {
  content: "\f107";
  font-family: FontAwesome;
  display: inline-block;
  animation: nav-buy-bounce 1.6s ease-in-out infinite;
}

@keyframes nav-buy-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(4px); }
}

.custom-navbar .nav li.nav-buy > a:focus {
  outline: none;
}

.custom-navbar .nav li.nav-buy > a:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: -6px;
}

/* десктоп и планшет: флажок со стрелкой вниз, как на cycloferon.ru.
   Сама ссылка ровно в высоту шапки, острие флажка — псевдоэлемент,
   свисает поверх контента и шапку не растягивает */

@media (min-width: 768px) {
  .custom-navbar .nav li.nav-buy > a,
  .custom-navbar .nav li.nav-buy > a:hover,
  .custom-navbar .nav li.nav-buy > a:focus,
  .custom-navbar .nav li.nav-buy.active > a {
    position: relative;
    z-index: 0;
    display: block;
    height: 70px;
    margin: 0 0 0 14px;
    padding: 15px 34px 0;
    background: transparent;
    color: #ffffff;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    filter: drop-shadow(0 4px 6px rgba(38, 57, 73, .18));
  }

  .custom-navbar .nav li.nav-buy > a::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 96px;
    z-index: -1;
    background: #d10a57;
    clip-path: polygon(0 0, 100% 0, 100% 72%, 50% 100%, 0 72%);
    transition: background .3s ease;
  }

  .custom-navbar .nav li.nav-buy > a:hover::before,
  .custom-navbar .nav li.nav-buy > a:focus-visible::before {
    background: #007fb6;
  }

  .custom-navbar .nav li.nav-buy > a::after {
    display: block;
    margin-top: 4px;
    font-size: 22px;
    line-height: 16px;
  }
}

@media (min-width: 768px) and (max-width: 991px) {
  .custom-navbar .container {
    display: block !important;
  }

  .custom-navbar .nav li a {
    font-size: 11px;
    line-height: 20px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .custom-navbar .navbar-brand {
    padding-top: 0;
    padding-bottom: 0;
    height: 50px;
    display: flex;
    align-items: center;
  }

  .custom-navbar .logo-svg {
    width: 170px;
  }

  .custom-navbar .nav li.nav-buy > a,
  .custom-navbar .nav li.nav-buy > a:hover,
  .custom-navbar .nav li.nav-buy > a:focus,
  .custom-navbar .nav li.nav-buy.active > a {
    height: 50px;
    margin-left: 6px;
    padding: 7px 18px 0;
  }

  .custom-navbar .nav li.nav-buy > a::before {
    height: 70px;
  }

  .custom-navbar .nav li.nav-buy > a::after {
    margin-top: 1px;
    font-size: 18px;
    line-height: 14px;
  }
}

/* компактная шапка на телефоне: логотип слева, гамбургер справа */

@media (max-width: 767px) {
  .custom-navbar .container {
    display: block !important;
  }

  .custom-navbar .container > .navbar-header {
    margin-left: 0;
    margin-right: 0;
  }

  .custom-navbar .navbar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
  }

  .custom-navbar .navbar-header::before,
  .custom-navbar .navbar-header::after {
    display: none;
  }

  .custom-navbar .navbar-brand {
    order: 0;
    float: none;
    height: auto;
    padding: 0;
    margin: 0;
    line-height: 1;
  }

  .custom-navbar .logo-svg {
    width: auto;
    height: 26px;
    display: block;
  }

  .custom-navbar .navbar-toggle {
    order: 2;
    float: none;
    margin: 0;
  }

  .custom-navbar .navbar-collapse {
    max-height: calc(100vh - 56px);
  }

  .custom-navbar .nav li.nav-buy > a,
  .custom-navbar .nav li.nav-buy.active > a {
    background: transparent;
    color: #d10a57;
    font-weight: 600;
  }

  .custom-navbar .nav li.nav-buy > a:hover,
  .custom-navbar .nav li.nav-buy > a:focus {
    background: #d10a57;
    color: #ffffff;
  }

  .custom-navbar .nav li.nav-buy > a::after {
    content: none;
  }
}

/* мини-флажок «Где купить» в мобильной шапке */

.nav-buy-mob {
  display: none;
}

@media (max-width: 767px) {
  .custom-navbar .logo-svg {
    height: 22px;
  }

  .nav-buy-mob {
    order: 1;
    position: relative;
    z-index: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 56px;
    margin: 0 12px 0 auto;
    padding: 10px 12px 0;
    color: #ffffff !important;
    font-size: 11px;
    font-weight: 600;
    line-height: 14px;
    letter-spacing: .3px;
    text-transform: uppercase;
    white-space: nowrap;
    filter: drop-shadow(0 3px 5px rgba(38, 57, 73, .2));
    -webkit-tap-highlight-color: transparent;
  }

  .nav-buy-mob::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    z-index: -1;
    background: #d10a57;
    clip-path: polygon(0 0, 100% 0, 100% 74%, 50% 100%, 0 74%);
    transition: background .3s ease;
  }

  .nav-buy-mob::after {
    content: "\f107";
    font-family: FontAwesome;
    display: block;
    margin-top: 2px;
    font-size: 18px;
    line-height: 14px;
    animation: nav-buy-bounce 1.6s ease-in-out infinite;
  }

  .nav-buy-mob:active::before,
  .nav-buy-mob:hover::before {
    background: #007fb6;
  }

  .nav-buy-mob:focus {
    outline: none;
  }

  .nav-buy-mob:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: -5px;
  }

  /* страница не должна быть шире экрана (вирусы, карусель) —
     иначе фиксированные элементы уезжают от края */
  html,
  body {
    overflow-x: clip;
  }

  /* кнопка «Наверх» */
  .go-top {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: 44px;
    height: 44px;
    line-height: 44px;
    font-size: 24px;
    border-radius: 50%;
    background-color: rgba(209, 10, 87, .9);
    box-shadow: 0 4px 12px rgba(38, 57, 73, .25);
  }
}

@media (max-width: 374px) {
  .custom-navbar .logo-svg {
    height: 19px;
  }

  .nav-buy-mob {
    margin-right: 10px;
    padding: 10px 10px 0;
  }
}

@media (max-width: 339px) {
  .custom-navbar .logo-svg {
    height: 16px;
  }

  .nav-buy-mob {
    margin-right: 8px;
    padding: 10px 9px 0;
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-buy-mob::after {
    animation: none;
  }
}

/* --- окно «Где купить» --- */

html.buy-modal-open,
body.buy-modal-open {
  overflow: hidden;
}

body.buy-modal-open {
  padding-right: var(--buy-sbw, 0px);
}

body.buy-modal-open .navbar-fixed-top,
body.buy-modal-open .go-top {
  margin-right: var(--buy-sbw, 0px);
}

.buy-modal {
  position: fixed;
  inset: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility 0s linear .3s;
}

.buy-modal.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity .3s ease, visibility 0s linear 0s;
}

.buy-modal__overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(16, 26, 36, .6);
  cursor: pointer;
}

.buy-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: #ffffff;
  border-radius: 20px;
  padding: 40px 44px 28px;
  box-shadow: 0 24px 60px rgba(16, 26, 36, .3);
  transform: translateY(18px);
  transition: transform .3s ease;
}

.buy-modal.is-open .buy-modal__dialog {
  transform: translateY(0);
}

.buy-modal__close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #9aa6b2;
  font-size: 36px;
  line-height: 44px;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}

.buy-modal__close:hover,
.buy-modal__close:focus-visible {
  color: #d10a57;
  background: #f4f7f9;
  outline: none;
}

.buy-modal__title {
  color: #007fb6;
  font-size: 30px;
  font-weight: 600;
  text-transform: none;
  margin: 0 0 18px;
}

.buy-modal__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.buy-modal__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid #e6edf2;
}

.buy-modal__item:last-child {
  border-bottom: 0;
}

.buy-modal__logo {
  flex: 0 0 190px;
  height: 56px;
  display: flex;
  align-items: center;
}

.buy-modal__logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: left center;
}

.buy-modal__btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 210px;
  height: 52px;
  padding: 0 44px;
  background: #d10a57;
  color: #ffffff !important;
  font-size: 17px;
  font-weight: 600;
  clip-path: polygon(0 0, calc(100% - 24px) 0, 100% 50%, calc(100% - 24px) 100%, 0 100%, 24px 50%);
  transition: background .3s ease;
}

.buy-modal__btn:hover,
.buy-modal__btn:focus-visible {
  background: #007fb6;
  outline: none;
}

@media (max-width: 480px) {
  .buy-modal {
    padding: 12px;
  }

  .buy-modal__dialog {
    padding: 28px 18px 16px;
    border-radius: 16px;
    max-height: calc(100vh - 24px);
  }

  .buy-modal__close {
    top: 6px;
    right: 6px;
  }

  .buy-modal__title {
    font-size: 24px;
    margin-bottom: 8px;
  }

  .buy-modal__item {
    gap: 12px;
    padding: 12px 0;
  }

  .buy-modal__logo {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
  }

  .buy-modal__btn {
    min-width: 0;
    width: 132px;
    height: 44px;
    padding: 0 28px;
    font-size: 15px;
    clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%, 18px 50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .custom-navbar .nav li.nav-buy > a::after {
    animation: none;
  }

  .buy-modal,
  .buy-modal.is-open,
  .buy-modal__dialog {
    transition: none;
  }
}
