/* ── Z Skills Standalone Docs Page ──────────────────────────── */
/*
 * Lifted from zimulink's docs__docs.css (193 LOC, light-only).
 * Phase 3 transformations:
 *   - Newsletter block (upstream L139-182) stripped.
 *   - Light-only palette (7 vars) replaced with dark-default + light
 *     overlay. The palettes were lifted verbatim from the now-deleted
 *     docs/guides/inspecting-and-monitoring.html (DOC_VIEWER Phase 5
 *     removed that hand-built page in favor of rendering the equivalent
 *     INSPECTING_AND_MONITORING.md through this viewer). The doc viewer
 *     uses the 9 vars relevant to viewer concerns; the original host
 *     page also defined --warn and --pill-* which the viewer does not
 *     need.
 *   - Variable-name rewrites:
 *       --color-bg            → --bg
 *       --color-surface       → --panel
 *       --color-border        → --line
 *       --color-text          → --ink
 *       --color-text-muted    → --muted
 *       --color-primary       → --accent
 *       --color-primary-light → split by call site:
 *         (a) nav-item hover/active  → --panel2 (subtle elevated tint)
 *         (b) inline <code> + <pre>  → --code (dedicated code accent)
 */

:root {
  /* Dark defaults */
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #161a22;
  --panel2: #1b2030;
  --ink: #e6e9ef;
  --muted: #9aa4b2;
  --line: #2a3142;
  --accent: #5db0ff;
  --accent2: #7ee2b8;
  --code: #0b0d12;
}

[data-theme="light"] {
  /* Light overlay */
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel2: #f0f3f8;
  --ink: #1b2430;
  --muted: #5b6776;
  --line: #dde3ec;
  --accent: #1668c7;
  --accent2: #0f8a5f;
  --code: #f6f8fa;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
}

/* Header */
#zl-docs-header {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.zl-docs-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.05em;
}
.zl-docs-logo:hover { text-decoration: underline; }
.zl-docs-header-title {
  font-size: 15px;
  color: var(--muted);
}
.zl-docs-header-link {
  margin-left: auto;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
.zl-docs-header-link:hover { text-decoration: underline; }

/* Theme toggle button (Phase 3 addition — not lifted). */
.zl-docs-theme-toggle {
  margin-left: 0;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 15px;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease;
}
.zl-docs-theme-toggle:hover {
  background: var(--panel2);
  border-color: var(--accent);
}

/* Layout */
#zl-docs-layout {
  display: flex;
  height: calc(100vh - 48px);
}

/* Sidebar nav */
#zl-docs-nav {
  width: 240px;
  min-width: 240px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 12px 0;
  background: var(--panel);
}
.zl-docs-section-header {
  padding: 10px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.zl-docs-nav-item {
  display: block;
  padding: 6px 16px 6px 28px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  transition: background 100ms ease;
}
.zl-docs-nav-item:hover {
  background: var(--panel2);
}
.zl-docs-nav-item.active {
  background: var(--panel2);
  font-weight: 600;
  color: var(--accent);
}

/* Main content
 *
 * The scrollbar lives on the OUTER flex item (#zl-docs-main), which fills
 * the viewport to the right edge — so the scrollbar is flush right.
 * Inside, a centered child holds the 900px-constrained content with
 * symmetric whitespace on both sides (margin: 0 auto on .zl-docs-content).
 * The renderer writes into #zl-docs-main, but renderDoc() wraps the HTML
 * in <div class="zl-docs-content"> at write time. */
#zl-docs-main {
  flex: 1;
  overflow-y: auto;
  padding: 0;          /* padding moves to the inner .zl-docs-content */
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
}
.zl-docs-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 32px;
}
#zl-docs-main h1 { font-size: 28px; margin: 24px 0 12px; font-weight: 700; }
#zl-docs-main h2 { font-size: 22px; margin: 22px 0 10px; font-weight: 600; }
#zl-docs-main h3 { font-size: 18px; margin: 16px 0 8px; font-weight: 600; }
#zl-docs-main p { margin: 10px 0; }
#zl-docs-main ul, #zl-docs-main ol { margin: 10px 0; padding-left: 24px; }
#zl-docs-main li { margin: 6px 0; }
#zl-docs-main code {
  background: var(--code);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 14.5px;
}
#zl-docs-main pre {
  background: var(--code);
  padding: 14px 18px;
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  font-size: 14.5px;
  margin: 12px 0;
}
#zl-docs-main pre code { background: none; padding: 0; border: none; }
#zl-docs-main hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
#zl-docs-main a { color: var(--accent); }
/* Bare slash-command mentions (e.g. /do) — accent-colored like skill names in
 * flow diagrams. The .skill class is applied by MarkdownRenderer's inline-code
 * pass only to single `/word` tokens, so flags/verbs/paths stay neutral. */
