/* ─────────────────────────────────────────────────────────────────────
   Documentation tree + docs index components.
   Loaded via {% block page_css %} (last in the cascade) so the brutal and
   warm layers cannot override it with !important.
   ───────────────────────────────────────────────────────────────────── */

/* ── Docs index: page layout ─────────────────────────────────────── */

/* The site has one shared interior-hero treatment (`.bbd-docs-hero`) that
   every page opens with — brutal and warm both define it with !important.
   Do not restyle it here. Only the docs-specific children are ours. */

.bbd-docs-hero .bbd-lead {
  max-width: 680px;
}

.bbd-docs-index-layout {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: clamp(24px, 4vw, 48px);
  padding-block: clamp(36px, 5vw, 56px);
}

.bbd-docs-tree-col {
  position: sticky;
  top: 100px;
  align-self: start;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  padding-right: 4px;
}

.bbd-docs-tree-col::-webkit-scrollbar { width: 5px; }
.bbd-docs-tree-col::-webkit-scrollbar-thumb {
  background: var(--bbd-border);
  border-radius: 3px;
}

.bbd-docs-body { min-width: 0; }

.bbd-docs-body h2 {
  font-family: var(--bbd-font-display);
}

.bbd-docs-body code {
  background: var(--bbd-surface-2);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--bbd-font-mono);
  font-size: 0.88em;
}

.bbd-docs-index-card code {
  font-size: 0.84em;
  word-break: break-word;
}

@media (max-width: 880px) {
  .bbd-docs-index-layout { grid-template-columns: 1fr; gap: 28px; }
  .bbd-docs-tree-col { position: static; max-height: none; }
}

.bbd-doc-tree { display: flex; flex-direction: column; gap: 20px; }

/* The warm layer sets `body .bbd-docs-nav h4` with !important (font-size
   0.7rem, text-transform none), so these two rules need !important to win.
   Everything else in this file avoids it. */
.bbd-doc-tree-heading {
  font-family: var(--bbd-font-display) !important;
  font-size: 0.72rem !important;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase !important;
  color: var(--bbd-text-soft) !important;
  margin: 0 0 8px !important;
}

.bbd-doc-tree ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bbd-doc-tree a {
  display: block;
  position: relative;
  padding: 6px 10px 6px 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--bbd-text);
  text-decoration: none;
  border-radius: 0 7px 7px 0;
  transition: color var(--bbd-transition), background var(--bbd-transition);
}

.bbd-doc-tree a:hover {
  color: var(--bbd-orange-dark);
  background: var(--bbd-orange-50);
}

/* Current page — orange text + a 2px orange rule on the left edge. */
.bbd-doc-tree a.is-current {
  color: var(--bbd-orange-dark);
  font-weight: 500;
  background: var(--bbd-orange-50);
}

.bbd-doc-tree a.is-current::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  border-radius: 2px;
  background: var(--bbd-orange);
}

/* ── Guide page: hero + article ──────────────────────────────────── */

.bbd-doc-guide-hero {
  padding-block: clamp(40px, 6vw, 64px) 36px;
  background: var(--bbd-surface-2);
  border-bottom: 1px solid var(--bbd-border);
}

.bbd-doc-guide-hero h1 {
  font-family: var(--bbd-font-display);
  font-size: clamp(1.85rem, 3.4vw, 2.35rem);
  line-height: 1.18;
  margin: 10px 0 14px;
  color: var(--bbd-ink);
}

.bbd-doc-guide-content h2 {
  margin: 0 0 12px;
  padding-top: 28px;
  border-top: 1px solid var(--bbd-border);
  font-family: var(--bbd-font-display);
  font-size: 1.4rem;
  line-height: 1.25;
  color: var(--bbd-ink);
}

.bbd-doc-guide-content section:first-of-type h2 {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.bbd-doc-guide-content p,
.bbd-doc-guide-content li { line-height: 1.75; }

.bbd-doc-guide-content ul,
.bbd-doc-guide-content ol { padding-left: 20px; margin-bottom: 16px; }

.bbd-doc-guide-content pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 16px 18px;
  background: var(--bbd-slate-900);
  color: #f1f5f9;
  border-radius: 10px;
  font-size: 0.86rem;
  margin: 16px 0;
}

.bbd-doc-guide-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  overflow-wrap: anywhere;
}

