/* ===== CSS Custom Properties ===== */
:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #1c2128;
  --bg-hover: #1f2937;
  --border: #30363d;
  --border-accent: #58a6ff;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --accent-subtle: rgba(88, 166, 255, 0.1);
  --purple: #bc8cff;
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --pink: #f778ba;
  --sidebar-width: 280px;
  --header-height: 64px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 150ms ease;
  --content-max-width: 900px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: clamp(14px, 0.35vw + 13px, 16px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Header ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.header-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
}

.header-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-links a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: color var(--transition);
}
.header-links a:hover { color: var(--text-primary); }

.github-link {
  display: flex;
  align-items: center;
  gap: 6px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

/* ===== Sidebar Overlay (mobile) ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 45;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ===== Layout ===== */
.layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  z-index: 50;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar-nav a {
  display: block;
  padding: 6px 12px;
  font-size: 14px;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: all var(--transition);
}

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

.sidebar-nav a.active {
  color: var(--accent);
  background: var(--accent-subtle);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

/* ===== Main Content ===== */
.main {
  margin-left: var(--sidebar-width);
  margin-right: auto;
  flex: 1;
  min-width: 0;
  padding: clamp(32px, 4vw, 56px) clamp(24px, 5vw, 80px) 120px;
  max-width: var(--content-max-width);
  width: 100%;
}

/* ===== Hero ===== */
.hero {
  position: relative;
  padding: 48px 0 56px;
  margin-bottom: 48px;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -25%;
  width: 150%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 50%, rgba(88, 166, 255, 0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 50%, rgba(188, 140, 255, 0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--purple), var(--green), transparent);
  background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { background-position: -200% 0; }
  50% { background-position: 200% 0; }
}

.hero-badge,
.hero h1,
.hero p,
.hero-actions,
.hero-terminal {
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--accent-subtle);
  color: var(--accent);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 20px;
  border: 1px solid rgba(88, 166, 255, 0.2);
}

.hero h1 {
  font-size: clamp(26px, 4vw + 10px, 48px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: clamp(15px, 1vw + 12px, 19px);
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 600px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--text-muted);
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ===== Sections ===== */
.section {
  margin-bottom: clamp(40px, 4vw, 64px);
}

.section h2 {
  font-size: clamp(22px, 1.5vw + 14px, 28px);
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.section h3 {
  font-size: clamp(16px, 0.5vw + 14px, 19px);
  font-weight: 600;
  margin: 28px 0 12px;
  color: var(--text-primary);
}

.section p {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.section ul, .section ol {
  color: var(--text-secondary);
  padding-left: 24px;
  margin-bottom: 16px;
}

.section li {
  margin-bottom: 6px;
}

.section li code {
  color: var(--accent);
}

/* ===== Code Blocks ===== */
pre {
  position: relative;
  background: var(--bg-tertiary) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px !important;
  overflow-x: auto;
  margin: 16px 0;
  font-size: 13.5px;
  line-height: 1.6;
}

pre code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  background: none !important;
  padding: 0 !important;
  border: none !important;
  color: var(--text-primary);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--accent);
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
}

td {
  padding: 10px 16px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

tr:hover td {
  background: rgba(22, 27, 34, 0.5);
}

/* ===== Feature Cards ===== */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.feature-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.feature-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 24px rgba(88, 166, 255, 0.08);
}

.feature-card .icon {
  width: 40px;
  height: 40px;
  background: var(--accent-subtle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--accent);
}

.feature-card h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.feature-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ===== Steps ===== */
.steps {
  counter-reset: step;
  margin: 24px 0;
}

.step {
  position: relative;
  padding-left: 48px;
  margin-bottom: 32px;
}

.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid rgba(88, 166, 255, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.step h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.step p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== Callout ===== */
.callout {
  background: var(--accent-subtle);
  border: 1px solid rgba(88, 166, 255, 0.2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.callout strong {
  color: var(--accent);
}

.callout-warning {
  background: rgba(210, 153, 34, 0.1);
  border-color: rgba(210, 153, 34, 0.2);
  border-left-color: var(--orange);
}

.callout-warning strong {
  color: var(--orange);
}

/* ===== Architecture Diagram ===== */
.arch-diagram {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin: 24px 0;
  text-align: center;
}

.arch-orchestrator {
  margin-bottom: 20px;
}

.arch-orchestrator .cli-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-top: 3px solid var(--orange);
  color: var(--orange);
  box-shadow: 0 2px 12px rgba(210, 153, 34, 0.1);
}

.arch-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.arch-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: box-shadow 0.3s ease;
}

.arch-box svg { margin-bottom: 2px; }
.arch-box small { font-weight: 400; color: var(--text-muted); font-size: 11px; }

.arch-box.source {
  border-top: 3px solid var(--text-secondary);
}

.arch-box.accent {
  border-top: 3px solid var(--accent);
  color: var(--accent);
  box-shadow: 0 2px 12px rgba(88, 166, 255, 0.08);
}

.arch-box.purple {
  border-top: 3px solid var(--purple);
  color: var(--purple);
  box-shadow: 0 2px 12px rgba(188, 140, 255, 0.08);
}

.arch-box.green {
  border-top: 3px solid var(--green);
  color: var(--green);
  box-shadow: 0 2px 12px rgba(63, 185, 80, 0.08);
}

.arch-arrow {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  animation: pulse-arrow 2s ease-in-out infinite;
}

@keyframes pulse-arrow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ===== Footer ===== */
.footer {
  margin-left: var(--sidebar-width);
  padding: 32px clamp(24px, 5vw, 80px);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.footer span,
.footer a { color: var(--text-secondary); }
.footer a:hover { color: var(--accent); }

/* ===== Hero Terminal ===== */
.hero-terminal {
  margin-top: 32px;
  background: #0a0e14;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 620px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.terminal-title {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
  font-family: var(--font-sans);
}

.terminal-body {
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  min-height: 80px;
}

.terminal-line {
  display: flex;
  gap: 8px;
}

.terminal-prompt {
  color: var(--green);
  font-weight: 600;
  user-select: none;
}

.terminal-typed {
  color: var(--text-primary);
}

.terminal-cursor {
  color: var(--accent);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.terminal-output {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.terminal-output .line-success { color: var(--green); }
.terminal-output .line-accent { color: var(--accent); }
.terminal-output .line-muted { color: var(--text-muted); }

/* ===== Fade-in Animations ===== */
.fade-in-section {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.feature-card.fade-in-section:nth-child(2) { transition-delay: 0.1s; }
.feature-card.fade-in-section:nth-child(3) { transition-delay: 0.2s; }
.feature-card.fade-in-section:nth-child(4) { transition-delay: 0.3s; }
.feature-card.fade-in-section:nth-child(5) { transition-delay: 0.4s; }
.feature-card.fade-in-section:nth-child(6) { transition-delay: 0.5s; }

/* ===== Code Language Labels ===== */
.code-lang-label {
  position: absolute;
  top: 0;
  left: 16px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-family: var(--font-sans);
  padding: 2px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 4px 4px;
}

/* ===== Back to Top ===== */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 90;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* ===== Table Wrapper (mobile scroll) ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 16px 0;
  border-radius: var(--radius);
}

.table-wrapper table {
  margin: 0;
}

@media (max-width: 768px) {
  .table-wrapper {
    position: relative;
    border: 1px solid var(--border);
  }
  .table-wrapper table {
    border: none;
  }
  .table-wrapper th:first-child,
  .table-wrapper td:first-child {
    position: sticky;
    left: 0;
    background: var(--bg-secondary);
    z-index: 1;
  }
}

/* ===== Responsive ===== */

/* Large desktop: expand content area */
@media (min-width: 1200px) {
  :root { --content-max-width: 980px; }
}

/* Ultra-wide: expand further */
@media (min-width: 1440px) {
  :root { --content-max-width: 1060px; }
  .feature-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1800px) {
  :root { --content-max-width: 1140px; }
}

/* Tablet */
@media (max-width: 1024px) {
  .footer { padding: 24px 32px; }
}

/* Mobile */
@media (max-width: 768px) {
  .menu-toggle { display: block; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }

  .main {
    margin-left: 0;
    padding: 24px 20px 80px;
    max-width: 100%;
  }

  .footer {
    margin-left: 0;
    padding: 20px;
    flex-direction: column;
    gap: 8px;
  }

  .hero-actions { flex-direction: column; }
  .hero-actions .btn { text-align: center; justify-content: center; }
  .hero-terminal { max-width: 100%; }
  .feature-grid { grid-template-columns: 1fr; }
  .arch-flow { flex-direction: column; gap: 8px; }
  .arch-arrow { transform: rotate(90deg); }
  .arch-arrow svg { transform: rotate(90deg); }
  .arch-box { width: 100%; max-width: 260px; }

  pre { font-size: 12.5px; }

  th, td { padding: 8px 10px; font-size: 12.5px; }
  th { font-size: 11.5px; }

  .back-to-top { bottom: 20px; right: 20px; width: 40px; height: 40px; }
}

/* Small mobile */
@media (max-width: 480px) {
  .main { padding: 16px 14px 60px; }

  .hero { padding: 32px 0 40px; }
  .hero-badge { font-size: 11px; }

  .feature-card { padding: 16px; }
  .feature-card .icon { width: 34px; height: 34px; }
  .feature-card h4 { font-size: 14px; }

  .step { padding-left: 40px; margin-bottom: 24px; }
  .step::before { width: 28px; height: 28px; font-size: 12px; }
  .step h4 { font-size: 14px; }

  pre { padding: 14px 16px !important; font-size: 12px; }
  code { font-size: 0.8em; }
  .code-lang-label { font-size: 9px; left: 12px; }
  .copy-btn { padding: 3px 8px; font-size: 11px; }

  .terminal-body { padding: 12px 14px; font-size: 12px; }
  .terminal-bar { padding: 8px 12px; }
  .terminal-dot { width: 8px; height: 8px; }

  .arch-diagram { padding: 20px 16px; }
  .arch-box { padding: 12px 14px; font-size: 12px; min-width: 110px; }

  .callout { padding: 12px 14px; font-size: 13px; }

  .footer { padding: 16px 14px; font-size: 12px; }
}
