
/* "Quiet Intelligence" — editorial, trustworthy, considered.
   Paper-and-ink with a burnt-orange accent. Serif for headings, sans for body.
   No frameworks — keeps the DOM close to what crawlers and LLMs see. */

:root {
  /* Light theme — editorial parchment (mirrors internetcomputer.org) */
  --bg: #faf9f5;              /* parchment */
  --bg-sunk: #f3f1ea;         /* alternating sections, sunk panels */
  --bg-elev: #ffffff;         /* cards that read as raised */
  --fg: #1a1a1a;              /* ink, never pure black */
  --fg-secondary: #4b4943;    /* meta strips, secondary copy */
  --muted: #868078;           /* captions, attributions */
  --rule: #e7e3da;            /* warm ivory hairline */
  --rule-strong: #4b4943;
  --accent: #a8482b;          /* rust, the single brand color */
  --accent-strong: #8e3b22;
  --accent-dim: rgba(168, 72, 43, 0.10);
  --code-bg: #efe8da;
  --code-fg: #1a1a1a;
  --grid-line: rgba(26, 26, 26, 0.04);  /* hero grid paper texture */
  --grid-tile: 24px;

  --serif: "Newsreader", Charter, Georgia, Cambria, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --max: 1280px;
  --max-prose: 720px;
}

/* Explicit light override */
[data-theme="light"] {
  --bg: #faf9f5; --bg-sunk: #f3f1ea; --bg-elev: #ffffff;
  --fg: #1a1a1a; --fg-secondary: #4b4943; --muted: #868078;
  --rule: #e7e3da; --rule-strong: #4b4943;
  --accent: #a8482b; --accent-strong: #8e3b22; --accent-dim: rgba(168, 72, 43, 0.10);
  --code-bg: #efe8da; --code-fg: #1a1a1a;
}

[data-theme="dark"] {
  --bg: #14110d;              /* deep bark */
  --bg-sunk: #1b1812;
  --bg-elev: #1b1812;
  --fg: #f0ebe0;              /* bone */
  --fg-secondary: #a29a8d;
  --muted: #7a7367;
  --rule: #2d2820;
  --rule-strong: #5a5446;
  --accent: #c25a37;          /* ember, passes AA on dark surfaces */
  --accent-strong: #d96a45;
  --accent-dim: rgba(194, 90, 55, 0.16);
  --code-bg: #1b1812;
  --code-fg: #f0ebe0;
  --grid-line: rgba(240, 235, 224, 0.05);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
::selection { background: var(--accent); color: #fff; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.container { max-width: var(--max); margin: 0 auto; padding: 0 1.75rem; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--fg); color: var(--bg); padding: 0.5rem 1rem; z-index: 100;
  border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; top: 0; }

a {
  color: inherit;
  text-decoration-color: var(--rule-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--accent); }

code, pre { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 3px; color: var(--code-fg); }
pre {
  background: var(--code-bg); color: var(--code-fg);
  padding: 1rem 1.1rem; overflow-x: auto; border-radius: 6px; border: 1px solid var(--rule);
  line-height: 1.5;
}
pre code { background: transparent; padding: 0; color: inherit; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 2.6rem; margin: 1.5rem 0 0.85rem; }
h2 { font-size: 1.7rem; margin: 2rem 0 0.85rem; }
h3 { font-size: 1.25rem; margin: 1.4rem 0 0.5rem; }
h4 { font-size: 1.05rem; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  background: none; border: none; cursor: pointer; padding: 0.25rem;
  color: var(--fg); opacity: 0.75; display: inline-flex; align-items: center;
  border-radius: 4px; font-size: 1.1rem; line-height: 1;
  transition: color .15s, opacity .15s;
}
.theme-toggle:hover { opacity: 1; color: var(--accent); }
/* Default (dark): show sun, hide moon */
.theme-toggle .icon-moon { display: none; }
/* Light mode: show moon, hide sun */
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: inline-flex; }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--rule); background: var(--bg); }
.site-header .container {
  display: flex; align-items: center; gap: 2rem; padding: 1.4rem 1.75rem;
  flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: 0.65rem; text-decoration: none; color: var(--fg); }
