/* Docs layout and prose. Builds on /pages.css (palette, type, topbar). */

.docs-wrap {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
}

.docs-top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.docs-top .topbar { padding-top: 16px; padding-bottom: 16px; }
/* The docs nav is short enough to share the brand's row on phones */
.docs-top .nav { flex: none; }

.docs-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 200px;
  gap: 56px;
  align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar-desktop {
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  padding: 36px 0 48px;
  scrollbar-width: thin;
}
.side-group + .side-group { margin-top: 26px; }
.side-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 8px;
}
.sidebar ul, .toc ul { list-style: none; }
.sidebar a {
  display: block;
  padding: 5px 10px;
  margin-left: -10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  transition: color .2s ease, background .2s ease;
}
.sidebar a:hover { color: var(--fg); }
.sidebar a[aria-current="page"] { color: var(--fg); background: var(--surface-hi); }

.side-toggle { display: none; }

/* ---------- On this page ---------- */
.toc {
  position: sticky;
  top: 70px;
  padding: 36px 0;
  font-size: 13px;
}
.toc li + li { margin-top: 8px; }
.toc a { color: var(--faint); text-decoration: none; transition: color .2s ease; }
.toc a:hover, .toc a.active { color: var(--fg); }
.toc code { font-size: 0.95em; }

/* ---------- Page ---------- */
.doc { padding: 40px 0 80px; min-width: 0; max-width: 760px; }
.doc-head { margin-bottom: 36px; }
.doc-head .eyebrow { display: block; margin-bottom: 12px; }
.doc-head h1 {
  font-size: clamp(30px, 4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.doc-head .lede { color: var(--muted); font-size: 18px; margin-top: 14px; }

/* ---------- Prose ---------- */
.prose { font-size: 16px; line-height: 1.7; color: rgba(255, 255, 255, 0.82); }
.prose > * + * { margin-top: 18px; }
.prose h2, .prose h3, .prose h4 { color: var(--fg); letter-spacing: -0.02em; line-height: 1.3; scroll-margin-top: 90px; }
.prose h2 { font-size: 24px; margin-top: 52px; }
.prose h3 { font-size: 18px; margin-top: 34px; }
.prose h4 { font-size: 16px; margin-top: 26px; }
.prose .anchor { text-decoration: none; }
.prose strong { color: var(--fg); font-weight: 600; }
.prose a:not(.anchor):not(.card-title):not(.doc-creation) {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color .2s ease;
}
.prose a:not(.anchor):not(.card-title):not(.doc-creation):hover { text-decoration-color: #fff; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 6px; }
.prose li > ul, .prose li > ol { margin-top: 6px; }
.prose hr { border: 0; border-top: 1px solid var(--line-soft); margin: 40px 0; }
.prose blockquote { border-left: 2px solid var(--line); padding-left: 16px; color: var(--muted); }

.prose :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-hi);
  color: var(--fg);
  overflow-wrap: anywhere;
}

/* ---------- Code blocks ---------- */
.code {
  position: relative;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #0b0b0b;
}
.code pre {
  overflow-x: auto;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  color: #e6e6e6;
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: #0b0b0b;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .2s ease, color .2s ease;
}
.code:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--fg); }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* Code groups and tabs share a tab bar built by docs.js */
.tab-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar button {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}
.tab-bar button:hover { color: var(--fg); }
.tab-bar button[aria-selected="true"] { color: var(--fg); background: var(--surface-hi); }

