/* Litopia Docs — 与主站设计系统完全一致，含侧边栏布局 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================================
   Design Tokens — 与 Litopia 主站 src/index.css 完全同步
   ============================================================ */
:root {
  --background: 200 30% 98%;
  --foreground: 210 40% 15%;
  --card: 0 0% 100%;
  --card-foreground: 210 40% 15%;
  --popover: 0 0% 100%;
  --popover-foreground: 210 40% 15%;
  --primary: 198 92% 52%;
  --primary-foreground: 0 0% 100%;
  --primary-dark: 200 98% 39%;
  --primary-light: 199 95% 93%;
  --secondary: 199 30% 94%;
  --secondary-foreground: 199 60% 30%;
  --muted: 200 20% 96%;
  --muted-foreground: 200 15% 45%;
  --accent: 199 70% 90%;
  --accent-foreground: 199 80% 35%;
  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 100%;
  --border: 200 25% 88%;
  --input: 200 25% 88%;
  --ring: 198 92% 52%;
  --radius: 0.75rem;
  --gradient-brand: linear-gradient(135deg, hsl(198 92% 52%) 0%, hsl(210 100% 56%) 100%);
  --gradient-hero: linear-gradient(180deg, hsl(200 30% 98%) 0%, hsl(199 95% 93%) 100%);
  --shadow-sm: 0 1px 2px 0 hsl(200 25% 88% / 0.5);
  --shadow-md: 0 2px 4px -1px hsl(200 25% 88% / 0.3), 0 4px 8px -2px hsl(200 25% 88% / 0.2);
  --shadow-lg: 0 4px 6px -2px hsl(199 89% 48% / 0.08), 0 10px 20px -5px hsl(199 89% 48% / 0.12);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Noto Serif SC', Georgia, serif;
  --sidebar-w: 268px;
  --toc-w: 200px;
}

.dark {
  --background: 210 40% 6%;
  --foreground: 200 25% 93%;
  --card: 210 30% 10%;
  --card-foreground: 200 25% 93%;
  --popover: 210 30% 10%;
  --popover-foreground: 200 25% 93%;
  --primary: 198 92% 56%;
  --primary-foreground: 210 40% 6%;
  --secondary: 210 25% 16%;
  --secondary-foreground: 199 65% 78%;
  --muted: 210 20% 14%;
  --muted-foreground: 200 12% 58%;
  --accent: 199 40% 18%;
  --accent-foreground: 199 75% 78%;
  --border: 210 20% 18%;
  --input: 210 20% 18%;
  --ring: 198 92% 58%;
  --gradient-hero: linear-gradient(180deg, hsl(210 30% 9%) 0%, hsl(210 20% 14%) 100%);
  --shadow-sm: 0 1px 2px 0 hsl(210 40% 2% / 0.6);
  --shadow-md: 0 2px 4px -1px hsl(210 40% 2% / 0.6), 0 4px 8px -2px hsl(210 40% 2% / 0.5);
  --shadow-lg: 0 4px 6px -2px hsl(210 40% 2% / 0.7), 0 10px 20px -5px hsl(210 40% 2% / 0.6);
}

/* ============================================================
   Base
   ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { font-family: var(--font-serif); line-height: 1.35; }
h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); font-weight: 600; margin-top: 2.5rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.1rem; font-weight: 600; margin-top: 1.75rem; margin-bottom: 0.5rem; }
p { margin-bottom: 1rem; }
a { color: hsl(var(--primary-dark)); text-decoration: none; transition: color 0.15s; }
a:hover { color: hsl(var(--primary)); }
ul, ol { padding-left: 1.5rem; margin-bottom: 1rem; }
li { margin-bottom: 0.3rem; }
code { font-size: 0.9em; background: hsl(var(--muted)); padding: 0.15em 0.4em; border-radius: 4px; font-family: 'SF Mono', 'Fira Code', monospace; }

/* ============================================================
   Top Nav
   ============================================================ */