.brand-mark { width: 26px; height: 26px; flex-shrink: 0; }
.brand-name {
  font-family: var(--sans); font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.98rem;
}
.site-header nav {
  display: flex; gap: 1.75rem; margin-left: auto; flex-wrap: wrap; font-size: 0.95rem;
}
.site-header nav a { color: var(--fg); text-decoration: none; opacity: 0.75; }
.site-header nav a:hover { opacity: 1; color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 5rem; padding: 2.5rem 0 3rem; border-top: 1px solid var(--rule);
  color: var(--muted); font-size: 0.88rem;
}
.site-footer .container {
  display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
}
.site-footer p { margin: 0.25rem 0; }
.site-footer a {
  color: var(--fg); text-decoration: none; margin-right: 1rem;
  border-bottom: 1px dotted var(--muted); padding-bottom: 1px;
}
.site-footer a:hover { color: var(--accent); border-color: var(--accent); }
.machine-links { white-space: normal; }

/* ---------- Grid paper overlay ---------- */
.grid-paper-overlay {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  opacity: 0.8;
  background-image:
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-tile) var(--grid-tile);
  background-position: -1px -1px;
  background-repeat: repeat;
}

/* ---------- Home: hero ---------- */
.hero { padding: 5rem 0 3rem; position: relative; overflow: hidden; }
.hero-inner { max-width: 52rem; position: relative; z-index: 1; }
.hero .eyebrow {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--fg-secondary); font-weight: 500;
}
.hero h1 {
  font-family: var(--serif); font-weight: 380;
  font-size: clamp(2.6rem, 5vw, 4.4rem); line-height: 1.05;
  margin: 1.25rem 0 1.5rem; letter-spacing: -0.015em;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero .lede { font-size: 1.2rem; color: var(--muted); max-width: 42rem; margin: 0 0 2rem; }
.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }

.cta {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1.25rem; border-radius: 9999px; text-decoration: none;
  font-family: var(--sans); font-weight: 600; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
}
.cta-primary { background: var(--accent); color: #fff; }
.cta-primary:hover { background: var(--accent-strong); color: #fff; }
.cta-secondary { border-color: var(--rule-strong); color: var(--fg); text-decoration: none; }
.cta-secondary:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Stats bar ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  margin: 3.5rem 0 2.5rem; padding: 1.5rem 0;
}
.stat { padding: 0 1rem; border-right: 1px solid var(--rule); }
.stat:last-child { border-right: none; }
.stat-num {
  font-family: var(--mono); font-size: 2.2rem; font-weight: 500; letter-spacing: -0.02em;
  color: var(--accent);
}
.stat-label { color: var(--muted); font-family: var(--mono); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; }

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); row-gap: 1.25rem; }
  .stat:nth-child(2) { border-right: none; }
}

/* ---------- Pull-quote callout ---------- */
.callout {
  margin: 3rem 0; padding: 1.5rem 1.75rem;
  border-left: 3px solid var(--accent); background: var(--accent-dim);
  border-radius: 0 6px 6px 0;
}
.callout p {
  margin: 0; font-family: var(--serif); font-size: 1.15rem; font-style: italic; color: var(--fg);
}
.callout cite {
  display: block; font-style: normal; font-family: var(--sans); color: var(--muted);
  font-size: 0.85rem; margin-top: 0.4rem;
}

/* ---------- Search bar ---------- */
.search-bar {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1rem; border-radius: 8px;
  border: 1px solid var(--rule); background: var(--bg-elev);
  margin-bottom: 1rem;
}
.search-bar svg { color: var(--meta); flex-shrink: 0; }
.search-bar input {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: 0.95rem; color: var(--fg); font-family: inherit;
}
.search-bar input::placeholder { color: var(--meta); }

