/* Drift Documentation — shared styles.
 * Brand-compliant: system-ui, three weights (300/600/700), ink borders,
 * no rounded corners, no gradients, no blurry shadows.
 */

:root {
  --brand-1: #f1a006;
  --brand-2: #8269eb;
  --brand-3: #10b981;
  --ink: #1b2844;
  --bg: #e2e2e2;
  --panel: #ffffff;
  --muted: #5f6b85;
  --error: #d23838;
  /* Match the main site (global.css) so the shared navbar (components/navbar.css)
   * resolves to the SAME width + padding here as on the landing page — otherwise
   * the docs pages, which don't load global.css, fall back to the navbar's
   * hardcoded --padding:150px and the bar visibly shrinks on page transition. */
  --max-width: 1500px;
  --padding: clamp(24px, 6vw, 150px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  font-weight: 300;
}

/* Docs pages have no navbar — the Drift logo is the sidebar's header. */
.docs-logo {
  display: block;
  padding: 18px 24px 10px;
  text-decoration: none;
  color: inherit;
}
.docs-logo .title {
  font-family: 'Tinos', serif;
  font-weight: 700;
  font-style: italic;
  font-size: 3rem;
  line-height: 1;
}

/* "closed alpha" disclaimer under the sidebar logo */
.docs-version {
  padding: 0 24px 14px;
  font-size: 12px;
  font-weight: 300;
  color: var(--muted);
}
.docs-version span {
  color: var(--brand-2);
  font-weight: 600;
}

/* ── Layout ──────────────────────────────────────── */

.docs-layout {
  display: flex;
  align-items: flex-start;
  gap: clamp(24px, 3vw, 56px);
  min-height: 100vh;
  margin-left: 280px; /* clear the fixed full-height sidebar */
  padding: 40px clamp(24px, 4vw, 96px) 80px;
}

/* ── Sidebar ─────────────────────────────────────── */

/* Fixed full-height sidebar, pinned to the left edge of the viewport */
.docs-right {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  overflow-y: auto;
  z-index: 500; /* below the navbar (999) */
  background: var(--panel);
  border-right: 1px solid var(--ink);
}

.docs-right .depth-control {
  margin-top: 12px;
}

.docs-sidebar {
  padding: 20px 0;
}

.docs-nav-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 16px 20px 6px;
}

.docs-nav a {
  display: block;
  padding: 5px 20px;
  font-size: 14px;
  font-weight: 300;
  color: var(--ink);
  text-decoration: none;
  border-right: 3px solid transparent;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.docs-nav a:hover {
  background: var(--bg);
}

.docs-nav a.active {
  font-weight: 600;
  border-right-color: var(--brand-1);
  background: var(--bg);
}

/* Tree children — indented sub-items under a parent link */
.docs-nav a.tree-child {
  padding-left: 40px;
}

/* Grandchildren — in-page section anchors (e.g. the Quick Start TOC) */
.docs-nav a.tree-grandchild {
  padding-left: 60px;
}

/* ── Content ─────────────────────────────────────── */

.docs-content {
  flex: 1 1 auto;
  min-width: 0; /* let wide <pre> blocks scroll instead of stretching the column */
  max-width: 860px;
}

/* ── On-this-page TOC (right column, auto-generated by docs.js) ───── */

.docs-toc {
  flex: 0 0 190px;
  position: sticky;
  top: 40px;
  align-self: flex-start;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  padding-left: 20px;
  border-left: 1px solid #cdcdcd;
}

.docs-toc-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 2px 0 8px;
}

.docs-toc-link {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.4;
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.1s ease, border-color 0.1s ease;
}

.docs-toc-link:hover { color: var(--ink); }

.docs-toc-link.active {
  color: var(--ink);
  font-weight: 600;
  border-left-color: var(--brand-1);
}

.docs-toc-link.toc-h4 {
  padding-left: 24px;
  font-size: 12px;
}

/* Three columns need room — drop the TOC when the viewport can't hold it. */
@media (max-width: 1240px) {
  .docs-toc { display: none; }
}

.docs-content h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.2;
}

.docs-content h2 {
  font-size: 1.8rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--bg);
}

.docs-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.docs-content h4 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.4rem;
  color: var(--ink);
}

/* Anchor-jump offset so a TOC click lands the heading below the fixed navbar */
.docs-content h2,
.docs-content h3,
.docs-content h4 {
  scroll-margin-top: 80px;
}

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

.docs-content .subtitle {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

/* ── Code ────────────────────────────────────────── */

.docs-content code {
  background: var(--panel);
  border: 1px solid var(--ink);
  padding: 2px 7px;
  font-size: 0.9em;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

.docs-content pre {
  background: #1e1e1e;
  color: #dadada;
  border: 1px solid var(--ink);
  padding: 16px 20px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  margin: 1rem 0;
}

.docs-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  font-weight: normal;
  white-space: pre;
  color: inherit;
}

/* Syntax highlighting (VS Code Dark+) */
.kw { color: #569CD6; }   /* keywords */
.str { color: #CE9178; }  /* strings */
.cmt { color: #6A9955; }  /* comments */
.fn { color: #DCDCAA; }   /* functions */
.num { color: #B5CEA8; }  /* numbers */
.ctrl { color: #C586C0; } /* control flow */

/* ── Tables ──────────────────────────────────────── */

.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9em;
}

.docs-content th {
  background: var(--ink);
  color: white;
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
}

.docs-content td {
  border-bottom: 1px solid var(--bg);
  padding: 8px 12px;
}

/* ── Cards ────────────────────────────────────────── */

.docs-card {
  background: var(--panel);
  border: 1px solid var(--ink);
  padding: 16px 20px;
  margin: 1rem 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.docs-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 0 var(--ink);
}

.docs-card h3 {
  margin-top: 0;
  font-size: 0.95rem;
}

.docs-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 1rem 0;
}

/* ── Badges ──────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  margin-right: 4px;
}

.badge-orange { background: var(--brand-1); }
.badge-purple { background: var(--brand-2); }
.badge-green  { background: var(--brand-3); }
.badge-ink    { background: var(--ink); }

/* Larger badge when it carries a page title (Atomic / Backbone / Canvas) */
.docs-content h2 .badge {
  font-size: 0.8em;
  padding: 4px 14px;
  margin-right: 8px;
  vertical-align: middle;
}

/* ── Callouts ────────────────────────────────────── */

.callout {
  background: var(--panel);
  border: 1px solid var(--ink);
  border-left: 4px solid var(--brand-1);
  padding: 12px 16px;
  margin: 1rem 0;
  font-size: 0.9em;
}

.callout-info  { border-left-color: var(--brand-2); }
.callout-tip   { border-left-color: var(--brand-3); }

/* ── Responsive ──────────────────────────────────── */

@media (max-width: 768px) {
  .docs-layout {
    margin-left: 0;
    padding-left: 16px;
    padding-right: 16px;
  }
  /* On small screens the sidebar un-pins and stacks above the content */
  .docs-right {
    position: static;
    width: auto;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--ink);
    padding-top: 0;
  }
  .docs-content {
    padding: 24px 0;
  }
  .docs-card-grid {
    grid-template-columns: 1fr;
  }
}
