/* Universal system top-nav — IDENTICAL on every page for a signed-in user.
   Loaded by BOTH the React SPA (via web/index.html) and the vanilla admin pages
   (via /admin/*.html). It is token-only: it relies on the design tokens that each
   context already defines (the SPA's bundled tokens.css; the admin pages' admin.css
   :root mirror), so it renders the same in both. The markup is produced two ways —
   React in routes/root.tsx, vanilla in /shared/topnav.js — but the classes here are
   the single source of truth for how it looks.

   This is the "system-wide" bar: brand + primary nav + identity + sign-out. Anything
   page-specific (e.g. the admin directory's title + DIRECTORY/GROUPS tabs) belongs in
   a SEPARATE bar beneath it, not here. */

/* Everything in the bar shares ONE text baseline. Box-center alignment put
   bordered buttons, plain mono cells, and links on subtly different baselines —
   mathematically centered, visually adrift. The mark (an image, no baseline)
   stays box-centered on its own. */
.topnav {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: var(--border-strong);
  background: var(--paper);
  color: var(--fg);
  flex-shrink: 0;
}

/* brand: the door mark alone, from the SVG masters (mark-alone is the sanctioned
   form for a horizontal strip header; the lockup would not fit at its 90px minimum).
   Small mark, quiet — never scaled up to fill the bar. */
.topnav__brand {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: var(--sp-2);
  text-decoration: none;
  color: var(--fg);
  transition: opacity var(--duration-fast) var(--ease-out);
}
.topnav__brand:hover {
  opacity: var(--hover-opacity);
}
.topnav__mark {
  display: block;
  height: 22px;
  width: auto;
}

/* primary nav: interface links */
.topnav__nav {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
}
.topnav__nav a {
  position: relative;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
  color: var(--muted);
  transition: opacity var(--duration-fast) var(--ease-out);
}
.topnav__nav a:hover {
  opacity: var(--hover-opacity);
}
.topnav__nav a.is-active,
.topnav__nav a.active,
.topnav__nav a[aria-current="page"] {
  color: var(--fg);
}
.topnav__nav a:not(:last-child)::after {
  content: none;
}

/* appearance + identity, pinned right */
.topnav__end {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
}
.topnav__theme {
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg);
  height: 32px;
  padding: 0 var(--sp-3);
  line-height: 1;
  cursor: pointer;
}
.topnav__theme:hover {
  background: var(--surface-subtle);
}
.topnav__id {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  font-family: var(--font-ui);
  font-size: var(--fs-label);
}
.topnav__cell {
  white-space: nowrap;
  color: var(--fg);
}
.topnav__cell b {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  color: var(--muted);
  margin-right: var(--sp-1);
}
.topnav__logout {
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  height: 32px;
  padding: 0 var(--sp-3);
  line-height: 32px;
}
.topnav__logout:hover {
  background: var(--surface-subtle);
  color: var(--fg);
}
.topnav__signin {
  margin-left: auto;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--fg);
  color: var(--paper);
  height: 32px;
  padding: 0 var(--sp-3);
  line-height: 32px;
}
.topnav__signin:hover {
  text-decoration: none;
  background: color-mix(in srgb, var(--fg) 88%, var(--paper));
  color: var(--paper);
}

/* ---- phone (≤640): scrollable nav row; identity collapses to sign-out --------- */
@media (max-width: 640px) {
  .topnav {
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
  }
  .topnav__brand { flex: none; }
  /* primary nav scrolls horizontally instead of overflowing the row */
  .topnav__nav {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;              /* Firefox: hide bar, still scrolls */
    gap: var(--sp-4);                   /* more room between tap targets */
  }
  .topnav__nav::-webkit-scrollbar { display: none; }  /* WebKit: hide bar */
  .topnav__nav a { white-space: nowrap; }
  .topnav__nav a:not(:last-child)::after { content: none; }  /* drop middots in the scroll row */
  /* identity text is one tap away on /me — keep only the sign-out affordance */
  .topnav__end { margin-left: var(--sp-2); gap: var(--sp-2); }
  .topnav__id { gap: var(--sp-2); }
  .topnav__cell { display: none; }
  .topnav__signin { margin-left: 0; }
}
