.menu {
  padding: 1em;
  position: fixed;
  top: 0;
  right: 0;
  width: 100vw;
  height: 90vh;
  transform: translateY(calc(-100% - 2em));
  user-select: none;
  z-index: var(--z-index-menu);
  pointer-events: none;
  transition: transform var(--layout-transition-extra-fast);
}

.menu:focus {
  outline: none;
}

.is-menu-open .menu {
  transform: translateY(0);
  user-select: auto;
}

.menu-area {
  background-color: rgb(var(--theme-color-01));
  border-radius: var(--theme-radius);
  width: 100%;
  max-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr calc(var(--menu-space) * 5);
  justify-items: stretch;
  align-items: stretch;
  overflow-y: auto;
  pointer-events: all;
  transition: background-color var(--layout-transition-extra-fast), box-shadow var(--layout-transition-extra-fast);
}

.is-menu-open .menu-area {
  box-shadow: var(--theme-shadow-bottom-large);
}

.is-edge .menu-area {
  background-color: rgba(var(--theme-color-01), var(--menu-edge-opacity));
}

.menu-nav {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

.menu-nav-item {
  flex-grow: 1;
  flex-basis: 33.33333333%;
}

.menu-nav-tab {
  background-color: transparent;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-radius: 0;
  height: calc(var(--menu-space) * 5);
  width: 100%;
  line-height: 1;
}

.menu-nav-tab:after {
  background-color: transparent;
  border-radius: 0;
}

.menu-close-tab {
  background-color: transparent;
  margin: 0;
  padding: 0;
  border-radius: 0;
  height: calc(var(--menu-space) * 5);
  width: calc(var(--menu-space) * 5);
  line-height: 1;
}

.menu-subnav {
  display: none;
}

.menu-nav-area-tab {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  flex-grow: 1;
}

.menu-nav-area-close {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
}

.menu-list {
  display: none;
}

.menu-content {
  grid-column-start: 1;
  grid-column-end: 3;
}

.menu-content-item {
  padding: calc(var(--menu-space) * 3);
  position: relative;
  z-index: 1;
}

.menu-content-item:not(:last-child) {
  border-bottom: var(--horizontal-rule-large);
  transition: border-color var(--layout-transition-extra-fast);
}

.menu-item-header {
  margin-bottom: var(--menu-space);
}

.menu-item-header-text {
  margin-bottom: 0;
}

.menu-item-form {
  padding-left: calc(var(--menu-space) * 3);
  z-index: 1;
}

@media (min-width: 550px) {
  .menu {
    width: 90vw;
  }
}

@media (min-width: 700px) {
  .menu {
    width: 100%;
    height: 100%;
    max-height: initial;
  }

  .menu-area {
    max-height: 100%;
    grid-template-rows: 1fr;
    grid-template-columns: calc(var(--menu-space) * 20) 1fr calc(var(--menu-space) * 4);
    overflow: hidden;
    position: relative;
  }

  .menu-nav {
    background-color: rgb(var(--theme-color-02));
    grid-column-start: 1;
    grid-column-end: 2;
    grid-row-start: 1;
    grid-row-end: 2;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    overflow-y: auto;
    z-index: 1;
    transition: background-color var(--layout-transition-extra-fast);
  }

  .is-edge .menu-nav {
    background-color: transparent;
  }

  .menu-content {
    grid-column-start: 2;
    grid-column-end: 4;
    grid-row-start: 1;
    grid-row-end: 2;
    scroll-behavior: smooth;
    overflow-y: auto;
    z-index: 2;
  }

  .menu-close {
    grid-column-start: 3;
    grid-column-end: 4;
    grid-row-start: 1;
    grid-row-end: 2;
    align-self: start;
    position: absolute;
    z-index: 3;
  }

  .menu-content-item {
    padding: calc(var(--menu-space) * 2) calc(var(--menu-space) * 4);
  }

  .menu-content-overscroll .menu-content-item:last-child {
    padding-bottom: calc(var(--menu-space) * 50);
  }

  .menu-item-header {
    margin-bottom: calc(var(--menu-space) * 2);
  }

  .menu-nav-item {
    flex-grow: 0;
    flex-basis: auto;
  }

  .menu-nav-tab {
    padding-left: calc(calc(var(--menu-space) * 2) + calc(var(--theme-radius) / 3));
    padding-right: calc(var(--menu-space) * 2);
    height: calc(var(--menu-space) * 4);
    justify-content: flex-start;
  }

  .menu-subnav {
    background-color: rgb(var(--theme-color-03));
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    overflow: hidden;
    height: 0;
    transition: background-color var(--layout-transition-extra-fast), height var(--layout-transition-extra-fast);
  }

  .menu-subnav.active {
    height: var(--menu-subnav-height);
  }

  .is-edge .menu-subnav {
    background-color: transparent;
  }

  .menu-nav-sub {
    background-color: transparent;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    padding-left: calc(calc(var(--menu-space) * 4) + calc(var(--theme-radius) / 3));
    border-radius: 0;
    height: 3em;
    min-height: 3em;
    width: 100%;
    line-height: 1;
    justify-content: flex-start;
  }

  .menu-nav-sub:focus,
  .menu-nav-sub:hover {
    background-color: rgb(var(--theme-color-04));
  }

  .menu-nav-sub:active {
    background-color: rgb(var(--theme-color-05));
  }

  .menu-nav-sub:after,
  .menu-nav-sub:after {
    background-color: transparent;
    border-radius: 0;
  }

  .menu-close-tab {
    border-radius: var(--theme-radius);
    height: calc(var(--menu-space) * 4);
    width: calc(var(--menu-space) * 4);
    position: relative;
    top: calc(var(--theme-radius) / 6);
    right: calc(var(--theme-radius) / 6);
  }

  .menu-item-form {
    padding-left: calc(var(--menu-space) * 4);
  }
}

@media (min-width: 900px) {
  .menu {
    width: 90vw;
  }

  .menu-area {
    grid-template-columns: calc(var(--menu-space) * 20) 1fr calc(var(--menu-space) * 5);
  }

  .menu-content-item {
    padding: calc(var(--menu-space) * 3) calc(var(--menu-space) * 5);
  }

  .menu-close-tab {
    height: calc(var(--menu-space) * 5);
    width: calc(var(--menu-space) * 5);
  }

  .menu-item-form {
    padding-left: calc(var(--menu-space) * 5);
  }
}

@media (min-width: 1100px) {
  .menu {
    width: 80vw;
    max-width: 60em;
  }
}
