/*
 * docs.local-ai.run — Documentation Site
 * Visual language mirrors local-ai-theme (WordPress).
 */

/* ──────────────────────────────────────────────────────────────
   FONTS
   ────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ──────────────────────────────────────────────────────────────
   TOKENS (from WordPress theme)
   ────────────────────────────────────────────────────────────── */
:root {
  --bg: #0a0a0f;
  --bg-elevated: #111118;
  --bg-card: #16161f;
  --bg-card-hover: #1c1c28;
  --border: #23233a;
  --border-accent: #2d4a3e;
  --text: #e8e8ef;
  --text-muted: #7a7a8f;
  --text-dim: #50506a;
  --accent: #34d399;
  --accent-glow: rgba(52, 211, 153, 0.15);
  --accent-glow-strong: rgba(52, 211, 153, 0.3);
  --accent-secondary: #22d3ee;
  --accent-warm: #f59e0b;
  --danger: #f87171;

  --font-body: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --nav-h: 64px;
  --sidebar-w: 260px;
  --toc-w: 220px;
  --content-max: 820px;
}

/* ──────────────────────────────────────────────────────────────
   BASE
   ────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-secondary); }

::selection { background: var(--accent-glow-strong); color: var(--text); }

/* ──────────────────────────────────────────────────────────────
   PAGE PROGRESS BAR
   ────────────────────────────────────────────────────────────── */
.page-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  z-index: 200;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-secondary) 50%, var(--accent) 100%);
  box-shadow: 0 0 10px var(--accent-glow-strong), 0 0 4px var(--accent);
  pointer-events: none;
  will-change: width, opacity;
  border-radius: 0 2px 2px 0;
}

/* Initial page-load fill animation */
.page-progress.loading {
  animation: pageLoadFill 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes pageLoadFill {
  0%   { width: 0%;   opacity: 1; }
  60%  { width: 70%;  opacity: 1; }
  85%  { width: 100%; opacity: 1; }
  100% { width: 100%; opacity: 0; }
}

/* After load — bar tracks scroll position */
.page-progress.scroll-mode {
  opacity: 1;
  transition: width 0.08s linear;
}

/* Click feedback — quick flash before navigating to another doc page */
.page-progress.navigating {
  animation: pageNavigate 0.45s ease-out forwards;
}

@keyframes pageNavigate {
  0%   { width: 0%;   opacity: 1; }
  100% { width: 90%;  opacity: 1; }
}

/* ──────────────────────────────────────────────────────────────
   TOP NAV
   ────────────────────────────────────────────────────────────── */
.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 50;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(10, 10, 15, 0.8);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.nav-logo svg { width: 26px; height: 26px; flex-shrink: 0; }

.nav-logo .logo-dash {
  font-weight: 400;
  color: var(--text-dim);
  animation: cursorBlink 1.2s step-end infinite;
}

@keyframes cursorBlink {
  0%, 100% { color: var(--text-dim); }
  50% { color: var(--text); }
}

.nav-logo .logo-suffix { color: var(--text-dim); font-weight: 400; }
.nav-logo .logo-docs { color: var(--text-muted); font-weight: 500; margin-left: 0.4rem; }

.nav-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.nav-search input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.9rem 0.55rem 2.2rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.nav-search input::placeholder { color: var(--text-dim); }

.nav-search input:focus {
  border-color: var(--border-accent);
  background: var(--bg-card);
}

.nav-search svg {
  position: absolute;
  top: 50%; left: 0.7rem;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.nav-search kbd {
  position: absolute;
  top: 50%; right: 0.6rem;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  pointer-events: none;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1.3rem;
}

.nav-right a {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.15s;
}

.nav-right a:hover { color: var(--accent); }

.nav-right svg { width: 18px; height: 18px; }

.nav-cta {
  background: var(--accent);
  color: var(--bg) !important;
  padding: 0.5rem 1rem;
  border-radius: 7px;
  font-weight: 600 !important;
  font-size: 0.82rem !important;
  transition: opacity 0.15s !important;
}

.nav-cta:hover { opacity: 0.88; color: var(--bg) !important; }

.nav-hamburger {
  display: none;
  background: none; border: none;
  cursor: pointer;
  padding: 6px;
  flex-direction: column;
  gap: 5px;
}

.nav-hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: background 0.15s;
}

.nav-hamburger:hover span { background: var(--accent); }

/* ──────────────────────────────────────────────────────────────
   LAYOUT — Sidebar / Content / TOC
   ────────────────────────────────────────────────────────────── */
.docs-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1400px;
  margin: 0 auto;
  padding-top: var(--nav-h);
  gap: 0;
}

