/* Shared site navigation (includes/nav.php). Scoped to .site-nav so it can't leak into pages. */

:root { --sn-h: 60px; }

/* Room for the fixed bar on theme pages; the home page banner sits under it */
#page-wrapper { padding-top: var(--sn-h) !important; }
body.landing #page-wrapper { padding-top: 0 !important; }

.site-nav {
  --sn-bg: rgba(39, 40, 51, 0.97);
  --sn-panel: #272833;
  --sn-line: rgba(255, 255, 255, 0.08);
  --sn-text: rgba(255, 255, 255, 0.78);
  --sn-muted: rgba(255, 255, 255, 0.55);
  --sn-accent: #e44c65;

  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  height: var(--sn-h);
  background: var(--sn-bg);
  box-shadow: 0 1px 0 var(--sn-line), 0 4px 18px rgba(0, 0, 0, 0.25);
  color: var(--sn-text);
  font: 400 15px/1.2 Roboto, Helvetica, Arial, sans-serif;
  letter-spacing: 0.01em;
  text-align: left;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
.site-nav--static { position: relative; flex: none; }

/* Home page: see-through over the banner until you scroll */
body.landing .site-nav:not(.site-nav--static):not(.sn-scrolled):not(.sn-open) {
  background: transparent;
  box-shadow: none;
}

/* Neutralise the theme's global element styles inside the bar */
.site-nav *, .site-nav *::before, .site-nav *::after { box-sizing: border-box; }
/* :where() keeps these at class-level weight so the component rules below win */
.site-nav :where(ul) { list-style: none; margin: 0; padding: 0; }
.site-nav :where(li) { margin: 0; padding: 0; }
.site-nav :where(a) { border: 0; color: inherit; text-decoration: none; }
.site-nav :where(button) {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: none;
  cursor: pointer;
}
.site-nav :where(svg) { display: block; flex: none; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.site-nav a:focus-visible, .site-nav button:focus-visible { outline: 2px solid var(--sn-accent); outline-offset: 2px; }

/* ---------- Bar ---------- */
.sn-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

.sn-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.site-nav .sn-brand img { display: block; width: 34px; height: 34px; }

.sn-menu { height: 100%; margin-left: auto; }
.sn-list { display: flex; align-items: center; gap: 2px; height: 100%; }
.sn-item { position: relative; display: flex; align-items: center; height: 100%; }

.sn-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.sn-link:hover, .sn-drop-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.07); color: #fff; }
/* The theme forces pink on every a:hover; keep the bar white like its buttons */
.site-nav .sn-link:hover, .site-nav .sn-brand:hover, .site-nav .sn-drop-all:hover { color: #fff !important; }
.sn-item.is-active > .sn-link { color: #fff; }
.sn-item.is-active > .sn-link::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--sn-accent);
}

.sn-caret { width: 12px; height: 12px; stroke-width: 1.7; transition: transform 0.2s ease; }
.sn-drop-btn[aria-expanded="true"] .sn-caret { transform: rotate(180deg); }
.sn-ext { width: 10px; height: 10px; stroke-width: 1.5; opacity: 0.55; }

/* ---------- Dropdown ---------- */
.sn-drop {
  position: absolute;
  top: calc(100% - 6px);
  left: 50%;
  width: 310px;
  margin-left: -155px;
  padding: 8px;
  background: var(--sn-panel);
  border: 1px solid var(--sn-line);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
}
.sn-has-drop.is-open > .sn-drop { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

.sn-drop-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 10px;
  transition: background-color 0.15s ease;
}
.sn-drop-link:hover, .sn-drop-link.is-active { background: rgba(255, 255, 255, 0.06); }

.sn-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--g);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  background: color-mix(in srgb, var(--g) 16%, transparent);
  color: var(--g);
  font-size: 15px;
  font-weight: 700;
}
.sn-drop-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sn-drop-name { color: #fff; font-size: 15px; font-weight: 500; }
.sn-drop-about { overflow: hidden; color: var(--sn-muted); font-size: 12.5px; white-space: nowrap; text-overflow: ellipsis; }
.sn-drop-link.is-active .sn-drop-name { color: var(--g); }

.sn-drop-all {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding: 11px 10px 5px;
  border-top: 1px solid var(--sn-line);
  color: var(--sn-muted);
  font-size: 13.5px;
}

/* ---------- Account (Discord sign-in, includes/auth.php) ---------- */
.sn-signin {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 36px;
  margin-left: -8px;
  padding: 0 15px 0 12px;
  border-radius: 999px;
  background: #5865f2;
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}
.sn-signin:hover { background: #4752c4; }
.site-nav .sn-signin:hover { color: #fff !important; }
.sn-signin-icon { width: 18px; height: 18px; }

.sn-acct { flex: none; margin-left: -8px; }
.site-nav .sn-acct-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 9px 0 5px;
  border-radius: 999px;
  transition: background-color 0.15s ease;
}
.sn-acct-btn:hover, .sn-acct-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.07); color: #fff; }
.site-nav .sn-avatar {
  display: block;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  object-fit: cover;
}
.sn-acct-name { max-width: 140px; overflow: hidden; color: #fff; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
/* Name only where the full bar has room for it; avatar alone below that */
@media (max-width: 1359px) { .sn-acct-name { display: none; } }

.site-nav .sn-acct-drop { left: auto; right: 0; width: 260px; margin-left: 0; }
.sn-acct-head { display: flex; align-items: center; gap: 12px; padding: 8px 10px 12px; }
.site-nav .sn-acct-head .sn-avatar { width: 40px; height: 40px; }
.site-nav .sn-acct-out { margin: 0; padding-top: 6px; border-top: 1px solid var(--sn-line); }
.site-nav .sn-acct-out button,
.site-nav .sn-acct-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: auto;
  padding: 10px;
  border-radius: 10px;
  color: var(--sn-text);
  font-size: 14.5px;
  line-height: 1.2;
  text-align: left;
  transition: background-color 0.15s ease;
}
.site-nav .sn-acct-out button:hover,
.site-nav .sn-acct-link:hover,
.site-nav .sn-acct-link.is-active { background: rgba(255, 255, 255, 0.06); color: #fff !important; }
.sn-acct-out svg { width: 16px; height: 16px; stroke-width: 1.6; }

/* ---------- Hamburger ---------- */
.sn-burger {
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: auto;
  border-radius: 10px;
}
.sn-burger span,
.sn-burger span::before,
.sn-burger span::after {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: #fff;
}
.sn-burger span { position: relative; transition: background-color 0.2s ease; }
.sn-burger span::before,
.sn-burger span::after { content: ""; position: absolute; left: 0; transition: transform 0.25s ease; }
.sn-burger span::before { top: -7px; }
.sn-burger span::after { top: 7px; }
.sn-open .sn-burger span { background: transparent; }
.sn-open .sn-burger span::before { transform: translateY(7px) rotate(45deg); }
.sn-open .sn-burger span::after { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Phones & small tablets ---------- */
@media (max-width: 1199px) {
  :root { --sn-h: 56px; }

  .sn-bar { padding: 0 8px 0 14px; }
  .sn-brand { font-size: 16px; }
  .site-nav .sn-brand img { width: 30px; height: 30px; }
  .sn-burger { display: grid; }

  .sn-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: auto;
    max-height: calc(100vh - var(--sn-h));
    max-height: calc(100dvh - var(--sn-h));
    overflow-y: auto;
    background: var(--sn-panel);
    border-top: 1px solid var(--sn-line);
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .sn-open .sn-menu { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

  .sn-list { flex-direction: column; align-items: stretch; gap: 2px; height: auto; padding: 8px 10px 14px; }
  .sn-item { display: block; height: auto; }
  .sn-link { justify-content: space-between; width: 100%; height: 48px; padding: 0 14px; font-size: 16px; }
  .sn-item.is-active > .sn-link { background: rgba(228, 76, 101, 0.13); }
  .sn-item.is-active > .sn-link::after { top: 12px; bottom: 12px; left: 0; right: auto; width: 3px; height: auto; border-radius: 0 3px 3px 0; }

  .sn-drop {
    position: static;
    display: none;
    width: auto;
    margin: 0;
    padding: 4px 0 8px 10px;
    background: none;
    border: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
  }
  .sn-has-drop.is-open > .sn-drop { display: block; }
  .sn-drop-all { border-top: 0; padding: 10px 14px 4px; }

  /* Account stays in the bar, just left of the menu button */
  .sn-bar { gap: 8px; }
  .sn-signin, .site-nav .sn-acct { order: 1; margin-left: auto; }
  .sn-burger { order: 2; margin-left: 0; }
  .sn-signin { height: 34px; padding: 0 13px 0 11px; font-size: 14px; }
  .site-nav .sn-acct { display: flex; height: 100%; }
  .site-nav .sn-acct-btn { padding-right: 7px; }
  .site-nav .sn-acct { position: static; }   /* menu lines up with the screen edge, not the avatar */
  .site-nav .sn-acct .sn-acct-drop {
    position: absolute;
    top: calc(100% + 4px);
    right: 8px;
    display: block;
    width: min(270px, calc(100vw - 16px));
    padding: 8px;
    background: var(--sn-panel);
    border: 1px solid var(--sn-line);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
  }
  .site-nav .sn-acct.is-open > .sn-acct-drop { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
}

/* Narrow phones: the Discord logo alone, so the site name still fits */
@media (max-width: 359px) {
  .sn-signin { width: 36px; padding: 0; justify-content: center; }
  .sn-signin span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .site-nav, .site-nav * { transition: none !important; }
}
