@import url(./navigation-menu-keyframes.css);

.navigation-menu.nested {
  [data-scope="navigation-menu"][data-part="root"] {
    --arrow-size: 20px;
    --indicator-size: 10px;

    &[data-type="submenu"] {
      display: grid;
      width: 100%;
      max-width: 800px;
      gap: 20px;

      &[data-orientation="vertical"] {
        grid-template-columns: 0.3fr 1fr;
      }

      &[data-orientation="horizontal"] {
        justify-items: center;
        margin-top: -10px;
      }
    }
  }

  [data-scope="navigation-menu"][data-part="list"] {
    all: unset;
    list-style: none;
    display: flex;

    &[data-orientation="vertical"] {
      flex-direction: column;
    }
  }

  [data-scope="navigation-menu"][data-part="trigger"] {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    font-size: inherit;
    gap: 4px;
    padding: 10px 16px;
    font-weight: bold;

    & svg {
      transition: rotate 200ms ease;
      width: 14px;
      height: 14px;
    }

    &[data-state="open"] svg {
      rotate: -180deg;
    }

    &[data-type="submenu"] {
      position: relative;
      width: 100%;
      border-radius: 4px;

      &[data-state="open"] {
        background-color: #f3f4f5;
      }
    }
  }

  [data-scope="navigation-menu"][data-part="link"] {
    padding: 10px;
    font-weight: bold;
    color: inherit;
    display: block;
    text-decoration: none;
  }

  [data-scope="navigation-menu"][data-part="content"] {
    &[data-type="root"] {
      display: flex;
      justify-content: center;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      padding-top: 35px;
      padding-bottom: 35px;
      &[data-motion="from-start"] {
        animation: nav-menu-from-left 250ms ease;
      }

      &[data-motion="from-end"] {
        animation: nav-menu-from-right 250ms ease;
      }

      &[data-motion="to-start"] {
        animation: nav-menu-to-left 250ms ease;
      }

      &[data-motion="to-end"] {
        animation: nav-menu-to-right 250ms ease;
      }
    }

    &[data-type="submenu"] {
      display: grid;
      gap: 20px;
      width: 100%;
    }
  }

  [data-scope="navigation-menu"][data-part="viewport"] {
    overflow: hidden;
    width: 100%;

    &[data-type="root"] {
      position: absolute;
      left: 0;
      top: 100%;
      border-top: 1px solid #dcdfe3;
      transform-origin: top center;
      background-color: white;
      height: var(--viewport-height);
      transition: height 300ms ease;
      box-shadow:
        0 50px 100px -20px rgba(50, 50, 93, 0.1),
        0 30px 60px -30px rgba(0, 0, 0, 0.2);

      &[data-state="open"] {
        animation: fadeIn 250ms ease;
      }

      &[data-state="closed"] {
        animation: fadeOut 250ms ease;
      }
    }
  }

  [data-scope="navigation-menu"][data-part="indicator"] {
    &[data-orientation="horizontal"] {
      left: 0px;
      translate: var(--trigger-x) 0;
      width: var(--trigger-width);
    }

    &[data-orientation="vertical"] {
      top: 0px;
      translate: 0 var(--trigger-y);
      height: var(--trigger-height);
    }

    &[data-type="root"] {
      display: flex;
      justify-content: center;
      height: var(--indicator-size);
      z-index: 1;
      transition:
        translate 250ms ease,
        width 250ms ease;
      overflow: hidden;
      bottom: calc(calc(var(--indicator-size) + var(--arrow-size)) * -1);

      &[data-state="open"] {
        animation: nav-menu-fade-in 250ms ease;
      }

      &[data-state="closed"] {
        animation: nav-menu-fade-out 250ms ease;
      }
    }

    &[data-type="submenu"] {
      background-color: black;
      border-radius: 4px;

      &[data-orientation="vertical"] {
        width: 3px;
        transition:
          translate 250ms ease,
          height 250ms ease;

        [dir="ltr"] & {
          right: 0;
        }
        [dir="rtl"] & {
          left: 0;
        }
      }

      &[data-orientation="horizontal"] {
        height: 3px;
        bottom: 0;
        transition:
          translate 250ms ease,
          width 250ms ease;
      }
    }
  }

  [data-scope="navigation-menu"][data-part="arrow"] {
    position: relative;
    top: 4px;
    width: var(--arrow-size);
    height: var(--arrow-size);
    background-color: white;
    rotate: 45deg;
    border-radius: 3px;
  }
}