/* ---------- Category heads & skill rows ---------- */
.category { margin: 3rem 0; }
.cat-head {
  display: flex; align-items: baseline; gap: 1rem; margin: 0 0 1rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--rule);
}
.cat-head h2 {
  margin: 0; font-family: var(--serif); font-weight: 500; font-size: 1.7rem; letter-spacing: -0.01em;
}
.cat-head .count { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

.skill-list { list-style: none; padding: 0; margin: 0; }
.skill-row {
  display: grid; grid-template-columns: 1fr 2fr auto;
  gap: 1.5rem; padding: 1.25rem 0; border-bottom: 1px solid var(--rule);
  align-items: baseline;
}
.skill-row:hover { background: var(--bg-elev); }
.skill-title {
  font-family: var(--serif); font-size: 1.2rem; font-weight: 500;
}
.skill-title a { color: var(--fg); text-decoration: none; }
.skill-title a:hover { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; }
.skill-desc { color: var(--muted); font-size: 0.98rem; margin: 0; }
.skill-links { display: flex; gap: 1rem; font-size: 0.86rem; }
.skill-links a {
  color: var(--muted); text-decoration: none;
  font-variant: all-small-caps; letter-spacing: 0.06em;
}
.skill-links a:hover { color: var(--accent); }

@media (max-width: 760px) {
  .skill-row { grid-template-columns: 1fr; gap: 0.4rem; padding: 1rem 0; }
  .skill-links { margin-top: 0.25rem; }
}

/* ---------- Skill detail page ---------- */
.breadcrumbs { color: var(--muted); font-size: 0.9rem; margin: 1rem 0; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); }

.skill-header { padding-bottom: 1.5rem; margin-bottom: 1.75rem; }
.skill-category {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--fg-secondary); font-weight: 500; margin: 0 0 0.5rem;
}
.skill-header h1 {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1.08; margin: 0.25rem 0 1rem;
  letter-spacing: -0.015em;
}
.skill-description { font-size: 1.15rem; color: var(--muted); margin: 0.5rem 0 1.5rem; max-width: 46rem; }

.skill-meta {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem 1.75rem; margin: 1.25rem 0; padding: 1rem 1.25rem;
  background: var(--bg-elev); border: 1px solid var(--rule); border-radius: 6px;
}
.skill-meta > div { display: flex; flex-direction: column; }
.skill-meta dt {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-weight: 600;
}
.skill-meta dd { margin: 0.3rem 0 0; font-size: 0.98rem; }
.skill-meta code { font-size: 0.88rem; }

