*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #141414;
  --surface: #1e1e1e;
  --border: #2e2e2e;
  --text: #d0d0d0;
  --text-dim: #777777;
  --accent: #85ffa4;
  --accent-hover: #85ffa4;
  --code-bg: #1a1a1a;
  --inline-code-bg: #2a2a2a;
  --sidebar-width: 260px;
}

html, body { margin: 0; padding: 0; }

body {
  display: flex;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;  
  z-index: 100;
  font-size: 14px;
  transition: transform 0.2s;
}

#sidebar .back-to-site {
  opacity: 0.5;
  transition: opacity 0.12s;
}

#sidebar .back-to-site:hover {
  color: var(--text);
  background: initial;
  opacity: 1.0;
}


#sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  margin-top: 8px;
}

#sidebar li { margin: 0; }

#sidebar a {
  display: block;
  padding: 0px 8px;
  padding-top: 4px;
  padding-bottom: 6px;
  border-radius: 4px;
  color: var(--text-dim);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar a:hover {
  background: var(--border);
  color: var(--accent-hover);
}

#sidebar a.active {
  color: var(--accent);
  font-weight: 500;
}

#sidebar details > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
  transition: background 0.12s, color 0.12s;
  position: relative;
}

#sidebar details > summary::-webkit-details-marker { display: none; }

#sidebar details > summary::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3 1l4 4-4 4' stroke='%238888a0' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 0.15s;
  transform-origin: center;
  flex-shrink: 0;
}

#sidebar details[open] > summary::before { transform: rotate(90deg); }

#sidebar details > summary:hover {
  background: var(--border);
  color: var(--accent-hover);
}

#sidebar details > ul {
  padding-left: 12px;
  border-left: 1px solid var(--border);
  margin-left: 8px;
  margin-top: 0;
  margin-bottom: 4px;
}

/* ── Main content ── */
#content {
  margin-left: var(--sidebar-width);
  min-width: 0;
  width: calc(100% - var(--sidebar-width));
  padding: 24px 40px 160px;
  max-width: 860px;
  transition: margin-left 0.2s, width 0.2s;
}

h1, h2, h3, h4 { margin-top: 32px; color: var(--text); }
h1 { font-size: 29px; }
h2 { font-size: 22px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }

pre, pre.hljs {
  background: var(--code-bg);
  padding: 16px;
  border-radius: 6px;
  overflow-x: visible;
  border: 1px solid var(--border);
  margin: 16px 0;
  width: max-content;
  max-width: 100%;
  min-width: 100%;
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

code {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.875em;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  background: var(--inline-code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre code, pre.hljs code { background: none; padding: 0; font-size: 0.875em; }

/* highlight.js — Visual Studio 2022 dark theme (C#) */
.hljs                          { color: #dcdcdc; }
.hljs-keyword                  { color: #569cd6; }          /* blue — control/type keywords */
.hljs-literal                  { color: #569cd6; }          /* blue — true/false/null */
.hljs-built_in                 { color: #4ec9b0; }          /* teal — built-in types */
.hljs-type                     { color: #4ec9b0; }
.hljs-title.class_             { color: #4ec9b0; }          /* teal — class names */
.hljs-title.class_.inherited__ { color: #4ec9b0; }
.hljs-title.function_          { color: #dcdcaa; }          /* yellow — method names */
.hljs-title                    { color: #4ec9b0; }          /* teal — fallback for class Foo form */
.hljs-number                   { color: #b5cea8; }          /* light green — numeric literals */
.hljs-string                   { color: #ce9178; }          /* orange/rust — string literals */
.hljs-attr                     { color: #ce9178; }
.hljs-comment                  { color: #57a64a; }
.hljs-quote                    { color: #57a64a; }
.hljs-variable                 { color: #9cdcfe; }          /* light blue — locals/fields */
.hljs-template-variable        { color: #9cdcfe; }
.hljs-params                   { color: #9cdcfe; }
.hljs-property                 { color: #9cdcfe; }
.hljs-symbol                   { color: #dcdcdc; }
.hljs-punctuation              { color: #dcdcdc; }
.hljs-operator                 { color: #dcdcdc; }
.hljs-meta                     { color: #9b9b9b; }          /* grey — preprocessor */
.hljs-tag                      { color: #569cd6; }
.hljs-attribute                { color: #9cdcfe; }
.hljs-type-name                { color: #4ec9b0; }          /* teal — PascalCase types */
.hljs-struct                   { color: #86c691; }          /* green — Vector3F, Matrix4F, MaterialType */
.hljs-addition                 { color: #b5cea8; }
.hljs-deletion                 { color: #ce9178; }
.hljs-emphasis                 { font-style: italic; }
.hljs-strong                   { font-weight: bold; }

blockquote {
  border-left: 3px solid var(--accent);
  margin: 16px 0;
  padding: 16px;
  padding-left: 24px;
  padding-bottom: 18px;
  color: var(--text);
  background: var(--code-bg);
  border-radius: 0 4px 4px 0;
}

blockquote p {
  margin: 0px;
}

blockquote code {
  background: var(--inline-code-bg);
}

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

table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
}

th, td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

th { background: var(--surface); font-weight: 600; }
tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

img { max-width: 100%; height: auto; border-radius: 4px; }

/* ── Sidebar header (title + toggle in a row) ── */
#sidebar-header {
  display: flex;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  gap: 4px;
}

#sidebar-header .site-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  padding: 0 0 0 8px;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sidebar toggle button ── */
#sidebar-toggle {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-dim);
  transition: background 0.12s, color 0.12s;
  padding: 0;
}

#sidebar-toggle:hover {
  background: var(--border);
  color: var(--text);
}

#sidebar-toggle svg {
  transition: transform 0.2s;
  display: block;
}

/* ── Sidebar expand strip ── */
#sidebar-expand {
  -webkit-appearance: none;
  appearance: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 32px;
  height: 100vh;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: background 0.12s, color 0.12s;
  padding: 0;
}

#sidebar-expand:hover {
  background: var(--border);
  color: var(--text);
}

/* Collapsed sidebar */
.sidebar-collapsed #sidebar {
  transform: translateX(-100%);
}

.sidebar-collapsed #content {
  margin-left: 0;
  width: 100%;
}

html:not(.sidebar-collapsed) #sidebar-expand {
  pointer-events: none;
}

/* Mobile: sidebar overlays content instead of pushing it */
@media (max-width: 767px) {
  #content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  #sidebar-expand {
    display: flex;
  }
}

/* scrollbar */
#sidebar::-webkit-scrollbar { width: 5px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* breadcrumbs */
.breadcrumbs { margin-bottom: 4px; padding: 10px 0; }
.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--text-dim);
  gap: 4px;
}
.bc-item a { color: var(--text-dim); text-decoration: none; }
.bc-item a:hover { color: var(--accent-hover); }
.bc-sep { color: var(--border); padding: 0 2px; user-select: none; }
.bc-current { color: var(--text); }

.page-title { margin-top: 0px; margin-bottom: 24px; }
