@import '//y14e.github.io/common/stylesheets/common.css';

.menu {
  align-items: start;
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem;
  /*
  transition: 0.3s filter;
  :has([data-portal-sentinel]) & {
    filter: blur(4px);
  }
  */
}

[data-menu-trigger] {
  align-items: center;
  background-color: rgb(0 0 0 / 0.2);
  border-radius: 0.4rem;
  display: flex;
  font-weight: bold;
  gap: 0.8rem;
  outline-offset: -2px;
  padding: 0.8rem 1.6rem;
  transition-duration: 0.3s;
  transition-property: background-color, color;
  &::after {
    aspect-ratio: 1;
    background-color: currentColor;
    clip-path: polygon(0 30%, 25% 30%, 50% 55%, 75% 30%, 100% 30%, 50% 80%);
    content: '';
    width: 1rem;
  }
  &[aria-expanded='true'] {
    background-color: #000;
    color: #fff;
  }
  &:is([disabled], [tabindex='-1']) {
    background-color: rgb(0 0 0 / 0.1);
    color: rgb(0 0 0 / 0.35);
  }
  &:not([aria-expanded='true']):hover {
    background-color: rgb(0 0 0 / 0.3);
  }
}

[role='menu'] {
  background-color: #fff;
  border-radius: 0.4rem;
  box-shadow:
    0 0 0.2rem rgb(0 0 0 / 0.1),
    0 0.4rem 0.8rem rgb(0 0 0 / 0.2);
  padding: 0.4rem;
  white-space: nowrap;
  :is([data-menu-trigger], [aria-haspopup]) + &,
  &[data-portaled] {
    display: none;
    position: absolute;
    transition: 0.3s transform cubic-bezier(0.33, 1, 0.68, 1);
    z-index: calc(infinity);
  }
  &:not([data-menu-open]):not([data-menu] > &) {
    transform: scale(0.9);
  }
  & & {
    display: none;
  }
}

[role^='menuitem'] {
  border-radius: 0.4rem;
  cursor: pointer;
  display: block;
  outline-offset: -2px;
  padding: 0.8rem 1.6rem;
  position: relative;
  transition: 0.3s background-color;
  width: 100%;
  z-index: 1;
  &[aria-haspopup] {
    align-items: center;
    display: flex;
    gap: 0.8rem;
    justify-content: space-between;
    padding: 0.8rem 1.6rem;
    position: relative;
    &::after {
      aspect-ratio: 1;
      background-color: currentColor;
      clip-path: polygon(30% 0%, 80% 50%, 30% 100%, 30% 75%, 55% 50%, 30% 25%);
      content: '';
      width: 1rem;
    }
  }
  &:is([data-menu-disabled], [disabled]) {
    color: rgb(0 0 0 / 0.35);
  }
  &:hover {
    background-color: rgb(0 0 0 / 0.1);
  }
  &[aria-expanded='true'] {
    background-color: rgb(0 0 0 / 0.1);
  }
}

:is([role='menuitemcheckbox'], [role='menuitemradio']) {
  align-items: center;
  display: flex;
  gap: 0.8rem;
  &::before {
    aspect-ratio: 1;
    background-color: currentColor;
    content: '';
    opacity: 0;
    width: 1rem;
  }
  &[aria-checked='true']::before {
    opacity: 1;
  }
}

[role='menuitemcheckbox']::before {
  clip-path: polygon(0 50%, 20% 50%, 32.5% 72.5%, 35% 75%, 80% 0, 100% 0, 40% 100%, 30% 100%);
}

[role='menuitemradio']::before {
  clip-path: circle(30%);
}

hr {
  background-color: rgb(0 0 0 / 0.1);
  border: 0;
  height: 0.1rem;
  margin: 0.8rem 1.6rem;
}

[data-menu-arrow] {
  aspect-ratio: 1;
  background-color: #fff;
  box-shadow: -0.1rem -0.1rem 0.1rem rgb(0 0 0 / 0.1);
  position: absolute;
  visibility: hidden;
  width: 0.8rem;
  :is([data-menu-trigger], [aria-haspopup]) + * > &,
  [data-portaled] > & {
    visibility: visible;
  }
  [data-menu-placement^='top'] & {
    box-shadow: -0.1rem -0.1rem 0.1rem rgb(0 0 0 / 0.2);
  }
  :is([data-menu-placement^='left'], [data-menu-placement^='right']) & {
    margin-top: 4px;
  }
}
