/* Suwu docs — DocSaurus-inspired design
 * Three-column layout: sidebar | content | TOC
 * Clean typography, subtle depth, calm colors
 */

/* ---------- Tokens ---------- */

.doc-page {
  --ds-text: #1e1e1e;
  --ds-text-secondary: #5a5a5a;
  --ds-text-tertiary: #888;
  --ds-surface: #f8f9fa;
  --ds-surface-raised: #ffffff;
  --ds-border: #e5e7eb;
  --ds-border-light: #eef0f2;
  --ds-accent: #2563eb;
  --ds-accent-light: #eff6ff;
  --ds-code-bg: #1e1e1e;
  --ds-code-text: #e4e4e7;
  --ds-success: #16a34a;
  --ds-warning: #d97706;
}

/* ---------- Layout ---------- */

.doc-page {
  padding-block: 0;
  background: var(--ds-surface);
}

.doc-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 200px;
  gap: 0;
  max-width: 1200px;
  margin-inline: auto;
  min-height: calc(100vh - 53px);
}

/* ---------- Left sidebar ---------- */

.doc-sidebar {
  position: sticky;
  top: 53px;
  align-self: start;
  height: calc(100vh - 53px);
  overflow-y: auto;
  padding: 24px 12px 24px 24px;
  border-right: 1px solid var(--ds-border-light);
  background: var(--ds-surface);
  scrollbar-width: none;
}

.doc-sidebar::-webkit-scrollbar {
  display: none;
}

.doc-sidebar-title {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ds-text-tertiary);
  padding: 0 8px;
  margin-bottom: 8px;
}

.doc-sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-sidebar-nav li {
  margin: 0;
}

.doc-sidebar-nav a {
  display: block;
  padding: 5px 8px;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--ds-text-secondary);
  text-decoration: none;
  border-radius: 6px;
  transition: all 150ms ease;
  line-height: 1.5;
}

.doc-sidebar-nav a:hover {
  color: var(--ds-text);
  background: rgba(0, 0, 0, 0.04);
}

.doc-sidebar-nav a[aria-current="page"] {
  color: var(--ds-accent);
  font-weight: 500;
  background: var(--ds-accent-light);
}

.doc-sidebar-group {
  margin-top: 24px;
}

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

.doc-main {
  min-width: 0;
  padding: 32px 48px 64px;
  max-width: 820px;
}

.doc-page .container {
  max-width: none;
}

/* ---------- Right TOC ---------- */

.doc-toc {
  position: sticky;
  top: 53px;
  align-self: start;
  height: calc(100vh - 53px);
  overflow-y: auto;
  padding: 32px 24px 32px 0;
  border-left: 1px solid var(--ds-border-light);
  scrollbar-width: none;
}

.doc-toc::-webkit-scrollbar {
  display: none;
}

.doc-toc-title {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ds-text-tertiary);
  margin-bottom: 12px;
}

.doc-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-toc-list li {
  margin: 0;
}

.doc-toc-list a {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--ds-text-tertiary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 150ms ease;
  line-height: 1.5;
}

.doc-toc-list a:hover {
  color: var(--ds-text);
  border-left-color: var(--ds-border);
}

.doc-toc-list .doc-toc-sub a {
  padding-left: 24px;
  font-size: 0.6875rem;
}

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

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--ds-text-tertiary);
}

.breadcrumb li + li::before {
  content: "/";
  margin-right: 6px;
  color: var(--ds-border);
}

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

.breadcrumb a:hover {
  color: var(--ds-accent);
}

.breadcrumb [aria-current="page"] {
  color: var(--ds-text);
  font-weight: 500;
}

/* ---------- Page header ---------- */

.doc-header {
  margin-bottom: 32px;
}

.doc-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 12px;
  color: var(--ds-text);
}

.doc-header .doc-lead {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ds-text-secondary);
  max-width: 52ch;
}

/* ---------- Prose ---------- */

.prose {
  font-size: 0.9375rem;
  line-height: 1.75;
  color: var(--ds-text);
  letter-spacing: -0.003em;
}

