:root {
  --header-height: 104px;
  --anchor-offset: calc(var(--header-height) + 8px);
}

body > header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-raised);
  border-bottom: 0.5px solid var(--border);
  backdrop-filter: saturate(1.1) blur(8px);

  > div {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "brand . premium account"
      "main main search search";
    gap: 0 0.5rem;
    align-items: center;
    padding-block: 0 0.625rem;

    > a:first-child {
      grid-area: brand;
      display: inline-flex;
      align-items: center;
      color: var(--ink);

      img {
        display: block;
        width: auto;
        height: 2.25rem;
      }
    }

    > a[href="/pricing/"] {
      grid-area: premium;
      display: inline-flex;
      min-height: 2rem;
      align-items: center;
      justify-content: center;
      padding: 0 0.75rem;
      color: #fff;
      background: var(--clay-deep);
      border: 0.5px solid color-mix(in srgb, var(--clay-deep) 72%, #000);
      border-radius: 6px;
      box-shadow: var(--shadow);
      font-size: 0.8125rem;
      font-weight: 700;
      white-space: nowrap;

      &:hover {
        background: color-mix(in srgb, var(--clay-deep) 88%, #000);
        text-decoration: none;
      }
    }
  }

  nav[aria-label="Main"] {
    grid-area: main;
    min-width: 0;

    > ul {
      display: flex;
      gap: 0.375rem;
      padding: 0;
      margin: 0;
      overflow-x: auto;
      list-style: none;
      scrollbar-width: none;

      &::-webkit-scrollbar {
        display: none;
      }

      > li {
        position: relative;
        flex: 0 0 auto;
      }
    }

    button {
      display: inline-flex;
      min-height: 2rem;
      gap: 0.4375rem;
      align-items: center;
      padding: 0 0.75rem;
      color: var(--ink-muted);
      background: transparent;
      border: 0;
      border-radius: 6px;
      cursor: pointer;
      font: inherit;
      font-size: 0.875rem;
      white-space: nowrap;

      &::after {
        width: 0.3125rem;
        height: 0.3125rem;
        border: solid currentColor;
        border-width: 0 1px 1px 0;
        content: "";
        transform: translateY(-2px) rotate(45deg);
      }
    }

    li:hover > button,
    li:focus-within > button {
      color: var(--ink);
      background: var(--bg-sunken);
    }

    li > ul {
      position: absolute;
      top: 100%;
      left: 0;
      z-index: 150;
      display: none;
      gap: 0.125rem;
      min-width: 13rem;
      padding: 0.5rem;
      margin: 0;
      background: var(--bg-raised);
      border: 0.5px solid var(--border);
      border-radius: var(--rad);
      box-shadow: var(--shadow);
      list-style: none;
    }

    li:hover > ul,
    li:focus-within > ul {
      display: grid;
    }

    a,
    span {
      display: block;
      padding: 0.4375rem 0.5625rem;
      border-radius: 5px;
      font-size: 0.8125rem;
    }

    a {
      color: var(--ink);

      &:hover {
        background: var(--bg-sunken);
        text-decoration: none;
      }
    }

    span {
      margin-top: 0.25rem;
      color: var(--ink-faint);
      font-size: 0.6875rem;
      font-weight: 750;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }
  }

  form[role="search"] {
    grid-area: search;
    min-width: 0;
    margin: 0;

    input {
      width: 100%;
      min-height: 2rem;
      padding: 0 0.75rem;
      color: var(--ink);
      background: var(--bg-raised);
      border: 0.5px solid var(--border);
      border-radius: 6px;
      font: inherit;
      font-size: 0.8125rem;

      &::placeholder {
        color: var(--ink-faint);
      }

      &:focus {
        border-color: color-mix(in srgb, var(--clay-deep) 55%, var(--border));
        outline: 2px solid color-mix(in srgb, var(--clay-deep) 16%, transparent);
        outline-offset: 1px;
      }
    }
  }
}

@media (min-width: 64rem) {
  :root {
    --header-height: 64px;
  }

  body > header {
    > div {
      grid-template-columns: auto minmax(0, 1fr) minmax(12rem, 18rem) auto auto;
      grid-template-areas: "brand main search premium account";
      gap: 1rem;
      align-items: center;
      min-height: var(--header-height);
      padding-block: 0.75rem;

      > a:first-child img {
        height: 2.5rem;
      }
    }

    nav[aria-label="Main"] > ul {
      overflow: visible;
    }

    form[role="search"] input {
      min-height: 2.125rem;
    }
  }
}
