/* ============================================================
   moatkit.dev — global.css
   Dark-first, typography-driven, agent-aligned dev site.
   2026: no gradients, no illustrations, code is the hero.
   ============================================================ */

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

:root {
  /* Palette */
  --bg: #0a0a0c;
  --bg-raised: #111114;
  --bg-code: #16161a;
  --bg-hover: #1c1c22;
  --border: #27272e;
  --border-subtle: #1e1e24;

  --text: #e8e6e3;
  --text-secondary: #9b9a97;
  --text-tertiary: #6b6a68;
  --text-code: #c4b5fd;

  --accent: #e2a336;
  --accent-dim: #b8832a;
  --accent-glow: rgba(226, 163, 54, 0.08);

  --green: #4ade80;
  --blue: #60a5fa;
  --red: #f87171;

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "Berkeley Mono", "Geist Mono", "JetBrains Mono", "SF Mono", "Fira Code", ui-monospace, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3.25rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Layout */
  --max-width: 64rem;
  --max-width-narrow: 48rem;
  --radius: 6px;
  --radius-lg: 10px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}

h1 {
  font-size: var(--text-5xl);
  font-weight: 700;
  letter-spacing: -0.03em;
}

h2 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-6);
}

h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-4);
}

p {
  color: var(--text-secondary);
  max-width: 40em;
}

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

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

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

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--text-code);
  background: var(--bg-code);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container--narrow {
  max-width: var(--max-width-narrow);
}

section {
  padding: var(--space-24) 0;
}

section + section {
  border-top: 1px solid var(--border-subtle);
}

/* --- Nav --- */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 12, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-4) 0;
}

nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.nav-logo span {
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  list-style: none;
}

.nav-links a {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.15s;
}

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

.nav-links .nav-github {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-links .nav-github svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* --- Hero --- */
.hero {
  padding: var(--space-24) 0 var(--space-20);
  text-align: center;
}

.hero h1 {
  margin-bottom: var(--space-6);
}

.hero h1 .accent {
  color: var(--accent);
}

.hero-subtitle {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 36em;
  margin: 0 auto var(--space-10);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-bottom: var(--space-16);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: var(--bg);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

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

/* --- Code Block --- */
.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-align: left;
  max-width: 44rem;
  margin: 0 auto;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-raised);
}

.code-block-dots {
  display: flex;
  gap: 6px;
}

.code-block-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.code-block-title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.code-block pre {
  padding: var(--space-5) var(--space-6);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text);
}

.code-block pre .kw { color: #c084fc; }
.code-block pre .fn { color: #60a5fa; }
.code-block pre .str { color: #4ade80; }
.code-block pre .cm { color: var(--text-tertiary); }
.code-block pre .ty { color: #fbbf24; }
.code-block pre .op { color: var(--text-secondary); }
.code-block pre .num { color: #f472b6; }

/* --- Install bar --- */
.install-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 28rem;
  margin: 0 auto var(--space-8);
}

.install-bar .prompt {
  color: var(--accent);
  user-select: none;
}

.install-bar code {
  background: none;
  padding: 0;
  color: var(--text);
}

/* --- Section Label --- */
.section-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: var(--space-4);
}

/* --- The Loop (How it works) --- */
.loop-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  margin-top: var(--space-10);
}

.loop-step {
  padding: var(--space-6);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s;
}

.loop-step:hover {
  border-color: var(--border);
}

.loop-step-number {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  margin-bottom: var(--space-3);
}

.loop-step h3 {
  font-size: var(--text-base);
  margin-bottom: var(--space-2);
}

.loop-step p {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* --- What's Possible --- */
.possible-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-1);
  margin-top: var(--space-10);
}

.possible-item {
  padding: var(--space-6) var(--space-8);
  border-radius: var(--radius);
  transition: background 0.15s;
}

.possible-item:hover {
  background: var(--accent-glow);
}

.possible-item h3 {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.possible-item p {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  line-height: 1.5;
}

.possible-item .possible-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent-dim);
  margin-top: var(--space-3);
}

/* --- Configs --- */
.configs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  margin-top: var(--space-10);
}

.config-card h3 {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text);
  margin-bottom: var(--space-4);
}

.config-card .code-block {
  max-width: none;
}

/* --- Primitives (API surface) --- */
.primitives {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
  margin-top: var(--space-10);
}

.primitive {
  padding: var(--space-6);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.primitive h3 {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--accent);
  margin-bottom: var(--space-2);
}

.primitive p {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.primitive code {
  font-size: var(--text-xs);
}

/* --- Docs Grid --- */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-10);
}

.docs-card {
  display: block;
  padding: var(--space-6);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: all 0.15s;
  text-decoration: none;
}

.docs-card:hover {
  border-color: var(--border);
  background: var(--bg-hover);
}

.docs-card h3 {
  font-size: var(--text-base);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.docs-card p {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* --- Agent-Aligned Section --- */
.agent-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-10);
}

.agent-card {
  padding: var(--space-6);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.agent-card h3 {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}

.agent-card p {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.agent-card code {
  font-size: var(--text-xs);
}

/* --- Footer --- */
footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-12) 0;
}

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

