/* Public header: a sticky bar in the page colour with the centred wordmark and nothing else.
   Landing variant (.site-bar--landing + js/landing-bar.js): white wordmark over the hero,
   the bar appears once the hero has left the screen. Scripts off: the plain bar from the start.
   Organizer and admin: .top-bar, plum, not sticky. */

html:has(.site-bar) { scroll-padding-top: var(--header-h); }

.site-bar {
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-bar);
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--header-h);
  background: var(--page);
  box-shadow: var(--shadow-bar);
}
.site-bar__wordmark {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  min-width: 0;
  max-width: 100%;
  padding-inline: var(--space-3);
  color: var(--text);
  /* Large text (fix 4.34): the wordmark may shrink so it never wraps or sits under a button. */
  font-size: min(var(--text-xl), 7vw);
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.site-bar--over,
.site-bar--shown { position: fixed; inset-inline: 0; }
.site-bar--over { background: transparent; box-shadow: none; }
.site-bar--over .site-bar__wordmark { color: var(--white); }
/* Fix 4.16 (boards 1, 9, 15): over the hero the wordmark is larger, about 1.4x on phones and
   2x from 1024px, clamped by the viewport width so it never wraps at 320 or at 200% text. */
.site-bar--over .site-bar__wordmark { font-size: min(calc(var(--text-xl) * 1.4), 9vw); }
@media (min-width: 1024px) {
  .site-bar--over .site-bar__wordmark { font-size: min(calc(var(--text-xl) * 2), 5vw); }
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  min-height: var(--header-h);
  padding-inline: var(--gutter);
  background: var(--plum);
  color: var(--white);
}
/* The wordmark links to the public landing page (L23), drawn as plain text: 44px tall hit area. */
.top-bar__wordmark {
  grid-column: 2;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  min-width: 0;
  color: var(--white);
  font-size: min(var(--text-xl), 7vw);
  white-space: nowrap;
  font-weight: 700;
  text-decoration: none;
}
.top-bar__right { grid-column: 3; justify-self: end; position: relative; display: flex; align-items: center; }
.top-bar a { color: var(--white); }

/* Organizer and admin (fix M1): one profile button (round photo or initial) opening a menu
   with the name or "Admin", account links and Sign out. A <details>, so it works without script. */
.top-bar__menu { position: relative; }
.top-bar__button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: 50%;
  list-style: none;
  cursor: pointer;
}
.top-bar__button::-webkit-details-marker { display: none; }
.top-bar__button::marker { content: ""; }
.top-bar__photo,
.top-bar__initial {
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  border: 2px solid var(--white);
  border-radius: 50%;
}
.top-bar__photo { display: block; object-fit: cover; background: var(--surface); }
/* Initial: Ink on gold, same in both themes (contrast about 10:1). */
.top-bar__initial {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: var(--ink);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1;
}
.top-bar__panel {
  position: absolute;
  inset-block-start: calc(100% + var(--space-2));
  inset-inline-end: 0;
  z-index: var(--z-bar);
  box-sizing: border-box;
  width: max-content;
  min-width: 12rem;
  max-width: calc(100vw - 2 * var(--gutter));
  padding: var(--space-2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}
.top-bar__who {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-block-end: 1px solid var(--outline);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.top-bar__links { margin: 0; padding: 0; list-style: none; }
.top-bar__form { margin: 0; }
.top-bar__panel .top-bar__item {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  min-height: var(--tap-min);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--link);
  font: inherit;
  text-align: start;
  text-decoration: underline;
  cursor: pointer;
}

/* Focus: gold ring on the plum bar (M4's rule), the link colour inside the light menu. */
.top-bar a:focus-visible,
.top-bar button:focus-visible,
.top-bar summary:focus-visible {
  outline: var(--focus-ring-width) solid var(--gold);
  outline-offset: var(--focus-ring-gap);
}
.top-bar .top-bar__panel .top-bar__item:focus-visible {
  outline-color: var(--focus-ring);
  outline-offset: calc(-1 * var(--focus-ring-width));
}
