/* ============================================================================
   Flero Docs layout + prose.
   Brand design tokens (--bg, --text, --blue, fonts, ...) and the .theme-toggle
   rule come from brand.css, which build.mjs extracts verbatim from index.html.
   This file is the only hand-written, docs-only CSS.
   ========================================================================== */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px; /* keep anchored headings clear of the sticky header */
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s, color 0.25s;
}

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

.docs-skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--bg-card); color: var(--text); padding: 10px 16px;
  border-radius: 10px; border: 1px solid var(--border-hi); z-index: 400;
}
.docs-skip-link:focus { left: 12px; top: 12px; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.docs-header {
  position: sticky; top: 0; z-index: 300;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.25s, border-color 0.25s;
}
.docs-header-inner {
  display: flex; align-items: center; gap: 14px;
  height: 60px; max-width: 1400px; margin: 0 auto; padding: 0 24px;
}
.docs-logo { display: inline-flex; align-items: center; height: 26px; }
.docs-logo svg { height: 26px; width: auto; display: block; }
.docs-logo .logo-light { display: block; }
.docs-logo .logo-dark  { display: none; }
[data-theme="dark"] .docs-logo .logo-light { display: none; }
[data-theme="dark"] .docs-logo .logo-dark  { display: block; }
.docs-logo-tag {
  font-family: var(--serif); font-size: 15px; color: var(--text-muted);
  border-left: 1px solid var(--border-hi); padding-left: 14px; line-height: 1;
}
.docs-header-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.docs-header-link { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.docs-header-link:hover { color: var(--text); text-decoration: none; }
.docs-menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--border-hi);
  color: var(--text-muted); cursor: pointer;
}

/* ── Layout grid ────────────────────────────────────────────────────────── */
.docs-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 240px;
  max-width: 1400px; margin: 0 auto;
  align-items: start;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.docs-sidebar {
  position: sticky; top: 60px; align-self: start;
  height: calc(100vh - 60px); overflow-y: auto;
  padding: 28px 16px 48px 24px;
  border-right: 1px solid var(--border);
}
.docs-sidebar ul { list-style: none; }
.docs-sb-home {
  display: block; font-family: var(--serif); font-size: 16px;
  color: var(--text); margin-bottom: 20px; font-weight: 700;
}
.docs-sb-home:hover { text-decoration: none; color: var(--blue); }
.docs-sb-section { margin-bottom: 18px; }
.docs-sb-label {
  display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px;
}
.docs-sb-section > ul > li > a {
  display: block; padding: 5px 10px; border-radius: 8px;
  font-size: 14px; color: var(--text-muted); line-height: 1.4;
}
.docs-sb-section > ul > li > a:hover {
  background: var(--bg-raised); color: var(--text); text-decoration: none;
}
.docs-sb-section > ul > li > a.active {
  background: var(--blue-soft); color: var(--blue); font-weight: 600;
}

/* ── Main / article ─────────────────────────────────────────────────────── */
.docs-main { min-width: 0; padding: 40px 0 96px; }
.docs-article {
  max-width: 760px; margin: 0 auto; padding: 0 40px;
}
.docs-article > *:first-child { margin-top: 0; }

.docs-article h1 {
  font-family: var(--serif); font-weight: 700;
  font-size: 2.1rem; line-height: 1.2; letter-spacing: -0.01em;
  margin: 0 0 18px;
}
.docs-article h2 {
  font-family: var(--serif); font-weight: 700; font-size: 1.5rem; line-height: 1.3;
  margin: 44px 0 14px; padding-top: 8px; border-top: 1px solid var(--border);
}
.docs-article h3 { font-size: 1.2rem; font-weight: 600; margin: 30px 0 10px; }
.docs-article h4 { font-size: 1.02rem; font-weight: 600; margin: 22px 0 8px; }
.docs-article p { margin: 0 0 16px; }
.docs-article ul, .docs-article ol { margin: 0 0 16px; padding-left: 22px; }
.docs-article li { margin: 4px 0; }
.docs-article li > ul, .docs-article li > ol { margin: 4px 0; }
.docs-article strong { font-weight: 600; color: var(--text); }
.docs-article hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
.docs-article img { max-width: 100%; height: auto; border-radius: 12px; }

