/* --- The app header ---
   Written flat, not nested: the centered shell draws this header and its
   language menu (centered_shell.css), and it is the frame of the page shown to
   a browser too old for ReadyNext (unauthenticated.md B-10). The browsers
   allow_browser's :modern turns away include every one that cannot read
   nested CSS, so on that page a nested rule here would be dropped. */

.app-header {
  position: sticky;
  top: var(--impersonation-strip-height);
  z-index: 20;
  background: var(--color-bg);
}

/* The centered shell's footer is this bar turned over: the same inset,
   its rule on the top edge (centered_shell.css). */
.app-header,
.app-footer {
  padding: 0 1.25rem;
}

.app-header .inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: var(--app-header-height);
  border-bottom: 1px solid var(--color-warm-border-strong);
  padding-left: 1rem;
}

/* The header flash takes the tool tier's metrics -- one height, one radius
   -- so it lines up with Feedback, the language switcher and the profile
   trigger rather than adding a size to that row. It departs from the tier
   in exactly one way, deliberately: those controls are bare until hovered,
   and this carries a rest fill, because it reports something rather than
   offering something and has to be legible without being pointed at. */
.app-header .inner:has(.app-header-flash) {
  justify-content: space-between;
  gap: 1.5rem;
}

.app-header .app-header-controls {
  display: flex;
  align-items: center;
  gap: 0;
  /* The header flash shares this row now and is the side that gives way. */
  flex-shrink: 0;
}

.app-header .app-header-controls .divider {
  width: 1px;
  height: 1.5rem;
  background: var(--color-warm-border);
  margin-left: 0.5rem;
  margin-right: 0.5rem;
}

@media (max-width: 40rem) {
  .app-shell .app-header {
    position: sticky;
    top: var(--impersonation-strip-height);
    z-index: 40;
    background: var(--color-bg);
  }

  .app-shell .app-header,
  .app-shell .app-footer {
    padding: 0;
  }

  .app-header .inner {
    height: var(--app-bar-height);
    gap: 0.2rem;
  }

  .app-header .inner,
  .app-footer .inner {
    padding-inline: var(--app-gutter);
  }
}

/* --- App header controls: Feedback, language, notifications, profile menu --- */

/* The tool tier: bare until hovered, so the header reads as content with
   affordances rather than a row of competing boxes. One height, one
   radius, no rest border or fill -- the only differences between them
   are whether they carry a label and which icon they carry. */
.header-feedback-button {
  display: inline-flex;
  align-items: center;
  height: var(--control-tool-size);
  border: 0;
  border-radius: var(--radius-sm);
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}
.header-language-menu-trigger,
.header-notifications-link,
.app-header .popover-menu-trigger {
  display: inline-flex;
  align-items: center;
  height: var(--control-tool-size);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-warm-muted);
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 0.12s ease,
    color 0.12s ease,
    var(--press);
}

/* Labelled controls are capsules; the icon-only notifications link and
   profile trigger are squares of the same height. */
.header-feedback-button,
.header-language-menu-trigger {
  gap: 0.4rem;
  padding: 0 0.6rem;
}

.header-language-menu-trigger {
  font-size: 0.85rem;
  font-weight: 600;
  list-style: none;
}

/* Flat, as the file's header comment says: the page shown to a browser too
   old for nested CSS draws this menu too. */
.header-language-menu-trigger::-webkit-details-marker {
  display: none;
}

/* The profile trigger is app chrome, not a row control, so it takes the
   tool tier rather than .popover-menu-trigger's cool-palette border
   and surface -- which is the styling the resource rows' kebabs want and
   which had leaked into the warm header. */
.app-header .popover-menu-trigger,
.header-notifications-link {
  justify-content: center;
  width: var(--control-tool-size);
  padding: 0;
  box-shadow: none;
}

/* The one hover in the chrome. Every tool-tier control washes to the same
   accent pill, and so do the secondary nav links; the place tier deepens
   to solid accent instead (see .nav-primary .link:hover). Between them
   that is the whole hover vocabulary of the shell -- nothing else in the
   chrome should introduce a third. */