.topnav {
  position: sticky; top: 0; z-index: 200;
  background: hsl(var(--card) / 0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid hsl(var(--border));
  height: 56px;
}
.topnav-inner {
  max-width: 100%; margin: 0 auto; padding: 0 1.5rem;
  display: flex; align-items: center; height: 100%; gap: 1.5rem;
}
.topnav-logo {
  font-family: var(--font-serif); font-weight: 700; font-size: 1.05rem;
  color: hsl(var(--foreground)); white-space: nowrap; display: flex; align-items: center; gap: 0.5rem;
  flex-shrink: 0;
}
.topnav-logo svg { width: 26px; height: 26px; }
.topnav-links { display: flex; gap: 0.15rem; list-style: none; font-size: 0.88rem; padding: 0; margin: 0; }
.topnav-links a { color: hsl(var(--muted-foreground)); padding: 0.3rem 0.6rem; border-radius: 0.4rem; font-weight: 500; }
.topnav-links a:hover, .topnav-links a.active { color: hsl(var(--foreground)); background: hsl(var(--muted)); text-decoration: none; }
.topnav-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.topnav-cta {
  background: var(--gradient-brand); color: #fff; padding: 0.35rem 0.9rem; border-radius: var(--radius);
  font-size: 0.82rem; font-weight: 600; white-space: nowrap; transition: opacity 0.2s, transform 0.2s;
}
.topnav-cta:hover { opacity: 0.92; transform: translateY(-1px); text-decoration: none; }
.theme-btn {
  background: none; border: 1px solid hsl(var(--border)); border-radius: 0.5rem;
  padding: 0.3rem 0.5rem; cursor: pointer; font-size: 1rem; color: hsl(var(--foreground));
}
.mobile-toggle { display: none; background: none; border: none; color: hsl(var(--foreground)); font-size: 1.4rem; cursor: pointer; }

/* ============================================================
   Layout: sidebar + main + toc
   ============================================================ */
.app-layout {
  display: flex;
  max-width: 1480px;
  margin: 0 auto;
  min-height: calc(100vh - 56px);
}

/* --- Left Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  overflow-y: auto;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  padding: 1.25rem 0 3rem;
  -webkit-overflow-scrolling: touch;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 4px; }

.sidebar-section { margin-bottom: 0.15rem; }

.sidebar-category {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  cursor: pointer; user-select: none;
  transition: color 0.15s;
}
.sidebar-category:hover { color: hsl(var(--foreground)); }
.sidebar-category .arrow { font-size: 0.6rem; transition: transform 0.2s; margin-left: auto; }
.sidebar-section.collapsed .sidebar-category .arrow { transform: rotate(-90deg); }
.sidebar-section.collapsed .sidebar-items { display: none; }

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

.sidebar-items li a {
  display: block; padding: 0.4rem 1.25rem 0.4rem 2rem;
  font-size: 0.85rem; color: hsl(var(--muted-foreground));
  border-left: 2px solid transparent; transition: all 0.12s;
  line-height: 1.5;
}
.sidebar-items li a:hover { color: hsl(var(--foreground)); background: hsl(var(--muted)); text-decoration: none; }
.sidebar-items li a.active { color: hsl(var(--primary-dark)); background: hsl(var(--primary-light)); border-left-color: hsl(var(--ring)); font-weight: 500; }

/* --- Main Content --- */
.main-content {
  flex: 1; min-width: 0;
  padding: 2.5rem clamp(1.5rem, 4vw, 3.5rem) 5rem;
}

/* --- Right TOC --- */
.page-toc {
  width: var(--toc-w); flex-shrink: 0;
  position: sticky; top: 80px;
  height: fit-content;
  padding: 1.5rem 0 2rem;
  font-size: 0.8rem;
  border-left: 1px solid hsl(var(--border));
  margin-left: 0;
}

.toc-title {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: hsl(var(--muted-foreground));
  padding: 0 1rem 0.5rem;
}

.page-toc ul { list-style: none; padding: 0; margin: 0; }
.page-toc ul ul { padding-left: 0.75rem; }

.page-toc li a {
  display: block; padding: 0.25rem 1rem; color: hsl(var(--muted-foreground));
  border-left: 2px solid transparent; transition: all 0.12s; line-height: 1.45;
}

.page-toc li a:hover, .page-toc li a.active {
  color: hsl(var(--foreground));
  border-left-color: hsl(var(--ring));
  text-decoration: none;
}

/* ============================================================
   Content components
   ============================================================ */
.content-header { border-bottom: 1px solid hsl(var(--border)); padding-bottom: 1.25rem; margin-bottom: 2rem; }
.content-header h1 { margin-bottom: 0.3rem; }
.content-header .subtitle { color: hsl(var(--muted-foreground)); font-size: 0.95rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; margin-top: 1.5rem; }

.card {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: var(--radius); padding: 1.5rem;
  box-shadow: var(--shadow-md); transition: box-shadow 0.25s, transform 0.25s;
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card-icon { font-size: 1.4rem; width: 44px; height: 44px; border-radius: 0.65rem; background: hsl(var(--primary-light)); display: flex; align-items: center; justify-content: center; margin-bottom: 0.85rem; }
.card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; color: hsl(var(--foreground)); }
.card p { font-size: 0.88rem; color: hsl(var(--muted-foreground)); margin-bottom: 0; line-height: 1.6; }
.card-link { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.85rem; font-size: 0.85rem; font-weight: 600; color: hsl(var(--primary-dark)); }
.card-link:hover { color: hsl(var(--primary)); }

/* Article list */
.doc-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.doc-list li a {
  display: block; padding: 0.8rem 1.1rem;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  color: hsl(var(--foreground)); box-shadow: var(--shadow-sm); transition: all 0.18s;
}
.doc-list li a:hover { border-color: hsl(var(--ring)); box-shadow: var(--shadow-md); text-decoration: none; }
.doc-list .doc-title { font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; gap: 0.5rem; }
.doc-list .doc-desc { font-size: 0.82rem; color: hsl(var(--muted-foreground)); margin-top: 0.15rem; }

.badge { display: inline-block; font-size: 0.7rem; padding: 0.1rem 0.5rem; border-radius: 50px; font-weight: 500; }
.badge-new  { background: hsl(var(--primary-light)); color: hsl(var(--primary-dark)); }
.badge-soon { background: hsl(45 93% 47% / 0.15); color: hsl(45 80% 35%); }

/* Prose */
.prose { font-family: var(--font-serif); font-size: 1rem; line-height: 1.78; letter-spacing: 0.02em; max-width: 70ch; }
.prose h2 { font-size: 1.5rem; }
.prose h3 { font-size: 1.15rem; }
.prose p { margin-bottom: 1.25em; }

.callout {
  background: hsl(var(--muted)); border-left: 4px solid hsl(var(--ring));
  padding: 0.9rem 1.2rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 1.5rem 0; font-size: 0.92rem;
}
.callout p { margin-bottom: 0; }

.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 2.8rem; margin-bottom: 1.2rem; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 1.75rem; height: 1.75rem; background: var(--gradient-brand); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; font-family: var(--font-sans);
}