/* Heading anchor affordance */
.docs-article :is(h2, h3, h4) { scroll-margin-top: 84px; position: relative; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.docs-article table {
  width: 100%; border-collapse: collapse; margin: 0 0 20px;
  font-size: 14px; display: block; overflow-x: auto;
}
.docs-article th, .docs-article td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left;
  vertical-align: top;
}
.docs-article th { background: var(--bg-raised); font-weight: 600; }

/* ── Blockquotes + screenshot callouts ─────────────────────────────────── */
.docs-article blockquote {
  margin: 0 0 18px; padding: 12px 16px;
  border-left: 3px solid var(--border-hi);
  background: var(--bg-raised); border-radius: 0 12px 12px 0;
  color: var(--text-muted);
}
.docs-article blockquote p:last-child { margin-bottom: 0; }
.docs-article blockquote.callout-shot {
  border-left: none; background: var(--amber-soft);
  color: var(--text); border-radius: 12px;
}

/* ── Code ───────────────────────────────────────────────────────────────── */
/* Carve-out from the global no-monospace rule: docs code uses a real mono stack. */
.docs-article :not(pre) > code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px;
  word-break: break-word;
}
.docs-article pre {
  margin: 0 0 20px; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: 14px;
  overflow-x: auto; line-height: 1.55; font-size: 13.5px;
}
.docs-article pre code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
/* Shiki dual-theme: light vars by default, dark vars under [data-theme="dark"]. */
.docs-article .shiki,
.docs-article .shiki span {
  background-color: var(--shiki-light-bg);
  color: var(--shiki-light);
}
[data-theme="dark"] .docs-article .shiki,
[data-theme="dark"] .docs-article .shiki span {
  background-color: var(--shiki-dark-bg) !important;
  color: var(--shiki-dark) !important;
}

/* ── Table of contents (right rail) ─────────────────────────────────────── */
.docs-toc {
  position: sticky; top: 60px; align-self: start;
  height: calc(100vh - 60px); overflow-y: auto;
  padding: 44px 24px 48px 8px; font-size: 13px;
}
.docs-toc-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 10px;
}
.docs-toc ul { list-style: none; }
.docs-toc a {
  display: block; padding: 3px 0; color: var(--text-muted); line-height: 1.4;
}
.docs-toc a:hover { color: var(--text); text-decoration: none; }
.docs-toc li.lvl-3 a { padding-left: 12px; font-size: 12.5px; }

/* ── Article footer note ────────────────────────────────────────────────── */
.docs-article-end { margin-top: 48px; }
.docs-edit-note { font-size: 13px; color: var(--text-dim); }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.docs-footer { border-top: 1px solid var(--border); }
.docs-footer-inner {
  max-width: 1400px; margin: 0 auto; padding: 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.docs-footer-wordmark { font-family: var(--serif); font-size: 18px; color: var(--text); }
.docs-footer-copy { font-size: 13px; color: var(--text-dim); }
.docs-footer-link { font-size: 13px; color: var(--text-muted); margin-left: auto; }

/* ── Mobile sidebar scrim ───────────────────────────────────────────────── */
.docs-sidebar-scrim {
  position: fixed; inset: 60px 0 0; z-index: 250;
  background: rgba(0,0,0,0.4);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .docs-layout { grid-template-columns: 260px minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 820px) {
  .docs-menu-btn { display: inline-flex; }
  .docs-layout { grid-template-columns: 1fr; }
  .docs-sidebar {
    position: fixed; top: 60px; left: 0; z-index: 260;
    width: 300px; max-width: 86vw; height: calc(100vh - 60px);
    background: var(--bg); transform: translateX(-100%);
    transition: transform 0.2s ease; border-right: 1px solid var(--border);
  }
  body.docs-nav-open .docs-sidebar { transform: translateX(0); }
  .docs-article { padding: 0 22px; }
  .docs-logo-tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .docs-sidebar { transition: none; }
}
