/* ===================================================
   compgen.io — Documentation Site
   A clean, scientific-instrument aesthetic.
   Precise spacing, typographic clarity, restrained palette.
   =================================================== */

:root {
  --navy: #2E3440;
  --navy-light: #3B4252;
  --blue: #7A9ACC;
  --blue-dim: #5c7faa;
  --purple: #7353ED;
  --purple-hover: #5e3dd4;
  --gray-bg: #f5f6fa;
  --gray-border: #e5e7eb;
  --gray-text: #6b7280;
  --white: #ffffff;
  --sidebar-w: 260px;
  --header-h: 52px;
  --content-max: 860px;
  --font-body: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Source Code Pro', 'SF Mono', 'Consolas', monospace;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  color: var(--navy);
  background: var(--white);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ---- Page layout ---- */
.page-wrap {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.side-bar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--gray-bg);
  border-right: 1px solid var(--gray-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.site-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--gray-border);
}

.site-title {
  display: block;
  text-decoration: none;
}

.site-logo {
  width: 180px;
  height: auto;
  display: block;
}

/* ---- Navigation ---- */
.site-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

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

.nav-item {
  margin: 0;
}

.nav-link {
  display: block;
  padding: 7px 24px;
  color: var(--gray-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color 0.15s, background 0.15s, padding-left 0.15s;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  color: var(--navy);
  background: rgba(0,0,0,0.03);
}

.nav-link.active {
  color: var(--navy);
  border-left-color: var(--purple);
  background: rgba(115, 83, 237, 0.06);
  font-weight: 600;
}

.nav-item.active > .nav-link {
  color: var(--navy);
}

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

.nav-child-item .nav-link {
  padding-left: 40px;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--blue-dim);
}

.nav-child-item .nav-link:hover {
  color: var(--navy);
}

.nav-child-item .nav-link.active {
  color: var(--navy);
  border-left-color: var(--purple);
}

/* ---- Sidebar footer ---- */
.site-footer {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--gray-border);
  margin-top: auto;
}

.footer-logo-link {
  display: block;
}

.footer-logo {
  width: 130px;
  height: auto;
  display: block;
  margin: 0 auto;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.footer-logo:hover {
  opacity: 1;
}

/* ---- Main content ---- */
.main-content-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-content {
  max-width: calc(var(--content-max) + 96px);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ---- Page header ---- */
.page-header {
  display: flex;
  align-items: center;
  height: var(--header-h);
  padding: 0 48px;
  border-bottom: 1px solid var(--gray-border);
  gap: 16px;
  flex-shrink: 0;
}

.subtitle {
  flex: 1;
  color: var(--blue);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

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

.aux-nav li {
  display: inline-block;
}

.aux-nav a {
  color: var(--gray-text);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 4px 12px;
  border: 1px solid var(--gray-border);
  border-radius: 4px;
  transition: border-color 0.15s, color 0.15s;
}

.aux-nav a:hover {
  color: var(--navy);
  border-color: var(--navy);
}

/* ---- Breadcrumbs ---- */
.breadcrumb-nav {
  padding: 16px 48px 0;
}

.breadcrumb-list {
  list-style: none;
  display: flex;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--gray-text);
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "/";
  margin-right: 6px;
  color: var(--gray-border);
}

.breadcrumb-item a {
  color: var(--blue);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  text-decoration: underline;
}

.breadcrumb-item.current {
  color: var(--gray-text);
}

/* ---- Page content ---- */
.page-content-wrap {
  flex: 1;
}

.page-content {
  padding: 32px 48px 64px;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  color: var(--navy);
  font-weight: 600;
  line-height: 1.3;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
}

h1 { font-size: 1.85rem; margin-top: 0; }
h2 { font-size: 1.4rem; padding-bottom: 6px; border-bottom: 1px solid var(--gray-border); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

p { margin-bottom: 1em; }

a {
  color: var(--purple);
  text-decoration: none;
  transition: color 0.12s;
}

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

strong { font-weight: 600; }

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

/* ---- Lists ---- */
ul, ol {
  margin-bottom: 1em;
  padding-left: 1.6em;
}

li {
  margin-bottom: 0.35em;
}

li > ul, li > ol {
  margin-top: 0.35em;
  margin-bottom: 0;
}

/* ---- Blockquotes / Cards ---- */
blockquote {
  border-left: 3px solid var(--purple);
  padding: 16px 20px 8px;
  margin: 0 0 16px 0;
  background: var(--gray-bg);
  border-radius: 0 6px 6px 0;
}

blockquote h3 {
  margin-top: 0;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--gray-border);
  padding-bottom: 6px;
}

blockquote h3 a {
  color: var(--navy);
}

blockquote h3 a:hover {
  color: var(--purple);
}

blockquote p {
  font-size: 0.92rem;
  color: #4b5563;
}

blockquote p:last-child {
  margin-bottom: 8px;
}

/* ---- Labels / Tags ---- */
.label {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--navy);
  color: var(--white);
  border-radius: 3px;
  vertical-align: middle;
}

.label-archived {
  background: var(--gray-text);
}

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--white);
  background: var(--purple);
  border: none;
  border-radius: 5px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:hover {
  background: var(--purple-hover);
  text-decoration: none;
  color: var(--white);
  transform: translateY(-1px);
}

