themes/olivero/css/components/navigation/nav-button-mobile.pcss.css
/**
 * @file
 * Nav Button Mobile.
 */

@import "../../base/media-queries.pcss.css";

.mobile-nav-button {
  position: relative;
  z-index: 505; /* Appear above mobile nav. */
  display: flex;
  align-items: center;
  align-self: center;
  width: var(--sp2);
  height: var(--sp2);
  margin-inline-start: auto;
  margin-inline-end: -6px;
  padding-block: 0;
  padding-inline-start: 6px;
  padding-inline-end: 6px;
  cursor: pointer;
  border: none;
  background: transparent;
  appearance: none;

  &:focus {
    outline: solid 2px var(--color--primary-40);
  }

  &:active {
    color: inherit; /* Override Safari's default UA styles. */
  }

  @media (--sm) {
    display: inline-flex;
    width: auto;
    padding-inline-start: var(--sp);
  }
}

/* Text that says "menu". */
.mobile-nav-button__label {
  position: absolute;
  display: block;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  width: 1px;
  height: 1px;
  word-wrap: normal;

  @media (--sm) {
    position: static;
    overflow: visible;
    clip: auto;
    width: auto;
    height: auto;
    margin-inline-end: 12px;
    letter-spacing: 0.05em;
    font-size: 14px;
    font-weight: 600;
  }
}

.mobile-nav-button__icon {
  position: relative;
  display: block;
  width: var(--sp2);
  height: 0;
  border-top: solid 3px var(--color--primary-50);

  &::before,
  &::after {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    width: 100%;
    height: 0;
    content: "";
    transition: transform 0.2s;
    border-top: solid 3px var(--color--primary-50);
  }

  &::before {
    transform: translateY(-11px);
  }

  &::after {
    transform: translateY(5px);
  }
}

.mobile-nav-button[aria-expanded="true"] .mobile-nav-button__icon {
  border-top-color: transparent;

  &::before {
    transform: translateY(-3px) rotate(-45deg);
  }

  &::after {
    transform: translateY(-3px) rotate(45deg);
  }
}
