/* The shared site nav built by mountNav() in /assets/app.js. Every page links this file, including
   the admin panel and the Lua docs, so the nav's styles live in exactly one place. Uses the
   palette variables each page defines on :root (--bg, --panel, --panel-2, --line, --text,
   --muted, --accent, --bad, --radius, --chip-1, --chip-2). */

/* #nav is only a mount point. Without this, the sticky header could only stick inside #nav's own
   box, which is exactly the header's height, so it scrolled away and left an empty gap above
   anything else pinned below it (the docs sidebar, the admin tab strip). */
#nav { display: contents; }

.site-header {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; min-height: 56px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40; box-shadow: 0 1px 0 rgba(255, 255, 255, .04), 0 4px 16px rgba(0, 0, 0, .2);
  font-size: 14px; line-height: normal;
}
.site-header a:hover { text-decoration: none; }
.nav-left, .nav-right, .nav-links, .nav-account { display: flex; align-items: center; gap: 4px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 16px; margin-right: 12px; }
.brand i { color: var(--accent); }
.nav-link { display: flex; align-items: center; gap: 7px; color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; }
.nav-link i { width: 14px; text-align: center; font-size: 12px; }
.nav-link:hover, .nav-link.on { color: var(--text); background: var(--panel-2); }
.nav-right .nav-link { padding: 7px 12px; }
.nav-who { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; padding: 4px 10px 4px 4px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.nav-who:hover, .nav-who.on { background: var(--panel-2); }
.nav-toggle { display: none; background: none; border: none; color: var(--muted); font-size: 16px; padding: 8px 10px; cursor: pointer; border-radius: 6px; }
.nav-toggle:hover { color: var(--text); background: var(--panel-2); }
.site-header .btn {
  display: inline-block; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px;
  color: var(--text); font: inherit; font-size: 12px; white-space: nowrap; text-decoration: none; cursor: pointer;
}
.site-header .btn:hover { border-color: #3a3a3f; background: #202023; }
.announcement { background: var(--panel-2); border-bottom: 1px solid var(--line); color: var(--text); font-size: 13px; line-height: normal; text-align: center; padding: 8px 16px; }

/* ------------------------------------------------------------------ avatars */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--chip-1), var(--chip-2)); flex: 0 0 auto;
  object-fit: cover;
}
.avatar-sm { width: 26px; height: 26px; font-size: 11px; }
.avatar-md { width: 40px; height: 40px; font-size: 15px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-xl { width: 96px; height: 96px; font-size: 30px; }

/* ------------------------------------------------------------------ notifications */
.notif-wrap { position: relative; }
.notif-bell { position: relative; background: none; border: none; color: var(--muted); font-size: 16px; padding: 8px 10px; cursor: pointer; border-radius: 6px; }
.notif-bell:hover { color: var(--text); background: var(--panel-2); }
.notif-badge {
  position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 999px;
  background: var(--bad); color: var(--bg); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 320px; max-width: calc(100vw - 32px); max-height: 420px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .4); z-index: 20;
}
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-list { display: grid; }
.notif-item { position: relative; display: block; padding: 10px 14px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--line); font-size: 13px; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--panel-2); }
.notif-item.unread { background: rgba(255, 255, 255, .05); }
.notif-item.unread::before { content: ''; position: absolute; left: 5px; top: 16px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.notif-when { color: var(--muted); font-size: 11px; margin-top: 2px; }
.notif-empty { padding: 20px 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------ narrow screens */
@media (max-width: 960px) and (min-width: 761px) {
  .site-header { padding: 0 12px; }
  .nav-link { font-size: 12px; padding: 8px 8px; }
}

/* Below this width the links and account controls collapse into a dropdown behind a hamburger
   toggle. The bell stays outside the collapse (see mountNav). */
@media (max-width: 760px) {
  .site-header { flex-wrap: wrap; padding: 8px 14px; }
  .nav-toggle { display: inline-flex; order: 1; }
  .notif-wrap { order: 0; }
  .nav-account { order: 2; }
  .nav-left { flex: 1 1 auto; min-width: 0; }
  .nav-links, .nav-account { display: none; }
  .site-header.menu-open .nav-left { flex-wrap: wrap; row-gap: 6px; }
  .site-header.menu-open .nav-links {
    display: flex; flex-direction: column; align-items: stretch; gap: 2px;
    flex: 0 0 100%; width: 100%; margin-top: 8px;
  }
  /* both groups take a full row each once open, so their children's 100% widths resolve against
     the real header width */
  .site-header.menu-open .nav-right { flex: 1 1 100%; width: 100%; flex-wrap: wrap; row-gap: 6px; }
  /* stays pinned where it was tapped instead of becoming its own row in the dropdown */
  .site-header.menu-open .nav-toggle { position: absolute; top: 12px; right: 14px; }
  .site-header.menu-open .nav-account {
    display: flex; flex-direction: column; align-items: stretch; gap: 2px; width: 100%;
    margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line);
  }
  .site-header.menu-open .nav-links .nav-link,
  .site-header.menu-open .nav-account .nav-link,
  .site-header.menu-open .nav-account .nav-who,
  .site-header.menu-open .nav-account .btn { width: 100%; box-sizing: border-box; }
  .site-header.menu-open .nav-account .nav-who { justify-content: flex-start; }
  .notif-panel { position: fixed; top: 60px; left: 12px; right: 12px; width: auto; max-width: none; }
}
