/* ================================================================
   docs.css  —  XStat documentation page styles
   Requires: style.css (theme tokens) loaded first
   ================================================================ */

/* ── Layout ─────────────────────────────────────────────────────── */
body.docs-page {
  background: var(--bg);
}

.docs-layout {
  display: grid;
  grid-template-columns: 272px 1fr;
  grid-template-rows: auto 1fr;
  min-height: calc(100vh - var(--nav-h));
  margin-top: var(--nav-h);
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 24px;
}

/* Mobile sidebar toggle button */
.docs-sidebar-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: Inter, sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  grid-column: 1 / -1;
  width: fit-content;
  margin: 16px 0 0;
  transition: border-color 0.15s;
}

.docs-sidebar-toggle:hover {
  border-color: var(--border-hover);
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.docs-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--nav-h) - 48px);
  overflow-y: auto;
  padding: 0 16px 40px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(124,110,245,.25) transparent;
}

.docs-sidebar::-webkit-scrollbar { width: 4px; }
.docs-sidebar::-webkit-scrollbar-thumb {
  background: rgba(124,110,245,.25);
  border-radius: 2px;
}

.docs-sidebar-inner {
  padding-top: 24px;
}

/* Search */
.docs-sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 24px;
  color: var(--text-muted);
  transition: border-color 0.15s;
}

.docs-sidebar-search:focus-within {
  border-color: var(--purple);
  color: var(--text);
}

.docs-sidebar-search input {
  background: none;
  border: none;
  color: var(--text);
  font-family: Inter, sans-serif;
  font-size: 13px;
  outline: none;
  width: 100%;
}

.docs-sidebar-search input::placeholder {
  color: var(--text-muted);
}

/* Nav groups */
.docs-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.docs-nav-group {
  margin-bottom: 8px;
}

.docs-nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 8px 4px;
}

.docs-nav-link {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  line-height: 1.5;
}

.docs-nav-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
}

.docs-nav-link.active {
  color: var(--purple);
  border-left-color: var(--purple);
  background: rgba(124, 110, 245, 0.08);
}

/* Hidden (search filter) */
.docs-nav-link.hidden {
  display: none;
}

.docs-nav-group.hidden-group {
  display: none;
}

/* ── Main content ─────────────────────────────────────────────── */
.docs-content {
  min-width: 0;
  padding: 32px 0 40px 48px;
  border-left: 1px solid var(--border);
}

/* ── Section wrapper ──────────────────────────────────────────── */
.doc-section {
  max-width: 820px;
  padding-bottom: 56px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 56px;
}

.doc-section:last-of-type {
  border-bottom: none;
}

/* Section eyebrow label */
.doc-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 8px;
}

/* ── Typography ──────────────────────────────────────────────── */
.doc-h1 {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  margin: 0 0 20px;
  line-height: 1.15;
}

.doc-h2 {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--text);
  margin: 0 0 16px;
  line-height: 1.2;
}

.doc-h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 28px 0 10px;
}

.doc-lead {
  font-size: 16px;
  line-height: 1.75;
  color: rgba(240,240,244,.80);
  margin: 0 0 28px;
  max-width: 68ch;
}

.doc-section p {
  font-size: 14.5px;
  line-height: 1.75;
  color: rgba(240,240,244,.72);
  margin: 0 0 16px;
  max-width: 72ch;
}

.doc-link {
  color: var(--purple);
  text-decoration: none;
}
.doc-link:hover {
  color: #9b8ef8;
  text-decoration: underline;
}

.doc-ul,
.doc-ol {
  font-size: 14.5px;
  line-height: 1.75;
  color: rgba(240,240,244,.72);
  padding-left: 22px;
  margin: 0 0 16px;
}

.doc-ul li,
.doc-ol li {
  margin-bottom: 6px;
}

/* ── Inline code ─────────────────────────────────────────────── */
.doc-code-inline,
code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .82em;
  background: rgba(124,110,245,.12);
  color: #c4b8ff;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(124,110,245,.18);
}

/* ── Code blocks ─────────────────────────────────────────────── */
.doc-codeblock {
  background: #111117;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: 0 0 20px;
  font-size: 13px;
}

.doc-codeblock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: .04em;
}

.doc-codeblock pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.doc-codeblock pre code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: #c8d3f5;
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
}

.doc-codeblock .c {
  color: #525775;
}

