/* Article pages — layout inspired by jakub.kr/writing */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --text: #0a0a0a;
  --text-secondary: #666666;
  --text-tertiary: #888888;
  --border: #e8e8e6;
  --code-bg: #f4f4f2;
  --code-border: #eaeae8;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --prose: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}

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

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

a { color: inherit; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 1.5rem;
}
.back:hover { color: var(--text); text-decoration: none; }

.article-shell {
  max-width: 800px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 3.5rem;
}

@media (min-width: 800px) {
  .article-shell { padding: 2.75rem 1.5rem 4.5rem; }
}

/* TOC + prose: mobile stacks TOC, then article; desktop = article | sticky TOC */
.article-with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem 2rem;
  align-items: start;
  margin-top: 0;
}

@media (min-width: 900px) {
  .article-with-sidebar {
    grid-template-columns: minmax(0, 1fr) 180px;
  }
  .prose { grid-column: 1; grid-row: 1; }
  .toc { grid-column: 2; grid-row: 1; }
}

.toc {
  position: static;
  font-size: 0.8rem;
  line-height: 1.45;
  padding: 0;
}

@media (min-width: 900px) {
  .toc {
    position: sticky;
    top: 1.5rem;
  }
}

.toc h2 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 0.65rem;
  font-family: var(--font);
}

.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li { margin-bottom: 0.45rem; }
.toc li:last-child { margin-bottom: 0; }

.toc a {
  color: var(--text-secondary);
  text-decoration: none;
  display: block;
  padding: 0.1rem 0;
}
.toc a:hover { color: var(--text); }

.toc--boxed {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem 1rem;
}

/* ── Front matter (above grid) ── */
.article-meta,
.article-title,
.lede {
  max-width: 40rem;
}

.article-meta {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.article-title {
  font-family: var(--font);
  font-size: clamp(1.75rem, 4vw, 2.15rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  text-wrap: balance;
  margin-bottom: 0.9rem;
}

.lede,
.prose .lede {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.75;
  font-family: var(--prose);
  margin-bottom: 0;
}

.lede { margin-bottom: 1.25rem; }

/* ── Prose ── */
.prose {
  font-size: 1.02rem;
  line-height: 1.72;
  color: var(--text);
  min-width: 0;
  max-width: 40rem;
}

.prose p {
  margin-bottom: 1rem;
  font-family: var(--prose);
}

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

.prose h2 {
  font-family: var(--font);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 1.85rem 0 0.65rem;
  line-height: 1.3;
  scroll-margin-top: 1.25rem;
}

.prose h2:first-of-type { margin-top: 0; }

.prose h3 {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.5rem 0 0.6rem;
}

.prose strong { font-weight: 600; }

.prose a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose code,
.code-inline {
  font-family: ui-monospace, 'SFMono-Regular', 'Menlo', Monaco, Consolas, monospace;
  font-size: 0.86em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 0.12em 0.35em;
}

.pre-wrap {
  margin: 0.75rem 0 1rem;
  border-radius: 8px;
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  overflow-x: auto;
}
.pre-wrap pre {
  font-family: ui-monospace, 'SFMono-Regular', 'Menlo', Monaco, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  padding: 1rem 1.1rem;
  margin: 0;
  white-space: pre;
  tab-size: 2;
}

.prose .command {
  display: block;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin: 0.75rem 0 1rem;
}

.prose ul,
.prose ol {
  margin: 0.75rem 0 1.1rem 1.25rem;
  font-family: var(--prose);
}
.prose li { margin-bottom: 0.4rem; }

.article-nav {
  margin-top: 2.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
  max-width: 40rem;
}

.article-nav a {
  color: var(--text-secondary);
  text-decoration: none;
}
.article-nav a:hover { color: var(--text); text-decoration: underline; }

.article-nav .next { font-weight: 500; color: var(--text); }