/* Headings — DocSaurus style: moderate, clean */
.doc-page h1,
.doc-page h2,
.doc-page h3,
.prose h1,
.prose h2,
.prose h3 {
  font-family: var(--font-display);
  scroll-margin-top: 72px;
}

.doc-page h1,
.prose h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.2;
}

.doc-page h2,
.prose h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
  margin-top: 36px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ds-border-light);
  color: var(--ds-text);
}

.doc-page h2:first-child,
.prose h2:first-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-top: 0;
}

.doc-page h3,
.prose h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.008em;
  line-height: 1.35;
  margin-top: 28px;
  margin-bottom: 12px;
  color: var(--ds-text);
}

/* Paragraphs */
.prose p {
  color: var(--ds-text-secondary);
  font-size: inherit;
  line-height: inherit;
  margin-bottom: 16px;
}

/* Lists */
.prose > ul,
.prose > ol {
  padding-left: 20px;
  margin-bottom: 16px;
}

.prose li {
  margin-bottom: 6px;
  color: var(--ds-text-secondary);
  line-height: 1.7;
}

.prose li::marker {
  color: var(--ds-text-tertiary);
}

.prose strong {
  color: var(--ds-text);
  font-weight: 600;
}

/* Links */
.prose a {
  color: var(--ds-accent);
  text-decoration: underline;
  text-decoration-color: rgba(37, 99, 235, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color 150ms ease;
}

.prose a:hover {
  text-decoration-color: var(--ds-accent);
}

/* Inline code */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  color: var(--ds-text);
  font-weight: 450;
}

/* ---------- Code blocks ---------- */

.prose pre {
  background: var(--ds-code-bg);
  color: var(--ds-code-text);
  border-radius: 8px;
  padding: 20px 24px;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.65;
  margin-bottom: 20px;
  -webkit-font-smoothing: antialiased;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
  font-weight: 400;
}

.prose .code-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--ds-text-tertiary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Tables ---------- */

.shortcut-table {
  width: 100%;
  margin-bottom: 20px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.shortcut-table th,
.shortcut-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ds-border-light);
}

.shortcut-table th {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ds-text-tertiary);
}

.shortcut-table td {
  color: var(--ds-text-secondary);
}

.shortcut-table td:first-child {
  font-weight: 500;
  color: var(--ds-text);
}

.shortcut-table tbody tr {
  transition: background 150ms ease;
}

.shortcut-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

/* ---------- Callouts ---------- */

.callout {
  border-left: 3px solid var(--ds-accent);
  background: var(--ds-accent-light);
  border-radius: 0 6px 6px 0;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.callout-title {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ds-accent);
  margin-bottom: 6px;
}

.callout p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--ds-text-secondary);
}

.callout-success {
  border-left-color: var(--ds-success);
  background: rgba(22, 163, 74, 0.06);
}

.callout-success .callout-title {
  color: var(--ds-success);
}

.callout-warning {
  border-left-color: var(--ds-warning);
  background: rgba(217, 119, 6, 0.06);
}

.callout-warning .callout-title {
  color: var(--ds-warning);
}

/* ---------- Video ---------- */

.doc-video {
  margin: 20px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--ds-border);
}

.doc-video video {
  display: block;
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  background: var(--ds-code-bg);
}

/* ---------- Feature cards (index) ---------- */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 32px;
}

.feature-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--ds-surface-raised);
  border: 1px solid var(--ds-border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ds-text);
  transition: all 150ms ease;
}

.feature-card:hover {
  border-color: var(--ds-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(37, 99, 235, 0.06);
  transform: translateY(-1px);
}

.feature-card-icon {
  font-size: 1.125rem;
  margin-bottom: 10px;
  opacity: 0.5;
}

.feature-card h3 {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin-bottom: 4px;
}

.feature-card p {
  font-size: 0.8125rem;
  color: var(--ds-text-secondary);
  margin: 0;
  line-height: 1.5;
}

.doc-section-heading {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 36px;
  margin-bottom: 12px;
  color: var(--ds-text-tertiary);
}

.doc-section-heading:first-child {
  margin-top: 0;
}

/* ---------- Prev / Next nav ---------- */

.doc-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--ds-border-light);
}