.header-language-menu-trigger:hover,
.header-language-menu[open] .header-language-menu-trigger,
.header-notifications-link:hover,
.app-header .popover-menu-trigger:hover,
.app-header .popover-menu[open] .popover-menu-trigger {
  background: var(--color-warm-accent-bg);
  border-color: transparent;
  color: var(--color-warm-accent);
}

/* The status region around it (layouts/_header_flash), which the row lays out
   in its place and so has to let it shrink. */
.header-flash-region {
  display: flex;
  min-width: 0;
}

.app-header-flash {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

/* --tone/--tone-bg rather than a .status-tone--* class: those name a
   Monitor's health and a flash is not one, but the .status-badge-icon
   inside reads its colours from these, so they are the component's
   interface. */
.header-flash {
  display: flex;
  align-items: center;
  min-width: 0;
  height: var(--control-tool-size);
  padding: 0 0.6rem 0 0.3rem;
  border-radius: var(--radius-sm);
  background: var(--tone-bg);
  color: var(--tone);
  font-size: 0.85rem;
  gap: 0.3rem;
}

.header-flash--notice {
  --tone: var(--color-pass);
  --tone-bg: var(--color-pass-bg);
}

.header-flash--alert {
  --tone: var(--color-fail);
  --tone-bg: var(--color-fail-bg);
}

/* Truncates rather than wraps: the header is a fixed --app-header-height
   row and cannot grow. The full string stays reachable as the element's
   title, but the real constraint is on the copy -- keep flash strings
   short enough not to need it. The centered shell's header is capped to
   its 64rem column, so a long message truncates there first. */
.header-flash-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-flash-dismiss {
  display: none;
}

/* On a phone the bar has no room left of its controls -- the floating
   sidebar toggle holds that corner -- so the flash leaves the row for one
   of its own under it: a strip the bar's full width, wrapping rather than
   truncating, with a dismiss, since a long message there can take a fifth
   of the screen. It is still the one region in the header, so it stays
   pinned with the bar and a message streamed in later lands in it too.

   Folded in from the flash placement UI prototype (2026-11-11,
   .claude/skills/prototype/UI.md), round two of the question
   .scratch/flash-placement/ settled for the signed-in shell alone: one
   place for the flash in every shell, at every width. Won out over a
   banner atop the page (what the centered shell had, which scrolls away),
   a toast under the header and a bar at the bottom of the screen (both
   cover the page), and the pill wrapping inside the bar. The reasoning is
   in .scratch/flash-placement-shells/. */
@media (max-width: 40rem) {
  .app-header .inner:has(.app-header-flash) {
    flex-wrap: wrap;
    height: auto;
    row-gap: 0;
  }

  .app-header .inner:has(.app-header-flash) > :not(.header-flash-region) {
    display: flex;
    align-items: center;
    height: var(--app-bar-height);
  }

  .app-header .inner:has(.app-header-flash) .app-header-controls {
    margin-left: auto;
  }

  .app-header .inner > .header-flash-region:has(.app-header-flash) {
    order: 1;
    flex-basis: calc(100% + 2 * var(--app-gutter));
    margin-inline: calc(var(--app-gutter) * -1);
    border-top: 1px solid var(--color-warm-border-strong);
  }

  .app-header-flash {
    flex: 1;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .header-flash {
    align-items: flex-start;
    height: auto;
    padding: 0.6rem 0.5rem 0.6rem var(--app-gutter);
    border-radius: 0;
    font-size: 0.95rem;
    font-weight: 600;
    gap: 0.6rem;
  }

  .header-flash-text {
    flex: 1;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .header-flash-dismiss {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    margin: -0.2rem 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
  }
}

.profile-menu .popover-menu-items {
  min-width: 14rem;
}

.profile-menu .popover-menu-item {
  overflow-wrap: anywhere;
}
