/* The navbar on every page but /login: the logo on the left, the pages and the account menu on the right (on phones, behind
   a ☰ button), on a see-through bar
   over the page's own background. Fixed over the Leaderboard's and Phone Board's TV screens, which start below it
   (NAV_HEIGHT); the form's scrolls away with the page. */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10; box-sizing: border-box; height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px;
  background: transparent; pointer-events: none;   /* only the logo and the links take clicks, not the bar between them */
  font: 600 15px/1 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}
.topnav > * { pointer-events: auto; }
.topnav .brand { flex: none; display: block; border-radius: 6px; }
.topnav .brand img { display: block; height: 42px; width: auto; filter: drop-shadow(0 1px 8px rgba(0, 0, 0, .75)); }
.topnav .links { position: relative; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px; }
.topnav .links a, .topnav .links button {
  font: inherit; color: rgba(255, 255, 255, .82); background: transparent; border: 0; border-radius: 999px;
  padding: 9px 14px; text-decoration: none; white-space: nowrap; cursor: pointer;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .7); transition: background-color .15s, color .15s;
}
.topnav .links a:hover, .topnav .links button:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.topnav .links a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45); }
.topnav a:focus-visible, .topnav button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.topnav [hidden] { display: none !important; }

/* /?demo-viewonly (demo.js): says the numbers are made up, on the bar just left of the links */
.topnav .demo-tag {
  margin-left: auto; margin-right: -8px; padding: 6px 12px; border-radius: 999px; white-space: nowrap; cursor: default;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; text-shadow: 0 1px 4px rgba(0, 0, 0, .7);
  color: #fde68a; background: rgba(251, 191, 36, .16); box-shadow: inset 0 0 0 1px rgba(251, 191, 36, .55);
}

/* Who's signed in (nav.js): a person icon that opens their name, email and Sign out */
.topnav .account { position: relative; margin-left: 6px; }
.topnav .links .account-btn {
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 50%;
  color: #fff; background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5);
}
.topnav .links .account-btn:hover, .topnav .links .account-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .22); }
.topnav .account-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }
.topnav .account-menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 20; box-sizing: border-box;
  width: max-content; min-width: 230px; max-width: min(320px, calc(100vw - 24px)); padding: 14px 6px 6px;
  text-align: left; line-height: 1.3; border-radius: 12px;
  background: rgba(12, 20, 32, .95); border: 1px solid rgba(255, 255, 255, .14); box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
  backdrop-filter: blur(10px);
}
.topnav .account-name { margin: 0 10px 3px; font-size: 15px; font-weight: 700; color: #fff; }
.topnav .account-email { margin: 0 10px; font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, .62); overflow-wrap: anywhere; }
.topnav .links .account-menu button {
  display: block; width: 100%; margin-top: 12px; padding: 10px; text-align: left; text-shadow: none; color: #fff;
  border-radius: 8px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
}
.topnav .links .account-menu button:hover { background: rgba(255, 255, 255, .1); }

/* The ☰ button (nav.js adds it to every page): only on phones, below */
.topnav .menu-btn { display: none; }

/* Phones and portrait screens: the bar scrolls away with the page, with the logo on the left and a ☰ button on the
   right that opens the pages, and who's signed in, in a box under it. (Never on the office TV: gate.js turns this
   query off there.) */
@media (max-width: 899px), (orientation: portrait) {
  .topnav { position: relative; height: auto; flex-wrap: nowrap; gap: 8px; padding: 12px 12px 0; }
  .topnav .brand img { height: 30px; }

  .topnav .menu-btn {
    display: grid; place-items: center; flex: none; width: 40px; height: 40px; margin-left: auto; padding: 0; border: 0;
    border-radius: 10px; color: #fff; cursor: pointer; -webkit-tap-highlight-color: transparent;
    background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5);
  }
  .topnav .menu-btn:hover, .topnav .menu-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .22); }
  .topnav .menu-btn span {
    grid-area: 1 / 1; width: 20px; height: 2px; border-radius: 2px; background: currentColor;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .45); transition: transform .2s, opacity .2s;
  }
  .topnav .menu-btn span:nth-child(1) { transform: translateY(-6px); }
  .topnav .menu-btn span:nth-child(3) { transform: translateY(6px); }
  /* open: the ☰ turns into an × */
  .topnav .menu-btn[aria-expanded="true"] span:nth-child(1) { transform: rotate(45deg); }
  .topnav .menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .topnav .menu-btn[aria-expanded="true"] span:nth-child(3) { transform: rotate(-45deg); }

  /* The box the ☰ opens: the pages one under another, then who's signed in and Sign out */
  .topnav .links {
    position: absolute; top: calc(100% + 8px); right: 12px; z-index: 20; box-sizing: border-box;
    width: min(300px, calc(100vw - 24px)); display: none; flex-direction: column; align-items: stretch; flex-wrap: nowrap;
    gap: 2px; padding: 8px; border-radius: 14px;
    background: rgba(12, 20, 32, .96); border: 1px solid rgba(255, 255, 255, .14); box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
    backdrop-filter: blur(10px);
  }
  .topnav.open .links { display: flex; animation: nav-drop .16s ease-out; }
  .topnav .links a, .topnav .links button {
    font-size: 16px; padding: 13px 14px; border-radius: 10px; text-align: left; text-shadow: none; color: rgba(255, 255, 255, .88);
  }
  .topnav .account { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, .12); }
  .topnav .links .account-btn { display: none; }
  .topnav .links .account-menu {   /* always shown in the box (when someone's signed in), not behind the person icon */
    display: block !important; position: static; width: auto; min-width: 0; max-width: none; padding: 10px 0 0;
    background: none; border: 0; box-shadow: none; backdrop-filter: none;
  }
  .topnav .account-name, .topnav .account-email { margin-left: 14px; margin-right: 14px; }
  .topnav .links .account-menu button { margin-top: 8px; padding: 13px 14px; box-shadow: none; }

  /* the demo's tag stays on the bar, beside the ☰ */
  .topnav .demo-tag { margin-right: 0; padding: 5px 10px; font-size: 11px; }
  .topnav .demo-tag ~ .menu-btn { margin-left: 0; }
}
@media (max-width: 409px) { .topnav .demo-more { display: none; } }   /* (just "Demo" when there's no room for the rest) */
@keyframes nav-drop { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) {
  .topnav .menu-btn span { transition: none; }
  .topnav.open .links { animation: none; }
}
