/* ============================================================
   Vireo Theme Documentation — GitBook-style UI
   Fully responsive: desktop 3-column → tablet 2-column → mobile drawer
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-soft: #f8f9fb;
  --bg-hover: #f1f3f7;
  --border: #e7e9ee;
  --border-strong: #d9dce3;
  --text: #16181d;
  --text-2: #4b5563;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef2ff;
  --accent-line: #c7d2fe;
  --code-bg: #f4f5f8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .16);
  --topbar-h: 60px;
  --sidebar-w: 292px;
  --toc-w: 232px;
  --content-max: 47rem;
  --radius: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0e1116;
  --bg-soft: #12161d;
  --bg-hover: #1a1f28;
  --border: #232936;
  --border-strong: #2e3644;
  --text: #e7e9ee;
  --text-2: #b4bac6;
  --muted: #8b93a1;
  --accent: #8b93f8;
  --accent-strong: #a5abfa;
  --accent-soft: rgba(99, 102, 241, .14);
  --accent-line: #3730a3;
  --code-bg: #171c25;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 24px); }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* ---------------- Topbar ---------------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 60;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  box-shadow: 0 2px 6px rgba(79, 70, 229, .35);
}
.brand-name { font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 2px 7px; border-radius: 999px;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; flex: 0 0 auto;
  background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.menu-btn { display: none; }
.theme-btn .ic-moon { display: none; }
[data-theme="dark"] .theme-btn .ic-sun { display: none; }
[data-theme="dark"] .theme-btn .ic-moon { display: block; }

.search-trigger {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 12px; min-width: 200px;
  font: inherit; font-size: 13.5px; color: var(--muted);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 9px;
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.search-trigger:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.search-label { flex: 1; text-align: left; }
.search-kbd {
  font-family: var(--font); font-size: 11px; color: var(--muted);
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px; background: var(--bg);
}

/* ---------------- Layout ---------------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1520px; margin: 0 auto;
  padding-top: var(--topbar-h);
}

/* ---------------- Sidebar ---------------- */
.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.sidebar-scroll {
  height: 100%; overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 12px 40px 16px;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.nav-root, .nav-sub, .nav-group-list { list-style: none; margin: 0; padding: 0; }
.nav-group { margin-top: 26px; }
.nav-root > .nav-item:first-child { margin-top: 2px; }
.nav-group-title {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); padding: 0 10px 7px;
}
.nav-row {
  display: flex; align-items: center; border-radius: 7px;
  transition: background .12s ease;
}
.nav-row:hover { background: var(--bg-hover); }
.nav-link {
  flex: 1; display: block; padding: 6px 10px;
  font-size: 13.5px; line-height: 1.45; color: var(--text-2); font-weight: 450;
  border-radius: 7px; word-break: break-word;
}
.nav-row:hover .nav-link { color: var(--text); }
.nav-row.is-active { background: var(--accent-soft); position: relative; }
.nav-row.is-active::before {
  content: ""; position: absolute; left: -1px; top: 6px; bottom: 6px; width: 3px;
  border-radius: 3px; background: var(--accent);
}
.nav-row.is-active .nav-link { color: var(--accent); font-weight: 600; }
.nav-caret {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; margin-right: 4px; flex: 0 0 auto;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer;
  transition: transform .18s ease, background .12s ease;
}
.nav-caret:hover { background: var(--border); color: var(--text); }
.nav-item.branch-open > .nav-row > .nav-caret { transform: rotate(90deg); }
.nav-sub {
  display: none;
  margin: 2px 0 4px 12px; padding-left: 10px;
  border-left: 1px solid var(--border);
}
.nav-sub.is-open, .nav-item.branch-open > .nav-sub { display: block; }
.nav-sub .nav-link { font-size: 13px; padding: 5px 10px; }

.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 55;
  background: rgba(10, 12, 18, .5);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}

/* ---------------- Content ---------------- */
.content { min-width: 0; padding: 36px 48px 80px; }
.doc { max-width: var(--content-max); margin: 0 auto; }

.crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--muted); margin-bottom: 14px;
}
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumb-sep { opacity: .55; }
.crumb-cur { color: var(--text-2); font-weight: 500; }

.doc-title {
  font-size: clamp(1.7rem, 3.4vw, 2.15rem);
  line-height: 1.2; font-weight: 800; letter-spacing: -.02em;
  margin: 0 0 6px;
  padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
.doc-h {
  position: relative;
  font-weight: 700; letter-spacing: -.01em; line-height: 1.3;
  margin: 2.1em 0 .6em; scroll-margin-top: calc(var(--topbar-h) + 24px);
}
h2.doc-h { font-size: 1.35rem; }
h3.doc-h { font-size: 1.12rem; }
h4.doc-h { font-size: 1rem; }
.h-anchor {
  margin-left: 8px; font-weight: 500; color: var(--accent);
  opacity: 0; transition: opacity .12s ease;
}
.doc-h:hover .h-anchor, .h-anchor:focus-visible { opacity: 1; }

.doc p { margin: .9em 0; color: var(--text); }
.doc ul, .doc ol { margin: .9em 0; padding-left: 1.5em; }
.doc li { margin: .4em 0; }
.doc li p { margin: .35em 0; }
.doc strong { font-weight: 650; }
.doc code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .875em; background: var(--code-bg);
  border: 1px solid var(--border); border-radius: 5px; padding: .12em .38em;
}
.doc-code {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.6;
}
.doc-code code { background: none; border: 0; padding: 0; }

