/* The page's title and main actions, which stay at the top as the page scrolls under them. Its background reaches past
   the content to the edges of the page's column, which .app-main cuts it off at. Only its own children are styled
   here, since the dialogs of a selection bar in it have titles and actions too */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;

  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 3.5rem;
  margin-bottom: var(--space-4);
  padding: calc(var(--space-2) + env(safe-area-inset-top)) 0 var(--space-2);

  &::before {
    content: "";
    position: absolute;
    inset: 0 -100vmax;
    z-index: -1;

    background-color: var(--bar-bg-color);
    backdrop-filter: var(--bar-backdrop-filter);
    border-bottom: 1px solid var(--border-color);
  }

  /* A long name is cut short instead of making the bar taller */
  > :is(h1, .selection-count) {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  > h1 {
    font-size: var(--fs-h2);
  }

  > .selection-count {
    font-size: 1.125rem;
    font-weight: 600;
  }

  > .actions {
    flex-wrap: nowrap;
  }

  /* The main action stands out beside Select, which comes last and is set apart, since it changes size */
  > .actions > .menu-buttons {
    margin-right: var(--space-4);

    > .primary {
      order: 1;
    }
  }

  @media (min-width: 800px) {
    min-height: 4.5rem;

    > h1 {
      font-size: var(--fs-h1);
    }

    /* The actions for the selected ones follow how many there are, in room enough for hundreds so they stay put as
       the number changes */
    &:has(> .selection-bar) > .selection-count {
      flex: none;
      min-width: 7em;
      font-variant-numeric: tabular-nums;
    }
  }
}
