/* ===== CSS Variables ===== */
:root {
  --color-bg: #ffffff;
  --color-bg-secondary: #f8fafc;
  --color-bg-code: #f1f5f9;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;
  --color-accent: #da7756;
  --color-accent-light: #e5917a;
  --color-accent-bg: #fdf4f1;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;
  --color-header-bg: rgba(255, 255, 255, 0.9);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --max-width: 1200px;
  --content-width: 800px;
  --header-height: 80px;
  --radius: 8px;
  --radius-lg: 12px;
}

/* Dark theme */
[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-bg-secondary: #1e293b;
  --color-bg-code: #1e293b;
  --color-text: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  --color-accent: #e5917a;
  --color-accent-light: #da7756;
  --color-accent-bg: #2d1f1a;
  --color-border: #334155;
  --color-border-light: #1e293b;
  --color-header-bg: rgba(15, 23, 42, 0.9);
  --color-version-text: #93c5fd;
  --color-version-bg: #1e3a5f;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border-light);
  height: var(--header-height);
}

.nav-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: -0.02em;
  line-height: 1;
}

.logo-version {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--color-version-text, #1e6091);
  background: var(--color-version-bg, #dbeafe);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  letter-spacing: 0.02em;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.5rem;
}

.nav-links a {
  display: block;
  padding: 0.375rem 0.75rem;
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}

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

.nav-links a.active {
  color: var(--color-accent);
  background: var(--color-accent-bg);
}

.github-link::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 0.375rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3E%3Cpath d='M3.75 2h3.5a.75.75 0 0 1 0 1.5h-2.19l5.22 5.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L4 4.56v2.19a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 3.25 2.5h.5Zm8.5 4a.75.75 0 0 1 .75.75v5.5a.75.75 0 0 1-.75.75h-8.5a.75.75 0 0 1-.75-.75v-5.5a.75.75 0 0 1 1.5 0v4.75h7v-4.75a.75.75 0 0 1 .75-.75Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  vertical-align: middle;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
}

.theme-toggle button {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--color-text-secondary);
  transition: color 0.15s, background 0.15s;
}

.theme-toggle button:hover {
  color: var(--color-text);
  background: var(--color-bg-secondary);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

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

/* ===== Main Content ===== */
main {
  min-height: calc(100vh - var(--header-height) - 120px);
}

/* ===== Hero Section ===== */

.hero-cta {
  display: flex;
  gap: 1rem;
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--color-accent);
  color: white;
  border: 1px solid var(--color-accent);
}

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

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

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

/* ===== Content Sections ===== */
.content-section {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.5rem 2rem 2.5rem;
}

.content-section h2 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
  color: var(--color-text);
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

.section-tagline {
  font-size: 0.95rem;
  font-weight: 400;
  font-style: italic;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
  letter-spacing: 0.01em;
}

/* Anchor links */
.anchor-link {
  color: inherit;
  text-decoration: none;
  position: relative;
}

.anchor-link::after {
  content: '';
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  margin-left: 0.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2394a3b8'%3E%3Cpath d='M4.715 6.542 3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1 1 0 0 0-.154.199 2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4 4 0 0 1-.128-1.287z'/%3E%3Cpath d='M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.15s;
}

.anchor-link:hover::after {
  opacity: 1;
}

.anchor-link:hover {
  color: var(--color-accent);
}

.content-section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--color-text);
}

.content-section p {
  margin-bottom: 1.25rem;
  color: var(--color-text-secondary);
}

.content-section p:last-child {
  margin-bottom: 0;
}

/* ===== Pillars Grid ===== */
.pillars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.pillar-card {
  padding: 1.5rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pillar-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.pillar-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
  color: var(--color-accent);
}

.pillar-card p {
  font-size: 0.9375rem;
  margin: 0;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

/* ===== Code Blocks ===== */
.example-block {
  margin: 2rem 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.example-header {
  padding: 0.75rem 1rem;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

pre {
  margin: 0;
  padding: 1.25rem;
  background: var(--color-bg-code);
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

code {
  font-family: var(--font-mono);
}

:not(pre) > code {
  padding: 0.125rem 0.375rem;
  background: var(--color-bg-code);
  border-radius: 4px;
  font-size: 0.875em;
  color: var(--color-accent);
}

/* Syntax highlighting */
.highlight .k, .highlight .kd, .highlight .kn { color: #c2410c; }
.highlight .s, .highlight .s1, .highlight .s2 { color: #059669; }
.highlight .c, .highlight .c1, .highlight .cm { color: var(--color-text-muted); font-style: italic; }
.highlight .na { color: #0ea5e9; }
.highlight .nf { color: #da7756; }
.highlight .mi, .highlight .mf { color: #b45309; }
.highlight .nt { color: #da7756; }

/* ===== Spec Page ===== */
.spec-content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
}

.spec-toc {
  margin: 1rem 0 1.5rem;
}

.spec-toc strong {
  display: inline;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-accent);
}

.spec-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: inline;
}

.spec-toc li {
  display: inline;
}

.spec-toc li:not(:last-child)::after {
  content: " · ";
  color: var(--color-text-muted);
}

.spec-toc a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.15s;
}

.spec-toc a:hover {
  color: var(--color-accent);
}

.spec-content h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: var(--color-accent);
}

.spec-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border-light);
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

.spec-content h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

.spec-content p {
  margin-bottom: 1rem;
}

.spec-content ul, .spec-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.spec-content li {
  margin-bottom: 0.5rem;
  color: var(--color-text-secondary);
}

.spec-content hr {
  margin: 3rem 0;
  border: none;
  border-top: 1px solid var(--color-border-light);
}

.spec-content pre {
  margin: 1.5rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.spec-content strong {
  color: var(--color-accent);
  font-weight: 600;
}

.spec-content em {
  color: var(--color-text-secondary);
}

/* ===== Examples Page ===== */
.examples-grid {
  display: grid;
  gap: 2rem;
  margin-top: 2rem;
}

.example-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.example-card-header {
  padding: 1rem 1.25rem;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.example-card-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.example-card-header p {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.example-card pre {
  border-radius: 0;
  border: none;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border-light);
  padding: 2.5rem 2rem;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-content {
  text-align: center;
}

.footer-tagline {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}

.footer-license {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .nav-container {
    padding: 0 1rem;
  }

  .nav-links {
    gap: 0;
  }

  .nav-links a {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  .hero {
    padding: 3rem 1.5rem;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 1.0625rem;
  }

  .content-section,
  .spec-content {
    padding: 2.5rem 1.5rem;
  }

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

@media (max-width: 480px) {
  .logo-version {
    display: none;
  }

  .github-link::after {
    display: none;
  }

  .hero-cta {
    flex-direction: column;
    align-items: flex-start;
  }
}
