/* RuntCMS Documentation — docs.css */

/* ─── CSS custom properties ─────────────────────────────────────────────── */
:root {
  --bg:            #f7f7fb;
  --sidebar-bg:    #ffffff;
  --sidebar-border:#cacae2;
  --text:          #3f3f46;
  --heading:       #18181b;
  --accent:        #672ccf;
  --accent-muted:  #ede9fb;
  --active-bg:     #ede9fb;
  --code-bg:       #f1f1f9;
  --code-text:     #18181b;
  --topbar-bg:     #ffffff;
  --topbar-border: #cacae2;
  --border:        #e2e2f0;
  --muted:         #52525c;
  --note-bg:       #ede9fb;
  --note-border:   #672ccf;
  --warning-bg:    #fff7ed;
  --warning-border:#ff6900;
  --tip-bg:        #f0fdf4;
  --tip-border:    #00c950;
  --shadow:        0 1px 3px rgba(0,0,0,.08);
}

[data-theme="dark"] {
  --bg:            #09090b;
  --sidebar-bg:    #18181b;
  --sidebar-border:#3f3f46;
  --text:          #9090b9;
  --heading:       #cacae2;
  --accent:        #a085f0;
  --accent-muted:  #2d1f5e;
  --active-bg:     #2d1f5e;
  --code-bg:       #18181b;
  --code-text:     #cacae2;
  --topbar-bg:     #18181b;
  --topbar-border: #3f3f46;
  --border:        #27272a;
  --muted:         #9090b9;
  --note-bg:       #1e1040;
  --note-border:   #a085f0;
  --warning-bg:    #2d1800;
  --warning-border:#ff6900;
  --tip-bg:        #002d1a;
  --tip-border:    #00c950;
  --shadow:        0 1px 3px rgba(0,0,0,.4);
}

/* ─── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  transition: background .15s, color .15s;
}

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

img { max-width: 100%; height: auto; }

/* ─── Top bar ───────────────────────────────────────────────────────────── */
.docs-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  z-index: 200;
  box-shadow: var(--shadow);
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--heading);
  text-decoration: none;
  flex-shrink: 0;
}

.topbar-logo:hover { text-decoration: none; opacity: .85; }

.topbar-logo-svg { flex-shrink: 0; height: 22px; width: auto; display: block; color: #3f3f46; }
[data-theme="dark"] .topbar-logo-svg { color: #9090b9; }

.topbar-docs-label {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-left: .25rem;
}

.topbar-spacer { flex: 1; }

.topbar-home-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  margin-right: 16px;
  white-space: nowrap;
  transition: color 0.15s;
}
.topbar-home-link:hover { color: var(--accent); }

.version-select {
  appearance: none;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .3rem .7rem .3rem .6rem;
  border-radius: 6px;
  font-size: .85rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236c757d'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .5rem center;
  padding-right: 1.6rem;
}

.version-select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}

.theme-toggle:hover { background: var(--sidebar-bg); }

.theme-toggle svg { pointer-events: none; }

.icon-moon { display: none; }
.icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: none; }

