/* Шапка: десктопное меню (от 992px) и мобильная шапка с меню (до 991px).
   Разметка — local/templates/main/header.php, скрипт — local/static/js/mobile-menu.js */

:root {
  --mhead-h: 64px;
  --mnav-ease: cubic-bezier(.22, .8, .24, 1);
  --mnav-dur: .38s;
}

/* ---------- десктоп ---------- */

.mhead {
  display: none;
}

@media only screen and (min-width: 992px) {
  .ul_top {
    display: table !important;
  }

  .ul_top > li > a {
    white-space: nowrap;
  }
}

@media only screen and (min-width: 992px) and (max-width: 1100px) {
  .ul_top > li > a {
    padding-left: 6px;
    padding-right: 6px;
  }
}

/* ---------- мобильная шапка ---------- */

@media only screen and (max-width: 991px) {
  .header {
    z-index: 1000;
    padding-top: var(--mhead-h);
  }

  .header > .wrapper_w {
    padding: 0 !important;
    background: none;
  }

  /* от десктопной шапки остаётся только строка с метро */
  .header__logo,
  .header__social,
  .main-start-wrapper {
    display: none !important;
  }

  .header__container {
    display: block;
    padding: 0 !important;
  }

  .header__contact {
    display: flex;
    justify-content: center;
    padding: 10px 16px;
    background: #bfeaef; /* rgba(43, 184, 201, .3) поверх белого */
  }

  .header-contact__item {
    margin: 0;
  }

  .header-contact__title {
    display: flex;
    align-items: center;
    margin: 0;
  }

  .header-contact__title-icon {
    display: flex;
    flex: 0 0 22px;
    width: 22px;
    margin-right: 10px;
  }

  .header-contact__title-icon svg {
    width: 100%;
    height: auto;
  }

  .header-contact__title-text {
    margin: 0;
    font-size: 16px;
    line-height: 1.3;
    color: #333;
  }

  .mhead {
    display: block;
  }

  /* панель с логотипом, телефоном и бургером */
  .mhead__bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 8px;
    height: var(--mhead-h);
    padding: 0 8px 0 16px;
    background: #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0);
    transition: box-shadow .25s ease;
  }

  .mhead--scrolled .mhead__bar,
  .mnav-open .mhead__bar {
    box-shadow: 0 1px 0 rgba(0, 0, 0, .06), 0 6px 16px rgba(7, 170, 187, .12);
  }

  .mhead__logo {
    display: flex;
    align-items: center;
    margin-right: auto;
    line-height: 0;
  }

  .mhead__logo img {
    display: block;
    width: 130px;
    max-width: 100%;
    height: auto;
  }

  .mhead__phone,
  .mhead__burger {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 50%;
    color: #333;
    -webkit-tap-highlight-color: transparent;
  }

  .mhead__phone {
    background: rgba(43, 184, 201, .3);
  }

  .mhead__phone:active {
    background: rgba(43, 184, 201, .45);
  }

  .mhead__phone svg {
    display: block;
    width: 22px;
    height: 22px;
  }

  /* бургер → крестик */
  .mhead__burger {
    position: relative;
    background: transparent;
    cursor: pointer;
    outline: none;
  }

  .mhead__burger:focus-visible {
    box-shadow: 0 0 0 2px #2bb8c9;
  }

  .mhead__burger span {
    position: absolute;
    left: 11px;
    top: 21px;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: #333;
    transition: transform .3s var(--mnav-ease), opacity .2s ease;
  }

  .mhead__burger span:nth-child(1) { transform: translateY(-7px); }
  .mhead__burger span:nth-child(3) { transform: translateY(7px); }

  .mnav-open .mhead__burger span:nth-child(1) { transform: rotate(45deg); }
  .mnav-open .mhead__burger span:nth-child(2) { opacity: 0; transform: scaleX(.2); }
  .mnav-open .mhead__burger span:nth-child(3) { transform: rotate(-45deg); }

  /* выпадающее меню */
  .mnav {
    position: fixed;
    top: var(--mhead-h);
    left: 0;
    right: 0;
    z-index: 2;
    max-height: calc(100vh - var(--mhead-h));
    max-height: calc(100dvh - var(--mhead-h));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 8px 16px 24px;
    background: #fff;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, .12);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-12px);
    clip-path: inset(0 0 100% 0);
    transition:
      clip-path var(--mnav-dur) var(--mnav-ease),
      transform var(--mnav-dur) var(--mnav-ease),
      opacity .2s ease,
      visibility 0s linear var(--mnav-dur);
  }

  .mnav-open .mnav {
    visibility: visible;
    opacity: 1;
    transform: none;
    clip-path: inset(0 0 -40px 0);
    transition:
      clip-path var(--mnav-dur) var(--mnav-ease),
      transform var(--mnav-dur) var(--mnav-ease),
      opacity .15s ease,
      visibility 0s;
  }

  .mnav__list {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .mnav__list li,
  .mnav__footer {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .2s ease, transform .2s ease;
  }

  .mnav-open .mnav__list li,
  .mnav-open .mnav__footer {
    opacity: 1;
    transform: none;
    transition:
      opacity .3s ease calc(60ms + var(--i, 0) * 30ms),
      transform .35s var(--mnav-ease) calc(60ms + var(--i, 0) * 30ms);
  }

  .mnav__list li + li {
    border-top: 1px solid rgba(43, 184, 201, .18);
  }

  .mnav__list a {
    display: block;
    padding: 14px 8px;
    font-size: 20px;
    line-height: 1.25;
    text-align: center;
    color: #333;
    text-decoration: none;
    border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .15s ease;
  }

  .mnav__list a:active,
  .mnav__list a:focus-visible {
    background: rgba(43, 184, 201, .15);
    outline: none;
  }

  .mnav__list a[aria-current="page"] {
    color: #07aabb;
  }

  .mnav__footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding-top: 20px;
  }

  .mnav__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 220px;
    height: 48px;
    padding: 0 28px;
    font-size: 18px;
    color: #fff !important;
    text-decoration: none !important;
    background: #f79765;
    border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .15s ease, transform .15s ease;
  }

  .mnav__cta:active {
    background: #f0844d;
    transform: scale(.98);
  }

  .mnav__tel {
    font-size: 18px;
    color: #333 !important;
    text-decoration: none !important;
  }

  /* затемнение под меню */
  .mnav-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background: rgba(18, 38, 43, .45);
    visibility: hidden;
    opacity: 0;
    transition: opacity var(--mnav-dur) ease, visibility 0s linear var(--mnav-dur);
  }

  .mnav-open .mnav-backdrop {
    visibility: visible;
    opacity: 1;
    transition: opacity var(--mnav-dur) ease, visibility 0s;
  }

  html.mnav-open,
  html.mnav-open body {
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mhead *,
  .mhead {
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
}
