.spr-menu {
  @media (min-width: 992px) {
    --menu-item-padding-block: 0.5rem;
    --menu-item-line-height: 1.25rem;
    --menu-item-icon-size: 0.875rem;
    --menu-item-icon-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='8' fill='none' viewBox='0 0 15 8'%3E%3Cpath stroke='%23000' d='m1 1 6.4 6 6.3-6'/%3E%3C/svg%3E");
  }

  @media (max-width: 991px) {
    .spr-menu-item--level-1 > a {
      --menu-item-padding-inline: 1rem;
    }
  }
}

.spr-menu--dark {
  --menu-color-text: white;

  .spr-menu-item--has-children > button {
    @media (min-width: 992px) {
      &::after {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='8' fill='none' viewBox='0 0 15 8'%3E%3Cpath stroke='%23fff' d='m1 1 6.4 6 6.3-6'/%3E%3C/svg%3E");
      }
    }
  }

  .spr-header:hover &,
  .spr-header.is-active & {
    --menu-color-text: black;

    .spr-menu-item--has-children > button {
      @media (min-width: 992px) {
        &::after {
          background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='8' fill='none' viewBox='0 0 15 8'%3E%3Cpath stroke='%23000' d='m1 1 6.4 6 6.3-6'/%3E%3C/svg%3E");
        }
      }
    }
  }
}

.spr-menu {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
  gap: var(--menu-gap);

  a,
  button {
    position: relative;
    display: block;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    color: var(--menu-color-text);
    border: none;
    background-color: transparent;
    font-size: var(--menu-item-size);
    font-weight: var(--menu-item-weight);
    line-height: var(--menu-item-line-height);
    padding-block: var(--menu-item-padding-block);
    padding-inline: var(--menu-item-padding-inline);

    &.is-active {
      @media (min-width: 992px) {
        text-decoration: underline;
        text-underline-offset: 0.25rem;
      }
    }

    @media (min-width: 992px) {
      --menu-item-size: var(--font-size-xxs);
      --menu-item-padding-block: var(--size-05);
      --menu-item-padding-inline: var(--size-05);
      --menu-item-line-height: var(--line-height-text);

      &:hover {
        text-decoration: underline;
        text-underline-offset: 0.25rem;
      }
    }

    @media (min-width: 1240px) {
      --menu-item-size: var(--font-size-xxs);
      --menu-item-padding-block: var(--size-05);
      --menu-item-padding-inline: var(--size-15);
      --menu-item-line-height: var(--line-height-text);
    }
  }

  .spr-menu-item--level-0:first-child {
    @media (min-width: 992px) {
      a,
      button {
        padding-inline-start: var(--size-15);
      }
    }
  }

  .spr-menu-item--level-0 > button {
    position: relative;
    width: 100%;

    @media (max-width: 991px) {
      &::after {
        position: absolute;
        top: 50%;
        right: 0.625rem;
        display: block;
        width: 1.5625rem;
        height: 0.75rem;
        content: "";
        transform: translateY(-50%);
        background-image: var(--menu-item-icon-arrow);
        background-repeat: no-repeat;
        background-position: center;
        background-size: 100%;
      }

      &.is-active {
        &::after {
          transform: translateY(-50%) rotate(180deg);
        }
      }
    }

    @media (min-width: 992px) {
      &::before {
        position: absolute;
        width: 100%;
        height: 100%;
        content: "";
        transform: translateY(100%);
        background-color: transparent;
        inset: 0;
      }
    }
  }

  &.spr-menu--level-1 {
    flex-direction: column;
    gap: 0;
    min-width: var(--menu-dropdown-width);
  }

  @media (min-width: 992px) {
    flex-direction: row;
    justify-content: var(--menu-align, flex-start);
    gap: 0;
  }
}

.spr-menu-item--has-children {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;

  > a,
  > button {
    @media (min-width: 992px) {
      width: auto;
      padding-right: calc(0.75rem + var(--menu-item-icon-size) + var(--size-05));

      &::after {
        position: absolute;
        top: 50%;
        right: var(--size-05);
        display: block;
        width: 0.875rem;
        height: 1.25rem;
        content: "";
        transform: translateY(-50%);
        background-image: var(--menu-item-icon-arrow);
        background-repeat: no-repeat;
        background-position: center;
        background-size: 0.875rem;
      }

      &:hover::after {
        transform: translateY(-50%) rotate(180deg);
      }
    }

    @media (min-width: 1240px) {
      padding-right: calc(0.75rem + var(--menu-item-icon-size) + var(--size-15));

      &::after {
        right: var(--size-15);
      }
    }
  }

  @media (min-width: 992px) {
    display: block;
  }
}

.spr-menu-item--level-0 {
  position: relative;

  &:last-child {
    display: none;
  }

  .spr-menu--level-1 {
    transition: var(--menu-dropdown-transition);

    @media (max-width: 991px) {
      display: none;
      flex-direction: column;
      width: 100%;
      gap: var(--space-x-small);
      padding-block-start: var(--padding-horizontal-main);

      &.is-opened {
        display: flex;
      }

      .spr-menu-item--level-1 > a {
        font-size: var(--font-size-xxs);
        line-height: var(--line-height-heading-6);
      }
    }

    @media (min-width: 992px) {
      position: absolute;
      z-index: 1;
      top: 100%;
      left: 0;
      visibility: visible;
      pointer-events: none;
      opacity: 0;
      box-shadow: var(--menu-dropdown-shadow);
    }
  }

  &.is-hovered .spr-menu--level-1 {
    visibility: visible;
    pointer-events: all;
    opacity: 1;
  }
}

