/* ─── Base ───────────────────────────────────────────────────────────── */
:root {
  --color-bg: #f8f9fb;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #5a6473;
  --color-accent: #0a66c2;
  --color-border: #e3e6eb;
  --max-width: 880px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0e1117;
    --color-surface: #161b22;
    --color-text: #e6edf3;
    --color-muted: #8b949e;
    --color-accent: #58a6ff;
    --color-border: #30363d;
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ─── Header ──────────────────────────────────────────────────────────── */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

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

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-header nav {
  display: flex;
  gap: 1.5rem;
}

.site-header nav a {
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.site-header nav a:hover {
  color: var(--color-accent);
}

/* ─── Main content ────────────────────────────────────────────────────── */
.content {
  padding: 2.5rem 1.25rem 4rem;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 2.5rem 0 0.75rem;
  line-height: 1.3;
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
}

p {
  margin: 0 0 1rem;
}

.lead {
  font-size: 1.1rem;
  color: var(--color-muted);
  margin-bottom: 2rem;
}

.muted {
  color: var(--color-muted);
  font-size: 0.95rem;
  margin-top: 2rem;
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: none;
}

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

li {
  margin-bottom: 0.4rem;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: 1rem;
  margin: 1.25rem 0;
  color: var(--color-muted);
}

code {
  background: var(--color-surface);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  border: 1px solid var(--color-border);
}

pre {
  background: var(--color-surface);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  overflow-x: auto;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
}

pre code {
  background: none;
  padding: 0;
  border: 0;
}

/* ─── Tables ──────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

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

tr:last-child td {
  border-bottom: 0;
}

/* ─── Cards (landing page) ────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 12px 24px rgba(0, 0, 0, 0.06);
}

.card h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.card p {
  color: var(--color-muted);
  font-size: 0.95rem;
  flex-grow: 1;
}

.card-cta {
  color: var(--color-accent);
  font-weight: 600;
  font-size: 0.95rem;
}

/* ─── Markdown-rendered content ───────────────────────────────────────── */
#markdown-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

#markdown-content :first-child {
  margin-top: 0;
}

#markdown-content table {
  box-shadow: none;
  border: 1px solid var(--color-border);
}

.loading-state, .error-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-muted);
}

.error-state {
  color: #c81e1e;
}

/* ─── Footer ──────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-top: 4rem;
}

.site-footer a {
  color: var(--color-muted);
  margin: 0 0.25rem;
}

/* ─── Mobile tweaks ───────────────────────────────────────────────────── */
@media (max-width: 600px) {
  h1 { font-size: 1.65rem; }
  h2 { font-size: 1.2rem; }
  .content { padding: 1.5rem 1rem 3rem; }
  #markdown-content { padding: 1.25rem; }
  .site-header { padding: 0.75rem 0; }
  .site-header nav { gap: 1rem; }
  table { font-size: 0.85rem; }
  th, td { padding: 0.5rem; }
}
