/* ══════════════════════════════════════════════════════════════
   BashaByte · Site navbar (templates/partials/app_nav.html)
   One navbar for every page. Self-contained: its own tokens and
   resets, so it renders the same next to Bootstrap (base.html)
   and next to home.css (courses, landing page).
   ══════════════════════════════════════════════════════════════ */

.bbn {
  --bbn-h: 64px;
  /* Points at the shared palette in tokens.css (DD-28). */
  --bbn-bg: var(--bb-surface);
  --bbn-surface: var(--bb-surface);
  --bbn-ink: var(--bb-text);
  --bbn-muted: var(--bb-text-secondary);
  --bbn-faint: var(--bb-text-tertiary);
  --bbn-line: var(--bb-border);
  --bbn-line-strong: var(--bb-border-strong);
  --bbn-hover: var(--bb-surface-subtle);
  --bbn-accent: var(--bb-accent);
  --bbn-on-accent: var(--bb-text-on-accent);
  --bbn-danger: var(--bb-danger);
  --bbn-shadow: var(--bb-shadow-2);

  position: sticky; top: 0; z-index: 1030;
  height: var(--bbn-h);
  border-bottom: 1px solid var(--bbn-line);
  background: var(--bbn-bg);
  color: var(--bbn-ink);
  font: 500 14px/1.4 var(--bb-font-sans, "Inter", system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, border-color 0.25s ease;
}
/* Landing page: transparent over the hero until the page scrolls. */
.bbn.is-overlay:not(.is-scrolled) { background: transparent; border-bottom-color: transparent; }

/* Resets (Bootstrap's reboot and home.css both style these elements). */
.bbn *, .bbn *::before, .bbn *::after { box-sizing: border-box; }
.bbn a { color: inherit; text-decoration: none; }
.bbn p { margin: 0; }
.bbn button { margin: 0; font: inherit; color: inherit; cursor: pointer; }
.bbn hr { margin: 6px 0; border: 0; border-top: 1px solid var(--bbn-line); opacity: 1; }
.bbn :focus-visible { outline: 2px solid var(--bbn-accent); outline-offset: 2px; border-radius: 8px; }

.bbn-inner {
  display: flex; align-items: center; gap: 28px;
  height: 100%; width: min(calc(100% - 32px), 1440px); margin-inline: auto;
}

/* Brand */
.bbn-brand { display: inline-flex; align-items: center; gap: 10px; flex: none; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.bbn-brand img { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; }
.bbn-brand b { color: var(--bbn-accent); font-weight: 700; }

/* Primary links */
.bbn-links { display: flex; align-items: center; gap: 2px; min-width: 0; }
.bbn-links > a, .bbn-soon {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: var(--bb-radius-sm, 6px);
  color: var(--bbn-muted); font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: color 0.2s ease, background 0.2s ease;
}
.bbn-links > a:hover { color: var(--bbn-ink); background: var(--bbn-hover); }
.bbn-links > a.is-active { color: var(--bbn-ink); background: transparent; }
.bbn-links > a.is-active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -15px; height: 2px;
  border-radius: 2px; background: var(--bbn-accent);
}
.bbn-soon { color: var(--bbn-faint); cursor: default; }
.bbn-soon small {
  padding: 1px 5px; border: 1px solid var(--bbn-line-strong); border-radius: var(--bb-radius-xs, 4px);
  font: 600 10px/1.3 var(--bb-font-sans, sans-serif); letter-spacing: 0.04em; text-transform: uppercase;
}
.bbn-sep { width: 1px; height: 18px; margin: 0 6px; background: var(--bbn-line-strong); }

/* Right side */
.bbn-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: none; }
.bbn-icon {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--bbn-line-strong); border-radius: var(--bb-radius-md, 8px); background: transparent;
  color: var(--bbn-muted); font-size: 16px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.bbn-icon:hover { color: var(--bbn-ink); border-color: var(--bb-border-control); }
#bbn-theme i { transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1); }
#bbn-theme:hover i { transform: rotate(40deg); }
.bbn-burger { display: none; }

