/* =============================================================================
   COMPONENT: app-bar — the persistent top bar (FEA-0000 / Dusk slice 1).
   Left: per-screen context (the local date on Today, the screen name elsewhere)
   as a tracked-caps kicker. Right: the care-recipient pill, which doubles as the
   one-tap team switcher (D-02). Stays put while content swaps in the Turbo Frame.
   ========================================================================== */
@layer components {
  .app-bar {
    display: grid;
    grid-template-columns: minmax(var(--touch-target), 1fr) minmax(0, max-content);
    align-items: center;
    column-gap: var(--space-sm);
    min-block-size: var(--touch-target);
    max-inline-size: 100%;
    padding: var(--space-2xs) max(var(--space-md), var(--safe-left)) var(--space-2xs) max(var(--space-md), var(--safe-right));
    background: var(--surface-raised);
    border-block-end: var(--border-width) solid var(--color-border);
    position: sticky;
    inset-block-start: 0;
    z-index: var(--z-header);
    box-sizing: border-box;
    overflow: hidden;
  }

  .app-bar__context {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    justify-self: start;
    min-block-size: var(--touch-target);
    min-inline-size: var(--touch-target);
    max-inline-size: 100%;
    padding-inline: var(--space-2xs);
    box-sizing: border-box;
    color: inherit;
    text-decoration: none;
    overflow: hidden;
    background: transparent;
    border: 0;
    font: inherit;
    cursor: pointer;
    text-align: start;
  }
  .app-bar__context:hover .app-bar__kicker,
  .app-bar__context:hover .app-bar__title { color: var(--accent); }
  .app-bar__mark { display: inline-flex; flex: none; color: var(--accent); }

  /* Teamless shell: brand + Sign out sit in the app-bar grid. */
  .app-bar__brand-form {
    justify-self: start;
    margin: 0;
    min-inline-size: 0;
    max-inline-size: 100%;
  }
  .app-bar__logout-form {
    justify-self: end;
    margin: 0;
  }
  .app-bar__logout {
    min-block-size: var(--touch-target);
    white-space: nowrap;
  }

  /* Context kicker: small tracked caps, muted — the date or screen name. */
  .app-bar__kicker {
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-bar__switcher {
    justify-self: end;
    min-inline-size: 0;
    max-inline-size: 100%;
  }

  /* Recipient pill (D-02): a compact surface pill — avatar + first name + a
     drill chevron when it can switch teams. Static (no chevron) for one team. */
  .app-bar__pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    min-block-size: var(--touch-target);
    min-inline-size: 0;
    max-inline-size: 100%;
    padding-inline: var(--space-2xs) var(--space-sm);
    background: var(--surface-sunken);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-pill);
    color: var(--color-text);
    text-decoration: none;
    font: inherit;
    cursor: pointer;

    &:hover { border-color: var(--color-border-strong); }
    &:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  }
  .app-bar__pill--static {
    justify-self: end;
    cursor: default;
  }
  .app-bar__pill--static:hover { border-color: var(--color-border); }

  .app-bar__title { font-weight: var(--weight-medium); min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-bar__chevron { color: var(--color-text-muted); flex: 0 0 auto; }

  /* Recipient avatar: solid identity fill with a light initial (see
     components/avatar.css), defaulting to the recipient gold; markup can
     override via --avatar-bg. */
  .app-bar__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 1.75rem;
    block-size: 1.75rem;
    flex: 0 0 auto;
    border-radius: var(--radius-pill);
    background: var(--avatar-bg, var(--person-5));
    color: var(--person-contrast);
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
  }

  /* Team switcher sheet rows (D-02). */
  .team-switcher__item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-block-size: var(--touch-target);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    color: var(--color-text);
    text-decoration: none;

    &:hover { background: var(--surface-sunken); }
    &:focus-visible { outline: none; box-shadow: var(--focus-ring); }
    &[aria-current="true"] { background: var(--accent-tint); }
  }
  .team-switcher__name { flex: 1 1 auto; min-inline-size: 0; }
  .team-switcher__current { color: var(--accent); }
}