.code-group.ready { border: 1px solid var(--line-soft); border-radius: 12px; background: #0b0b0b; }
.code-group.ready .tab-bar { padding: 8px 8px 0; }
.code-group.ready .code { border: 0; background: none; }
.code-group > * + * { margin-top: 12px; }
.code-group.ready > * + * { margin-top: 0; }

.tabs.ready > .tab-bar { border-bottom: 1px solid var(--line-soft); padding-bottom: 8px; margin-bottom: 22px; }
.tab-panel > * + * { margin-top: 18px; }
.tabs:not(.ready) .tab-panel::before {
  content: attr(data-title);
  display: block;
  font-weight: 600;
  color: var(--fg);
  margin: 28px 0 12px;
}
[hidden] { display: none !important; }

/* ---------- Callouts ---------- */
.callout {
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--accent, rgba(255, 255, 255, 0.5));
  border-radius: 10px;
  background: var(--surface);
  padding: 14px 18px;
  font-size: 15px;
}
.callout > * + * { margin-top: 10px; }
.callout::before {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.callout-note { --accent: #8ab4ff; }
.callout-note::before { content: "Note"; }
.callout-tip { --accent: #7ee2a8; }
.callout-tip::before { content: "Tip"; }
.callout-warning { --accent: #ffc56b; }
.callout-warning::before { content: "Warning"; }

/* ---------- Cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: 14px;
}
.card {
  position: relative;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--surface);
  padding: 18px 20px;
  font-size: 14.5px;
  color: var(--muted);
  transition: border-color .2s ease, background .2s ease;
}
.card:has(a.card-title):hover { border-color: rgba(255, 255, 255, 0.35); background: var(--surface-hi); }
.card > * + * { margin-top: 6px; }
.card-title {
  display: block;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}
a.card-title::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }

/* Video cards: thumbnail on the left, text on the right */
.card-video {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  column-gap: 20px;
  align-content: start;
  padding: 14px;
}
.card-video > * { grid-column: 2; }
.card-video > * + * { margin-top: 6px; }
.card-video > .video-kicker { margin-top: 4px; }
.video-thumb {
  grid-column: 1;
  grid-row: 1 / span 20;
  position: relative;
  align-self: start;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #0b0b0b;
}
.video-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.play-badge {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform .2s var(--ease), background .2s ease;
}
.play-badge svg { margin-left: 2px; }
.card-video:hover .play-badge { transform: scale(1.08); background: rgba(0, 0, 0, 0.8); }
.video-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
@media (max-width: 560px) {
  .card-video { grid-template-columns: 1fr; }
  .card-video > * { grid-column: 1; }
  .video-thumb { grid-row: auto; margin-bottom: 8px; }
}

/* ---------- Steps ---------- */
.prose .doc-steps { list-style: none; padding-left: 0; counter-reset: step; }
.doc-steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 28px 46px;
  margin-top: 0;
}
.doc-steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  background: #000;
}
.doc-steps > li::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 34px;
  bottom: 6px;
  width: 1px;
  background: var(--line-soft);
}
.doc-steps > li:last-child { padding-bottom: 0; }
.doc-steps > li:last-child::after { display: none; }
.doc-steps > li > * + * { margin-top: 14px; }
.prose .step-title { font-size: 17px; margin-top: 2px; line-height: 1.5; }
.doc-steps > li.untitled > :first-child { margin-top: 0; padding-top: 1px; }

/* ---------- Accordions ---------- */
.accordion { border-bottom: 1px solid var(--line-soft); }
.prose .accordion { margin-top: 0; }
.prose > :not(.accordion) + .accordion { border-top: 1px solid var(--line-soft); margin-top: 18px; }
.accordion summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  font-weight: 600;
  color: var(--fg);
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after { content: "+"; color: var(--faint); font-weight: 400; transition: transform .2s var(--ease); }
.accordion[open] summary::after { transform: rotate(45deg); }
.accordion-body { padding-bottom: 18px; }
.accordion-body > * + * { margin-top: 14px; }

/* ---------- Media & tables ---------- */
.frame { border: 1px solid var(--line-soft); border-radius: 14px; overflow: hidden; background: #0b0b0b; }
.frame iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }
.video-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}
.video-icon { flex: none; }
.video-title {
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.video-title::before { content: "·"; margin-right: 8px; color: var(--faint); }
.frame img { display: block; max-width: 100%; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 12px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prose th, .prose td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.prose th { color: var(--fg); font-weight: 600; background: var(--surface); }
.prose tr:last-child td { border-bottom: 0; }

/* ---------- Pager ---------- */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--line-soft);
}
.pager a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  transition: border-color .2s ease, background .2s ease;
}
.pager a:hover { border-color: rgba(255, 255, 255, 0.35); background: var(--surface); }
.pager span { font-size: 12px; font-weight: 500; color: var(--faint); }
.pager-next { text-align: right; grid-column: 2; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .docs-layout { grid-template-columns: 210px minmax(0, 1fr); gap: 48px; }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .docs-layout { display: block; }
  .sidebar-desktop { display: none; }
  .side-toggle {
    display: block;
    margin: 16px 0 0;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    background: var(--surface);
  }
  .side-toggle summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    gap: 10px;
  }
  .side-toggle summary::-webkit-details-marker { display: none; }
  .side-toggle summary span { color: var(--faint); font-weight: 400; }
  .side-toggle .sidebar { padding: 4px 16px 18px 26px; }
  .doc { padding-top: 28px; }
  .cards { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .docs-wrap { padding: 0 16px; }
  .docs-top .nav { gap: 16px; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
}

/* ---------- Creations from X (<Creations> component) ---------- */
.doc-creations {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0 0;
}
.prose .doc-creation {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: border-color .2s ease;
}
.prose .doc-creation:hover { border-color: rgba(255, 255, 255, 0.3); }
.doc-creation-media { position: relative; display: block; aspect-ratio: 4 / 3; background: #0b0b0b; overflow: hidden; }
.doc-creation-media img { display: block; width: 100%; height: 100%; object-fit: cover; margin: 0; border: 0; border-radius: 0; transition: transform .6s cubic-bezier(.23, 1, .32, 1); }
.doc-creation:hover .doc-creation-media img { transform: scale(1.03); }
.doc-creation-media.is-video::after {
  content: '';
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5.5 4v8l6.5-4z' fill='white'/%3E%3C/svg%3E") center / 13px no-repeat;
}
.doc-creation-text {
  padding: 12px 14px 0;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.72);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.doc-creation-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 10px 14px 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}
.doc-creation-meta img { width: 20px; height: 20px; margin: 0; border-radius: 999px; flex: none; }
.doc-creation-meta span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-creations-more { margin-top: 14px; font-size: 14px; }
@media (max-width: 700px) {
  .doc-creations { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-creations > :nth-child(n+5), .doc-creations > :nth-child(3):last-child { display: none; }
}