.skill-formats { display: flex; align-items: baseline; gap: 0.5rem; margin: 1.25rem 0; }
.skill-formats strong {
  font-weight: 500; color: var(--muted); font-size: 0.82rem;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.skill-formats ul { display: flex; gap: 0.5rem; list-style: none; margin: 0; padding: 0; }
.skill-formats a {
  padding: 0.3rem 0.6rem; border: 1px solid var(--rule); border-radius: 6px;
  text-decoration: none; background: var(--bg-elev); color: var(--fg); font-size: 0.82rem;
}
.skill-formats a:hover { border-color: var(--accent); color: var(--accent); }

.trust-banner {
  margin-top: 1.5rem; padding: 1rem 1.25rem;
  border-left: 3px solid var(--accent); background: var(--accent-dim);
  font-size: 0.95rem; color: var(--fg); border-radius: 0 6px 6px 0;
}
.trust-banner strong { color: var(--accent); }

/* ---------- Prose (rendered markdown) ---------- */
.prose { max-width: var(--max-prose); }
.prose h1 { font-size: 2.1rem; }
.prose h2 {
  font-size: 1.55rem; margin-top: 2.25rem;
  padding-bottom: 0.3rem; border-bottom: 1px solid var(--rule);
}
.prose h3 { font-size: 1.2rem; }
.prose h1, .prose h2, .prose h3 { scroll-margin-top: 4rem; }
.prose p, .prose ul, .prose ol, .prose pre, .prose table, .prose blockquote {
  margin: 0.9rem 0;
}
.prose ul, .prose ol { padding-left: 1.35rem; }
.prose li { margin: 0.3rem 0; }
.prose table {
  border-collapse: collapse; width: 100%; font-size: 0.95rem;
  border: 1px solid var(--rule);
}
.prose th, .prose td { border: 1px solid var(--rule); padding: 0.5rem 0.7rem; text-align: left; vertical-align: top; }
.prose th { background: var(--bg-elev); font-weight: 600; }
.prose blockquote {
  padding: 0.25rem 1.25rem; border-left: 3px solid var(--rule);
  color: var(--muted); font-family: var(--serif); font-style: italic;
}
.prose img { max-width: 100%; height: auto; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  body { font-size: 16px; }
  .container { padding: 0 1rem; }

  /* Header */
  .site-header .container { padding: 1rem; gap: 0.75rem; }
  .site-header nav { gap: 1rem; font-size: 0.88rem; }
  .brand-name { font-size: 0.88rem; }

  /* Hero */
  .hero { padding: 2.5rem 0 1.5rem; }
  .hero .lede { font-size: 1.05rem; }

  /* Stats */
  .stats { margin: 2rem 0 1.5rem; padding: 1rem 0; }
  .stat-num { font-size: 1.6rem; }

  /* Callout */
  .callout { padding: 1rem 1.25rem; margin: 2rem 0; }
  .callout p { font-size: 1rem; }

  /* Skill detail */
  .skill-meta { padding: 0.75rem 1rem; gap: 0.75rem 1rem; }
  .skill-header h1 { font-size: 1.8rem; }
  .skill-description { font-size: 1rem; }
  .trust-banner { padding: 0.75rem 1rem; font-size: 0.88rem; }

  /* Footer */
  .site-footer .container { flex-direction: column; gap: 0.75rem; }
  .site-footer { margin-top: 3rem; padding: 1.5rem 0 2rem; }

  /* Prose */
  .prose pre { padding: 0.75rem 0.85rem; font-size: 0.85em; }
  .prose table { font-size: 0.85rem; display: block; overflow-x: auto; }

  /* Community section — no overrides needed */
}

/* ---------- 404 ---------- */
main h1 { font-family: var(--serif); }

/* ---------- Community / Ecosystem section ---------- */
.community-divider {
  display: flex; align-items: center; gap: 1rem;
  margin: 4rem 0 0;
  color: var(--muted); font-size: 0.72rem; font-family: var(--mono);
  text-transform: uppercase; letter-spacing: 0.16em;
}
.community-divider::before,
.community-divider::after {
  content: ''; flex: 1; border-top: 1px dashed var(--rule);
}

.community-notice {
  display: flex; gap: 0.75rem; align-items: flex-start;
  margin: 0 0 1.5rem; padding: 0.9rem 1.1rem;
  border-left: 3px solid var(--rule-strong);
  background: var(--bg-sunk); border-radius: 0 6px 6px 0;
}
.community-notice-icon {
  font-size: 1rem; line-height: 1.55; flex-shrink: 0; color: var(--fg-secondary);
}
.community-notice p {
  margin: 0; font-size: 0.95rem; color: var(--fg-secondary);
}

.community-badge {
  display: inline-block; margin-left: 0.5rem;
  padding: 0.1em 0.45em;
  background: var(--bg-sunk); border: 1px solid var(--rule); border-radius: 9999px;
  font-size: 0.65rem; font-family: var(--mono);
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); vertical-align: middle;
}

.skill-maintainer {
  color: var(--muted); font-size: 0.82rem; font-style: italic; margin: 0.2rem 0 0;
}

.community-skill-row .skill-title a {
  color: var(--fg-secondary);
}
.community-skill-row .skill-title a:hover { color: var(--accent); }

.community-skill-row > div { min-width: 0; }

.community-install-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: none; border: none; cursor: pointer; padding: 0;
  margin-top: 0.55rem; color: var(--muted); font-family: inherit;
  font-size: inherit; text-align: left; width: 100%;
}
.community-install-btn:hover svg { color: var(--accent); }

.community-install-code {
  font-family: var(--mono); font-size: 0.82rem;
  background: var(--code-bg); color: var(--code-fg);
  padding: 0.2em 0.55em; border-radius: 4px;
  border: 1px solid var(--rule);
  white-space: nowrap; overflow-x: auto; display: block;
  max-width: 100%;
}

.community-install-btn .icon-check { display: none; color: var(--accent); }
.community-install-btn.copied .icon-copy { display: none; }
.community-install-btn.copied .icon-check { display: inline; }
