/* ==========================================================================
   Thames Uro — site header  (v1, 1 Oct 2026)
   Requires tokens.css. Rendered by /assets/nav.js; see DESIGN_SYSTEM.md → Header.

   Two variants, one structure (Fin, 1 Oct 2026: "two variants, each consistent"):
     .tunav--public   marketing / info pages: translucent, blurred, 1040px
     .tunav--app      viva room + Part 1: solid surface bar with a teal top rule
   Same brand lockup, same link order, same controls (◑, Sign in, ☰) in both.

   Every selector is namespaced (.tunav / .tn-*) so a page's own legacy
   .brand / .navlinks / nav{} rules can't leak in, and vice versa.
   ========================================================================== */

.tunav {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
}
.tunav--app {
  background: var(--surface);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-top: 3px solid var(--accent);
  box-shadow: 0 2px 8px color-mix(in srgb, #000 18%, transparent);
}

.tn-in {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  position: relative;
}

/* brand lockup: logo + wordmark, byline underneath (sizes are the lockup's own) */
/* the brand block is the one thing allowed to shrink: on a phone the byline ellipsises rather than
   pushing ◑ / Sign out / ☰ off-screen (measured: account overflowed 375px by 14px with flex:none) */
.tn-brandwrap { display: flex; flex-direction: column; flex: none; min-width: 0; overflow: hidden; }
/* ...but only when folded (see below). Unfolded, the brand never shrinks: with flex-shrink on, the
   wrapping link row squeezed the wordmark to "Thames Ur" at 1280px. */
.tn-brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: var(--fw-heavy); font-size: var(--fs-lg);
  color: var(--text); text-decoration: none; white-space: nowrap;
}
.tn-brand svg { width: 26px; height: 26px; flex: none; }
.tn-byline {
  font-size: .62rem; color: var(--text-2);
  margin: 2px 0 0 35px; letter-spacing: .08em;
  text-transform: uppercase; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.tn-byline:empty { display: none; }
/* tight (nav.js fit(), step 2): the byline drops its page part ("· How it works"), keeping "FRCS (Urol)",
   so it no longer makes the brand block wider than the wordmark */
.tunav.tn-tight .tn-byline-page { display: none; }

.tn-links {
  display: flex; align-items: center; gap: 1px;
  flex-wrap: wrap; justify-content: flex-end; margin-left: auto;
}
.tn-right { display: flex; align-items: center; gap: 3px; flex: none; }

.tn-link {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; border: none;
  color: var(--text-2);
  /* 7px sides (was 10): the public bar's 8 links + Sign in then fit one row in the 1040px container
     (712 of 730px measured); narrower windows fold to ☰ rather than wrap (nav.js fit()) */
  padding: 6px 7px; border-radius: var(--r-sm);
  font: inherit; font-size: .85rem; font-weight: var(--fw-semibold);
  white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.tn-link:hover { background: var(--border); color: var(--text); }
.tn-link[aria-current="page"] { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); }
.tn-link.tn-signin { border: 1px solid var(--border); color: var(--text); }
.tn-link[hidden] { display: none !important; }   /* .tn-link sets display; restore [hidden] (estate-wide trap) */
.tn-new {
  font-size: .58rem; font-weight: var(--fw-heavy); letter-spacing: .04em;
  background: var(--accent); color: var(--on-accent);
  border-radius: var(--r-pill); padding: 1px 6px;
}

.tn-thm, .tn-toggle {
  background: transparent; border: none; color: var(--text-2);
  line-height: 1; cursor: pointer; font-family: inherit;
  border-radius: var(--r-sm);
}
.tn-thm { font-size: 1.05rem; padding: 6px 9px; }
.tn-toggle { display: none; color: var(--text); font-size: 1.35rem; padding: 4px 9px; }
.tn-thm:hover, .tn-toggle:hover { background: var(--border); color: var(--text); }

.tunav :is(.tn-link, .tn-thm, .tn-toggle, .tn-brand):focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}
@media (pointer: coarse) { .tn-link, .tn-thm, .tn-toggle { min-height: 44px; } }

@media (max-width: 860px) { .tn-in { padding: var(--sp-3) var(--sp-4); } }

/* FOLDED: links behind ☰; brand left, controls right. nav.js adds .tn-fold whenever the links will not
   fit on one row (always on a phone, and on narrower desktop windows), so the bar never wraps to two
   rows. There is no fixed breakpoint: the fold follows the actual widths of the links. */
.tunav.tn-fold .tn-brandwrap { flex: 0 1 auto; }
.tunav.tn-fold .tn-toggle { display: inline-flex; align-items: center; }
.tunav.tn-fold .tn-right { margin-left: auto; }
.tunav.tn-fold .tn-links {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  flex-direction: column; align-items: stretch; justify-content: flex-start;
  margin: 0; gap: 2px; padding: var(--sp-2) var(--sp-4) var(--sp-3);
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-2); z-index: 30;
}
.tunav.tn-fold .tn-links.open { display: flex; }
.tunav.tn-fold .tn-links .tn-link { width: 100%; justify-content: flex-start; padding: 11px 12px; font-size: .95rem; min-height: 44px; }

/* the narrowest phones (320px): tighten the bar so a signed-out visitor's Sign in pill, ◑ and ☰ leave the
   full wordmark (measured 10px short at 320 before) */
@media (max-width: 380px) {
  .tn-in { padding-left: var(--sp-3); padding-right: var(--sp-3); gap: var(--sp-2); }
  .tn-brand { gap: 7px; }
  .tn-thm { padding: 6px 6px; }
  .tn-link.tn-signin { padding: 6px 8px; }
  .tn-toggle { padding: 4px 6px; }
}

/* app variant: during a live viva station only the in-exam tools survive (Fin's rule, 23 Sep 2026) */
.tunav.in-station .tn-brandwrap,
.tunav.in-station .tn-links,
.tunav.in-station .tn-toggle,
.tunav.in-station .tn-right > :not(.keep-in-station) { display: none !important; }
.tunav.in-station .tn-right { margin-left: auto; }
