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

/* ── Dark theme (default — Cool Teal) ── */
:root, [data-theme="dark"] {
  --bg-primary: #12121A;
  --bg-secondary: #16162A;
  --bg-elevated: #1A1A30;
  --bg-code: #14142A;
  --text-primary: #E2E2EF;
  --text-secondary: #9B9BB5;
  --text-muted: #65657A;
  --purple: #818CF8;
  --purple-light: #A5B4FC;
  --accent: #2DD4BF;
  --accent-hover: #5EEAD4;
  --blue-muted: #6B8DAD;
  --border: #2A2A42;
  --border-light: #33335A;
  --content-width: min(65vw, 960px);
  --wide-width: min(72vw, 1080px);
  --nav-bg: rgba(18, 18, 26, 0.92);
  --nav-bg-solid: rgba(18, 18, 26, 0.97);
  --grain-opacity: 0.035;
  --badge-color: #2DD4BF;
  --badge-bg: rgba(45, 212, 191, 0.08);
  --badge-border: rgba(45, 212, 191, 0.2);
  --step-border: rgba(42, 42, 66, 0.5);
  --flow-bg: rgba(129, 140, 248, 0.05);
  --code-text: #9B9BB5;
  --code-comment: #65657A;
  --code-cmd: #E2E2EF;
  --arch-purple: #A5B4FC;
  --arch-accent: #2DD4BF;
  --arch-blue: #6B8DAD;
  --arch-text: #65657A;
  --arch-line: #555566;
}

/* ── Light theme ── */
[data-theme="light"] {
  --bg-primary: #FAFBFC;
  --bg-secondary: #F3F4F6;
  --bg-elevated: #FFFFFF;
  --bg-code: #1E1E2E;
  --text-primary: #1A1A2E;
  --text-secondary: #4A4A5E;
  --text-muted: #8888A0;
  --purple: #6D28D9;
  --purple-light: #7C3AED;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --blue-muted: #6B7DB8;
  --border: #E2E4EA;
  --border-light: #D1D3DD;
  --nav-bg: rgba(250, 251, 252, 0.92);
  --nav-bg-solid: rgba(250, 251, 252, 0.97);
  --grain-opacity: 0.015;
  --badge-color: #D97706;
  --badge-bg: rgba(217, 119, 6, 0.08);
  --badge-border: rgba(217, 119, 6, 0.2);
  --step-border: rgba(226, 228, 234, 0.5);
  --flow-bg: rgba(109, 40, 217, 0.06);
  --code-text: #c0bdb5;
  --code-comment: #706d65;
  --code-cmd: #e0ddd5;
  --arch-purple: #A78BFA;
  --arch-accent: #60A5FA;
  --arch-blue: #7DA0C4;
  --arch-text: #706d65;
  --arch-line: #555566;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.75;
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Grain texture overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: var(--grain-opacity);
  background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA3ElEQVRoge2YQQ6DMADD8v+f0l7YoUICxnaSqhI3YGzPEMYYAAAAAPif29UDaOLl6gHYIhEBEhEgEQESESARAaYj8rp6ALbYvbX2+vfvo2MuCyWuE7m3tr/52Bj+tNgT5XnE3G/M/LUmqhh5PpEvJrIw+cPDnNaJPQ/3J8pl6Gkjcp8lIkBEBEhEgEQEiJ1af5V3bZe61dYiUfM4MW+t7WN7pYmzIpOq0GNV3IvkMXLF04T/8B9uLJYKZrLRYlXciyQ9Rd7/+PjIoAkAAAD4Fz4AmVBBHwTbBN0AAAAASUVORK5CYII=");
}

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

h2 {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 1.125rem;
  margin-bottom: 0.75rem;
}

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

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

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

code, .mono {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

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

/* ── Navigation ── */
nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 2000;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 0.55rem 0.8rem;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0.75rem;
}

