/* ==========================================================================
   Nagelfluh Documentation
   ========================================================================== */

:root {
  --sidebar-w: 268px;
  --sidebar-bg: #1b2737;
  --sidebar-text: #b8cfe0;
  --sidebar-hover-bg: rgba(255,255,255,0.07);
  --sidebar-active-bg: rgba(255,255,255,0.14);
  --sidebar-active-text: #ffffff;
  --sidebar-section-text: #6b96b8;
  --sidebar-border: rgba(255,255,255,0.08);

  --accent: #3a8fd4;
  --link: #1d70b8;

  --body-bg: #ffffff;
  --body-text: #24303d;
  --border: #dde4ec;
  --muted: #5a6472;
  --code-bg: #f3f6f9;
  --code-border: #dde4ec;

  --max-w: 820px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--body-text);
  background: var(--body-bg);
  display: flex;
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

/* Sidebar header */
#sidebar-header {
  position: relative;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

#site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 62px 18px 16px;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
#site-logo img {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
}
#site-logo:hover { color: #fff; }

#github-link {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: #fff;
  text-decoration: none;
}
#github-link svg {
  width: 34px;
  height: 34px;
}
#github-link:hover { opacity: 0.75; }

/* Nav list */
nav { flex: 1; padding: 10px 0 16px; }

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-list > li { position: relative; }

.nav-list > li > a {
  display: block;
  padding: 6px 12px;
  margin: 1px 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 5px;
  transition: background 0.12s, color 0.12s;
}
.nav-list > li > a:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}
.nav-list > li > a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

/* Section groups */
.nav-section { margin-top: 6px; }

.section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 5px 12px;
  background: none;
  border: none;
  color: var(--sidebar-section-text);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.12s;
  margin: 0 8px;
  width: calc(100% - 16px);
  border-radius: 5px;
}
.section-toggle:hover { color: #fff; }

.chevron { flex-shrink: 0; transition: transform 0.2s ease; }
.nav-section.open .chevron { transform: rotate(180deg); }

.section-pages {
  list-style: none;
  padding: 0;
  margin: 0;
  display: none;
}
.nav-section.open .section-pages { display: block; }

.section-pages li a {
  display: block;
  padding: 5px 12px 5px 22px;
  margin: 1px 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.845rem;
  border-radius: 5px;
  transition: background 0.12s, color 0.12s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.section-pages li a:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}
.section-pages li a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

/* ── Right TOC sidebar ───────────────────────────────────────────────────── */

#toc-sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--body-bg);
  border-left: 1px solid var(--border);
  padding: 52px 20px 80px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  font-size: 0.8rem;
}

.toc-heading {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

#toc-sidebar .toc ul  { list-style: none; padding: 0; margin: 0; }
#toc-sidebar .toc ul ul { padding-left: 12px; }
#toc-sidebar .toc a {
  display: block;
  padding: 3px 0;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.5;
}
#toc-sidebar .toc a:hover { color: var(--body-text); }

/* ── Main content ─────────────────────────────────────────────────────────── */

#content {
  flex: 1;
  min-width: 0;
  padding: 52px 64px 80px;
}

article { max-width: var(--max-w); }

/* Headings */
article h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 28px;
  color: #151e2b;
}
article h2 {
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 44px 0 14px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: #1d2b3a;
}
article h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 28px 0 10px;
}
article h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 20px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
article h5, article h6 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 16px 0 6px;
}

/* Paragraphs & lists */
article p { margin: 0 0 16px; }
article ul, article ol { margin: 0 0 16px; padding-left: 24px; }
article li { margin-bottom: 5px; line-height: 1.65; }
article li > ul, article li > ol { margin-top: 4px; margin-bottom: 4px; }

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

/* Inline emphasis */
article strong { font-weight: 700; }
article em { font-style: italic; }

/* Blockquotes */
article blockquote {
  border-left: 3px solid var(--accent);
  margin: 0 0 16px;
  padding: 10px 16px;
  color: var(--muted);
  background: #f7fafd;
  border-radius: 0 4px 4px 0;
}
article blockquote p:last-child { margin-bottom: 0; }

/* Horizontal rule */
article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

/* Inline code */
article :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 0.1em 0.38em;
  color: #c7254e;
}

/* Code blocks (Pygments wraps in .highlight > pre) */
article .highlight,
article pre {
  background: #f5f7fa;
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 20px;
  font-size: 0.875rem;
  line-height: 1.55;
}
article .highlight pre { background: none; border: none; padding: 0; margin: 0; }
article pre code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }

/* Tables */
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 24px;
  font-size: 0.9rem;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--border);
}
article thead { background: #eef2f7; }
article th {
  font-weight: 600;
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
article td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
article tr:last-child td { border-bottom: none; }
article tbody tr:hover td { background: #f8fbff; }

/* Images */
article img {
  border-radius: 6px;
  display: block;
  margin: 16px 0;
}
article img:not([height]) {
  max-width: 100%;
  height: auto;
}
article img[height] {
  max-width: none;
  width: auto;
}

/* Definition lists */
article dl { margin: 0 0 16px; }
article dt { font-weight: 700; margin-top: 10px; }
article dd { margin-left: 20px; color: var(--muted); }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  #toc-sidebar { display: none; }
}

@media (max-width: 860px) {
  #sidebar {
    width: 220px;
    min-width: 220px;
    --sidebar-w: 220px;
  }
  #content { padding: 36px 32px 60px; }
}

@media (max-width: 640px) {
  body { flex-direction: column; }
  #sidebar {
    position: static;
    width: 100%;
    min-width: unset;
    height: auto;
    max-height: 50vh;
  }
  #content { padding: 24px 20px 48px; }
}

/* ── Feature card grid ───────────────────────────────────────────────────── */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin: 1rem 0 2rem;
}

.feature-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  background: #f7fafd;
}

.feature-card h3 {
  margin-top: 0;
  font-size: 1rem;
  color: var(--link);
}

.feature-card p:last-child {
  margin-bottom: 0;
}
