/* ========================================
   Zuxi Documentation Site
   ======================================== */

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

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --max-width: 1200px;
  --radius: 10px;
  --radius-sm: 6px;
}

/* --- Dark Theme (default) --- */
[data-theme="dark"] {
  --bg: #0a0e17;
  --bg-alt: #0f1420;
  --surface: #151b2b;
  --surface-hover: #1c2438;
  --border: #1e2740;
  --border-light: #283350;
  --text: #e2e8f0;
  --text-secondary: #8892a8;
  --text-muted: #5a6478;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-bg: rgba(96, 165, 250, 0.1);
  --code-bg: #0d1117;
  --code-border: #1b2332;
  --hero-gradient: linear-gradient(135deg, #0a0e17 0%, #111827 50%, #0f172a 100%);
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
  --glow: 0 0 60px rgba(96, 165, 250, 0.08);
}

/* --- Light Theme --- */
[data-theme="light"] {
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --surface: #f1f5f9;
  --surface-hover: #e2e8f0;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-bg: rgba(37, 99, 235, 0.08);
  --code-bg: #f8fafc;
  --code-border: #e2e8f0;
  --hero-gradient: linear-gradient(135deg, #f8fafc 0%, #eef2ff 50%, #f0f9ff 100%);
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06);
  --glow: none;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

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

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

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.2rem;
}

.logo-icon { font-size: 1.4rem; }

.nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav a:hover { color: var(--text); }

.nav-github { display: flex; align-items: center; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover { color: var(--text); border-color: var(--border-light); }

[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }

/* --- Hero --- */
.hero {
  background: var(--hero-gradient);
  padding: 100px 0 80px;
  text-align: center;
}

.hero-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 24px;
  letter-spacing: 0.02em;
}

.hero-title {
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
}

.hero-accent {
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 36px;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 56px;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius);
  transition: all 0.2s;
}

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

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-light); }

/* --- Code blocks --- */
.hero-code {
  max-width: 640px;
  margin: 0 auto;
  text-align: left;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--code-border);
  box-shadow: var(--glow);
}

.code-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--code-border);
}

.code-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-light);
}