.nav-inner {
  max-width: var(--wide-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.nav-brand img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.nav-links a {
  color: var(--text-secondary);
  transition: color 0.2s ease;
  white-space: nowrap;
}

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

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

.nav-github {
  color: var(--text-primary) !important;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-github:hover {
  opacity: 1;
}

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

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

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
}

.hamburger svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* ── Theme toggle ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}

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

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

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

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

/* ── Main Content ── */
main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

section {
  margin-bottom: 4rem;
}

section:last-child {
  margin-bottom: 2rem;
}

/* ── Hero ── */
.hero {
  margin-bottom: 4rem;
  padding-top: 1rem;
}

.hero-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.hero-header img {
  width: 68px;
  height: 68px;
  border-radius: 50%;
}

.hero-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero-tagline {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.65;
}

.hero-intro {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.hero-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.hero-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.2s ease, color 0.2s ease;
}

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

.hero-link svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.status-badge {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--badge-color);
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  border-radius: 4px;
  padding: 0.3rem 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  transition: color 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

/* ── Section index (on-page TOC) ── */
.section-index {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1rem;
  margin-bottom: 3rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
}

.section-index a {
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.section-index a:hover {
  color: var(--accent);
}

.section-index a + a::before {
  content: '\00b7';
  margin-right: 1rem;
  color: var(--border-light);
  pointer-events: none;
}

/* ── Module definitions ── */
.module-list {
  margin-top: 1.5rem;
}

.module-item {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.module-item:last-child {
  border-bottom: 1px solid var(--border);
}

.module-name {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--purple-light);
  margin-bottom: 0.35rem;
}

.module-desc {
  color: var(--text-secondary);
  font-size: 0.925rem;
  line-height: 1.7;
  margin-bottom: 0;
}

/* ── Code blocks (dark in both themes) ── */
.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  white-space: pre;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.65;
  margin: 1.5rem 0;
  max-width: var(--wide-width);
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% + 4rem);
  max-width: min(var(--wide-width), calc(100vw - 2rem));
}

.code-block code {
  color: var(--code-text);
  white-space: pre;
}

.code-block .comment {
  color: var(--code-comment);
}

/* Architecture diagram colors */
.arch-purple { color: var(--arch-purple); }
.arch-accent { color: var(--arch-accent); }
.arch-blue { color: var(--arch-blue); }
.arch-text { color: var(--arch-text); }
.arch-line { color: var(--arch-line); }

/* ── Numbered list ── */
.step-list {
  counter-reset: steps;
  list-style: none;
  margin: 1.25rem 0;
}

.step-list li {
  counter-increment: steps;
  padding: 0.65rem 0;
  padding-left: 2.25rem;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.925rem;
  line-height: 1.7;
  border-top: 1px solid var(--step-border);
}

.step-list li:first-child {
  border-top: none;
}

.step-list li::before {
  content: counter(steps);
  position: absolute;
  left: 0;
  top: 0.7rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  font-weight: 500;
}

.step-label {
  color: var(--text-primary);
  font-weight: 600;
}

/* ── Capability blocks ── */
.capability {
  margin-bottom: 1.5rem;
}

.capability-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.capability p {
  font-size: 0.925rem;
  line-height: 1.75;
}

/* ── Homepage idea list ── */
.idea-list {
  margin: 1rem 0 1.25rem 1.25rem;
}

.idea-list li {
  color: var(--text-secondary);
}

/* ── Compact capability list (home page) ── */
.capability-list {
  list-style: none;
  margin: 1rem 0;
}

.capability-list li {
  padding: 0.4rem 0;
  padding-left: 1.25rem;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.925rem;
  line-height: 1.7;
}

.capability-list li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* ── Security flow ── */
.security-flow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1.25rem 0 1.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

.flow-step {
  color: var(--purple-light);
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--flow-bg);
}

.flow-arrow {
  color: var(--text-muted);
}

/* ── Policy list ── */
.policy-list {
  list-style: none;
  margin: 1rem 0;
}

.policy-list li {
  padding: 0.5rem 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.925rem;
  line-height: 1.7;
  margin-bottom: 0.35rem;
}

.policy-list li strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--purple);
}

/* ── Limitation list ── */
.limitation-list {
  list-style: none;
  margin: 1rem 0;
}

.limitation-list li {
  padding: 0.4rem 0;
  padding-left: 1.25rem;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.925rem;
  line-height: 1.7;
}