.bbd-doc-guide-content code {
  background: var(--bbd-surface-2);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--bbd-font-mono);
  font-size: 0.88em;
  overflow-wrap: anywhere;
}

.bbd-doc-guide-content pre code { font-size: 1em; }

/* Labelled code blocks with a copy button — the user-data variable reference. */
.bbd-docs-snippets {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 20px 0 24px;
}

.bbd-docs-snippet {
  border: 1px solid var(--bbd-border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bbd-surface);
}

.bbd-docs-snippet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  background: var(--bbd-surface-2);
  border-bottom: 1px solid var(--bbd-border);
}

.bbd-docs-snippet-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.bbd-docs-snippet-label {
  font-family: var(--bbd-font-mono);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--bbd-ink);
  word-break: break-word;
}

.bbd-docs-snippet-note {
  font-size: 0.78rem;
  color: var(--bbd-text-muted);
  line-height: 1.5;
}

.bbd-docs-snippet-copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--bbd-border);
  border-radius: 8px;
  background: var(--bbd-surface);
  color: var(--bbd-text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.bbd-docs-snippet-copy:hover {
  border-color: var(--bbd-orange);
  color: var(--bbd-orange-dark);
}

.bbd-docs-snippet-copy.is-done {
  border-color: var(--bbd-orange);
  color: var(--bbd-orange-dark);
  background: var(--bbd-orange-50);
}

.bbd-docs-snippet pre {
  margin: 0;
  border-radius: 0;
  overflow-x: hidden;
}

/*
 * Long JS lines wrap instead of scrolling sideways. The copied text is the
 * element's textContent, so a wrapped line still copies as one line.
 */
.bbd-docs-snippet pre code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: block;
}

.bbd-doc-guide-related {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.bbd-doc-guide-related a {
  display: inline-flex;
  padding: 10px 14px;
  border: 1px solid var(--bbd-border);
  border-radius: 9px;
  background: var(--bbd-surface);
  font-size: 0.9rem;
  color: var(--bbd-text);
  text-decoration: none;
  transition: border-color var(--bbd-transition), color var(--bbd-transition);
}

.bbd-doc-guide-related a:hover {
  border-color: var(--bbd-orange);
  color: var(--bbd-orange-dark);
}

/* Platform setup — the integration links a guide points at.
   A guide points at 1 to 4 integrations, so a tile grid would wrap unevenly
   (3 links = 2 + 1, with an empty cell). These are compact rows instead:
   the title on the left, the note on the right, full width, so the block
   reads the same however many links there are. */
.bbd-doc-related-sub {
  font-family: var(--bbd-font-display);
  font-size: 0.95rem;
  font-weight: 700;
  margin: 28px 0 0;
  color: var(--bbd-text);
}

.bbd-doc-int-related {
  display: block;
  margin-top: 12px;
}

.bbd-doc-guide-related a.bbd-doc-int-link {
  display: flex;
  align-items: baseline;
  gap: 14px;
  width: 100%;
  margin-bottom: 6px;
  padding: 11px 14px;
  text-align: left;
}

.bbd-doc-int-title {
  flex: 0 0 auto;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--bbd-text);
}

.bbd-doc-int-note {
  flex: 1 1 auto;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.45;
  color: var(--bbd-text-soft);
}

@media (max-width: 640px) {
  .bbd-doc-guide-related a.bbd-doc-int-link {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}

/* The warm layer sets `body a:not(...)` with underline on every link that
   is not on its exception list. These selectors carry a body-prefixed
   class chain so they out-rank it without needing !important. */
body .bbd-docs-index-card,
body .bbd-docs-method,
body .bbd-doc-tree a,
body .bbd-doc-guide-related a,
body .bbd-doc-guide-toc a {
  text-decoration: none;
}

body .bbd-docs-index-card h3,
body .bbd-docs-method h4 {
  text-decoration: none;
}

/* ── Docs index: card grid ───────────────────────────────────────── */

.bbd-docs-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.bbd-docs-index-card {
  display: block;
  padding: 18px 18px 16px;
  background: var(--bbd-surface);
  border: 1px solid var(--bbd-border);
  border-radius: var(--bbd-radius-lg);
  text-decoration: none;
  transition: border-color var(--bbd-transition), transform var(--bbd-transition),
              box-shadow var(--bbd-transition);
}

.bbd-docs-index-card:hover {
  border-color: var(--bbd-orange);
  transform: translateY(-2px);
  box-shadow: 4px 4px 0 rgba(255, 107, 53, 0.14);
}

.bbd-docs-index-card h3 {
  margin: 0 0 6px;
  font-family: var(--bbd-font-display);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--bbd-ink);
}