.footer-left {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.footer-left a {
  color: var(--text-secondary);
}

.footer-links {
  display: flex;
  gap: var(--space-8);
  list-style: none;
}

.footer-links a {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

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

/* --- Responsive --- */
@media (max-width: 768px) {
  h1 {
    font-size: var(--text-3xl);
  }

  h2 {
    font-size: var(--text-2xl);
  }

  section {
    padding: var(--space-16) 0;
  }

  .hero {
    padding: var(--space-16) 0 var(--space-12);
  }

  .loop-steps,
  .primitives,
  .agent-row,
  .configs-grid {
    grid-template-columns: 1fr;
  }

  .possible-grid,
  .docs-grid {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    flex-direction: column;
  }

  .nav-links {
    gap: var(--space-4);
  }

  footer .container {
    flex-direction: column;
    gap: var(--space-6);
    text-align: center;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: var(--text-2xl);
  }

  .code-block pre {
    font-size: var(--text-xs);
    padding: var(--space-4);
  }
}

/* ============================================================
   Docs pages — level tabs, sidebar, content layout
   ============================================================ */

/* --- Docs Layout --- */
.docs-layout {
  display: flex;
  gap: var(--space-10);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-10) var(--space-6) var(--space-24);
}

.docs-sidebar {
  position: sticky;
  top: 7rem;
  flex-shrink: 0;
  width: 14rem;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
  padding-right: var(--space-4);
}

.docs-sidebar ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.docs-sidebar a {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  padding: var(--space-1) var(--space-3);
  border-left: 2px solid transparent;
  border-radius: 0;
  transition: all 0.15s;
}

.docs-sidebar a:hover {
  color: var(--text);
  border-left-color: var(--border);
}

.docs-sidebar a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.docs-sidebar .sidebar-heading {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.docs-content {
  flex: 1;
  min-width: 0;
  max-width: 50rem;
}

.docs-content h1 {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-4);
}

.docs-content h2 {
  font-size: var(--text-2xl);
  margin-top: var(--space-16);
  margin-bottom: var(--space-4);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-subtle);
}

.docs-content h2:first-of-type {
  margin-top: var(--space-10);
  border-top: none;
  padding-top: 0;
}

.docs-content h3 {
  font-size: var(--text-lg);
  margin-top: var(--space-10);
  margin-bottom: var(--space-3);
}

.docs-content h4 {
  font-size: var(--text-base);
  margin-top: var(--space-8);
  margin-bottom: var(--space-2);
  font-family: var(--font-mono);
  color: var(--accent);
}

.docs-content > p {
  margin-bottom: var(--space-4);
  line-height: 1.7;
  max-width: 48rem;
}

.docs-content .lead {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
}

.docs-content .code-block {
  margin: var(--space-6) 0;
  max-width: none;
}

.docs-content ul,
.docs-content ol {
  margin: var(--space-4) 0;
  padding-left: var(--space-6);
  color: var(--text-secondary);
}

.docs-content li {
  margin-bottom: var(--space-2);
  line-height: 1.6;
  font-size: var(--text-sm);
}

.docs-content li code {
  font-size: var(--text-xs);
}

.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-6) 0;
  font-size: var(--text-sm);
}

.docs-content th {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid var(--border);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
}

.docs-content td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: top;
}

.docs-content td code {
  font-size: var(--text-xs);
  white-space: nowrap;
}

.docs-content .note {
  padding: var(--space-4) var(--space-5);
  background: var(--accent-glow);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: var(--space-6) 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.docs-content .note strong {
  color: var(--accent);
}

/* --- Level Tabs --- */
.level-tabs {
  position: sticky;
  top: 3.5rem;
  z-index: 90;
  background: rgba(10, 10, 12, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-3) 0;
}

.level-tabs .container {
  display: flex;
  gap: var(--space-2);
}

.level-tab {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--space-2) var(--space-4);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
}

.level-tab:hover {
  color: var(--text);
  border-color: var(--text-tertiary);
}

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

.level-tab-desc {
  display: none;
  font-family: var(--font-sans);
  margin-left: var(--space-2);
}

@media (min-width: 768px) {
  .level-tab-desc {
    display: inline;
  }
}

/* Level content visibility — fallback: show all */
.level-vibe,
.level-beginner,
.level-advanced {
  display: block;
}

body.level-active .level-vibe,
body.level-active .level-beginner,
body.level-active .level-advanced {
  display: none;
}

body.level-active.show-vibe .level-vibe,
body.level-active.show-beginner .level-beginner,
body.level-active.show-advanced .level-advanced {
  display: block;
}

/* --- Nav active state for docs --- */
.nav-links a.active {
  color: var(--accent);
}

/* --- Docs breadcrumb --- */
.docs-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-bottom: var(--space-6);
}

.docs-breadcrumb a {
  color: var(--text-tertiary);
}

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

.docs-breadcrumb .sep {
  color: var(--border);
}

/* --- Responsive docs --- */
@media (max-width: 768px) {
  .docs-layout {
    flex-direction: column;
    gap: var(--space-6);
    padding: var(--space-6) var(--space-4) var(--space-16);
  }

  .docs-sidebar {
    position: static;
    width: 100%;
    max-height: none;
    padding-right: 0;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: var(--space-4);
  }

  .docs-content h1 {
    font-size: var(--text-2xl);
  }

  .docs-content h2 {
    font-size: var(--text-xl);
  }

  .level-tabs .container {
    overflow-x: auto;
  }
}
