/* 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. */

.topnav {
  display: flex;
  align-items: center;
  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: a single boxed mono EXIT wordmark, matching the admin datasheet aesthetic */
.topnav__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  text-decoration: none;
  color: var(--fg);
}
.topnav__logo {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.15em;
  border: var(--border-strong);
  padding: 2px 6px;
  line-height: 1;
}

/* primary nav: middot-separated links */
.topnav__nav {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.topnav__nav a {
  position: relative;
  font-size: var(--fs-sm);
  text-decoration: none;
  color: var(--muted);
}
.topnav__nav a:hover,
.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: "·";
  position: absolute;
  right: calc(var(--sp-3) / -2);
  color: var(--ink-300);
}

/* appearance + identity, pinned right */
.topnav__end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.topnav__theme {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  padding: 2px 6px;
  line-height: 1.2;
  cursor: pointer;
}
.topnav__theme:hover {
  border-color: var(--line-strong);
}
.topnav__id {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.topnav__cell {
  white-space: nowrap;
  color: var(--fg);
}
.topnav__cell b {
  font-weight: 400;
  color: var(--muted);
  margin-right: var(--sp-1);
}
.topnav__logout {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  text-decoration: none;
  border: var(--border);
  border-radius: 0;
  color: var(--ink-600);
  line-height: 1;
}
.topnav__logout:hover {
  border-color: var(--line-strong);
  color: var(--fg);
}
.topnav__signin {
  margin-left: auto;
  font-size: var(--fs-sm);
  text-decoration: none;
  border: var(--border-strong);
  border-radius: 0;
  padding: var(--sp-1) var(--sp-3);
  color: var(--fg);
}
.topnav__signin:hover {
  text-decoration: none;
  border-color: var(--line-strong);
}

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