/* The header sits on the page ground above the indigo hero, so it
   reads in ink, not in on-deep tones.

   Below 62rem the nav list lives in a popover panel and the toggle is
   visible; above it the panel is forced back into normal flow and the
   toggle is hidden. No JavaScript is involved either way. */

@layer components {
  .site-header {
    position: sticky;
    inset-block-start: 0;
    z-index: 20;
    padding-block: var(--space-s);
    background: var(--color-bg);
    border-block-end: 1px solid var(--color-line);
  }

  .site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-m);
  }

  .site-header__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
    text-decoration: none;
  }

  .brand-mark {
    flex: none;
    inline-size: 1.9rem;
    block-size: auto;
  }

  .site-header__wordmark {
    font-family: var(--font-display);
    font-size: var(--step-1);
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  .site-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-s);
  }

  /* Below 62rem the bar holds the mark, the phone number and the menu
     button and nothing else; the call to action moves into the panel,
     where it has room to be a full sentence. */
  .site-header__cta {
    display: none;
  }

  .site-nav__cta {
    margin-block-start: var(--space-2xs);
  }

  .site-header__phone {
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
  }

  .site-header__phone:hover,
  .site-header__phone:focus-visible {
    color: var(--color-accent);
  }

  /* -- the toggle ------------------------------------------------ */

  .site-nav__toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
    padding: var(--space-2xs) var(--space-xs);
    border: 1px solid var(--color-line);
    border-radius: 100px;
    background: none;
    color: inherit;
    font-family: var(--font-display);
    font-size: var(--step--1);
    font-weight: 600;
    font-stretch: var(--width-label);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    cursor: pointer;
  }

  .site-nav__bars {
    position: relative;
    inline-size: 1rem;
    block-size: 2px;
    background: currentColor;
  }

  .site-nav__bars::before,
  .site-nav__bars::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    block-size: 2px;
    background: currentColor;
  }

  .site-nav__bars::before {
    inset-block-start: -5px;
  }

  .site-nav__bars::after {
    inset-block-start: 5px;
  }

  /* -- the panel ------------------------------------------------- */

  .site-nav__panel {
    inset: auto;
    inset-block-start: 4.5rem;
    inset-inline: var(--gutter);
    inline-size: auto;
    max-inline-size: 22rem;
    margin-block: 0;
    margin-inline-start: auto;
    margin-inline-end: 0;
    padding: var(--space-s);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
    color: var(--color-ink);
  }

  .site-nav__list {
    display: grid;
    gap: var(--space-2xs);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .site-nav__list a {
    display: block;
    padding-block: var(--space-2xs);
    font-weight: 500;
    text-decoration: none;
  }

  .site-nav__list a:hover,
  .site-nav__list a:focus-visible {
    color: var(--color-accent);
  }

  @media (min-width: 62rem) {
    .site-nav__toggle {
      display: none;
    }

    /* Author styles beat the UA rules that hide a closed popover and
       pin it to the viewport, so the panel simply becomes a row. */
    .site-nav__panel {
      display: block;
      position: static;
      max-inline-size: none;
      padding: 0;
      border: 0;
      background: none;
    }

    .site-nav__list {
      grid-auto-flow: column;
      gap: var(--space-m);
    }

    .site-nav__list a {
      padding-block: 0;
      font-size: var(--step--1);
      white-space: nowrap;
    }

    .site-header__cta {
      display: inline-flex;
    }

    .site-nav__cta {
      display: none;
    }
  }
}