/* Hamburger */
.hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Layout shell ──────────────────────────────────────────────────────── */
.docs-layout {
  display: flex;
  min-height: 100vh;
  padding-top: 56px;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.docs-sidebar {
  width: 260px;
  flex-shrink: 0;
  position: fixed;
  top: 56px;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 1rem 0 0;
  z-index: 100;
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
}
.docs-sidebar nav {
  flex: 1;
}
.sidebar-footer {
  padding: 1rem 1rem 1.25rem;
  margin-top: 1rem;
}
.sidebar-home-btn {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s, color 0.15s;
  box-sizing: border-box;
}
.sidebar-home-btn:hover {
  background: var(--accent);
  color: #fff;
}
.sidebar-copy {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* Search */
.sidebar-search {
  padding: .25rem .9rem .75rem;
  position: relative;
}

.sidebar-search input {
  width: 100%;
  padding: .45rem .75rem .45rem 2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: .85rem;
  outline: none;
  transition: border-color .15s;
}

.sidebar-search input::placeholder { color: var(--muted); }
.sidebar-search input:focus { border-color: var(--accent); }

.sidebar-search .search-icon {
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  margin-top: .125rem;
}

.search-results {
  position: absolute;
  left: .9rem;
  right: .9rem;
  top: calc(100% - .4rem);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  max-height: 320px;
  overflow-y: auto;
  z-index: 300;
  display: none;
}

.search-results.open { display: block; }

.search-result-item {
  display: block;
  padding: .55rem .85rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  transition: background .1s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.focused { background: var(--active-bg); }

.result-title { font-size: .875rem; font-weight: 600; color: var(--heading); }
.result-section { font-size: .75rem; color: var(--muted); }

.search-no-results {
  padding: .75rem .85rem;
  font-size: .85rem;
  color: var(--muted);
}

/* Nav sections */
.nav-section { margin-bottom: .25rem; }

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .45rem 1rem .45rem .9rem;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: color .15s;
}

.nav-section-header:hover { color: var(--text); }

.nav-chevron {
  transition: transform .2s;
  flex-shrink: 0;
}

.nav-section.open .nav-chevron { transform: rotate(90deg); }

.nav-section-links {
  display: none;
  list-style: none;
  padding: .1rem 0;
}

.nav-section.open .nav-section-links { display: block; }

.nav-section-links a {
  display: block;
  padding: .35rem .9rem .35rem 1.5rem;
  font-size: .875rem;
  color: var(--text);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color .12s, background .12s, border-color .12s;
  line-height: 1.4;
}

.nav-section-links a:hover {
  color: var(--accent);
  background: var(--active-bg);
}

.nav-section-links a.active {
  color: var(--accent);
  background: var(--active-bg);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* ─── Content wrapper ───────────────────────────────────────────────────── */
.docs-content-wrap {
  margin-left: 260px;
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  padding: 0 2rem 4rem;
}

.docs-content-inner {
  width: 100%;
  max-width: 800px;
  min-width: 0;
}

/* Breadcrumbs */
.docs-breadcrumbs {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  color: var(--muted);
  padding: 1.25rem 0 .75rem;
  flex-wrap: wrap;
}

.docs-breadcrumbs a { color: var(--muted); }
.docs-breadcrumbs a:hover { color: var(--accent); }
.docs-breadcrumbs .sep { color: var(--border); }
.docs-breadcrumbs .current { color: var(--text); }

/* ─── Article typography ────────────────────────────────────────────────── */
.docs-article h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.25;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

.docs-article h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--heading);
  margin-top: 2.5rem;
  margin-bottom: .75rem;
  padding-top: .5rem;
}

.docs-article h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--heading);
  margin-top: 1.75rem;
  margin-bottom: .5rem;
}

.docs-article h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
  margin-top: 1.25rem;
  margin-bottom: .35rem;
}

.docs-article p { margin-bottom: 1rem; }

.docs-article ul,
.docs-article ol {
  margin: 0 0 1rem 1.4rem;
}

.docs-article li { margin-bottom: .3rem; }
.docs-article li > ul,
.docs-article li > ol { margin-top: .3rem; margin-bottom: .25rem; }

.docs-article strong { font-weight: 600; color: var(--heading); }
.docs-article em { font-style: italic; }

/* Inline code */
.docs-article code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: .85em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: .15em .4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Code blocks */
.docs-article pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  line-height: 1.6;
}

.docs-article pre code {
  font-size: .825rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--code-text);
}

/* Tables */
.docs-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: .9rem;
}

.docs-article th,
.docs-article td {
  padding: .6rem .9rem;
  text-align: left;
  border: 1px solid var(--border);
}

.docs-article th {
  background: var(--sidebar-bg);
  font-weight: 600;
  color: var(--heading);
}

.docs-article tr:nth-child(even) td {
  background: var(--sidebar-bg);
}

/* Callouts */
.note, .warning, .tip {
  border-radius: 6px;
  padding: .9rem 1.1rem;
  margin: 1.25rem 0;
  border-left: 4px solid;
  font-size: .9rem;
}

.note    { background: var(--note-bg);    border-color: var(--note-border); }
.warning { background: var(--warning-bg); border-color: var(--warning-border); }
.tip     { background: var(--tip-bg);     border-color: var(--tip-border); }

