/* ============================================
   Docs Section – GitBook-style layout
   ============================================ */

:root {
  --docs-toggle-height: 44px;
}

/* Override the site's default flex-container so the docs wrapper fills the space */
.docs-wrapper {
  display: flex;
  min-height: calc(100vh - var(--site-header-height, 56px));
  background: #fff;
}

/* ---- Sidebar ---- */

.docs-sidebar {
  width: 280px;
  min-width: 280px;
  background: #F7F9FC;
  border-right: 1px solid #EAEDF2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--site-header-height, 56px);
  height: calc(100vh - var(--site-header-height, 56px));
  overflow-y: auto;
  z-index: 10;
}

.docs-sidebar__nav {
  list-style: none;
  margin: 0;
  padding: 16px 0;
}

.docs-sidebar__top-link {
  list-style: none;
  margin-bottom: 8px;
}

.docs-sidebar__top-link .docs-sidebar__link {
  padding-left: 24px;
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
}

.docs-sidebar__section {
  margin-bottom: 2px;
}

.docs-sidebar__section-separator {
  list-style: none;
  margin: 12px 20px 10px;
  border-top: 1px solid #d9e0e8;
  height: 0;
}

.docs-sidebar__section-title {
  display: block;
  padding: 10px 24px 4px;
  font-size: var(--fs-micro);
  font-weight: var(--fw-medium);
  line-height: var(--lh-micro);
  letter-spacing: var(--ls-caps);
  color: #6c757d;
  text-transform: uppercase;
}

.docs-sidebar__pages {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-sidebar__pages--open {
  display: block;
}

.docs-sidebar__link {
  display: block;
  padding: 5px 24px 5px 46px;
  font-size: var(--fs-meta);
  font-weight: var(--fw-body);
  line-height: var(--lh-meta);
  color: #6c757d;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  border-left: 2px solid transparent;
}

.docs-sidebar__link:hover {
  color: #009b72;
  background: rgba(0, 155, 114, 0.04);
  text-decoration: none;
}

.docs-sidebar__link--active {
  color: #009b72;
  font-weight: var(--fw-semibold);
  background: rgba(0, 155, 114, 0.07);
  border-left-color: #009b72;
}

/* ---- Main content area ---- */

.docs-main {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: flex-start;
}

.docs {
  width: 100%;
  max-width: 900px;
  padding: 32px 48px 64px;
  margin: 0 auto;
}

/* ---- On-page TOC (right sidebar) ---- */

.docs-toc {
  width: 220px;
  min-width: 220px;
  padding: 32px 16px 32px 0;
  position: sticky;
  top: var(--site-header-height, 56px);
  height: fit-content;
  max-height: calc(100vh - var(--site-header-height, 56px));
  overflow-y: auto;
  flex-shrink: 0;
}

.docs-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid #EAEDF2;
}

.docs-toc__item {
  margin: 0;
}

.docs-toc__item--h2 {
  padding-left: 0;
}

.docs-toc__item--h3 {
  padding-left: 10px;
}

.docs-toc__link {
  display: block;
  padding: 4px 12px;
  font-size: var(--fs-meta);
  font-weight: var(--fw-body);
  line-height: var(--lh-meta);
  color: #6c757d;
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.docs-toc__link:hover {
  color: #009b72;
  text-decoration: none;
}

.docs-toc__link--active {
  color: #2C3038;
  font-weight: var(--fw-semibold);
  border-left-color: #009b72;
}

/* ---- Breadcrumb ---- */

.docs-breadcrumb {
  font-size: var(--fs-meta);
  font-weight: var(--fw-medium);
  line-height: var(--lh-meta);
  color: #6c757d;
  margin-bottom: 24px;
}

.docs-breadcrumb a {
  color: #009b72;
  text-decoration: none;
}

.docs-breadcrumb a:hover {
  text-decoration: underline;
}

.docs-breadcrumb__sep {
  margin: 0 6px;
  color: #EAEDF2;
}

/* ---- Article typography ---- */

.docs-article {
  font-size: var(--fs-lead);
  font-weight: var(--fw-body);
  line-height: 1.75;
  color: #2C3038;
}

.docs-article h1 {
  font-size: var(--fs-subhead);
  font-weight: var(--fw-medium);
  line-height: var(--lh-subhead);
  letter-spacing: var(--ls-subhead);
  margin: 0 0 16px;
  color: #2C3038;
}

.docs-article h2 {
  font-size: var(--fs-title);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-title);
  letter-spacing: var(--ls-title);
  margin: 40px 0 12px;
  padding-top: 16px;
  border-top: 1px solid #EAEDF2;
  color: #2C3038;
  scroll-margin-top: 88px;
}