/* Copy button */
.doc-copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  font-family: Inter, sans-serif;
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.doc-copy-btn:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.doc-copy-btn.copied {
  color: var(--cyan);
  border-color: var(--cyan);
}

/* ── Tables ──────────────────────────────────────────────────── */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 0 0 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.doc-table thead tr {
  background: rgba(255,255,255,0.04);
}

.doc-table th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.doc-table td {
  padding: 10px 16px;
  color: rgba(240,240,244,.72);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: top;
  line-height: 1.6;
}

.doc-table tr:last-child td {
  border-bottom: none;
}

.doc-table tbody tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* ── Callouts ────────────────────────────────────────────────── */
.doc-callout {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0 0 20px;
  border-left: 3px solid;
}

.doc-callout svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.doc-callout--info {
  background: rgba(124,110,245,.08);
  border-color: var(--purple);
  color: rgba(240,240,244,.80);
}

.doc-callout--info svg {
  color: var(--purple);
}

.doc-callout--warn {
  background: rgba(255,165,0,.07);
  border-color: #e8a14a;
  color: rgba(240,240,244,.80);
}

.doc-callout--warn svg {
  color: #e8a14a;
}

/* ── Cards ───────────────────────────────────────────────────── */
.doc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 0 0 28px;
}

.doc-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.2s;
}

.doc-card:hover {
  border-color: var(--border-hover);
}

.doc-card-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: rgba(124,110,245,.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--purple);
}

.doc-card strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.doc-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

/* ── Badge ───────────────────────────────────────────────────── */
.doc-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: rgba(3,218,198,.12);
  color: var(--cyan);
  border: 1px solid rgba(3,218,198,.22);
  border-radius: 4px;
  padding: 2px 7px;
  vertical-align: middle;
  margin-left: 8px;
}

/* ── Screenshots ─────────────────────────────────────────────── */
.doc-screenshot {
  margin: 0 0 24px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.doc-screenshot img {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Image row (Android screenshots) ─────────────────────────── */
.doc-img-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 24px 0;
}
.doc-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-figure img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.doc-figure figcaption {
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-align: center;
  line-height: 1.4;
}
@media (max-width: 640px) {
  .doc-img-row { grid-template-columns: 1fr; }
}

/* ── Architecture diagram ─────────────────────────────────────── */
.doc-arch-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin: 24px 0;
}

.arch-box {
  width: 100%;
  max-width: 640px;
  border-radius: var(--radius);
  padding: 18px 22px;
  border: 1px solid var(--border);
}

.arch-box--electron {
  background: rgba(124,110,245,.06);
  border-color: rgba(124,110,245,.3);
}

.arch-box--service {
  background: rgba(3,218,198,.05);
  border-color: rgba(3,218,198,.25);
}

.arch-box--browser {
  background: rgba(255,255,255,0.03);
  border-color: var(--border-hover);
}

.arch-box-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.arch-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.arch-inner {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.arch-inner-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.arch-inner ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.arch-inner ul li {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 0;
}

.arch-arrow-h {
  font-size: 12px;
  color: var(--purple);
  font-weight: 600;
  white-space: nowrap;
}

.arch-arrow-v {
  font-size: 13px;
  color: var(--border-hover);
  padding: 6px 0;
  text-align: center;
}

.arch-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.arch-chips span {
  font-size: 12px;
  background: rgba(3,218,198,.08);
  color: var(--cyan);
  border: 1px solid rgba(3,218,198,.18);
  border-radius: 4px;
  padding: 3px 8px;
}

.arch-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Keyboard key ────────────────────────────────────────────── */
kbd {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}

/* ── nav-active state ────────────────────────────────────────── */
.nav-links a.nav-active {
  color: var(--purple);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }

  .docs-sidebar-toggle {
    display: flex;
  }

  .docs-sidebar {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    bottom: 0;
    width: 280px;
    max-height: 100%;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 0 16px 40px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    overflow-y: auto;
  }

  .docs-sidebar.open {
    transform: translateX(0);
  }

  .docs-content {
    padding: 24px 0 40px;
    border-left: none;
  }

  .arch-row {
    flex-direction: column;
  }

  .arch-arrow-h {
    transform: rotate(90deg);
  }
}

@media (max-width: 600px) {
  .doc-cards {
    grid-template-columns: 1fr;
  }

  .doc-table {
    font-size: 12.5px;
  }

  .doc-table th,
  .doc-table td {
    padding: 8px 10px;
  }

  .doc-codeblock pre {
    padding: 14px;
  }
}
