/* Class Docs: a clean, VS Code-docs-inspired layout (topbar, left nav, article, right "On this page"). */

:root {
  --bg: #ffffff;
  --bg-soft: #f8f8f8;
  --text: #1e1e1e;
  --muted: #616161;
  --border: #e5e5e5;
  --link: #0066b8;
  --link-hover: #005ba4;
  --topbar: #2c2c32;
  --topbar-text: #e7e7e7;
  --code-bg: #f3f3f3;
  --inline-code: #a31515;
  --table-head: #f3f3f3;
  --note: #0066b8;   --note-bg: #eaf3fb;
  --tip: #16825d;    --tip-bg: #e8f5ef;
  --warn: #bf8803;   --warn-bg: #fdf6e3;
  --danger: #c72e0f; --danger-bg: #fbecea;
  --tok-kw: #0000ff; --tok-str: #a31515; --tok-num: #098658; --tok-com: #008000; --tok-fn: #795e26;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1e1e1e; --bg-soft: #252526; --text: #d4d4d4; --muted: #9d9d9d; --border: #3c3c3c;
    --link: #3794ff; --link-hover: #75beff; --topbar: #181818; --topbar-text: #e7e7e7;
    --code-bg: #2a2a2a; --inline-code: #ce9178; --table-head: #2d2d2d;
    --note-bg: #1b2a3a; --tip-bg: #17302a; --warn-bg: #3a3218; --danger-bg: #3d1f1b;
    --note: #3794ff; --tip: #4ec9b0; --warn: #cca700; --danger: #f48771;
    --tok-kw: #569cd6; --tok-str: #ce9178; --tok-num: #b5cea8; --tok-com: #6a9955; --tok-fn: #dcdcaa;
  }
}
:root[data-theme="dark"] {
  --bg: #1e1e1e; --bg-soft: #252526; --text: #d4d4d4; --muted: #9d9d9d; --border: #3c3c3c;
  --link: #3794ff; --link-hover: #75beff; --topbar: #181818; --topbar-text: #e7e7e7;
  --code-bg: #2a2a2a; --inline-code: #ce9178; --table-head: #2d2d2d;
  --note-bg: #1b2a3a; --tip-bg: #17302a; --warn-bg: #3a3218; --danger-bg: #3d1f1b;
  --note: #3794ff; --tip: #4ec9b0; --warn: #cca700; --danger: #f48771;
  --tok-kw: #569cd6; --tok-str: #ce9178; --tok-num: #b5cea8; --tok-com: #6a9955; --tok-fn: #dcdcaa;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 72px; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  height: 56px; padding: 0 20px;
  background: var(--topbar); color: var(--topbar-text);
}
.brand { color: var(--topbar-text); font-weight: 600; font-size: 17px; white-space: nowrap; }
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark { color: #3794ff; font-family: Consolas, monospace; margin-right: 4px; }
.topnav { display: flex; gap: 18px; }
.topnav a { color: #cccccc; font-size: 14px; }
.topnav a:hover { color: #fff; text-decoration: none; }
.search {
  margin-left: auto; width: 220px; padding: 6px 10px;
  border: 1px solid #555; border-radius: 4px;
  background: #3c3c3c; color: #fff; font: inherit; font-size: 14px;
}
.search::placeholder { color: #aaa; }
.menu-btn, .theme-btn {
  background: none; border: 0; color: var(--topbar-text); font-size: 20px; cursor: pointer; padding: 4px 8px;
}
.menu-btn { display: none; }

/* ---------- Three-column layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 220px;
  max-width: 1400px; margin: 0 auto;
}
.sidebar, .onthispage {
  position: sticky; top: 56px; align-self: start;
  height: calc(100vh - 56px); overflow-y: auto;
  padding: 24px 16px; font-size: 14px;
}
.sidebar { border-right: 1px solid var(--border); background: var(--bg-soft); }
.sidebar h3, .onthispage h3 {
  margin: 0 0 10px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.nav, .nav ul, #toc { list-style: none; margin: 0; padding: 0; }
.nav > li > a { display: block; padding: 6px 10px; border-radius: 4px; color: var(--text); font-weight: 600; }
.nav > li > a.active { background: var(--border); }
.nav a:hover { text-decoration: none; color: var(--link); }
.subnav { margin: 4px 0 8px 10px !important; border-left: 1px solid var(--border); }
.subnav a { display: block; padding: 3px 12px; color: var(--muted); font-size: 13.5px; }
.subnav a.current { color: var(--link); border-left: 2px solid var(--link); margin-left: -1px; }

#toc a { display: block; padding: 3px 0 3px 10px; color: var(--muted); border-left: 2px solid transparent; }
#toc li.sub a { padding-left: 22px; font-size: 13px; }
#toc a.current { color: var(--link); border-left-color: var(--link); }

/* ---------- Article ---------- */
.content { padding: 32px 48px 80px; min-width: 0; }
article { max-width: 860px; }
article h1 { font-size: 2.4em; font-weight: 600; line-height: 1.2; margin: 0 0 12px; }
article h2 { font-size: 1.75em; font-weight: 600; margin: 48px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
article h3 { font-size: 1.3em; font-weight: 600; margin: 32px 0 8px; }
article h4 { font-size: 1.08em; font-weight: 600; margin: 24px 0 6px; }
.topic + .topic { margin-top: 64px; }
.lead, .rubric { font-size: 1.15em; color: var(--muted); margin-top: 0; }
.rubric { font-weight: normal; }

code, pre, tt, .literal {
  font-family: Consolas, "Cascadia Code", "SF Mono", Menlo, monospace; font-size: 0.9em;
}
:not(pre) > code, span.literal, code.literal {
  background: var(--code-bg); color: var(--inline-code); padding: 1px 5px; border-radius: 3px;
}
pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px;
  padding: 14px 16px; overflow-x: auto; line-height: 1.45;
}
pre code, pre .literal { background: none; color: inherit; padding: 0; }

/* Pygments "short" classes for SQL/XML highlighting */
pre .k, pre .kn, pre .kd, pre .kt, pre .nt { color: var(--tok-kw); }
pre .s, pre .s1, pre .s2 { color: var(--tok-str); }
pre .mi, pre .mf, pre .m { color: var(--tok-num); }
pre .c1, pre .cm, pre .c { color: var(--tok-com); font-style: italic; }
pre .nf, pre .na { color: var(--tok-fn); }

/* Tables */
table { border-collapse: collapse; margin: 16px 0; width: 100%; font-size: 0.95em; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
thead th, th { background: var(--table-head); font-weight: 600; }
td p, th p { margin: 0; }

/* Definition lists (word banks, term lists) */
dl dt { font-weight: 600; margin-top: 12px; }
dl dd { margin: 2px 0 0 20px; }

/* Callouts: note, tip, warning, etc. */
.admonition {
  margin: 20px 0; padding: 12px 16px;
  border-left: 4px solid var(--note); background: var(--note-bg); border-radius: 0 4px 4px 0;
}
.admonition > :last-child { margin-bottom: 0; }
.admonition-title { font-weight: 600; margin: 0 0 6px; }
.admonition.tip, .admonition.hint { border-color: var(--tip); background: var(--tip-bg); }
.admonition.warning, .admonition.important, .admonition.caution { border-color: var(--warn); background: var(--warn-bg); }
.admonition.danger, .admonition.error { border-color: var(--danger); background: var(--danger-bg); }

/* Home page cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 24px; }
.card { display: block; padding: 18px 20px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-soft); color: var(--text); }
.card:hover { border-color: var(--link); text-decoration: none; color: var(--text); }
.card h3 { margin: 0 0 6px; color: var(--link); font-size: 1.15em; }
.card p { margin: 0; color: var(--muted); font-size: 0.95em; }

/* Search highlight */
mark { background: #ffd33d66; color: inherit; padding: 0 1px; border-radius: 2px; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .onthispage { display: none; }
}
@media (max-width: 760px) {
  .layout { display: block; }
  .menu-btn { display: block; }
  .topnav { display: none; }
  .search { width: 100%; min-width: 0; }
  .sidebar {
    position: fixed; top: 56px; left: 0; z-index: 15; width: 280px;
    transform: translateX(-100%); transition: transform .2s; box-shadow: 2px 0 8px #0003;
  }
  .sidebar.open { transform: none; }
  .content { padding: 24px 16px 60px; }
  article h1 { font-size: 1.9em; }
}