/* ── Sidebar ── */
.docs-sidebar {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  padding: 1.8rem 1rem 3rem 2rem;
  border-right: 1px solid var(--border);
}

.docs-sidebar::-webkit-scrollbar { width: 6px; }
.docs-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sidebar-section { margin-bottom: 1.6rem; }

.sidebar-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.6rem;
  padding-left: 0.7rem;
}

.sidebar-list { list-style: none; }

.sidebar-list li { margin: 0.1rem 0; }

.sidebar-list a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.sidebar-list a svg {
  width: 16px; height: 16px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.sidebar-list a:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

.sidebar-list a.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-color: var(--border-accent);
}

.sidebar-list a.active svg { color: var(--accent); }

/* ── Main content ── */
.docs-main {
  padding: 2.5rem 3rem 5rem;
  max-width: calc(var(--content-max) + 6rem);
  min-width: 0;
}

.breadcrumb {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}

.docs-main h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 0.6rem;
}

.page-lede {
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 300;
  line-height: 1.6;
  margin-bottom: 2.5rem;
  max-width: 640px;
}

.docs-main h2 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 3rem 0 1rem;
  padding-top: 0.5rem;
  scroll-margin-top: calc(var(--nav-h) + 1rem);
}

.docs-main h2::before {
  content: '';
  display: block;
  width: 28px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  margin-bottom: 0.7rem;
  border-radius: 2px;
}

.docs-main h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 2rem 0 0.7rem;
  scroll-margin-top: calc(var(--nav-h) + 1rem);
}

.docs-main h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.4rem 0 0.5rem;
}

.docs-main p {
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.75;
  font-weight: 300;
  margin-bottom: 1rem;
}

.docs-main p strong,
.docs-main li strong { color: var(--text); font-weight: 600; }

.docs-main ul, .docs-main ol {
  color: var(--text-muted);
  margin: 0 0 1.2rem 1.4rem;
  font-weight: 300;
}

.docs-main li {
  margin-bottom: 0.45rem;
  line-height: 1.7;
}

.docs-main hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* Inline code */
.docs-main :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.45em;
  color: var(--accent);
}

/* Code block — matches WP install page */
.code-block {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  overflow-x: auto;
  line-height: 1.7;
  margin: 1rem 0 1.5rem;
}

.code-block pre {
  margin: 0;
  background: none;
  padding: 0;
  font-family: inherit;
  white-space: pre;
}

.code-block .copy-btn {
  position: absolute;
  top: 0.5rem; right: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.28rem 0.65rem;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}