#zl-docs-main code.skill { color: var(--accent); }
#zl-docs-main img { max-width: 100%; border-radius: 6px; margin: 10px 0; }

/* Loading placeholder — shown before the first doc renders and during
 * subsequent fetches. Centered both axes within the main pane so the
 * empty-state doesn't read as a stuck top-left fragment. */
.zl-docs-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

/* Frontmatter strip (Phase 4) — subtle muted metadata above plan H1. */
.zs-frontmatter {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
  padding: 4px 0 6px;
  border-bottom: 1px dashed var(--line);
  line-height: 1.5;
}
.zs-frontmatter-field { white-space: nowrap; }
.zs-frontmatter-key {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 12px;
}
.zs-frontmatter-val { color: var(--ink); }
.zs-frontmatter-sep { color: var(--line); margin: 0 2px; }

/* Tables */
.zl-docs-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 15px;
}
.zl-docs-table th, .zl-docs-table td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
}
.zl-docs-table th {
  background: var(--panel);
  font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
  #zl-docs-nav {
    width: 180px;
    min-width: 180px;
  }
  #zl-docs-main {
    padding: 16px 20px;
  }
}

/* ── Workflow flow strips (ported from PRESENTATION.html, themed to viewer vars) ── */
/* Vertical flow: larger stacked boxes with down-arrow connectors — plenty of
   room for the real wording (no horizontal scroll, no tiny text). */
.flow {
  display: flex;
  flex-direction: column;
  gap: 20px;               /* room for the down-arrow between boxes */
  margin: 20px auto;       /* centered column */
  max-width: 580px;
}
.flow-step {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 18px;
  position: relative;
  text-align: center;
}
.flow-step p { font-size: 0.95em; color: var(--ink); margin: 0; line-height: 1.5; }
.flow-step strong { color: var(--accent); font-weight: 600; }
/* down-arrow connector between stacked steps */
.flow-step + .flow-step::before {
  content: '';
  position: absolute;
  top: -15px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid var(--accent);   /* points down to this box */
}
/* optional / conditional step (brainstorm·quiz lead-in, "if auto" trailing) — dashed + dimmed */
.flow-step.optional { border-style: dashed; background: transparent; }
.flow-step.optional p { color: var(--muted); font-style: italic; }
.flow-step.optional strong { color: var(--muted); }
.flow-step.optional::before { border-top-color: var(--muted); }

/* Collapsible per-command flow — framed as a callout card so it stands out
   from the surrounding prose. Open/closed persisted by docs-app.js. */
details.flow-cmd {
  margin: 22px auto;
  max-width: 620px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);   /* accent stripe draws the eye */
  border-radius: 10px;
  background: var(--panel2);               /* fallback for older browsers */
  background: color-mix(in srgb, var(--accent) 6%, var(--bg));
}
details.flow-cmd > summary {
  cursor: pointer;
  padding: 11px 18px;
  font-size: 1.02em;
  font-weight: 600;
  color: var(--ink);
  border-radius: 9px;
  list-style-position: inside;
}
details.flow-cmd[open] > summary {
  border-bottom: 1px solid var(--line);
  border-radius: 9px 9px 0 0;
}
details.flow-cmd > summary:hover { color: var(--accent); }
details.flow-cmd > summary code { color: var(--accent); }
