.header {
  display: flex;
  align-items: flex-start;
  min-height: 20.8rem;
  padding: 7.4rem 0 0 20rem;
  color: var(--color-white);
  justify-content: space-between;
}

.header__logo {
  flex-shrink: 0;
  width: 20.185rem;
  margin-top: 0.9rem;
}

.header__logo img {
  width: 100%;
  height: auto;
}

/* In Figma the items sit in fixed-width boxes; one even gap keeps every item within 5px of them
   and still works for any menu from the admin */
.nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 3.7rem;
}

.nav__link {
  display: block;
  font-size: max(1.4rem, 11px);
  font-style: italic;
  line-height: 1.2143;
  text-transform: uppercase;
  text-underline-offset: 0.2em;
}

.nav__link:hover {
  text-decoration: underline;
}

.nav__phone {
  display: none;
}

/* Messengers and the phone travel together, so the row keeps its place when a link is missing */
.header__aside {
  display: flex;
  align-items: flex-start;
}

/* Telegram, MAX and the call icon sit in one row inside the contacts block */
.header__contacts {
  flex-shrink: 0;
  margin: -1.1rem 5.4rem 0 0.8rem;
}

.header__contacts .messengers__link {
  margin-top: 0.35rem;
}

.header__contacts .messengers__link img {
  filter: invert(1);
}

.burger {
  display: none;
}

/* Tablet & mobile
   ========================================================================== */

@media (max-width: 1279.98px) {
  .header {
    align-items: center;
    gap: 2.4rem;
    min-height: 0;
    padding: 2rem var(--gutter);
  }

  .header__logo {
    position: relative;
    z-index: 60;
    width: 14rem;
    margin-top: 0;
  }

  .nav {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0;
    padding: 12rem var(--gutter) 4rem;
    overflow-y: auto;
    background-color: var(--color-dark);
    visibility: hidden;
    opacity: 0;
    transition: opacity var(--transition), visibility var(--transition);
  }

  .nav.is-open {
    visibility: visible;
    opacity: 1;
  }

  .nav__list {
    flex-direction: column;
    gap: 2.4rem;
  }

  .nav__link {
    font-size: 2.6rem;
  }

  .nav__phone {
    display: block;
    margin-top: 4.8rem;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--color-sand);
  }

  .header__contacts .messengers__link {
    width: 2.4rem;
    height: 2.4rem;
    margin-top: 0.5rem;
  }

  .header__aside {
    min-width: 0;
    margin-left: auto;
  }



  .header__contacts {
    flex-shrink: 1;
    width: auto;
    margin: 0 0 0 auto;
    padding: 0;
  }

  .header__contacts .contacts__icon {
    position: relative;
    width: 2.4rem;
    height: 2.4rem;
    margin-top: 0.5rem;
  }

  /* Tap area of at least 44px around the small icon */
  .header__contacts .contacts__icon::after {
    content: "";
    position: absolute;
    inset: -1rem;
  }

  .burger {
    position: relative;
    z-index: 60;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.7rem;
    flex-shrink: 0;
    width: 4.4rem;
    height: 4.4rem;
    padding: 0 0.8rem;
  }

  .burger__line {
    display: block;
    height: 2px;
    background-color: var(--color-white);
    transition: transform var(--transition), opacity var(--transition);
  }

  .burger[aria-expanded="true"] .burger__line:nth-child(1) {
    transform: translateY(0.9rem) rotate(45deg);
  }

  .burger[aria-expanded="true"] .burger__line:nth-child(2) {
    opacity: 0;
  }

  .burger[aria-expanded="true"] .burger__line:nth-child(3) {
    transform: translateY(-0.9rem) rotate(-45deg);
  }
}

@media (max-width: 767.98px) {
  .header__logo {
    width: 11rem;
  }

  .header__contacts .contacts__phone {
    display: none;
  }

  .header__contacts .contacts__icon,
  .header__contacts .messengers__link {
    margin-top: 0;
  }
}