.section-divider { margin: 3rem 0 1.5rem; }
.section-divider h2 { margin-bottom: 0.2rem; }
.section-divider p { color: hsl(var(--muted-foreground)); font-size: 0.9rem; }

/* Footer */
.footer { border-top: 1px solid hsl(var(--border)); text-align: center; padding: 2.5rem 2rem; color: hsl(var(--muted-foreground)); font-size: 0.82rem; background: hsl(var(--muted)); }
.footer-links { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.footer-links a { color: hsl(var(--muted-foreground)); font-size: 0.82rem; }
.footer-links a:hover { color: hsl(var(--foreground)); }

/* Hero */
.hero { text-align: center; padding: 4rem 2rem 3rem; background: var(--gradient-hero); }
.hero h1 { font-size: clamp(2rem, 5vw, 2.8rem); margin-bottom: 0.5rem; }
.hero h1 .brand { background: var(--gradient-brand); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero p { font-size: 1.05rem; color: hsl(var(--muted-foreground)); max-width: 600px; margin: 0 auto 1.5rem; }

/* Sidebar toggle (mobile) */
.sidebar-overlay { display: none; }
.sidebar-close { display: none; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1200px) {
  .page-toc { display: none; }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 300;
    width: 280px; height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 299;
    background: rgba(0,0,0,0.3);
  }
  .sidebar-overlay.show { display: block; }
  .sidebar-close {
    display: block; position: absolute; top: 0.75rem; right: 0.75rem;
    background: none; border: none; font-size: 1.3rem; cursor: pointer;
    color: hsl(var(--muted-foreground));
  }
  .mobile-toggle { display: block; }
  .main-content { padding: 1.5rem 1rem 4rem; }
  .card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  html { font-size: 15px; }
  .topnav-links { display: none; }
  .topnav-cta { font-size: 0.78rem; padding: 0.3rem 0.7rem; }
}
