@layer components {
  @scope (blog-nav-bar) to ([data-component]) {
    :scope {
      position: absolute;
      z-index: 20;
      top: 0;
      left: 50%;
      transform: translateX(-50%);
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: center;
      width: max-content;
      max-width: calc(100% - 1rem);
      margin: 1rem 0 0;
      padding: 0.25rem;
      font-weight: 500;
      font-size: 0.75rem;
      line-height: 1;
      font-family: var(--font-mono);

      &[data-scroll-floating="true"] {
        position: fixed;
        transform: translate(-50%, calc(-100% - 2rem));
      }

      &[data-scroll-floating="true"]:is([data-scroll-visible="true"], :focus-within, :has(.menu[open])) {
        transform: translate(-50%, 0);
      }

      &[data-scroll-ready="true"] {
        @media (prefers-reduced-motion: no-preference) {
          transition: transform 200ms ease;
        }
      }
    }

    .backdrop {
      border-radius: 9999px;
      position: absolute;
      z-index: -1;
      inset: 0;
    }

    .items {
      display: flex;
      align-items: center;
      gap: 2px;
    }

    .link {
      display: inline-flex;
      align-items: center;
      min-height: 2.25rem;
      padding-inline: clamp(0.375rem, 2vw, 0.75rem);
      border-radius: 9999px;
      color: inherit;
      text-decoration-line: none;
      white-space: nowrap;

      &[aria-current="page"] {
        background: rgb(255 255 255 / 80%);
        box-shadow: 0 1px 4px rgb(41 37 36 / 12%);

        :root[data-color-scheme="dark"] & {
          background: rgb(255 255 255 / 16%);
          box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
        }
      }

      &:hover:not([aria-current="page"]) {
        background: rgb(255 255 255 / 45%);

        :root[data-color-scheme="dark"] & {
          background: rgb(255 255 255 / 9%);
        }
      }
    }

    .menu {
      display: block;
    }

    .menu-details {
      position: relative;

      &::details-content {
        @media (prefers-reduced-motion: no-preference) {
          transition: content-visibility 180ms allow-discrete;
        }
      }
    }

    .menu-trigger {
      display: grid;
      place-items: center;
      width: 2.25rem;
      height: 2.25rem;
      border-radius: 50%;
      cursor: pointer;
      list-style: none;

      &::-webkit-details-marker {
        display: none;
      }

      &:hover,
      .menu[open] & {
        background: rgb(255 255 255 / 45%);

        :root[data-color-scheme="dark"] & {
          background: rgb(255 255 255 / 9%);
        }
      }
    }

    .menu-icon {
      width: 1.125rem;
      height: 1.125rem;
    }

    .menu-items {
      position: absolute;
      top: calc(100% + 0.75rem);
      right: -2rem;
      min-width: 7rem;
      box-sizing: border-box;
      padding: 0.5rem;
      border-radius: 1rem;
      font-weight: 500;
      font-size: 0.75rem;
      line-height: 1.25;
      font-family: var(--font-mono);

      @media (prefers-reduced-motion: no-preference) {
        opacity: 0;
        transform: translateY(-0.35rem);
        transition: opacity 180ms ease, transform 180ms ease;

        .menu-details[open] & {
          opacity: 1;
          transform: translateY(0);
          @starting-style {
            opacity: 0;
            transform: translateY(-0.35rem);
          }
        }
      }
    }

    .menu-link {
      display: flex;
      align-items: center;
      min-height: 2.25rem;
      padding: 0 0.75rem;
      border-radius: 9999px;
      color: inherit;
      text-decoration: none;
      white-space: nowrap;

      &:hover,
      &[aria-current="page"] {
        background: rgb(255 255 255 / 80%);
        box-shadow: 0 1px 4px rgb(41 37 36 / 12%);

        :root[data-color-scheme="dark"] & {
          background: rgb(255 255 255 / 16%);
          box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
        }
      }
    }
  }
}
