/* =============================================================================
   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: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    min-block-size: var(--touch-target);
    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);
  }

  .app-bar__context { display: flex; align-items: center; gap: var(--space-xs); min-inline-size: 0; }
  .app-bar__mark { display: inline-flex; color: var(--accent); }

  /* 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);
  }

  /* 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;
    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 { 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); }
}