.bbn-text { color: var(--bbn-muted); font-weight: 600; }
.bbn-text:hover { color: var(--bbn-ink); }
.bbn-cta {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: var(--bb-radius-md, 8px); background: var(--bbn-accent); color: var(--bbn-on-accent) !important;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.bbn-cta:hover { background: var(--bb-accent-hover); }

/* Account menu */
.bbn-account { position: relative; }
.bbn-me {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px 0 4px;
  border: 1px solid var(--bbn-line-strong); border-radius: var(--bb-radius-md, 8px); background: transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.bbn-me:hover, .bbn-me[aria-expanded="true"] { border-color: var(--bb-border-control); background: var(--bbn-hover); }
.bbn-me > i { color: var(--bbn-faint); font-size: 11px; transition: transform 0.25s ease; }
.bbn-me[aria-expanded="true"] > i { transform: rotate(180deg); }
.bbn-me-name { max-width: 140px; overflow: hidden; font-size: 13.5px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.bbn-avatar {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--bb-radius-sm, 6px);
  background: var(--bbn-accent); color: var(--bbn-on-accent); font-size: 13px; font-weight: 700;
}
.bbn-menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 2;
  display: grid; gap: 2px; width: 240px; padding: 8px;
  border: 1px solid var(--bbn-line-strong); border-radius: 12px;
  background: var(--bbn-surface); box-shadow: var(--bbn-shadow);
}
.bbn-menu[hidden] { display: none; }
.bbn-menu-head { display: grid; gap: 2px; padding: 8px 10px 10px; margin-bottom: 4px !important; border-bottom: 1px solid var(--bbn-line); }
.bbn-menu-head b { font-size: 14px; font-weight: 700; }
.bbn-menu-head span { overflow: hidden; color: var(--bbn-faint); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.bbn-menu a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--bbn-muted); font-size: 14px; font-weight: 600;
}
.bbn-menu a i { width: 16px; color: var(--bbn-faint); font-size: 15px; }
.bbn-menu a:hover, .bbn-menu a[aria-current="page"] { color: var(--bbn-ink); background: var(--bbn-hover); }
.bbn-menu a.is-danger:hover, .bbn-menu a.is-danger:hover i { color: var(--bbn-danger); }

/* Login / register pages: brand and theme switch only. */
.auth-page .bbn-links, .auth-page .bbn-burger, .auth-page .bbn-text, .auth-page .bbn-cta, .auth-page .bbn-account { display: none; }

/* ── Small screens: links collapse into a panel under the bar ── */
@media (max-width: 1020px) {
  .bbn-soon { display: none; }
}
@media (max-width: 900px) {
  .bbn-burger { display: grid; }
  .bbn-me-name, .bbn-me > i { display: none; }
  .bbn-me { padding: 0 4px; }
  .bbn-links {
    position: absolute; top: calc(var(--bbn-h) - 4px); left: 12px; right: 12px;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 8px;
    border: 1px solid var(--bbn-line-strong); border-radius: 12px;
    background: var(--bbn-surface); box-shadow: var(--bbn-shadow);
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  }
  .bbn-links.is-open { opacity: 1; visibility: visible; transform: none; }
  .bbn-links > a, .bbn-soon { height: 44px; padding: 0 14px; border-radius: 8px; font-size: 15px; }
  .bbn-links > a.is-active::after { left: 0; right: auto; top: 12px; bottom: 12px; width: 3px; height: auto; }
  .bbn-soon { display: inline-flex; justify-content: space-between; }
  .bbn-sep { width: auto; height: 1px; margin: 6px 4px; }
  .bbn.is-overlay:not(.is-scrolled) .bbn-links { background: var(--bbn-surface); }
}
@media (max-width: 420px) {
  .bbn-inner { gap: 12px; }
  .bbn-brand span { display: none; }
  .auth-page .bbn-brand span { display: inline; }
  .bbn-text { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bbn, .bbn-links, .bbn-me > i, #bbn-theme i { transition: none; }
}
@media print { .bbn { display: none !important; } }