.note p:last-child,
.warning p:last-child,
.tip p:last-child { margin-bottom: 0; }

.note strong    { color: var(--note-border); }
.warning strong { color: var(--warning-border); }
.tip strong     { color: var(--tip-border); }

/* Doc screenshots */
.doc-screenshot {
  display: block;
  max-width: 50%;
  height: auto;
  margin: 1.5rem auto;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: zoom-in;
  transition: border-color .2s;
}
.doc-screenshot:hover {
  border-color: var(--accent);
}

/* Lightbox */
.docs-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.85);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: auto;
}
.docs-lightbox.is-open {
  display: flex;
}
.docs-lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  flex-shrink: 0;
}
.docs-lightbox.is-actual-size img {
  max-width: none;
  max-height: none;
  margin: auto;
}
.docs-lightbox-toolbar {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.docs-lightbox-toolbar button {
  background: #3f3f46;
  border: 1px solid #52525c;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  transition: background .15s, border-color .15s;
}
.docs-lightbox-toolbar button:hover { background: #52525c; }
.docs-lightbox-toolbar button.is-active { background: #672ccf; border-color: #672ccf; }
.docs-lightbox-toolbar button svg { pointer-events: none; }

/* Screenshot placeholders */
.screenshot-placeholder {
  background: var(--sidebar-bg);
  border: 2px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: .85rem;
  padding: 2rem;
  text-align: center;
  margin: 1rem 0 1.5rem;
}

/* ─── On this page (TOC) ────────────────────────────────────────────────── */
.docs-toc {
  position: fixed;
  top: 56px;
  right: 0;
  width: 220px;
  padding: 1.5rem 1rem 1.5rem 1.25rem;
  overflow-y: auto;
  max-height: calc(100vh - 56px);
  font-size: .8rem;
}

.docs-toc-title {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .65rem;
}

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

.docs-toc-list a {
  display: block;
  padding: .25rem 0 .25rem .6rem;
  color: var(--muted);
  border-left: 2px solid var(--border);
  text-decoration: none;
  line-height: 1.4;
  transition: color .12s, border-color .12s;
}

.docs-toc-list a:hover { color: var(--accent); border-left-color: var(--accent); }
.docs-toc-list a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }

.toc-h3 { padding-left: 1.25rem !important; font-size: .78rem; }

/* When TOC is visible, shrink content */
.has-toc .docs-content-wrap { padding-right: 240px; }

/* ─── Prev / Next navigation ────────────────────────────────────────────── */
.docs-prevnext {
  display: flex;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.prevnext-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: .9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, background .15s;
}

.prevnext-btn:hover {
  border-color: var(--accent);
  background: var(--active-bg);
  text-decoration: none;
}

.prevnext-btn.next { text-align: right; }

.prevnext-label {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: .2rem;
  display: flex;
  align-items: center;
  gap: .3rem;
}

.prevnext-btn.next .prevnext-label { justify-content: flex-end; }

.prevnext-title { font-weight: 600; font-size: .9rem; color: var(--accent); }

/* ─── Footer ────────────────────────────────────────────────────────────── */
.docs-footer {
  margin-top: 2rem;
  padding: 1rem 0 0;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ─── Overlay for mobile sidebar ───────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .docs-toc { display: none; }
  .has-toc .docs-content-wrap { padding-right: 2rem; }
}

@media (max-width: 768px) {
  .hamburger { display: flex; }

  .docs-sidebar {
    transform: translateX(-100%);
    z-index: 150;
  }

  .docs-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.2);
  }

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

  .docs-content-wrap {
    margin-left: 0;
    padding: 0 1rem 3rem;
  }

  .docs-content-inner { max-width: 100%; }

  .docs-article h1 { font-size: 1.6rem; }
  .docs-article h2 { font-size: 1.2rem; }

  .docs-prevnext { flex-direction: column; }
}

/* ─── Utility ───────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* Anchor link offset for fixed header */
.docs-article h2[id],
.docs-article h3[id] {
  scroll-margin-top: 72px;
}
