/* =========================================================================
   header.css — app header bar, nav, avatar, and the profile dropdown menu.

   LOAD ORDER: after tokens.css, base.css, layout.css, components.css;
   before pages.css, legacy.css. The `header.nav` back-compat aliases for
   every selector below live in legacy.css instead (see that file); nothing
   in this file depends on legacy.css's load position since the paired
   rules carry identical declarations and legacy.css is only ever more, not
   less, specific.
   ========================================================================= */

/* -------------------------------------------------------------------------
   Header + profile menu
   ------------------------------------------------------------------------- */
.app-header {
  display: flex; align-items: center; gap: var(--space-5);
  padding: var(--space-3) var(--space-8);
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  /* Its own stacking level above page content, so the profile menu hanging
     below it wins against anything the page raises -- the map's top bar is
     z-index 30 and comes later in the document, which at .profile__menu's
     equal 30 put the search card on top of the open menu. */
  position: relative; z-index: 100;
}
.app-header__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  letter-spacing: .04em;
  color: var(--text-heading);
  text-decoration: none;
  white-space: nowrap;
}
.app-header__brand:hover { text-decoration: none; color: var(--text-heading); }
.app-header__brand-logo {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 auto;
}

.standalone-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}
.standalone-brand__logo {
  display: block;
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.app-header__nav { display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; }
.app-header__nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: var(--space-1) 0;
  position: relative;
}
.app-header__nav a:hover { color: var(--text-body); text-decoration: none; }
.app-header__nav a.on {
  color: var(--text-heading);
}
.app-header__nav a.on::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px;
  height: 2px; background: var(--brand); border-radius: var(--radius-pill);
}

.app-header__spacer { flex: 1; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-pill);
  background: var(--surface-raised); border: 1px solid var(--border-default);
  color: var(--text-heading); font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: 0; flex-shrink: 0;
}

.profile { position: relative; }
.profile__button {
  display: flex; align-items: center; gap: var(--space-2);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-2); cursor: pointer;
  height: auto; font: inherit; color: var(--text-body);
}
.profile__button:hover { background: var(--surface-raised); }
.profile__caret { color: var(--text-muted); font-size: var(--text-xs); }

.profile__menu {
  position: absolute; top: calc(100% + var(--space-2)); right: 0; z-index: 30;
  min-width: 220px;
  background: var(--surface-raised); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); box-shadow: var(--shadow-overlay);
  padding: var(--space-2);
  display: flex; flex-direction: column;
}
.profile__menu[hidden] { display: none; }
.profile__menu.open { display: flex; }
.profile__menu a {
  display: block; color: var(--text-body); text-decoration: none;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}
.profile__menu a:hover, .profile__menu a:focus-visible { background: var(--surface-card); text-decoration: none; }
/* `border:0` + a single top border, otherwise the default 3D groove renders as
   an invisible gap on a dark surface -- the separators read as stray whitespace. */
.profile__menu hr {
  margin: var(--space-2) var(--space-1);
  border: 0; border-top: 1px solid var(--border-default);
}
.profile__id {
  padding: var(--space-2) var(--space-3) var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-1);
  align-items: flex-start;   /* else the Owner badge stretches the menu's full width */
}
.profile__id strong { color: var(--text-heading); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.profile__id .mono { color: var(--text-muted); }

/* =========================================================================
   Responsive — the header-owned half of app.css's original max-width:719.98
   block (the other half, .wrap/.narrow/.page-head, is in layout.css; the
   .facts/.admin-grid half is in pages.css). Appended after this file's own
   base rules above so the override wins.
   ========================================================================= */
@media (max-width: 719.98px) {
  .app-header { padding: var(--space-3) var(--space-4); gap: var(--space-3); }
  .app-header__nav { row-gap: var(--space-2); }
}
