/* ══════════════════════════════════════════════════════════ header ══
   The public pages' (SiteHeader), and the account forms' with no links
   (AuthLayout). From 901px the public one (.site-top) stays at the top as
   you scroll, so its links and join button are in reach down a long page.
   A phone's bar is two rows and would cost too much of the screen, so it
   scrolls away and the join bar takes over. A member's pages have the
   frame's bar (MemberLayout, frame.css). The wordmark is ground.css's
   .brand.

   The links lead from the wordmark and the end group sits at the edge, so
   the links stay put whatever the end holds: Danish is wider, and signed
   in it holds the initials (and a waiting account's pill) instead.        */

/* How much of the top of the screen the bar keeps covered: its height where it sticks, nothing
   where it scrolls away. The bar takes it as its height (below), so the two never differ; 72px, or
   4.5rem once a larger default font would make the links outgrow that. Not frame.css's --bar-h,
   which is the member frame's and loads here too. */
:root { --topbar-h: 0px; }
@media (min-width: 901px) { :root { --topbar-h: max(calc(2 * 18px + var(--ctl-h)), 4.5rem); } }

.topbar {
  display: flex;
  align-items: center;
  gap: clamp(14px, 3vw, 28px);
  max-width: var(--maxw);
  margin-inline: auto;
  padding: 18px var(--gutter);
}

/* A step larger than the members' frame: the logo leads the public pages and the account screens. */
.topbar .brand,
.auth > .brand { font-size: 1.25rem; }

.topnav { display: flex; gap: 24px; margin-inline-start: clamp(4px, 1.5vw, 16px); white-space: nowrap; }
.bar-end { display: flex; align-items: center; gap: 18px; margin-inline-start: auto; white-space: nowrap; }

/* The bar's own links only, never the account menu's inside it, which frame.css draws. */
.topnav a,
.bar-end > a:not(.btn) {
  color: var(--ink-soft);
  font-size: .9375rem;
  text-decoration: none;
  transition: color 160ms ease-out;
}
.topnav a:hover,
.bar-end > a:not(.btn):hover { color: var(--ink); }

/* The page you are on (NavLink's "active", with aria-current="page"), as the admin host marks it:
   ink and a rule under it. Never teal, which means "grew". */
.topnav a.active { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--ink); }

/* Signed in, the initials' menu (AccountMenu): under the button (the bar's 18px top padding and
   the control's height) and at the end of the 1360px column. Placed on the page where the bar
   scrolls away; where it sticks, fixed under it (below), since a popover in the top layer placed
   on the page would open at the page's top once you had scrolled. */
.topbar #account {
  position: absolute;
  inset: calc(18px + var(--ctl-h) + 6px) max(var(--gutter), calc((100% - var(--maxw)) / 2 + var(--gutter))) auto auto;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* The public bar from 901px: on the paper across the whole width, so nothing scrolling under it
   shows past its sides, with what it holds padded back into the 1360px column. */
@media (min-width: 901px) {
  .site-top {
    position: sticky;
    top: 0;
    z-index: 30;
    max-width: none;
    min-height: var(--topbar-h);
    padding-block: 0;
    padding-inline: max(var(--gutter), calc((100% - var(--maxw)) / 2 + var(--gutter)));
    background: var(--paper);
  }
  .site-top #account { position: fixed; top: calc(var(--topbar-h) - 12px); }
}

/* Every anchor jump, the skip link and every Tab stop land below the bar (WCAG 2.4.11), on top of
   [id]'s own margin, as the join bar's padding keeps them clear of the foot of a phone. */
html:has(.site-top) { scroll-padding-top: var(--topbar-h); }

/* A hairline under the bar once the page has moved, none at rest, so the bar reads as part of the
   page until something passes under it. Its own line fading in, since opacity follows the scroll
   on the compositor where a box-shadow would repaint the whole bar each frame. Without scroll
   timelines it never shows. */
@media (min-width: 901px) and (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    .site-top::after {
      content: "";
      position: absolute;
      inset: auto 0 -1px;
      height: 1px;
      background: var(--line);
      opacity: 0;
      pointer-events: none;
      animation: bar-rule linear both;
      animation-timeline: scroll();
      animation-range: 0 48px;
    }
  }
}
@keyframes bar-rule { to { opacity: 1; } }

/* Signed in but not let in yet: where they stand, as a quiet pill rather than one more link. */
.bar-end a.waiting {
  color: var(--ink);
  font-size: .8125rem;
  font-weight: 600;
  padding: .3rem .7rem;
  border: 1px solid var(--line-hi);
  border-radius: 999px;
  white-space: nowrap;
}
/* On /waiting itself (NavLink's "active"): an ink rim, as the nav marks the page you are on. */
.bar-end a.waiting.active { border-color: var(--ink); background: var(--tint); }

/* The language switch (LanguageSwitch). The header draws it as a link like the others; here it is
   the members' frame, whose frame.css is shared with the admin host and has no rule for it, and
   /account, which has no bar, so it sits where the bar's end would be. */
.top-end .lang-switch,
.auth > .lang-switch {
  color: var(--ink-soft);
  font-size: .875rem;
  text-decoration: none;
  transition: color 160ms ease-out;
}
.top-end .lang-switch:hover,
.auth > .lang-switch:hover { color: var(--ink); }
.top-end .lang-switch { display: inline-flex; align-items: center; min-height: var(--ctl-h); padding-inline: 6px; }
.auth > .lang-switch { position: absolute; top: 18px; inset-inline-end: var(--gutter); }

/* A phone or a small tablet: the links take their own row under the bar, every one in sight.
   Behind a menu button they are found less often (NN/g), and four fit. Tall enough to tap; the
   active rule sits on the row's edge like a tab. 900px, the member frame's own break: in Danish
   one row needs about 860px, and at 830px "Log ind" and the join button broke onto two lines. */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; padding-bottom: 0; }
  .topnav {
    order: 3;
    flex-basis: 100%;
    margin-inline-start: 0;
    gap: clamp(16px, 5vw, 28px);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .topnav a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* On a phone the hero's own "Start free" is on the first screen, so the bar keeps Sign in. A
   waiting account's pill leaves no room for the name beside the switch and the initials: the
   parcel stays as the way home, and the name stays for a screen reader. 520px, not a phone's
   usual 420: in Danish the join button beside "Log ind" needs about 500, and up to there the
   whole end dropped onto a row of its own, a 430px iPhone among them. */
@media (max-width: 520px) {
  /* Edge to edge, so a member's four links still fit a 360px phone. */
  .topnav { justify-content: space-between; gap: 8px; }
  .bar-end { gap: 14px; }
  .bar-end .btn { display: none; }
  .topbar:has(a.waiting) .brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
