/* Builders documentation guide (DogeGo-style rail + article) */

body.docs-page {
  --docs-rail: 280px;
}

.docs-guide {
  position: relative;
  display: grid;
  grid-template-columns: var(--docs-rail) minmax(0, 1fr);
  gap: 0;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

.docs-toc-fab,
.docs-toc-backdrop {
  display: none;
}

.docs-rail {
  position: sticky;
  top: 12px;
  align-self: start;
  max-height: calc(100dvh - 24px);
  overflow: hidden;
  padding: 8px 14px 0 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.docs-rail-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 28px;
}

.docs-rail-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.docs-rail-bar h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.docs-rail-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}

.docs-search {
  width: 100%;
  margin: 0 0 14px;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    var(--white)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z' fill='%238a9199'/%3E%3C/svg%3E")
    10px 50% / 18px no-repeat;
  color: var(--ink);
  font: inherit;
}

.docs-search:focus {
  outline: 2px solid rgba(194, 146, 26, 0.35);
  outline-offset: 1px;
  border-color: var(--gold);
}

.docs-rail-section {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
  overflow: hidden;
}

.docs-rail-section.is-replica {
  border-color: #d7c48a;
  background: #fffaf0;
}

.docs-rail-head {
  padding: 12px 12px 8px;
}

.docs-rail-copy h2 {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}

.docs-rail-copy p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.docs-rail-links {
  list-style: none;
  margin: 0;
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.docs-rail-links a {
  display: block;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.35;
}

.docs-rail-links a:hover {
  background: var(--white);
  color: var(--gold);
}

.docs-rail-links a.is-active {
  background: var(--gold-soft);
  color: var(--ink);
  font-weight: 650;
}

.docs-stage {
  min-width: 0;
  padding: 8px 0 0 28px;
}

.docs-hero {
  margin: 0 0 18px;
}

.docs-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  letter-spacing: -0.04em;
  line-height: 1.2;
}

.docs-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 42rem;
}

.docs-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
}

.docs-crumb {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

.docs-doc {
  padding: 26px 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--shadow);
  max-width: 100%;
  overflow-x: hidden;
}

.docs-doc.markdown-body > :first-child {
  margin-top: 0;
}

.docs-doc.markdown-body h1,
.docs-doc.markdown-body h2,
.docs-doc.markdown-body h3 {
  scroll-margin-top: 20px;
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.docs-doc.markdown-body h1 {
  font-size: 1.7rem;
  margin: 0 0 0.75rem;
}

.docs-doc.markdown-body h2 {
  font-size: 1.22rem;
  margin: 1.55rem 0 0.6rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
}

.docs-doc.markdown-body h3 {
  font-size: 1.05rem;
  margin: 1.2rem 0 0.4rem;
}

.docs-doc.markdown-body p,
.docs-doc.markdown-body li {
  color: var(--ink);
}

.docs-doc.markdown-body a {
  color: #8a6a12;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.docs-doc.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 6px;
}

.docs-code {
  position: relative;
  margin: 1rem 0;
}

.docs-code pre {
  margin: 0;
  overflow: auto;
  padding: 14px 16px 16px;
  border-radius: 12px;
  background: #1c1c1c;
  color: #f3f1ea;
  font-size: 0.85rem;
  max-width: 100%;
}

.docs-code pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.docs-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--gold);
  color: #fff;
  font: 650 12px/1 Inter, sans-serif;
  cursor: pointer;
}

.docs-copy:hover {
  background: #a87e14;
}

.docs-table-scroll {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
}

.docs-doc.markdown-body table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.docs-doc.markdown-body th,
.docs-doc.markdown-body td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.docs-doc.markdown-body th {
  background: var(--soft);
}

.docs-doc.markdown-body ul,
.docs-doc.markdown-body ol {
  padding-left: 1.2rem;
}

.docs-empty,
.docs-error {
  padding: 24px;
  border-radius: 16px;
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--muted);
}

.docs-error {
  border-color: #f1c0c0;
  color: #b42318;
}

.docs-loading {
  color: var(--muted);
}

@media (max-width: 960px) {
  .docs-guide {
    grid-template-columns: 1fr;
    padding: 0 16px 96px;
  }

  .docs-toc-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 85;
    min-height: 48px;
    padding: 0 16px;
    border: 1px solid rgba(26, 26, 26, 0.12);
    border-radius: 999px;
    background: #1c1c1c;
    color: #fff;
    font: 650 14px/1 Inter, sans-serif;
    box-shadow: 0 10px 28px rgba(26, 26, 26, 0.22);
    cursor: pointer;
  }

  .docs-toc-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 86;
    background: rgba(26, 26, 26, 0.35);
  }

  .docs-rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 87;
    width: min(86vw, 320px);
    height: 100dvh;
    max-height: 100dvh;
    padding: 16px 14px 0;
    background: #fff;
    border-right: 1px solid var(--line);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

  .docs-rail-scroll {
    padding-bottom: max(48px, env(safe-area-inset-bottom));
  }

  .docs-guide.docs-toc-open .docs-rail {
    transform: translateX(0);
  }

  .docs-rail-bar {
    display: flex;
  }

  .docs-stage {
    padding: 8px 0 0;
  }

  .docs-doc {
    padding: 20px 16px;
  }

  body.docs-toc-lock {
    overflow: hidden;
  }
}
