/* ===========================================================
   GlouOS Wiki - documentation stylesheet
   Layout inspired by Material for MkDocs: sticky top bar with
   search, left navigation, centered content, right table of
   contents, and a footer. GlouOS green branding throughout.
   =========================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f4f6f9;
  --surface: #f3f5f8;
  --surface-2: #e9edf2;
  --text: #1a212b;
  --muted: #55606f;
  --muted-2: #8b94a2;

  --brand: #16a34a;
  --brand-2: #22c55e;
  --brand-3: #15803d;

  --header-h: 56px;
  --footer-h: 46px;
  --sidebar-w: 240px;
  --toc-w: 220px;
  --maxw: 1360px;
  --radius: 6px;
  --radius-sm: 4px;

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

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand-3); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ---------- Top header bar ---------- */
.md-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 100;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 10px -2px rgba(15, 23, 34, 0.35);
}
.md-header .bar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 18px;
}
.md-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.md-header .brand:hover { text-decoration: none; }
.md-header .brand img { width: 26px; height: 26px; display: block; }
.md-header .brand .sub {
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.18);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}
.md-header .spacer { flex: 1; }
.md-header .header-link {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.md-header .header-link:hover { background: rgba(255, 255, 255, 0.15); text-decoration: none; }

/* Search */
.md-search { position: relative; }
.md-search input {
  width: 230px;
  height: 36px;
  border: none;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font: 0.9rem var(--font);
  padding: 0 12px 0 36px;
  transition: background 0.15s ease, width 0.2s ease;
}
.md-search input::placeholder { color: rgba(255, 255, 255, 0.8); }
.md-search input:focus {
  outline: none;
  background: #fff;
  color: var(--text);
}
.md-search input:focus::placeholder { color: var(--muted-2); }
.md-search .search-icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: rgba(255, 255, 255, 0.9);
  pointer-events: none;
}
.md-search input:focus + .search-icon { color: var(--muted); }
@media (max-width: 500px) { .md-search input { width: 140px; } }

/* Search results dropdown */
.md-search { position: relative; }
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 400px;
  max-width: 82vw;
  max-height: 70vh;
  overflow-y: auto;
  background: #fff;
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: 0 20px 55px -12px rgba(15, 23, 34, 0.45);
  padding: 6px;
  z-index: 200;
}
.search-results[hidden] { display: none; }
.search-results .sr-empty { padding: 16px 14px; color: var(--muted); font-size: 0.9rem; }
.search-results a.sr-item {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
}
.search-results a.sr-item:hover,
.search-results a.sr-item.active { background: var(--surface); text-decoration: none; }
.sr-item .sr-crumb {
  display: block;
  font-size: 0.7rem;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sr-item .sr-title { display: block; font-weight: 600; font-size: 0.92rem; margin: 1px 0 2px; }
.sr-item .sr-snippet { display: block; font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
.sr-item mark { background: rgba(22, 163, 74, 0.22); color: inherit; padding: 0 1px; border-radius: 2px; }

/* Hamburger (mobile) */
.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  color: #fff;
  width: 40px; height: 40px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ---------- Page shell ---------- */
.md-container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-top: var(--header-h);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 0;
  align-items: start;
}

/* ---------- Left navigation ---------- */
.md-sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h) - var(--footer-h));
  overflow-y: auto;
  padding: 26px 14px 40px;
}
.md-sidebar--primary { border-right: 1px solid var(--surface-2); }
.nav-group { margin-bottom: 22px; }
.nav-group > .nav-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: var(--muted-2);
  padding: 4px 10px;
  margin-bottom: 4px;
}
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.nav-group li a {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
}
.nav-group li a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav-group li a.active {
  color: var(--brand-3);
  font-weight: 600;
  background: rgba(22, 163, 74, 0.10);
  border-left-color: var(--brand);
}

