.menu {
  width: 100%;
}

.menu__list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.menu__link {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  transition: color 0.3s ease;
}

.menu-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  flex-shrink: 0;
}

.menu-arrow svg {
  display: block;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
}

@media (min-width: 1200px) {
  .menu.menu__mobile {
    display: none;
  }

  .menu__list {
    display: flex;
    gap: 20px;
    align-items: center;
  }

  .menu.menu__top .menu__list {
    justify-content: flex-end;
  }

  .menu.menu__bottom .menu__list {
    padding: 0 var(--wrap);
    justify-content: space-between;
  }

  .menu-item {
    position: relative;
  }

  .menu-row {
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .menu-arrow {
    margin-left: 6px;
    pointer-events: none;
  }

  .menu.menu__top .menu-item:hover .menu__link {
    color: var(--color-black);
  }

  .menu-item:hover > .menu-row .menu-arrow svg {
    transform: rotate(180deg);
  }

  .menu__link span {
    position: relative;
    text-align: center;
  }

  .menu__link span::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  }

  .menu-item:hover > .menu-row .menu__link span::before {
    transform: scaleX(1);
  }

  .sub-menu {
    display: none;
    position: absolute;
    min-width: 320px;
    background: var(--color-white);
    border: none;
    padding: 0;
    z-index: 100;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    top: 100%;
    left: 0;
  }

  .menu__bottom .sub-menu {
    background: var(--color-blue-200);
    color: var(--color-white);
    right: 0;
    left: auto;
  }

  .menu-item:hover > .sub-menu {
    display: flex;
    animation: fadeIn 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
  }

  .sub-menu .menu-item {
    width: 100%;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }

  .menu__bottom .sub-menu .menu-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .sub-menu .menu-item:last-child {
    border-bottom: none;
  }

  .sub-menu .menu-row {
    width: 100%;
    padding: 0;
  }

  .sub-menu .menu__link {
    font-size: 0.9rem;
    flex-grow: 1;
    padding: 5px 15px;
    width: auto;
  }

  .sub-menu .menu-arrow {
    margin-left: auto;
    padding-right: 15px;
  }

  .sub-menu .sub-menu {
    top: 0;
    margin-top: 0;
    right: 100%;

    overflow-y: auto;
    max-height: 60vh;
    overscroll-behavior: contain;
  }

  .sub-menu > .menu-item:nth-last-child(-n + 4) > .sub-menu {
    top: auto;
    bottom: 0;
    transform-origin: bottom left;
  }
}

@media (max-width: 1199px) {
  .menu.menu__top,
  .menu.menu__bottom {
    display: none;
  }

  .menu.menu__mobile {
    color: var(--color-white);
    font-size: 1.1rem;
    line-height: 1.4;
    display: block;
    width: 100%;
    overflow-x: hidden;
    margin-top: 40px;
  }

  .menu__mobile .menu-item-has-children > a::after,
  .menu__mobile .menu-item-has-children > a::before {
    content: none !important;
    display: none !important;
  }

  .menu__mobile .menu-item {
    display: block;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .menu__mobile .menu-row {
    display: flex;
    width: 100%;
    min-height: 50px;
    background: transparent;
    position: relative;
    z-index: 2;
    align-items: stretch;
    transition: background-color 0.3s ease;
  }

  .menu__mobile .menu__link {
    flex: 1;
    padding: 15px 10px;
    display: flex;
    align-items: center;
    word-break: break-word;
    hyphens: auto;
  }

  .menu__mobile .menu__link span {
    display: block;
    width: 100%;
  }

  .menu__mobile .menu-arrow {
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    background: transparent;
  }

  .menu__mobile .menu-item._open > .menu-row {
    background: rgba(255, 255, 255, 0.05);
  }

  .menu__mobile .menu-item._open > .menu-row .menu-arrow svg {
    transform: rotate(180deg);
  }

  .menu__mobile .sub-menu {
    display: none;
    width: 100%;
    background: rgba(0, 0, 0, 0.1);
  }

  .menu__mobile .menu-item._open > .sub-menu {
    display: block;
  }

  .menu__mobile .sub-menu .menu__link {
    padding-left: 20px;
    font-size: 0.95em;
  }

  .menu__mobile .sub-menu .sub-menu {
    background: rgba(0, 0, 0, 0.15);
  }

  .menu__mobile .sub-menu .sub-menu .menu__link {
    padding-left: 40px;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
