/*
 * site-header: content of the top bar (menu button, brand, optional search, user area).
 * Mixed with .app__header from layout.css; also renders standalone. The menu button opens the
 * drawer styled by site-nav.css (aria-expanded + aria-controls) and hides from 56.25em.
 */
@layer components {
  .site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    background: var(--color-surface);
    border-block-end: var(--border-width) solid var(--color-border);
  }

  /* Shared look of the header buttons: menu, search submit and sign out. */
  .site-header__control {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--space-12);
    padding: var(--space-2) var(--space-3);
    border: var(--border-width) solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);

    &:hover {
      background: var(--color-surface-sunken);
    }

    &:active,
    &[aria-expanded="true"] {
      border-color: var(--color-action);
      background: var(--color-action-tint);
      color: var(--color-action);
    }

    &:disabled {
      border-color: var(--color-border);
      background: var(--color-surface);
      color: var(--color-text-muted);
    }
  }

  .site-header__icon {
    flex: none;
    width: 1.25em;
    height: 1.25em;
  }

  .site-header__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-inline-end: auto;
    color: var(--color-text);
    font-weight: var(--weight-bold);
    text-decoration: none;

    &:hover {
      color: var(--color-action-hover);
    }
  }

  /* Below 37.5em the search drops to its own row so the top row never overflows. */
  .site-header__search {
    display: flex;
    flex-basis: 100%;
    order: 1;
    gap: var(--space-2);
  }

  .site-header__search-input {
    flex: 1;
    min-width: 0;
  }

  /* User area: initials, name (from 37.5em) and the sign-out button. */
  .site-header__user {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  /* Initials and name only from 37.5em: at 375px the top row has room for menu, brand and sign out. */
  .site-header__avatar {
    display: none;
    place-items: center;
    width: var(--space-8);
    height: var(--space-8);
    border-radius: var(--radius-full);
    background: var(--color-action);
    color: var(--color-on-action);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
  }

  .site-header__name {
    display: none;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
  }

  @media (min-width: 37.5em) {
    .site-header__search {
      flex: 0 1 32ch;
      order: 0;
    }

    .site-header__name {
      display: inline;
    }

    .site-header__avatar {
      display: inline-grid;
    }
  }

  @media (min-width: 56.25em) {
    .site-header {
      padding-inline: var(--space-8);
    }

    .site-header__menu {
      display: none;
    }
  }

  /* App shell header: the account button sits at the end; below 37.5em the logo shrinks so
     menu, logo and account share one row. */
  .site-header__user {
    margin-inline-start: auto;
  }

  .site-header__user .site-header__control {
    gap: var(--space-2);
  }

  @media (width < 37.5em) {
    .site-header > .brand-logo {
      --brand-logo-height: var(--space-6);
    }
  }
}