.limitation-list li::before {
  content: '\2013';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

/* ── Getting started ── */
.code-block.bash {
  font-size: 0.8rem;
}

.code-block.bash .prompt {
  color: var(--code-comment);
  user-select: none;
}

.code-block.bash .cmd {
  color: var(--code-cmd);
}

.note {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-top: 0.5rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
}

/* ── Contributing ── */
.contrib-list {
  list-style: none;
  margin: 1rem 0;
}

.contrib-list li {
  padding: 0.35rem 0;
  padding-left: 1.25rem;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.925rem;
  line-height: 1.7;
}

.contrib-list li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* ── Read-more links ── */
.read-more-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}

.read-more-links a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.read-more-links a:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}

.prompt-list {
  list-style: none;
  margin: 1rem 0;
}

.prompt-list li {
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.925rem;
}

.prompt-list code {
  display: block;
  color: var(--code-cmd);
  white-space: pre-wrap;
  line-height: 1.7;
}

.screenshot-grid {
  display: grid;
  gap: 1rem;
  margin: 1.25rem 0;
}

.screenshot-placeholder {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-elevated));
  border: 1px dashed var(--border-light);
  border-radius: 10px;
  padding: 1.25rem;
}

.screenshot-placeholder strong {
  display: block;
  margin-bottom: 0.35rem;
}

.screenshot-placeholder p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

/* ── Blog styles ── */
.blog-list {
  list-style: none;
  margin: 1.5rem 0;
}

.blog-list li {
  position: relative;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  margin-left: -1rem;
  margin-right: -1rem;
  border-radius: 4px;
  transition: background 0.2s ease, border-left-color 0.2s ease;
}

.blog-list li:first-child {
  padding-top: 1.25rem;
}

.blog-list li:hover {
  background: var(--bg-secondary);
  border-left-color: var(--accent);
}

.blog-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 0.25rem;
}

.blog-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.blog-title a {
  color: var(--text-primary);
  text-decoration: none;
}

.blog-title a::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

.blog-list li:hover .blog-title a {
  color: var(--accent);
}

.blog-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 0;
}

/* ── Article (blog post) ── */
.article-header {
  margin-bottom: 2.5rem;
}

.article-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.35;
  margin-bottom: 0.75rem;
}

.article-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.article-body h2 {
  margin-top: 2.5rem;
}

.article-body ul,
.article-body ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.article-body li {
  color: var(--text-secondary);
  font-size: 0.925rem;
  line-height: 1.75;
  margin-bottom: 0.5rem;
}

.article-body li strong {
  color: var(--text-primary);
}

/* ── CTA block ── */
.cta-block {
  margin-top: 3rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
}

.cta-block h3 {
  margin-bottom: 0.5rem;
}

.cta-block p {
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.cta-block .hero-links {
  margin-bottom: 0;
}

/* ── Page title (for subpages) ── */
.page-title {
  margin-bottom: 2.5rem;
  padding-top: 1rem;
}

.page-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.page-title p {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* ── Differentiator blocks ── */
.differentiator {
  margin-bottom: 1.5rem;
}

.differentiator p {
  font-size: 0.925rem;
  line-height: 1.75;
}

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
}

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

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

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

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

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

/* ── Scroll fade-in ── */
.fade-in {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .fade-in {
    opacity: 1;
    transform: none;
  }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    background: var(--nav-bg-solid);
    flex-direction: column;
    padding: 1rem 1.5rem;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
  }

  .nav-links.open {
    display: flex;
  }

  .hamburger {
    display: block;
  }

  .hero-header h1 {
    font-size: 1.6rem;
  }

  .hero-header img {
    width: 52px;
    height: 52px;
  }

  .code-block {
    width: calc(100% + 2rem);
    padding: 1rem;
    font-size: 0.72rem;
    border-radius: 6px;
  }

  main {
    padding: 2rem 1rem 3rem;
  }

  .security-flow {
    font-size: 0.7rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  .section-index {
    gap: 0.35rem 0.75rem;
    font-size: 0.75rem;
  }

  .article-header h1 {
    font-size: 1.4rem;
  }
}

@media (max-width: 480px) {
  .hero-header h1 {
    font-size: 1.35rem;
  }

  .hero-tagline {
    font-size: 1rem;
  }

  .code-block {
    font-size: 0.65rem;
  }
}
