/* SOMA e-Manual style docs — layout + content typography
   Modeled after ROBOTIS e-Manual (top bar + left sidebar + content). */

:root {
  --header-h: 64px;
  --sidebar-w: 280px;
  --accent: #2e9e5b;          /* SOMA green */
  --accent-dark: #1f7d45;
  --header-bg: #111418;
  --sidebar-bg: #f6f7f8;
  --border: #e3e6e8;
  --text: #24292f;
  --muted: #6b7280;
  --link: #2563eb;
  --warn: #d4351c;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: #fff;
  font-size: 16px;
  line-height: 1.7;
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--header-bg);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.brand {
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
  text-decoration: none;
  margin-right: 40px;
}
.brand span { color: var(--accent); }
.topnav { display: flex; gap: 8px; }
.topnav a {
  color: #d8dadd;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.topnav a:hover,
.topnav a.active { color: #fff; background: rgba(255, 255, 255, 0.12); }

/* search box lives in the top bar, centre-right */
.topsearch {
  position: relative;
  margin-left: auto;
  margin-right: 13vw;
  width: 300px;
}
.topsearch input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid #34383d;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.topsearch input:focus { border-color: var(--accent); }
.search-note {
  display: none;
  position: absolute;
  left: 0; right: 0;
  top: 44px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  z-index: 120;
}
.search-note.show { display: block; }

/* ---------- Left sidebar (project / chapter / section tree) ---------- */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 0 40px;
}
.sidebar h2.section {
  margin: 6px 0 12px;
  padding: 0 20px;
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 800;
}
.sidebar ul.nav,
.sidebar ul.subnav { list-style: none; margin: 0; padding: 0; }

/* chapter title — works for both <a> (single-chapter) and <summary> (collapsible) */
.sidebar .chapter-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 20px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.sidebar .chapter-title:hover { background: #eceef0; }
.sidebar .nav > li + li { border-top: 1px solid var(--border); }
.sidebar summary.chapter-title { list-style: none; }
.sidebar summary.chapter-title::-webkit-details-marker { display: none; }
.sidebar summary.chapter-title::after {
  content: "▸";
  color: #b7bcc1;
  font-size: 12px;
  transition: transform .15s;
}
.sidebar details[open] > summary.chapter-title::after { transform: rotate(90deg); }

/* section (e.g. 安装) */
.sidebar .subnav li a {
  display: block;
  padding: 9px 20px 9px 38px;
  color: var(--text);
  text-decoration: none;
  font-size: 14.5px;
  border-left: 3px solid transparent;
}
.sidebar .subnav li a:hover { background: #eceef0; }
.sidebar .subnav li a.active {
  background: #e7f4ec;
  color: var(--accent-dark);
  font-weight: 700;
  border-left-color: var(--accent);
}

/* ---------- Right floating in-page nav (本页导航) ---------- */
.pagenav {
  position: fixed;
  top: calc(var(--header-h) + 24px);
  right: 24px;
  width: 232px;
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.09);
  padding: 14px 14px 16px;
  z-index: 50;
}
.pagenav-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.pagenav ul { list-style: none; margin: 0; padding: 0; }
.pagenav ul ul { padding-left: 12px; }
.pagenav li { margin: 1px 0; }
.pagenav a {
  display: block;
  padding: 3px 6px;
  font-size: 13px;
  line-height: 1.45;
  color: #4b5563;
  text-decoration: none;
  border-radius: 4px;
}
.pagenav a:hover { background: #f1f3f5; color: var(--accent-dark); }

/* ---------- Main content ---------- */
.main {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 32px 48px 96px;
}
.content {
  max-width: 880px;
  margin: 0 auto;
}
.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.breadcrumb span { margin: 0 6px; color: #b7bcc1; }
.page-title {
  font-size: 30px;
  font-weight: 800;
  margin: 0 0 24px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border);
}

/* Headings inside the tutorial body */
.content h1, .content h2, .content h3,
.content h4, .content h5, .content h6 {
  line-height: 1.35;
  margin: 1.8em 0 .7em;
  font-weight: 700;
}
.content h1 { font-size: 26px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.content h2 { font-size: 23px; }
.content h3 { font-size: 21px; }
.content h4 { font-size: 19px; }
.content h5 { font-size: 17px; }
.content h6 { font-size: 16px; color: var(--muted); }

.content p { margin: .8em 0; }
.content a { color: var(--link); text-decoration: none; }
.content a:hover { text-decoration: underline; }

.content strong { font-weight: 700; }
.content font[color="red"] { color: var(--warn); }

/* Images — shown at a moderate size, click to zoom (lightbox) */
.content img {
  max-width: 480px;
  width: auto;
  height: auto;
  display: block;
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: zoom-in;
}
/* part photos inside table cells stay compact thumbnails */
.content table img { max-width: 170px; margin: 6px auto; }
@media (max-width: 600px) {
  .content img { max-width: 100%; }
}

/* ---------- Image lightbox (click-to-zoom floating viewer) ---------- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  width: auto;
  height: auto;
  border: none;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  cursor: default;
}
.lightbox-close {
  position: fixed;
  top: 14px;
  right: 26px;
  color: #fff;
  font-size: 42px;
  line-height: 1;
  font-weight: 300;
  cursor: pointer;
  z-index: 1001;
  user-select: none;
}
.lightbox-close:hover { color: #ccc; }

/* ---------- Math (self-contained MathJax SVG) ---------- */
.content mjx-container { display: inline-block; line-height: 0; }
.content mjx-container[display="true"] {
  display: block;
  text-align: center;
  margin: 1em 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}
.content mjx-container svg { max-width: 100%; vertical-align: -0.25em; }
/* video placeholder frame (source videos are on a login-only bucket) */
.content .video-frame {
  margin: 14px 0;
  max-width: 560px;
  aspect-ratio: 16 / 9;
  background: #15181c;
  border: 1px solid #2a2e33;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  color: #cfd3d8;
}
.content .video-frame__icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  padding-left: 4px;
}
.content .video-frame__cap { font-size: 13.5px; line-height: 1.55; }
.content .video-frame__cap a { color: #7ab8ff; }
.content .video-frame code { background: rgba(255, 255, 255, 0.1); color: #e6e9ec; }

/* embedded public video player (e.g. Bilibili) */
.content .video-embed {
  margin: 14px 0;
  max-width: 720px;
  aspect-ratio: 16 / 9;
  border: 1px solid #2a2e33;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.content .video-embed iframe { width: 100%; height: 100%; border: 0; display: block; }
.content .video-embed-cap { font-size: 13px; color: #888; margin: 6px 0 14px; }
.content .video-embed-cap a { color: #7ab8ff; }

/* Lists */
.content ul, .content ol { padding-left: 1.6em; margin: .7em 0; }
.content li { margin: .35em 0; }

/* Blockquote / warnings */
.content blockquote {
  margin: 1em 0;
  padding: 12px 16px;
  background: #fff7f6;
  border-left: 4px solid var(--warn);
  border-radius: 0 6px 6px 0;
  color: #5a3a36;
}
.content blockquote p { margin: .35em 0; }

/* Tables */
.content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2em 0;
  font-size: 14.5px;
  display: block;
  overflow-x: auto;
}
.content table th, .content table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.content table th { background: #f1f3f5; font-weight: 700; }
.content table tr:nth-child(even) td { background: #fafbfc; }

/* Code */
.content code {
  background: #f1f3f5;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .9em;
}
.content pre {
  background: #f6f8fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
}
.content pre code { background: none; padding: 0; }

/* In-content table of contents (vditor-toc) */
.content .vditor-toc {
  background: #f8fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px 16px 12px;
  margin: 0 0 28px;
}
.content .vditor-toc > ul { padding-left: 1.2em; }
.content .vditor-toc ul { list-style: none; padding-left: 1.1em; margin: .2em 0; }
.content .vditor-toc li { margin: .2em 0; }
.content .vditor-toc a { color: var(--link); cursor: pointer; }
.content .vditor-toc a:hover { text-decoration: underline; }

/* ---------- Responsive ---------- */
/* Wide screens: show the floating page-nav and reserve room for it. */
@media (min-width: 1240px) {
  .main { padding-right: 296px; }
}
/* Below that, hide the floating nav (the content stays full width). */
@media (max-width: 1239px) {
  .pagenav { display: none; }
}

@media (max-width: 860px) {
  body { padding-top: var(--header-h); }
  .topsearch { margin-right: 0; width: 150px; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    top: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 0 20px;
  }
  .main { margin-left: 0; margin-top: 0; padding: 24px 18px 80px; }
  .topbar { padding: 0 16px; }
  .brand { margin-right: 20px; font-size: 22px; }
}
