/* === variables === */
:root {
  --bg:        #0f1117;
  --bg-subtle: #161b22;
  --fg:        #e6edf3;
  --fg-muted:  #8b949e;
  --border:    #30363d;
  --accent:    #58a6ff;
  --code-bg:   #1c2128;
  --font-sans: Inter, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:        #ffffff;
    --bg-subtle: #f6f8fa;
    --fg:        #1f2328;
    --fg-muted:  #656d76;
    --border:    #d0d7de;
    --accent:    #0969da;
    --code-bg:   #f6f8fa;
  }
}

/* === reset === */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-left: 1.5rem; }

/* === base === */
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
}

/* === layout === */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* === nav === */
nav {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

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

.site-name {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}

nav ul {
  display: flex;
  gap: 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

nav a {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.875rem;
}

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

/* === main + footer === */
main { padding: 3rem 0; }

footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  font-size: 0.8125rem;
  color: var(--fg-muted);
}

/* === typography === */
h1 { font-size: 1.875rem; line-height: 1.2; margin-bottom: 0.5rem; }
h2 { font-size: 1.3125rem; line-height: 1.3; margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1.0625rem; line-height: 1.4; margin: 2rem 0 0.5rem; }
h4 { font-size: 1rem; margin: 1.5rem 0 0.25rem; }

li { margin-bottom: 0.25rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

blockquote {
  border-left: 3px solid var(--border);
  margin: 1.5rem 0;
  padding: 0.5rem 1rem;
  color: var(--fg-muted);
  font-style: italic;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  margin: 1.5rem 0;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
}

th {
  background: var(--bg-subtle);
  font-weight: 600;
}

/* === code === */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.55;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8125rem;
}

/* prism light-mode overrides */
@media (prefers-color-scheme: light) {
  pre[class*="language-"],
  code[class*="language-"] { background: var(--code-bg); }
  .token.comment,
  .token.prolog  { color: #6e7781; }
  .token.keyword { color: #cf222e; }
  .token.string  { color: #0a3069; }
  .token.function { color: #8250df; }
  .token.number  { color: #0550ae; }
  .token.boolean { color: #0550ae; }
  .token.operator { color: #1f2328; }
  .token.punctuation { color: #6e7781; }
}

/* === article header === */
.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.article-meta {
  font-size: 0.8125rem;
  color: var(--fg-muted);
  margin-top: 0.5rem;
}

/* === article list (homepage + section indexes) === */
.article-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.article-list li {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.article-list li:first-child { border-top: 1px solid var(--border); }

.article-list a {
  font-size: 1.0625rem;
  font-weight: 500;
  display: block;
  margin-bottom: 0.25rem;
  color: var(--fg);
}

.article-list a:hover { color: var(--accent); text-decoration: none; }

.article-desc {
  font-size: 0.875rem;
  color: var(--fg-muted);
}

.tag {
  display: inline-block;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.5em;
  color: var(--fg-muted);
  margin-right: 0.375rem;
  vertical-align: middle;
}

/* === complexity groups (homepage) === */
.complexity-group { margin-bottom: 2.5rem; }

.complexity-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--fg-muted);
  font-weight: 600;
  margin-bottom: 0;
}

/* === pattern list === */
.pattern-category { margin-bottom: 2.5rem; }

.pattern-category-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--fg-muted);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.pattern-grid { display: grid; gap: 0.5rem; }

.pattern-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.1s;
}

.pattern-item:hover {
  border-color: var(--accent);
  text-decoration: none;
  color: var(--fg);
}

.pattern-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.pattern-item-name { font-size: 0.9375rem; }

.pattern-item-desc {
  font-size: 0.8125rem;
  color: var(--fg-muted);
  line-height: 1.5;
}

.pip-bar { display: flex; gap: 2px; align-items: center; }

.pip-bar span {
  width: 6px;
  height: 12px;
  border-radius: 1px;
  background: var(--border);
}

.pip-bar span.on { background: var(--accent); opacity: 0.75; }

/* === pattern metadata === */
.pattern-meta {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 2rem;
  font-size: 0.8125rem;
}

.pattern-meta-item { display: flex; flex-direction: column; gap: 0.3rem; }
.meta-label { color: var(--fg-muted); }
.meta-value { font-weight: 500; }

.popularity-bar { display: flex; gap: 3px; margin-top: 0.1rem; }

.popularity-bar span {
  width: 9px;
  height: 16px;
  border-radius: 2px;
  background: var(--border);
}

.popularity-bar span.on { background: var(--accent); }

/* === section intro === */
.section-intro {
  color: var(--fg-muted);
  margin-bottom: 2.5rem;
  font-size: 0.9375rem;
  max-width: 56ch;
}

/* === language index === */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.lang-card {
  display: block;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.1s;
}

.lang-card:hover { border-color: var(--accent); text-decoration: none; }
.lang-card-name { font-weight: 600; font-size: 1rem; }
.lang-card-sub { font-size: 0.8125rem; color: var(--fg-muted); margin-top: 0.25rem; }

/* === 404 === */
.not-found { padding: 4rem 0; }
.not-found-code {
  font-family: var(--font-mono);
  font-size: 4.5rem;
  font-weight: 600;
  color: var(--fg-muted);
  line-height: 1;
  margin-bottom: 1rem;
}