/* Standalone "AI Use" nav item, sits above the first group */
.nav-special {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 24px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: #6d28d9;
  background: rgba(124, 58, 237, 0.10);
  border: 1px solid rgba(124, 58, 237, 0.22);
}
.nav-special svg { width: 16px; height: 16px; flex: none; }
.nav-special:hover { color: #5b21b6; background: rgba(124, 58, 237, 0.16); text-decoration: none; }
.nav-special.active { color: #5b21b6; background: rgba(124, 58, 237, 0.18); border-color: rgba(124, 58, 237, 0.42); }

/* The AI Use page itself is purple: repaint the brand accents */
body.ai-use { --brand: #7c3aed; --brand-2: #8b5cf6; --brand-3: #6d28d9; }

/* ---------- Main content ---------- */
.md-content {
  min-width: 0;
  padding: 34px 44px calc(40px + var(--footer-h));
}
.md-content .breadcrumbs {
  font-size: 0.82rem;
  color: var(--muted-2);
  margin-bottom: 10px;
}
.md-content .breadcrumbs a { color: var(--muted-2); }
.md-content h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  line-height: 1.2;
}
.md-content h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 44px 0 12px;
  padding-top: 6px;
}
.md-content h3 { font-size: 1.1rem; font-weight: 700; margin: 28px 0 8px; }
.md-content p { margin: 0 0 15px; color: var(--text); }
.md-content ul, .md-content ol { margin: 0 0 15px; padding-left: 22px; }
.md-content li { margin: 5px 0; }
.md-content .lead { color: var(--muted); font-size: 1.08rem; margin-bottom: 26px; }

/* Anchor link on headings */
.md-content h2, .md-content h3 { position: relative; }
.md-content .headerlink {
  opacity: 0;
  margin-left: 8px;
  color: var(--brand);
  font-weight: 400;
  transition: opacity 0.15s ease;
}
.md-content h2:hover .headerlink,
.md-content h3:hover .headerlink { opacity: 1; }

/* Code */
.md-content code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--surface);
  color: var(--brand-3);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.md-content pre {
  background: #0f1722;
  color: #e6edf3;
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 18px;
}
.md-content pre code { background: none; color: inherit; padding: 0; font-size: 0.85rem; }

/* Tables */
.md-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 18px;
  font-size: 0.92rem;
}
.md-content th, .md-content td { text-align: left; padding: 10px 14px; }
.md-content thead th { background: var(--surface); font-weight: 700; }
.md-content tbody tr + tr td { border-top: 1px solid var(--surface-2); }

/* Admonitions */
.admonition {
  border-radius: var(--radius);
  padding: 14px 18px 4px;
  margin: 0 0 20px;
  background: var(--surface);
  border-left: 4px solid var(--muted-2);
}
.admonition .admonition-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.admonition.note { background: rgba(37, 99, 235, 0.07); border-left-color: #2563eb; }
.admonition.note .admonition-title { color: #1d4ed8; }
.admonition.tip { background: rgba(22, 163, 74, 0.09); border-left-color: var(--brand); }
.admonition.tip .admonition-title { color: var(--brand-3); }
.admonition.warning { background: rgba(217, 119, 6, 0.09); border-left-color: #d97706; }
.admonition.warning .admonition-title { color: #b45309; }

/* FAQ answer emphasis */
.md-content h2 .q-tag {
  display: inline-block;
  font: 700 0.7rem var(--mono);
  color: var(--brand-3);
  background: rgba(22, 163, 74, 0.12);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  margin-right: 10px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

/* No results message */
.no-results { display: none; color: var(--muted); padding: 24px 0; }
.md-content.searching .lead,
.md-content.searching .breadcrumbs { display: none; }

/* ---------- Right table of contents ---------- */
.md-sidebar--secondary { border-left: 1px solid var(--surface-2); }
.toc-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: var(--muted-2);
  padding: 4px 12px;
  margin-bottom: 6px;
}
.toc { list-style: none; margin: 0; padding: 0; }
.toc li a {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
  padding: 5px 12px;
  border-left: 2px solid transparent;
}
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.active { color: var(--brand-3); border-left-color: var(--brand); font-weight: 600; }

/* ---------- Footer ---------- */
/* Fixed to the bottom of the viewport so it never scrolls up into
   (or shows through) the transparent sticky sidebars. The sidebars
   and content reserve room for it via --footer-h. */
.md-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--footer-h);
  z-index: 60; /* above content and sidebars, below mobile drawer/scrim/header */
  border-top: 1px solid var(--surface-2);
  background: var(--bg-soft);
}
.md-footer .footer-inner {
  height: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  color: var(--muted-2);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
}
.md-footer .footer-inner a { color: var(--muted); }
.md-footer .made-with { font-size: 0.8rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .md-container { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .md-sidebar--secondary { display: none; }
}
@media (max-width: 820px) {
  :root { --sidebar-w: 260px; }
  .nav-toggle { display: inline-flex; }
  .md-container { grid-template-columns: 1fr; }
  .md-sidebar--primary {
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    background: var(--bg);
    box-shadow: 8px 0 30px -12px rgba(15, 23, 34, 0.35);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 90;
    height: auto;
  }
  .md-sidebar--primary.open { transform: translateX(0); }
  .md-content { padding: 26px 22px calc(30px + var(--footer-h)); }
  .md-footer .footer-inner { padding: 0 22px; }
  .nav-scrim {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(15, 23, 34, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 80;
  }
  .nav-scrim.show { opacity: 1; pointer-events: auto; }
}
@media (max-width: 620px) {
  .md-footer .made-with { display: none; }
}