.code-block .copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.code-block .copy-btn.copied { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

/* Syntax tints (kept subtle — no JS highlighter to stay lightweight) */
.code-block .c-cmt { color: var(--text-dim); font-style: italic; }
.code-block .c-key { color: var(--accent-secondary); }
.code-block .c-str { color: var(--accent-warm); }
.code-block .c-var { color: var(--accent); }
.code-block .c-num { color: var(--accent-warm); }

/* Tabs (OS / variant switcher) */
.code-os-group { display: flex; flex-direction: column; gap: 0; margin: 1rem 0 1.5rem; }

.os-switcher {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

.os-tab {
  padding: 0.3rem 0.9rem;
  border-radius: 6px;
  font-size: 0.74rem;
  font-family: var(--font-mono);
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.01em;
}

.os-tab:hover { color: var(--text-muted); border-color: var(--text-dim); }

.os-tab.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

.os-panel { display: none; }
.os-panel.active { display: block; }

/* Tables */
.docs-main table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1rem 0 1.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.docs-main thead { background: var(--bg-elevated); }

.docs-main th {
  text-align: left;
  padding: 0.7rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.docs-main td {
  padding: 0.7rem 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.55;
}

.docs-main tbody tr:last-child td { border-bottom: none; }
.docs-main tbody tr:hover { background: rgba(255, 255, 255, 0.015); }

.docs-main td code,
.docs-main th code { font-size: 0.8em; }

.docs-main td:first-child { color: var(--text); font-weight: 500; }

/* Callout / Note boxes */
.callout {
  display: flex;
  gap: 0.9rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--bg-card);
  border-radius: 8px;
  margin: 1.4rem 0;
}

.callout-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 0.05rem;
}

.callout-body { font-size: 0.92rem; color: var(--text-muted); line-height: 1.65; }
.callout-body strong { color: var(--text); }
.callout-body p:last-child { margin-bottom: 0; }

.callout.warn { border-left-color: var(--accent-warm); }
.callout.warn .callout-icon { color: var(--accent-warm); }

.callout.danger { border-left-color: var(--danger); }
.callout.danger .callout-icon { color: var(--danger); }

.callout.info { border-left-color: var(--accent-secondary); }
.callout.info .callout-icon { color: var(--accent-secondary); }

/* Cards grid (intro page) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}

.card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem;
  color: var(--text);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.25s;
}

.card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  color: var(--text);
}

.card:hover::before { opacity: 1; }

.card-icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: var(--accent-glow);
  border: 1px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: var(--accent);
}

.card-icon svg { width: 20px; height: 20px; }

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem !important;
  margin-top: 0 !important;
  color: var(--text);
}

.card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

/* Step / numbered blocks */
.step {
  position: relative;
  padding-left: 2.6rem;
  margin: 1.6rem 0;
}

.step-num {
  position: absolute;
  left: 0; top: 0;
  width: 1.9rem; height: 1.9rem;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--border-accent);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step h3 { margin-top: 0; }

/* Pager (Prev / Next) */
.docs-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.docs-pager a {
  flex: 1;
  max-width: 280px;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-muted);
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.docs-pager a:hover {
  border-color: var(--border-accent);
  color: var(--text);
}

.docs-pager .pager-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.docs-pager .pager-title {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
}

.docs-pager a:last-child { text-align: right; align-items: flex-end; }

/* ── Right: On this page (TOC) ── */
.docs-toc {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  padding: 2.5rem 1.5rem 3rem;
  border-left: 1px solid var(--border);
  font-size: 0.85rem;
}

.docs-toc::-webkit-scrollbar { width: 6px; }
.docs-toc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.toc-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.9rem;
}

.toc-title svg { width: 14px; height: 14px; }

.toc-list { list-style: none; }

.toc-list a {
  display: block;
  padding: 0.32rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 400;
  border-left: 2px solid transparent;
  padding-left: 0.7rem;
  margin-left: -0.7rem;
  transition: color 0.15s, border-color 0.15s;
}

.toc-list a:hover { color: var(--text); }

.toc-list a.toc-active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc-list .toc-h3 {
  padding-left: 1.5rem;
  margin-left: -0.7rem;
  font-size: 0.8rem;
}

/* ──────────────────────────────────────────────────────────────
   FOOTER
   ────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-left {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.footer-left svg { width: 18px; height: 18px; color: var(--accent); }

.footer-links { display: flex; gap: 1.5rem; list-style: none; }

.footer-links a { color: var(--text-dim); font-size: 0.82rem; }
.footer-links a:hover { color: var(--accent); }

/* ──────────────────────────────────────────────────────────────
   MOBILE / RESPONSIVE
   ────────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .docs-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .docs-toc { display: none; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }
  .docs-main { padding: 2rem 1.5rem 4rem; }
  .nav-search { display: none; }
}

@media (max-width: 760px) {
  .nav-hamburger { display: flex; }
  .nav-right > a:not(.nav-cta) { display: none; }
  .docs-shell { grid-template-columns: 1fr; }
  .docs-sidebar {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    width: 280px;
    height: calc(100vh - var(--nav-h));
    background: var(--bg);
    border-right: 1px solid var(--border);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  .docs-sidebar.open { transform: translateX(0); }
  .docs-main { padding: 1.5rem 1.2rem 3rem; }
  .docs-main h1 { font-size: 1.9rem; }
  .docs-main h2 { font-size: 1.3rem; }
  .site-nav { padding: 0 1rem; }
  .nav-logo .logo-docs { display: none; }
  .docs-pager { flex-direction: column; }
  .docs-pager a { max-width: none; }
  .docs-pager a:last-child { text-align: left; align-items: flex-start; }
}

/* Backdrop when mobile sidebar open */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: var(--nav-h) 0 0 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
}

.sidebar-backdrop.open { display: block; }