.docs-article h2:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.docs-article h3 {
  font-size: var(--fs-strong);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-strong);
  margin: 28px 0 8px;
  color: #2C3038;
  scroll-margin-top: 88px;
}

.docs-article p {
  margin: 0 0 16px;
}

.docs-article ul,
.docs-article ol {
  margin: 0 0 16px;
  padding-left: 24px;
}

.docs-article li {
  margin-bottom: 6px;
}

.docs-article a {
  color: #009b72;
  text-decoration: none;
}

.docs-article a:hover {
  text-decoration: underline;
}

.docs-article code {
  background: #F7F9FC;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  color: #c7254e;
}

.docs-article pre {
  background: #F7F9FC;
  border-radius: 6px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 0 0 16px;
}

.docs-article pre code {
  background: none;
  padding: 0;
  color: #2C3038;
}

/* Mermaid diagrams (fenced ```mermaid — routes/docs.js renders .docs-mermaid) */
.docs-article .docs-mermaid {
  background: #F7F9FC;
  border-radius: 6px;
  padding: 16px 20px;
  margin: 0 0 16px;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.docs-article .docs-mermaid svg {
  max-width: 100%;
  height: auto;
}

.docs-article blockquote {
  border-left: 3px solid #009b72;
  margin: 0 0 16px;
  padding: 12px 20px;
  background: rgba(0, 155, 114, 0.04);
  color: #2C3038;
}

.docs-article blockquote p:last-child {
  margin-bottom: 0;
}

.docs-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: var(--fs-body);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
}

.docs-article thead th {
  background: #F7F9FC;
  font-weight: var(--fw-semibold);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid #EAEDF2;
}

.docs-article tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #EAEDF2;
}

.docs-article tbody tr:hover {
  background: #F7F9FC;
}

.docs-article img {
  max-width: 100%;
  border-radius: 6px;
  margin: 8px 0;
}

.docs-article hr {
  border: none;
  border-top: 1px solid #EAEDF2;
  margin: 32px 0;
}

/* ---- Callout boxes ---- */

.docs-callout {
  border-radius: 8px;
  padding: 16px 20px;
  margin: 0 0 16px;
  border-left: 4px solid;
}

.docs-callout__header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-micro);
  font-weight: var(--fw-medium);
  line-height: var(--lh-micro);
  letter-spacing: var(--ls-caps);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.docs-callout__icon {
  font-size: var(--fs-strong);
  font-weight: var(--fw-semibold);
}

.docs-callout__body {
  font-size: var(--fs-body);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
}

.docs-callout__body p:last-child {
  margin-bottom: 0;
}

.docs-callout--tip {
  background: #f0faf6;
  border-color: #009b72;
  color: #1a5c42;
}

.docs-callout--note {
  background: #f0f4ff;
  border-color: #4a7eff;
  color: #1e3a6e;
}

.docs-callout--warning {
  background: #fff8f0;
  border-color: #e8912d;
  color: #6e3a0a;
}

.docs-callout--info-advanced {
  background: #f5f0ff;
  border-color: #7c3aed;
  color: #3b1e6e;
}

/* ---- Prev / Next pagination ---- */

.docs-pagination {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #EAEDF2;
}

.docs-pagination__link {
  display: flex;
  flex-direction: column;
  padding: 14px 20px;
  border: 1px solid #EAEDF2;
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  max-width: 48%;
}

