/* Domain-wide LVL site sidebar (works with hub + marketing pages) */

:root {
  --lvl-sidebar-w: 272px;
}

/* When site-nav injects a fixed sidebar on marketing pages */
body.lvl-has-site-nav {
  --lvl-nav-pad: 0px;
}

/* Injected shell (pages without .hub) */
body.lvl-has-site-nav:not(:has(.hub)) {
  padding-left: var(--lvl-sidebar-w);
}
@media (max-width: 960px) {
  body.lvl-has-site-nav:not(:has(.hub)) {
    padding-left: 0;
  }
}

/* Prefer :has when available; fallback class from JS optional */
@supports not selector(body:has(.hub)) {
  body.lvl-has-site-nav.lvl-marketing-pad {
    padding-left: var(--lvl-sidebar-w);
  }
  @media (max-width: 960px) {
    body.lvl-has-site-nav.lvl-marketing-pad {
      padding-left: 0;
    }
  }
}

aside.sidebar.lvl-site-sidebar,
.hub aside.sidebar {
  background: linear-gradient(175deg, #121a2c 0%, #0d1422 45%, #0a101c 100%);
  border-right: 1px solid rgba(148, 163, 184, 0.14);
  padding: 0.9rem 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  z-index: 70;
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.22);
}

aside.sidebar.lvl-site-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--lvl-sidebar-w);
  height: 100vh;
  overflow: hidden;
}

.lvl-side-nav-scroll,
#side-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.55rem 0.85rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.sidebar-brand:hover {
  text-decoration: none;
  color: #fff;
}
.sidebar-brand .logo,
.logo {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.65rem;
  background: linear-gradient(135deg, #5b8cff, #8b5cf6);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  font-family: "Space Grotesk", Inter, system-ui, sans-serif;
  box-shadow: 0 0 18px rgba(91, 140, 255, 0.35);
  font-size: 0.75rem;
}
.sidebar-brand strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
}
.sidebar-brand span {
  display: block;
  font-size: 0.68rem;
  color: #8b9bb8;
}

.nav-section {
  margin-top: 0.7rem;
  padding: 0.35rem 0.6rem 0.25rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7a99;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.52rem 0.7rem;
  border-radius: 0.6rem;
  color: #b0bdd6;
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.nav-link:hover {
  color: #ffffff;
  background: rgba(79, 140, 255, 0.12);
  text-decoration: none;
}
.nav-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(79, 140, 255, 0.22), rgba(139, 92, 246, 0.12));
  border-color: rgba(147, 197, 253, 0.28);
  box-shadow: inset 3px 0 0 #60a5fa;
}
.nav-link .ico {
  width: 1.15rem;
  text-align: center;
  opacity: 0.9;
  flex-shrink: 0;
  font-size: 0.85rem;
}
.nav-link .lbl {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-foot {
  flex-shrink: 0;
  margin-top: 0.35rem;
  padding: 0.75rem 0.55rem 0.15rem;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 0.7rem;
  color: #6b7a99;
  line-height: 1.45;
}
.sidebar-foot a {
  color: #93c5fd;
}

/* Mobile drawer */
.sidebar-backdrop,
.lvl-site-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 65;
}
.sidebar-backdrop.open,
.lvl-site-backdrop.open {
  display: block;
}

.lvl-nav-fab.menu-btn,
button.lvl-nav-fab {
  display: none;
  position: fixed;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 80;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(11, 16, 32, 0.92);
  color: #fff;
  border-radius: 0.6rem;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  font-size: 1.05rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

@media (max-width: 960px) {
  body.lvl-has-site-nav:not(:has(.hub)) {
    padding-left: 0;
  }
  aside.sidebar.lvl-site-sidebar {
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    width: min(288px, 88vw);
  }
  aside.sidebar.lvl-site-sidebar.open {
    transform: translateX(0);
  }
  /* Hub pages already use .sidebar fixed pattern from hub.css */
  .hub .sidebar {
    /* keep hub.css mobile behavior */
  }
  .lvl-nav-fab.menu-btn,
  button.lvl-nav-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* Avoid double menu if hub topbar has menu-btn */
  .hub .topbar .menu-btn + * {
    /* ok */
  }
  body.lvl-has-site-nav .nav .nav-inner {
    padding-left: 3rem;
  }
}

/* Hub pages: keep sticky column; ensure scroll for long nav */
.hub {
  grid-template-columns: var(--lvl-sidebar-w) 1fr;
}
.hub .sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
@media (max-width: 960px) {
  .hub {
    grid-template-columns: 1fr;
  }
}

/* Reduce top marketing nav clutter slightly when sidebar present on desktop */
@media (min-width: 961px) {
  body.lvl-has-site-nav .nav-links a[href="/docs/"],
  body.lvl-has-site-nav .nav-links a[href="/status/"] {
    /* keep — domain sidebar is primary */
  }
}