@supports selector(:has(*)) {
  .spr-mega-menu:has(.spr-menu--level-0 > li:nth-child(1):hover) + .spr-header__content .spr-header__nav .spr-menu--level-0 > li:nth-child(1) button,
  .spr-mega-menu:has(.spr-menu--level-0 > li:nth-child(2):hover) + .spr-header__content .spr-header__nav .spr-menu--level-0 > li:nth-child(2) button,
  .spr-mega-menu:has(.spr-menu--level-0 > li:nth-child(5):hover) + .spr-header__content .spr-header__nav .spr-menu--level-0 > li:nth-child(5) button {
    text-decoration: underline;
    text-underline-offset: 0.25rem;

    &::after {
      transform: translateY(-50%) rotate(180deg);
    }
  }

  .spr-mega-menu:has(+ .spr-header__content .spr-header__nav .spr-menu--level-0 > li:nth-child(1) button:hover) .spr-menu--level-0 > li:not(:last-child, :nth-child(1)),
  .spr-mega-menu:has(+ .spr-header__content .spr-header__nav .spr-menu--level-0 > li:nth-child(2) button:hover) .spr-menu--level-0 > li:not(:last-child, :nth-child(2)),
  .spr-mega-menu:has(+ .spr-header__content .spr-header__nav .spr-menu--level-0 > li:nth-child(5) button:hover) .spr-menu--level-0 > li:not(:last-child, :nth-child(5)) {
    opacity: 0.5;
  }
}

.spr-mega-menu {
  position: absolute;
  z-index: 1;
  top: 100%;
  right: 0;
  left: 0;
  display: none;
  visibility: hidden;
  transition: var(--menu-dropdown-transition);
  pointer-events: none;
  opacity: 0;
  background-color: var(--color-white);
  box-shadow: var(--shadow-2);
  padding-block: var(--space-large);
  padding-inline: var(--padding-horizontal-main);

  .spr-menu--dark {
    --menu-color-text: black;
  }

  .spr-menu {
    a,
    button {
      color: var(--menu-color-text);
    }
  }

  .spr-menu--level-0 {
    display: grid;
    grid-template-columns: repeat(var(--grid-columns), 1fr);
    /*gap: var(--grid-gap);*/
    gap: 2.5rem;

    /*.spr-menu-item--has-children:nth-of-type(1) {
      grid-column: 1 / 3;
    }

    .spr-menu-item--has-children:nth-of-type(2) {
      grid-column: 3 / 6;
    }

    .spr-menu-item--has-children:nth-of-type(3) {
      grid-column: 7 / 8;
    }

    .spr-menu-item--has-children:nth-of-type(5) {
      grid-column: 9 / 10;

      .spr-menu-item--level-1 > a {
        font-size: 1rem;
        line-height: 1.25rem;
      }
    }*/
    .spr-menu-item--has-children:nth-of-type(5) {
      .spr-menu-item--level-1 > a {
        font-size: 1rem;
        line-height: 1.25rem;
      }
    }

    .spr-menu-item--level-0:last-child {
      grid-column: 9 / 12;
      aspect-ratio: 32 / 20;

      span {
        display: none;
      }

      img {
        position: absolute;
        width: 100%;
        height: 100%;
        object-fit: cover;
        inset: 0;
      }
    }

    @supports selector(:has(*)) {
      > li {
        transition: opacity 0.25s;
      }

      &:has(> li:hover) > li:not(:last-child, :hover) {
        opacity: 0.5;
      }
    }
  }

  .spr-menu-item--level-0 {
    display: none;

    &:last-child,
    &.spr-menu-item--has-children {
      display: block;
    }
  }

  .spr-menu-item--level-0 > button {
    margin-block-end: var(--space-small);
    padding: 0;
    pointer-events: none;

    &::after {
      content: none;
    }
  }

  .spr-menu-item--level-1 > a {
    padding: 0;

    @media (min-width: 992px) {
      font-size: var(--font-size-xs);
      line-height: var(--font-size-xs);
    }

    @media (min-width: 1240px) {
      font-size: var(--font-size-s);
      line-height: var(--font-size-s);
    }
    /*font {
      word-wrap: break-word;
    };*/
  }

  .spr-menu-item--level-1:not(:last-child) > a {
    margin-block-end: 0.75rem;
  }

  .spr-menu--level-1 {
    position: static;
    z-index: 0;
    top: auto;
    left: auto;
    visibility: visible;
    pointer-events: all;
    opacity: 1;
    box-shadow: none;
  }

  @media (min-width: 992px) {
    &.is-hovered {
      display: block;
      visibility: visible;
      pointer-events: all;
      opacity: 1;
    }
  }
}
