/*
 * page-header: the first block of every screen. Title on the left, actions on the right, an optional
 * one-line description under the title and an optional slot (breadcrumb above, tabs below).
 * Markup: <header class="page-header">
 *           [<nav class="breadcrumb">…]
 *           <div class="page-header__row">
 *             <div class="page-header__text"><h1 class="page-header__title">…</h1><p class="page-header__description">…</p></div>
 *             <div class="page-header__actions">…buttons…</div>
 *           </div>
 *           [<div class="page-header__tabs">…tabs…]
 *         </header>
 * Below 37.5em the actions wrap under the title; the primary action stays last in the DOM, so it is the
 * one on the right (or the last row) everywhere.
 */
@layer components {
  .page-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding-block-end: var(--space-4);
    border-block-end: var(--border-width) solid var(--color-border);
  }

  .page-header__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3) var(--space-6);
  }

  .page-header__text {
    display: flex;
    flex: 1 1 24rem;
    flex-direction: column;
    gap: var(--space-1);
    min-inline-size: 0;
  }

  .page-header__title {
    font-size: var(--text-2xl);
    letter-spacing: var(--tracking-tight);
    overflow-wrap: anywhere;
  }

  /* A count or status next to the title ("12 alunos"), never a kicker above it. */
  .page-header__meta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-inline-start: var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--text-base);
    font-weight: var(--weight-regular);
    letter-spacing: normal;
    vertical-align: middle;
  }

  .page-header__description {
    max-inline-size: 65ch;
    color: var(--color-text-muted);
  }

  .page-header__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }

  /* Tabs sit flush with the header's bottom rule: the selected tab's bar replaces it. */
  .page-header__tabs {
    margin-block-end: calc(-1 * var(--space-4) - var(--border-width));
  }

  /* Compact: a section header inside a page (h2), same anatomy, smaller type and no rule. */
  .page-header--section {
    padding-block-end: 0;
    border-block-end: 0;

    & .page-header__title {
      font-size: var(--text-xl);
    }
  }

  @media (min-width: 37.5em) {
    .page-header__actions {
      justify-content: flex-end;
    }
  }
}