.doc-img {
  margin: 1.4em 0;
}
.doc-img img {
  display: block; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: zoom-in;
  background: var(--bg-soft);
}
.video-embed {
  position: relative; margin: 1.4em 0; padding-top: 56.25%;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow); background: #000;
}
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.table-wrap { margin: 1.2em 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.doc-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc-table th {
  background: var(--bg-soft); font-weight: 600; text-align: left;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.doc-table td {
  padding: 12px 16px; vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.doc-table tbody tr:last-child td { border-bottom: 0; }
.doc-table td:first-child, .doc-table th:first-child {
  width: 34%; min-width: 150px; border-right: 1px solid var(--border);
}
.doc-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-soft) 55%, transparent); }
.doc-table td p { margin: 0 0 .4em; }
.doc-table td p:last-child { margin-bottom: 0; }
.doc-table td ul, .doc-table td ol { margin: .3em 0; padding-left: 1.2em; }
.doc-table td li { margin: .2em 0; }

.doc table {
  width: 100%; border-collapse: collapse; margin: 1.2em 0; font-size: 14px;
  display: block; overflow-x: auto;
}
.doc th, .doc td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.doc th { background: var(--bg-soft); font-weight: 650; }

.doc-updated {
  margin-top: 40px; font-size: 13px; color: var(--muted);
}

/* pager */
.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin-top: 22px; padding-top: 26px; border-top: 1px solid var(--border);
}
.pager-card {
  display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.pager-card:hover {
  border-color: var(--accent-line); color: var(--text);
  box-shadow: var(--shadow); transform: translateY(-1px);
}
.pager-next { text-align: right; align-items: flex-end; }
.pager-dir {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  color: var(--muted);
}
.pager-card:hover .pager-dir { color: var(--accent); }
.pager-title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.pager-spacer { display: block; }

.doc-footer {
  margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted);
}

/* ---------------- Right TOC ---------------- */
.toc { position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h)); }
.toc-inner { padding: 34px 20px 40px 8px; overflow-y: auto; max-height: 100%; }
.toc-title {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc-list a {
  display: block; padding: 4px 0 4px 14px; margin-left: -1px;
  font-size: 12.8px; line-height: 1.45; color: var(--muted);
  border-left: 2px solid transparent;
}
.toc-list a:hover { color: var(--text); }
.toc-list li.toc-h3 a { padding-left: 26px; }
.toc-list a.is-current { color: var(--accent); font-weight: 600; border-left-color: var(--accent); }

/* ---------------- Search modal ---------------- */
.search-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh 16px 16px;
  background: rgba(10, 12, 18, .55);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.search-modal[hidden] { display: none; }
.search-panel {
  width: 100%; max-width: 620px; max-height: 70vh;
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.search-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--muted);
}
.search-input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 15px; color: var(--text);
}
.search-close { background: none; border: 0; cursor: pointer; padding: 0; }
.search-close kbd {
  font-family: var(--font); font-size: 11px; color: var(--muted);
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; padding: 2px 7px; background: var(--bg-soft);
}
.search-results { overflow-y: auto; padding: 8px; }
.search-empty { padding: 26px 14px; text-align: center; color: var(--muted); font-size: 14px; }
.result {
  display: block; padding: 10px 12px; border-radius: 9px; cursor: pointer;
  color: var(--text);
}
.result:hover, .result.is-selected { background: var(--accent-soft); color: var(--text); }
.result-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.result-group {
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--accent-line); border-radius: 999px; padding: 1px 7px;
}
.result-snippet { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.result mark { background: transparent; color: var(--accent); font-weight: 700; }

/* ---------------- Lightbox ---------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center; padding: 4vh 4vw;
  background: rgba(8, 10, 14, .88); cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%; max-height: 100%;
  border-radius: 10px; box-shadow: var(--shadow-lg);
}
.lightbox-close {
  position: absolute; top: 18px; right: 22px;
  width: 40px; height: 40px; border-radius: 999px; border: 0;
  font-size: 24px; line-height: 1; color: #fff; background: rgba(255,255,255,.14); cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,.26); }

/* ---------------- Responsive ---------------- */
@media (max-width: 1280px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 1023px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; inset: var(--topbar-h) auto 0 0; z-index: 58;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: none; border-right: 1px solid var(--border);
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar-backdrop { display: block; }
  body.nav-open { overflow: hidden; }
  .content { padding: 26px 22px 64px; }
  .search-trigger { min-width: 0; }
  .search-label, .search-kbd { display: none; }
  .search-trigger { width: 36px; justify-content: center; padding: 0; border: 1px solid transparent; background: transparent; color: var(--text-2); }
  .search-trigger:hover { background: var(--bg-hover); }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .brand-tag { display: none; }
  .content { padding: 20px 16px 56px; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; align-items: flex-start; }
  .search-modal { padding: 8px; align-items: stretch; }
  .search-panel { max-width: none; max-height: none; height: 100%; border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* print */
@media print {
  .topbar, .sidebar, .toc, .pager, .search-modal, .lightbox { display: none !important; }
  .layout { display: block; padding-top: 0; }
  .content { padding: 0; }
}

/* image caption labels (side-by-side option names) */
.img-labels {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  text-align: center; margin: 1.1em 0 .2em;
}
