/* ============================================================
   Docs layout — uses only tokens from site.css
   ============================================================ */

/* Layout */
.docs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 64px);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  gap: 0;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.docs-sidebar {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 2rem 1rem 2rem 0;
  border-right: 1px solid var(--surface-border);
}

.docs-sidebar-section {
  margin-bottom: 1.75rem;
}

.docs-sidebar-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  padding: 0 0.75rem;
  margin-bottom: 0.35rem;
}

.docs-sidebar a {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  line-height: 1.4;
  transition:
    color 0.15s,
    background 0.15s;
}

.docs-sidebar a:hover {
  color: var(--text);
  background: var(--bg-accent);
}

.docs-sidebar a[aria-current='page'] {
  color: var(--accent);
  background: var(--bg-accent);
  font-weight: 600;
}

.docs-sidebar-changelog {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  display: block;
  transition:
    color 0.15s,
    background 0.15s;
}

.docs-sidebar-changelog:hover {
  color: var(--text);
  background: var(--bg-accent);
}

/* ── Content area ────────────────────────────────────────── */
.docs-content {
  padding: 2.5rem 0 4rem 3rem;
  min-width: 0;
  max-width: 760px;
}

.docs-breadcrumb {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
}

.docs-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs-breadcrumb li {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
}

.docs-breadcrumb li:not(:last-child)::after {
  content: '\203A'; /* › */
  margin-left: 0.4rem;
  color: var(--text-soft);
}

.docs-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 150ms ease;
}

.docs-breadcrumb a:hover,
.docs-breadcrumb a:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  outline: none;
}

.docs-breadcrumb [aria-current='page'] {
  color: var(--text);
  font-weight: 600;
}

.docs-content article h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.docs-content article .docs-lead {
  font-size: 1.125rem;
  color: var(--text-muted);
  margin: 0 0 2rem;
  line-height: 1.6;
}

.docs-content article h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 2.5rem 0 0.75rem;
  color: var(--text);
}

.docs-content article h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.75rem 0 0.5rem;
  color: var(--text);
}

.docs-content article p {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.docs-content article ul,
.docs-content article ol {
  margin: 0 0 1rem 1.25rem;
  color: var(--text-muted);
}

.docs-content article li {
  margin-bottom: 0.35rem;
  line-height: 1.6;
}

.docs-content article a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}

.docs-content article a:hover {
  text-decoration-color: var(--accent);
}

/* ── Tables ──────────────────────────────────────────────── */
.docs-content article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 0 0 1.5rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.docs-content article thead {
  background: var(--bg-accent);
}

.docs-content article th,
.docs-content article td {
  padding: 0.65rem 1rem;
  text-align: left;
  border: 1px solid var(--surface-border);
  vertical-align: top;
  line-height: 1.5;
}

.docs-content article th {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.docs-content article td {
  color: var(--text-muted);
}

.docs-content article tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--bg-accent) 40%, transparent);
}

/* ── Code ────────────────────────────────────────────────── */
.docs-content article code {
  font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
  font-size: 0.85em;
  background: var(--bg-accent);
  border: 1px solid var(--surface-border);
  border-radius: 4px;
  padding: 0.15em 0.4em;
  color: var(--accent-strong);
}

.docs-content article pre {
  background: var(--bg-strong);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 0 0 1.25rem;
}

.docs-content article pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
  color: var(--text);
}

/* ── Callouts ────────────────────────────────────────────── */
.docs-callout {
  border-left: 3px solid var(--accent);
  background: var(--bg-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1rem 1.25rem;
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.docs-callout--warning {
  border-left-color: #f59e0b;
  background: color-mix(in srgb, #f59e0b 8%, var(--bg));
}

.docs-callout--danger {
  border-left-color: #ef4444;
  background: color-mix(in srgb, #ef4444 8%, var(--bg));
}

.docs-callout strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.25rem;
}

/* ── Step list ───────────────────────────────────────────── */
.docs-steps {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  counter-reset: steps;
}

.docs-steps li {
  counter-increment: steps;
  position: relative;
  padding-left: 2.75rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.docs-steps li::before {
  content: counter(steps);
  position: absolute;
  left: 0;
  top: 0.1rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Pagination ──────────────────────────────────────────── */
.docs-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--surface-border);
  gap: 1rem;
}

.docs-pagination a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  background: var(--bg-elevated);
  transition:
    background 0.15s,
    border-color 0.15s;
}

.docs-pagination a:hover {
  background: var(--bg-accent);
  border-color: var(--accent);
}

.docs-pagination-next {
  margin-left: auto;
}

/* ── Docs landing cards ──────────────────────────────────── */
.docs-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.docs-card {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition:
    box-shadow 0.2s,
    border-color 0.2s;
  display: block;
}

.docs-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.docs-card-icon {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.docs-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.4rem;
  color: var(--text);
}

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

/* Docs navigation toggle — mobile only */
.docs-nav-toggle {
  display: none;
}

/* ── Mobile / narrow ─────────────────────────────────────── */
@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: 1fr;
    padding: 0 1rem;
    position: relative;
  }

  /* Backdrop overlay when sidebar is open */
  .docs-layout::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(8, 12, 22, 0);
    backdrop-filter: blur(0);
    pointer-events: none;
    transition:
      background 220ms ease,
      backdrop-filter 220ms ease;
  }

  .docs-layout:has(.docs-sidebar.is-open)::before {
    background: rgba(8, 12, 22, 0.5);
    backdrop-filter: blur(2px);
    pointer-events: auto;
  }

  /* Lock body scroll when sidebar is open */
  body:has(.docs-sidebar.is-open) {
    overflow: hidden;
  }

  /* Toggle button */
  .docs-nav-toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0 0;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition:
      background 0.15s,
      border-color 0.15s;
  }

  .docs-nav-toggle:hover,
  .docs-nav-toggle:focus-visible {
    background: var(--bg-accent);
    border-color: var(--accent);
    outline: none;
  }

  .docs-nav-toggle-icon {
    position: relative;
    width: 1rem;
    height: 0.75rem;
    flex: 0 0 auto;
    margin-left: auto;
  }

  .docs-nav-toggle-icon::before,
  .docs-nav-toggle-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition:
      top 150ms ease,
      transform 150ms ease,
      opacity 150ms ease;
  }

  .docs-nav-toggle-icon::before {
    top: 0.1rem;
    box-shadow: 0 0.25rem 0 currentColor;
  }

  .docs-nav-toggle-icon::after {
    top: 0.6rem;
  }

  .docs-nav-toggle[aria-expanded='true'] .docs-nav-toggle-icon::before {
    top: 0.35rem;
    box-shadow: none;
    transform: rotate(45deg);
  }

  .docs-nav-toggle[aria-expanded='true'] .docs-nav-toggle-icon::after {
    top: 0.35rem;
    transform: rotate(-45deg);
  }

  /* Sidebar — off-canvas slide-over (slides in from left) */
  .docs-sidebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 80;
    width: min(85vw, 320px);
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding: 1.5rem 1.25rem 2rem;
    border-right: 1px solid var(--surface-border);
    border-bottom: none;
    background: var(--bg-strong);
    box-shadow: 0 18px 60px rgba(8, 12, 22, 0.32);
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
    visibility: hidden;
  }

  .docs-sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  .docs-sidebar-section {
    margin-bottom: 1.25rem;
  }

  .docs-sidebar-label {
    display: block;
  }

  .docs-content {
    padding: 1.75rem 0 3rem;
  }

  .docs-pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .docs-pagination-next {
    margin-left: 0;
  }
}