.btn-purple { background: var(--purple); }

/* ---- Code ---- */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--gray-bg);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--navy-light);
}

pre {
  margin-bottom: 1.5em;
  border-radius: 6px;
  overflow-x: auto;
  border: 1px solid var(--gray-border);
}

pre code {
  display: block;
  padding: 16px 20px;
  background: #f8f9fc;
  font-size: 0.82rem;
  line-height: 1.6;
  border-radius: 6px;
}

/* Syntax highlight overrides */
.highlight pre {
  border: 1px solid var(--gray-border);
  border-radius: 6px;
}

.highlight pre code {
  background: #f8f9fc;
}

/* ---- Tables ---- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
  font-size: 0.9rem;
}

th {
  text-align: left;
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 2px solid var(--gray-border);
  color: var(--navy);
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-border);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

/* ---- Images ---- */
.page-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* ---- 404 page ---- */
.error-page {
  text-align: center;
  padding: 80px 24px;
}

.error-page h1 {
  font-size: 5rem;
  color: var(--gray-border);
  margin-bottom: 0.2em;
}

.error-page p {
  color: var(--gray-text);
}

.error-page .btn {
  margin-top: 24px;
}

/* ---- Mobile toggle ---- */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 28px;
  height: 20px;
  position: relative;
  flex-shrink: 0;
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--navy);
  position: absolute;
  left: 0;
  transition: transform 0.2s, opacity 0.2s;
}

.menu-toggle span:nth-child(1) { top: 0; }
.menu-toggle span:nth-child(2) { top: 9px; }
.menu-toggle span:nth-child(3) { top: 18px; }

.menu-toggle.active span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

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

.overlay.active {
  display: block;
}

/* ---- Responsive ---- */
@media (max-width: 800px) {
  .side-bar {
    transform: translateX(-100%);
    width: 280px;
  }

  .side-bar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }

  .main-content-wrap {
    margin-left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .page-header {
    padding: 0 20px;
  }

  .page-content {
    padding: 24px 20px 48px;
  }

  .breadcrumb-nav {
    padding: 12px 20px 0;
  }
}

@media (max-width: 480px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }

  .page-content {
    padding: 20px 16px 40px;
  }

  .breadcrumb-nav {
    padding: 10px 16px 0;
  }

  blockquote {
    padding: 12px 14px 6px;
  }
}

/* ---- Print ---- */
@media print {
  .side-bar, .page-header, .menu-toggle, .overlay { display: none; }
  .main-content-wrap { margin-left: 0; }
  .page-content { padding: 0; }
}