.docs-pagination__link:hover {
  border-color: #009b72;
  box-shadow: 0 2px 8px rgba(0, 155, 114, 0.08);
  text-decoration: none;
}

.docs-pagination__link--prev {
  align-items: flex-start;
}

.docs-pagination__link--next {
  align-items: flex-end;
  margin-left: auto;
}

.docs-pagination__direction {
  font-size: var(--fs-micro);
  font-weight: var(--fw-medium);
  line-height: var(--lh-micro);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: #6c757d;
}

.docs-pagination__title {
  font-size: var(--fs-strong);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-strong);
  color: #009b72;
  margin-top: 2px;
}

/* ---- Mobile toggle ---- */

.docs-mobile-toggle {
  display: none;
  width: 100%;
  justify-content: center;
  background: #009b72;
  color: #ffffff;
  border: none;
  border-bottom: 1px solid #008765;
  padding: 12px 16px;
  font-size: var(--fs-strong);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-strong);
  cursor: pointer;
  align-items: center;
  gap: 6px;
}

.docs-sidebar-overlay {
  display: none;
}

/* ---- Responsive ---- */

@media (max-width: 1199px) {
  .docs-toc {
    display: none;
  }
}

@media (max-width: 991px) {
  .docs-wrapper {
    display: block;
    min-height: auto;
  }

  .docs-main {
    display: block;
  }

  .docs-sidebar {
    position: fixed;
    top: calc(var(--site-header-height, 56px) + var(--docs-toggle-height, 44px));
    left: -300px;
    width: 280px;
    min-width: 280px;
    height: calc(100vh - var(--site-header-height, 56px) - var(--docs-toggle-height, 44px));
    z-index: 1070;
    transition: left 0.3s ease;
    box-shadow: none;
  }

  .docs-sidebar--open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  }

  .docs-mobile-toggle {
    display: flex;
    position: sticky;
    top: var(--site-header-height, 56px);
    z-index: 1060;
  }

  body.docs-nav-open .docs-mobile-toggle {
    z-index: 1080;
  }

  .docs-sidebar-overlay--visible {
    display: block;
    position: fixed;
    top: calc(var(--site-header-height, 56px) + var(--docs-toggle-height, 44px));
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1050;
  }

  .docs {
    padding: 24px 20px 64px;
  }

  .docs-pagination {
    flex-direction: column;
  }

  .docs-pagination__link {
    max-width: 100%;
    width: 100%;
  }

  .docs-pagination__link--next {
    align-items: flex-start;
    margin-left: 0;
  }
}

@media (max-width: 576px) {
  .docs {
    padding: 16px 16px 48px;
  }
}

/* Treasury widget */
.docs-treasury {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid #e2e8f0;
}

.docs-treasury__overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 1.5rem 0 2rem;
}

.docs-treasury__stat {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.docs-treasury__stat-label {
  font-size: var(--fs-micro);
  font-weight: var(--fw-medium);
  line-height: var(--lh-micro);
  letter-spacing: var(--ls-caps);
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.docs-treasury__stat-value {
  font-size: var(--fs-title);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-title);
  color: #1e293b;
}

.docs-treasury__chart-wrap {
  max-width: 480px;
  margin: 1rem 0 2rem;
}

.docs-treasury__table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.docs-treasury__table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-body);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
}

.docs-treasury__table thead {
  background: #f8fafc;
}

.docs-treasury__table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: var(--fw-semibold);
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.docs-treasury__table td {
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  white-space: nowrap;
}

.docs-treasury__table tbody tr:last-child td {
  border-bottom: none;
}

.docs-treasury__table tbody tr:hover {
  background: #f8fafc;
}

.docs-treasury__table a {
  color: #2563eb;
  text-decoration: none;
}

.docs-treasury__table a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .docs-treasury__overview {
    grid-template-columns: 1fr;
  }

  .docs-treasury__chart-wrap {
    max-width: 100%;
  }
}