.doc-nav a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--ds-border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ds-text);
  flex: 1;
  max-width: 48%;
  transition: all 150ms ease;
}

.doc-nav a:hover {
  border-color: var(--ds-accent);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.06);
}

.doc-nav-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--ds-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-nav-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.875rem;
}

.doc-nav-next {
  text-align: right;
  margin-left: auto;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 32px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: #1d1d1f;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: background 150ms ease;
}

.lightbox-close:hover {
  background: #fff;
}

.lightbox-video-wrap {
  max-width: 960px;
  width: 100%;
  max-height: calc(100vh - 64px);
}

.lightbox-video-wrap video {
  display: block;
  width: 100%;
  max-height: calc(100vh - 64px);
  border-radius: 8px;
  background: #000;
  object-fit: contain;
}

/* ---------- Code copy button ---------- */

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  color: #888;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease, color 150ms ease;
}

.prose pre:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.code-copy-btn-done {
  color: #4ade80 !important;
  border-color: rgba(74, 222, 128, 0.3) !important;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .doc-sidebar-nav a,
  .feature-card,
  .doc-nav a,
  .shortcut-table tbody tr,
  .doc-toc-list a {
    transition: none;
  }
}

/* ---------- Responsive: collapse TOC, then sidebar ---------- */

/* Desktop: show sidebar nav by default */
.doc-sidebar-nav-wrap {
  display: block;
}

.doc-sidebar-header {
  display: none;
}

@media (max-width: 1080px) {
  .doc-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .doc-toc {
    display: none;
  }
}

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

  .doc-sidebar {
    position: relative;
    top: 0;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--ds-border-light);
    padding: 0;
  }

  .doc-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    cursor: pointer;
  }

  .doc-sidebar-header .doc-sidebar-title {
    margin-bottom: 0;
  }

  .doc-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    transition: background 150ms ease;
  }

  .doc-sidebar-toggle:hover {
    background: rgba(0, 0, 0, 0.06);
  }

  .doc-sidebar-toggle-icon {
    display: block;
    width: 16px;
    height: 2px;
    background: var(--ds-text-secondary);
    border-radius: 1px;
    position: relative;
  }

  .doc-sidebar-toggle-icon::before,
  .doc-sidebar-toggle-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--ds-text-secondary);
    border-radius: 1px;
    transition: transform 200ms ease;
  }

  .doc-sidebar-toggle-icon::before {
    top: -6px;
  }

  .doc-sidebar-toggle-icon::after {
    top: 6px;
  }

  .doc-sidebar-toggle[aria-expanded='true'] .doc-sidebar-toggle-icon {
    background: transparent;
  }

  .doc-sidebar-toggle[aria-expanded='true'] .doc-sidebar-toggle-icon::before {
    top: 0;
    transform: rotate(45deg);
  }

  .doc-sidebar-toggle[aria-expanded='true'] .doc-sidebar-toggle-icon::after {
    top: 0;
    transform: rotate(-45deg);
  }

  .doc-sidebar-nav-wrap {
    display: none;
    padding: 4px 24px 16px;
    background: rgba(37, 99, 235, 0.04);
    border-top: 1px solid var(--ds-border-light);
  }

  .doc-sidebar-nav-wrap.is-open {
    display: block;
  }

  .doc-sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .doc-sidebar-nav a {
    padding: 4px 10px;
    font-size: 0.8125rem;
    white-space: nowrap;
  }

  .doc-sidebar-group {
    margin-top: 12px;
  }

  .doc-sidebar-group:first-child {
    margin-top: 0;
  }

  .doc-main {
    padding: 24px;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .doc-nav {
    flex-direction: column;
  }

  .doc-nav a {
    max-width: none;
  }
}
