/* ── Docs layout ── */
.docs-body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.docs-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 760px);
  min-height: calc(100vh - 60px);
  padding: 0 clamp(1.25rem, 5vw, 2.5rem);
}

/* ── Sidebar ── */
.docs-sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 2rem 1.25rem;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
.sidebar-group { margin-bottom: 1.75rem; }
.sidebar-group-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding: 0 0.5rem;
}
.sidebar-link {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text-sub);
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: var(--bg-card); color: var(--text); }
.sidebar-link.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
  border: 1px solid rgba(46,204,113,0.15);
}

/* ── Scroll-margin for anchor links ── */
.docs-content section[id] {
  scroll-margin-top: 80px;
}

/* ── Section dividers (Apps, Reference) ── */
.docs-section-divider {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  margin-bottom: 0.5rem;
  border-top: 1px solid var(--border);
}
.docs-section-label {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.025em;
  color: var(--text);
}

/* ── Content ── */
.docs-content {
  padding: 3rem clamp(1.25rem, 4vw, 3.5rem) 5rem;
  min-width: 0; /* critical — prevents grid blowout */
}
.docs-content h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.docs-content .subtitle {
  color: var(--text-sub);
  font-size: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.7;
}
.docs-content h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}
.docs-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
.docs-content p {
  margin-bottom: 1rem;
  color: var(--text-sub);
  line-height: 1.8;
}
.docs-content ul, .docs-content ol {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text-sub);
}
.docs-content li { margin-bottom: 0.4rem; line-height: 1.75; }
.docs-content a { color: var(--accent); }
.docs-content a:hover { text-decoration: underline; }

/* ── Inline code ── */
.docs-content code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  color: var(--accent);
  word-break: break-word;
}

/* ── Code blocks — KEY FIX for horizontal scroll ── */
.docs-content pre {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  overflow-x: auto;       /* scroll the block, not the page */
  margin-bottom: 1.5rem;
  max-width: 100%;        /* never exceed parent width */
  box-sizing: border-box;
}
.docs-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 0.84rem;
  line-height: 1.8;
  word-break: normal;
  white-space: pre;       /* preserve formatting inside the scrollable block */
}

/* ── Terminal-style code blocks ──────────────────────────────────────────────
   One unified block: title bar (env type + copy button) + code area.
   The whole thing is a single card with one outer border and radius.
   ──────────────────────────────────────────────────────────────────────────── */
.code-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;           /* clips header + pre into one rounded shape */
  margin-bottom: 1.5rem;
}

/* Title bar — the "window chrome" row */
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);  /* slightly lighter than code area */
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.9rem;
  gap: 0.75rem;
}

/* Three dots — left side of title bar */
.code-block-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.code-block-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.06);
}

/* Env/language label */
.code-lang {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Copy button — right side of title bar */
.copy-btn {
  margin-left: auto;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  line-height: 1.5;
}
.copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(46,204,113,0.06);
}
.copy-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(46,204,113,0.08);
}

/* Code area — no separate border, inherits from wrapper */
.code-block pre {
  background: var(--bg-surface);
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  padding: 1rem 1.25rem;
  overflow-x: auto;
}

/* ── Platform tabs ── */
.platform-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.platform-tab-label {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-ui);
  color: var(--text-sub);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  transition: color 0.15s, border-color 0.15s;
}
.platform-tab-label:hover { color: var(--text); }
.platform-tab-label.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.platform-panel { display: none; padding-top: 1.5rem; }

/* ── Token placeholder ── */
.token-placeholder {
  color: #F59E0B;
  font-style: italic;
}

/* ── Callouts ── */
.callout {
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
  line-height: 1.65;
  border-left: 3px solid;
}
.callout.tip  { background: rgba(46,204,113,0.07); border-color: var(--accent); color: var(--text-sub); }
.callout.warn { background: rgba(245,158,11,0.08); border-color: #F59E0B; color: var(--text-sub); }
.callout.note { background: rgba(99,102,241,0.08); border-color: #6366F1; color: var(--text-sub); }
.callout strong { color: var(--text); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-sidebar { display: none; }
  .docs-content { padding: 1.75rem 1.25rem 4rem; }
}
