/* Main menu */
.navigation {
  @media (max-width: 1366px) {
    display: none;
  }

  > ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    gap: 0;

    /* Nav-bar (Fibbl Design System): each item owns a 24px slot on both sides of its
       label, so neighbouring labels sit 48px apart and the slot edges fall exactly in
       the middle of the gap. The current page shows two 1px lines through the full bar
       height on those edges, like the divider next to Sign in. Hover inverts the whole
       slot (Stone fill, Cream text), so it stands out and never doubles up with the
       current page's lines. */
    > li {
      position: relative;
      padding: 16px 24px;
      z-index: 1;

      &::before,
      &::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 1px;
        background-color: transparent;
        pointer-events: none;
      }

      &::before {
        left: 0;
      }

      &::after {
        right: 0;
      }

      > a {
        display: block;
        /* 9px keeps the bar height the old 1px link border used to add */
        padding: 9px 0;
        color: var(--c-gray-900);
        letter-spacing: -0.4px;
        white-space: nowrap;
        background-color: var(--c-gray-25);

        @media (max-width: 1680px) {
          font-size: 16px;
        }
      }

      &.current-menu-ancestor,
      &.current-menu-item {
        &::before,
        &::after {
          background-color: var(--c-gray-900);
        }
      }

      @media (hover: hover) {
        &:hover {
          background-color: var(--c-gray-900);

          > a {
            color: var(--c-gray-25);
            background-color: transparent;
          }
        }
      }

      &:hover {
        z-index: 3;
      }

      /* Dropdowns hang from the item's lines: the left border sits on the left line,
         and the list lines up under the label (24px padding) */
      ul {
        z-index: 1;
        display: none;
        gap: 0;
        flex-direction: column;
        position: absolute;
        left: 0;
        top: 100%;
        margin: 0;
        padding: 16px 24px 20px;
        list-style: none;
        border: 1px solid var(--c-gray-900);
        border-radius: 0 0 4px 4px;
        background-color: #fffaee;
        overflow: hidden;

        li {
          position: relative;
          padding: 2px 0;
          a {
            padding: 0 !important;
            display: block;
            position: relative;
            padding: 0;
            color: var(--c-gray-900);
            white-space: nowrap;
            font-size: 13px;
            font-style: normal;
            font-weight: 400;
            line-height: 150%;
            letter-spacing: -0.2px;
          }

          &.current_page_item {
            > a {
              text-decoration: underline;
            }
          }

          &:hover {
            > a {
              opacity: 0.5;
            }
          }

          &.current-menu-ancestor,
          &.current-menu-item {
            > a {
              color: var(--c-gray-900);
            }
          }

          ul {
            left: 100%;
            top: -15px;
          }

          &:hover {
            > ul {
              display: flex;
            }
          }
        }
      }

      &:hover {
        > ul {
          display: flex;
        }
      }

      /* A single-column dropdown (Categories) spans exactly the item's slot,
         from its left line to its right line */
      &:not(.wide-sub-menu) > ul {
        right: 0;
        padding-right: 12px;

        /* The labels are 16px below 1680px, so the slot is narrower */
        @media (max-width: 1680px) {
          padding-right: 4px;
        }
      }

      &.wide-sub-menu {
        > ul {
          flex-direction: row;
          gap: 40px;
          > li {
            ul {
              display: block;
              position: relative;
              left: auto;
              top: auto;
              margin-top: 6px;
              padding: 0;
              border: none;
            }
            &:hover {
              > a {
                opacity: 1;
              }
            }
            > a {
              font-size: 18px;
              font-style: italic;
              &:hover {
                opacity: 0.5;
              }
            }
          }
        }
      }
    }
  }
}

.hide {
  .active-sub-menu-clone {
    transform: translateY(-20%);
    opacity: 0;
    transition:
      transform 0.3s ease-in-out,
      opacity 0.3s ease-in-out;
  }
}

/* Responsive menu */
.resp_menu_toggle {
  display: none;
  position: absolute;
  width: 26px;
  height: 16px;
  top: 23px;
  right: 20px;
  cursor: pointer;
  position: fixed;
  z-index: 1001;
  transform: translateY(0);
  transition: transform 0.3s ease-in-out;

  @media (max-width: 1366px) {
    display: block;
  }

  div {
    position: absolute;
    width: 100%;
    height: 3px;
    background-color: var(--c-black);
    transition: all 0.4s ease;

    &:nth-child(2) {
      margin-top: 6px;
    }

    &:nth-child(3) {
      margin-top: 12px;
    }
  }

  &.hide {
    transform: translateY(-300%);
    transition: transform 0.3s ease-in-out;
  }

  &.resp_menu_toggled {
    div {
      &:first-child,
      &:nth-child(4) {
        opacity: 0;
      }

      &:nth-child(2) {
        transform: rotate(45deg) translateX(4px);
      }

      &:nth-child(3) {
        transform: rotate(-45deg) translateX(4px);
      }
    }
  }
}