.code-dot:nth-child(1) { background: #ef4444; }
.code-dot:nth-child(2) { background: #f59e0b; }
.code-dot:nth-child(3) { background: #22c55e; }

.code-title {
  margin-left: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.hero-code pre,
.code-block pre {
  background: var(--code-bg);
  padding: 20px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.7;
}

.code-block pre code,
.hero-code pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 0.85rem;
}

/* Syntax colors */
.c-prompt { color: #22c55e; font-weight: 600; }
.c-cmd { color: var(--accent); font-weight: 600; }
.c-str { color: #f59e0b; }
.c-out { color: var(--text-secondary); }
.c-comment { color: var(--text-muted); }
.c-key { color: var(--accent); }
.c-sel { color: #22c55e; font-weight: 600; }
.c-bool { color: #c084fc; }

[data-theme="light"] .c-prompt { color: #16a34a; }
[data-theme="light"] .c-str { color: #d97706; }
[data-theme="light"] .c-out { color: #334155; }
[data-theme="light"] .c-bool { color: #7c3aed; }

/* --- Stats --- */
.stats {
  padding: 40px 0;
  border-bottom: 1px solid var(--border);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 4px;
}

/* --- Sections --- */
.section {
  padding: 80px 0;
}

.section-alt {
  background: var(--bg-alt);
}

.section-title {
  font-size: 2rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.section-desc {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 48px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Full-width container override for wider sections */
.section-wide .container {
  max-width: 1280px;
}

/* --- Features Grid --- */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.feature-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--card-shadow);
}

.feature-icon {
  font-size: 1.6rem;
  margin-bottom: 14px;
}

.feature-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Install Grid --- */
.install-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 100%;
}

.install-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 0;
}

.install-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.install-card .code-block pre {
  white-space: pre-wrap;
  word-break: break-all;
}

.install-card .code-block pre code {
  word-break: break-all;
}

.code-block {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--code-border);
}

.code-block pre {
  background: var(--code-bg);
  padding: 16px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.7;
}

.code-block pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 0.82rem;
  word-break: break-all;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: all 0.2s;
}

.code-block:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--border-light); }
.copy-btn.copied { color: #22c55e; border-color: #22c55e; }

/* --- Command Tabs --- */
.cmd-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 32px;
  justify-content: center;
  flex-wrap: wrap;
}

.cmd-tab {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.cmd-tab:hover { color: var(--text); border-color: var(--border-light); }

.cmd-tab.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Command Panels --- */
.cmd-panel { display: none; }
.cmd-panel.active { display: block; }

.cmd-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.cmd-list h4 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  margin-top: 20px;
}

.cmd-list h4:first-child { margin-top: 0; }

.cmd-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.cmd-item:last-child { border-bottom: none; }

.cmd-item code {
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 500;
}

.cmd-item span {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.cmd-example .code-block {
  position: sticky;
  top: 80px;
}

/* --- Flags Table --- */
.flags-table-wrap {
  max-width: 640px;
  margin: 0 auto;
}

.flags-table {
  width: 100%;
  border-collapse: collapse;
}

.flags-table th,
.flags-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.flags-table th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.flags-table td {
  font-size: 0.9rem;
}

.flags-table td:first-child { white-space: nowrap; }

/* --- TUI Section --- */
.tui-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.tui-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.tui-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.tui-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tui-demo {
  max-width: 900px;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--code-border);
  box-shadow: var(--glow);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.tui-titlebar {
  background: #1a1e2e;
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--code-border);
}

[data-theme="light"] .tui-titlebar {
  background: #e2e8f0;
  color: #475569;
}

.tui-hotkeys {
  background: #111827;
  color: var(--text-muted);
  padding: 4px 12px;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--code-border);
}

[data-theme="light"] .tui-hotkeys {
  background: #f1f5f9;
  color: #64748b;
}

.tui-mock {
  display: grid;
  grid-template-columns: 200px 1fr;
  background: var(--code-bg);
  min-height: 340px;
}

.tui-left {
  border-right: 1px solid var(--code-border);
  display: flex;
  flex-direction: column;
}

.tui-right {
  display: flex;
  flex-direction: column;
}

.tui-panel-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 4px 10px;
  border-bottom: 1px solid var(--code-border);
  text-transform: capitalize;
}

.tui-commands {
  flex: 1;
  overflow: hidden;
  padding: 2px 0;
}

.tui-cmd {
  padding: 1px 10px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: nowrap;
}

.tui-cmd.selected {
  background: #3b82f6;
  color: #fff;
}

[data-theme="light"] .tui-cmd.selected {
  background: #3b82f6;
  color: #fff;
}

.tui-input {
  padding: 10px 14px;
  border-bottom: 1px solid var(--code-border);
  min-height: 80px;
}

.tui-input code {
  background: none;
  color: var(--text);
  font-size: 0.82rem;
  padding: 0;
}

.tui-output {
  flex: 1;
  padding: 10px 14px;
}

.tui-output pre {
  background: none;
  padding: 0;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.6;
}

.tui-output pre code {
  background: none;
  color: var(--text);
  font-size: 0.82rem;
  padding: 0;
}

.tui-statusbar {
  padding: 4px 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--code-border);
  margin-top: auto;
}

/* --- Footer --- */
.footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-left {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.footer-right {
  display: flex;
  gap: 24px;
}

.footer-right a {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.footer-right a:hover { color: var(--text); }

/* --- Responsive --- */
@media (max-width: 900px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .cmd-split { grid-template-columns: 1fr; }
  .cmd-example .code-block { position: static; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
  .tui-features { grid-template-columns: 1fr; }
  .tui-mock { grid-template-columns: 160px 1fr; }
}

@media (max-width: 640px) {
  .features-grid { grid-template-columns: 1fr; }
  .install-grid { grid-template-columns: 1fr; }
  .hero { padding: 60px 0 50px; }
  .section { padding: 56px 0; }
  .hero-title { font-size: 2rem; }
  .nav a:not(.nav-github) { display: none; }
  .footer-inner { flex-direction: column; gap: 16px; text-align: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