.bbd-docs-index-card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--bbd-text-muted);
}

/* The group name is already the section heading above the grid, so the
   per-card repeat of it was noise. Only the reference cards keep a label. */
.bbd-docs-index-card .bbd-docs-index-card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bbd-text-soft);
}

.bbd-docs-index-card.is-plain .bbd-docs-index-card-meta { display: flex; }

.bbd-docs-index-card .bbd-docs-index-card-meta::before {
  content: '';
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--bbd-orange);
}

/* ── Docs index: method cards (integration methods) ───────────────── */

.bbd-docs-methods-section {
  padding: 0 0 8px;
}

.bbd-docs-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.bbd-docs-method {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  background: var(--bbd-surface);
  border: 1px solid var(--bbd-border);
  border-radius: var(--bbd-radius-md);
  text-decoration: none;
  transition: border-color var(--bbd-transition), background var(--bbd-transition);
}

.bbd-docs-method:hover {
  border-color: var(--bbd-orange);
  background: var(--bbd-orange-50);
}

.bbd-docs-method-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--bbd-orange-50);
  color: var(--bbd-orange-dark);
}

.bbd-docs-method-icon svg {
  width: 18px;
  height: 18px;
}

.bbd-docs-method h4 {
  margin: 0 0 3px;
  font-family: var(--bbd-font-display);
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--bbd-ink);
}

.bbd-docs-method p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--bbd-text-muted);
}

/* ── Docs index: section headings ─────────────────────────────────── */

.bbd-docs-section { margin-top: 40px; }

.bbd-docs-section:first-of-type { margin-top: 32px; }

.bbd-docs-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bbd-border);
}

.bbd-docs-section-head h2 {
  margin: 0;
  font-family: var(--bbd-font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bbd-ink);
}

.bbd-docs-section-head p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--bbd-text-soft);
}

/* ── Guide page: 3-column layout (tree | content | on-this-page) ──── */

.bbd-doc-guide-layout {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 196px;
  gap: clamp(24px, 3vw, 44px);
  padding-block: clamp(36px, 5vw, 56px);
}

.bbd-doc-guide-layout.is-wide { grid-template-columns: 236px minmax(0, 1fr); }

.bbd-doc-guide-side {
  position: sticky;
  top: 100px;
  align-self: start;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  padding-right: 4px;
}

.bbd-doc-guide-side::-webkit-scrollbar { width: 5px; }
.bbd-doc-guide-side::-webkit-scrollbar-thumb {
  background: var(--bbd-border);
  border-radius: 3px;
}

.bbd-doc-guide-content { min-width: 0; max-width: 78ch; }

.bbd-doc-guide-toc h4 {
  font-family: var(--bbd-font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bbd-text-soft);
  margin: 0 0 10px;
}

.bbd-doc-guide-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bbd-doc-guide-toc a {
  display: block;
  padding: 4px 0 4px 10px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--bbd-text-muted);
  text-decoration: none;
  border-left: 1px solid var(--bbd-border);
  transition: color var(--bbd-transition), border-color var(--bbd-transition);
}

.bbd-doc-guide-toc a:hover {
  color: var(--bbd-orange-dark);
  border-left-color: var(--bbd-orange);
}

/* ── Guide page: eyebrow above the H1 ─────────────────────────────── */

.bbd-doc-guide-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--bbd-text-soft);
  margin-bottom: 4px;
}

.bbd-doc-guide-eyebrow a { color: var(--bbd-orange-dark); text-decoration: none; }
.bbd-doc-guide-eyebrow a:hover { text-decoration: underline; }

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

@media (max-width: 1100px) {
  .bbd-doc-guide-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .bbd-doc-guide-toc-col { display: none; }
}

@media (max-width: 880px) {
  .bbd-doc-guide-layout { grid-template-columns: 1fr; gap: 24px; }
  .bbd-doc-guide-side { position: static; max-height: none; }
  .bbd-doc-guide-layout.is-wide { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .bbd-docs-index-grid { grid-template-columns: 1fr; }
  .bbd-docs-methods { grid-template-columns: 1fr; }
  .bbd-doc-tree a { font-size: 0.9rem; }
}