.resp_menu {
  flex-direction: column;
  position: fixed;
  width: 100%;
  height: 100vh;
  left: 0;
  top: 0;
  transform: translateY(-100%);
  background-color: var(--c-gray-25);
  transition: all 0.4s ease;
  overflow: hidden;
  z-index: 1000;

  .cta {
    text-align: center;
  }

  &.opened {
    transform: translateY(0);
  }

  .resp_menu_ul {
    flex: 1;
    display: flex;
    align-items: flex-start;
    overflow-y: auto;
    margin-bottom: 42px;

    > ul {
      width: 100%;
      margin: 0;
      padding: 0;
      list-style: none;
      padding-top: 60px;

      > li {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        position: relative;
        border-bottom: 1px solid #181818;
        transition: all 0.2s ease;

        .parent_menu {
          display: flex;
          align-items: center;
          justify-content: space-between;
          position: relative;
          width: 100%;

          .plus_minus {
            width: 35px;
            height: 35px;
            cursor: pointer;
            position: absolute;
            top: 14px;
            right: 14px;

            &::before {
              content: url('data:image/svg+xml,<svg width="18" height="10" viewBox="0 0 18 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.19873 2.91431C2.69633 3.36667 3.29113 3.7706 3.82556 4.18111C4.26823 4.52113 4.64251 4.98855 5.13236 5.24788C5.97667 5.69487 6.85833 6.25378 7.52594 6.92139C8.07326 7.4687 8.74066 8.71266 9.63949 8.13484C10.4399 7.62032 11.1727 7.26167 11.8597 6.57468C12.2974 6.13701 12.8069 5.77154 13.2399 5.31456C14.0331 4.47723 14.9699 3.1894 16.0001 2.67429" stroke="%23181818" stroke-width="3.3941" stroke-linecap="round"/></svg>');
              color: var(--c-gray-900);
              position: absolute;
              left: 50%;
              top: 50%;
              transform: translate(-50%, -50%);
              transition: all 0.3s ease;
            }

            &.plus_minus_toggled::before {
              content: url('data:image/svg+xml,<svg width="18" height="10" viewBox="0 0 18 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.19873 2.91431C2.69633 3.36667 3.29113 3.7706 3.82556 4.18111C4.26823 4.52113 4.64251 4.98855 5.13236 5.24788C5.97667 5.69487 6.85833 6.25378 7.52594 6.92139C8.07326 7.4687 8.74066 8.71266 9.63949 8.13484C10.4399 7.62032 11.1727 7.26167 11.8597 6.57468C12.2974 6.13701 12.8069 5.77154 13.2399 5.31456C14.0331 4.47723 14.9699 3.1894 16.0001 2.67429" stroke="%23ffffff" stroke-width="3.3941" stroke-linecap="round"/></svg>');

              transform: translate(-50%, -50%) rotate(180deg);
            }
          }
        }

        a {
          display: block;
          width: 100%;
          padding: 10px 24px;
          text-align: left;
          color: var(--c-black);
          font-size: var(--fs-xl);
        }

        &.current_page_item,
        &.current-menu-ancestor,
        &.current-menu-item,
        &:hover {
          background-color: #181818;

          .plus_minus {
            &::before {
              content: url('data:image/svg+xml,<svg width="18" height="10" viewBox="0 0 18 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.19873 2.91431C2.69633 3.36667 3.29113 3.7706 3.82556 4.18111C4.26823 4.52113 4.64251 4.98855 5.13236 5.24788C5.97667 5.69487 6.85833 6.25378 7.52594 6.92139C8.07326 7.4687 8.74066 8.71266 9.63949 8.13484C10.4399 7.62032 11.1727 7.26167 11.8597 6.57468C12.2974 6.13701 12.8069 5.77154 13.2399 5.31456C14.0331 4.47723 14.9699 3.1894 16.0001 2.67429" stroke="%23ffffff" stroke-width="3.3941" stroke-linecap="round"/></svg>');
              color: var(--c-white);
            }
          }

          a {
            color: var(--c-white);
          }
        }

        &.open {
          background-color: #181818;

          .plus_minus {
            &::before {
              color: var(--c-white);
            }
          }

          a {
            color: var(--c-white);
          }
        }

        ul {
          display: none;
          width: 100%;
          margin: 0;
          list-style: none;

          li {
            position: relative;
            padding-bottom: 4px;

            a {
              display: block;
              text-align: left;
              color: var(--c-white);
              font-size: var(--fs-md);
              transition: all 0.2s ease;
              padding-block: 4px;

              &:hover {
                text-decoration: underline;
              }
            }

            &.current_page_item,
            &.current-menu-ancestor,
            &.current-menu-item,
            &:hover {
              > a {
                text-decoration: underline;
              }
            }

            ul {
              display: block;
              width: 100%;
              margin: 0;
              padding: 0;
              padding-left: 15px; /* indent 3rd level items slightly */
              list-style: none;

              li {
                position: relative;
                padding-bottom: 4px;

                a {
                  display: block;
                  text-align: left;
                  color: var(--c-white);
                  font-size: var(--fs-md);
                  transition: all 0.2s ease;
                  padding-block: 4px;

                  &:hover {
                    text-decoration: underline;
                  }
                }

                &.current_page_item,
                &.current-menu-ancestor,
                &.current-menu-item,
                &:hover {
                  > a {
                    text-decoration: underline;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
