/* Maintenance gate via root class — no JS race conditions */
html.locked .layout { display: none; }
html.locked #maintenance { display: flex; }
html.unlocked #maintenance { display: none; }

:root {
  --bg: #0b0b0f;
  --card: #111319;
  --border: #262a33;
  --text: #e8e9ef;
  --muted: #b7bccb;
  --link: #ffd15c;
  --accent: #ffcc4d;
  --sidebar-width: 350px;
  --scrollbar-size: 12px;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Inter, Helvetica Neue, Arial, Noto Sans, Apple Color Emoji, Segoe UI Emoji;
}

body.drawer-open {
  overflow: hidden;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  background: linear-gradient(180deg, #1a1c23, #12141a);
  border-bottom: 1px solid var(--border);
}

.banner {
  display: block;
  width: 100%;
  height: auto;
  max-height: 240px;
  padding: 0;
}

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar-column {
  display: flex;
  flex: 0 0 var(--sidebar-width);
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  background: #1a1a1a;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.topbar {
  display: none;
}

.sidebar {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
  color: #eee;
  overflow: hidden;
}

.brand {
  flex: 0 0 auto;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 16px;
}

#nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  margin: 0;
  padding: 0 8px 16px 16px;
  scrollbar-gutter: stable;
}

.content {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: #181818;
  color: #eee;
  padding: 24px 28px 56px;
  scrollbar-gutter: stable;
}

.doc-content { max-width: 980px; }
.doc-content h1,
.doc-content h2,
.doc-content h3 { line-height: 1.25; margin: 1.25em 0 0.5em; }
.doc-content h1 { font-size: 2rem; }
.doc-content h2 { font-size: 1.5rem; }
.doc-content h3 { font-size: 1.2rem; color: var(--muted); }
.doc-content p,
.doc-content ul,
.doc-content ol { color: var(--text); margin: 0.7em 0; }
.doc-content code,
.doc-content pre {
  background: #0f1117;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.15em 0.4em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, Liberation Mono, monospace;
}
.doc-content pre { padding: 12px 14px; overflow: auto; }
.doc-content img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 36px;
  padding-top: 12px;
  color: var(--muted);
}

.medium-zoom-image {
  max-width: none !important;
  max-height: none !important;
}

/* shared scrollbar styling */
#nav,
.content {
  scrollbar-width: auto;
  scrollbar-color: #3b4252 #14161d;
}

#nav::-webkit-scrollbar,
.content::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

#nav::-webkit-scrollbar-track,
.content::-webkit-scrollbar-track {
  background: #14161d;
}

#nav::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb {
  background: #3b4252;
  border-radius: 999px;
  border: 2px solid #14161d;
}

#nav::-webkit-scrollbar-thumb:hover,
.content::-webkit-scrollbar-thumb:hover {
  background: #535d72;
}

/* nav links */
#nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  border: 1px solid transparent;
}

#nav a:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}

#nav a.active {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
  color: #fff;
  font-weight: 700;
}

/* maintenance overlay */
.hidden { display: none; }
#maintenance {
  position: fixed;
  inset: 0;
  background: #0b0b0f radial-gradient(circle at 50% 35%, #ff000008, #000);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #eee;
  z-index: 9999;
  text-align: center;
}
.maintenance-inner {
  background: rgba(0, 0, 0, 0.6);
  padding: 40px 50px;
  border-radius: 14px;
  border: 1px solid #333;
}
#maintenance h1 {
  font-size: 1.8rem;
  color: var(--accent, #ffcc4d);
  margin-bottom: 0.4em;
}

/* iBOM embed area */
.ibom-frame-wrap {
  height: calc(100vh - 240px - 56px);
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.ibom-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* navigation groups */
.nav-group-header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  margin: 0 0 4px;
}

.nav-group-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

.group-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  font-size: 14px;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
}

.group-toggle:hover { opacity: 0.8; }

.group-toggle::before {
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent var(--accent);
  content: "";
  transition: transform 0.15s ease;
}

.group-toggle.expanded::before {
  transform: rotate(90deg);
}

.nav-group-content {
  display: none;
  margin-left: 12px;
}

.nav-group-content.expanded {
  display: block;
}

#nav .nav-group-header + .nav-group-content a {
  padding-left: 32px;
  font-size: 0.95em;
  color: var(--muted);
  border-left: 2px solid transparent;
}

#nav .nav-group-header + .nav-group-content a.active {
  border-left-color: var(--accent);
  color: #fff;
}

.hamburger,
.mobile-topbar {
  display: none;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 999;
}

.sidebar-overlay.show {
  display: block;
}

@media (max-width: 860px) {
  .layout {
    display: block;
    height: auto;
    overflow: visible;
  }

  .sidebar-column {
    display: block;
    width: auto;
    height: auto;
    border-right: 0;
    background: transparent;
    overflow: visible;
  }
}

@media (max-width: 768px) {
  :root {
    --hamburger-offset: 12px;
    --hamburger-size: 40px;
    --hamburger-gap: 24px;
  }

  .banner {
    margin-top: 75px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(350px, 86vw);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1000;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.4);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-column {
    background: transparent;
  }

  .sidebar {
    border-right: 1px solid var(--border);
  }

  #nav {
    padding-bottom: 24px;
    -webkit-overflow-scrolling: touch;
  }

  .content,
  main,
  article {
    margin-left: 0;
    height: auto;
    overflow: visible;
  }

  .mobile-topbar {
    display: flex !important;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 75px;
    background: #1a1a1a;
    color: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    z-index: 1100;
  }

  .mobile-topbar .page-title {
    margin-left: 55px;
    font-weight: 600;
  }

  .hamburger {
    display: block !important;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    background: #1a1a1a;
    color: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 40px;
    height: 40px;
    font-size: 22px;
    cursor: pointer;
  }
}
