/* ---------- Theme tokens ---------- */
:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-body: #3b3f45;
  --muted: #6b7078;
  --border: #e7e7e4;
  --accent: #2563eb;
  --code-bg: #f6f8fa;
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --text: #f2f2f2;
    --text-body: #c9cdd2;
    --muted: #9aa0a6;
    --border: #262a31;
    --accent: #60a5fa;
    --code-bg: #171a21;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --text: #f2f2f2;
  --text-body: #c9cdd2;
  --muted: #9aa0a6;
  --border: #262a31;
  --accent: #60a5fa;
  --code-bg: #171a21;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.wrapper {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px;
}

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

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 450;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}
h1 { font-size: 2.75rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.65rem; margin: 2.75rem 0 0.75rem; }
h3 { font-size: 1.3rem; margin: 2rem 0 0.5rem; }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0;
}

.site-name {
  color: var(--text);
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-nav a { color: var(--muted); }
.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--text); text-decoration: none; }

.theme-toggle {
  display: inline-flex;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Show the moon in light mode and the sun in dark mode. */
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

main { min-height: 60vh; }

/* ---------- Home ---------- */
.intro { padding: 24px 0 8px; }
.intro p { color: var(--text-body); }
.intro .role { color: var(--muted); margin: 0 0 1rem; }

.social {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.more { margin-top: 1.25rem; }

/* ---------- Post lists ---------- */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.post-link {
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}
.post-link:hover { color: var(--accent); text-decoration: none; }

.post-meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

/* ---------- Posts and pages ---------- */
.post-header { margin: 16px 0 32px; }
.post-header .post-meta { white-space: normal; }

.content { color: var(--text-body); }
.content strong { color: var(--text); font-weight: 600; }
.content img { max-width: 100%; height: auto; }

.content blockquote {
  margin: 1.5rem 0;
  padding: 0 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 1.15em;
  font-style: italic;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}

pre {
  overflow-x: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  line-height: 1.5;
}

pre code { padding: 0; background: none; font-size: 0.85rem; }
.highlighter-rouge .highlight { background: none; }

.back { margin-top: 3rem; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 64px;
  padding: 24px 0 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer .social { margin: 0 0 0.5rem; }
.site-footer p { margin: 0; }

/* ---------- Syntax highlighting (Rouge) ---------- */
.highlight .c, .highlight .c1, .highlight .cm { color: var(--muted); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kt, .highlight .kn, .highlight .kc { color: #cf222e; }
.highlight .s, .highlight .s1, .highlight .s2 { color: #0a3069; }
.highlight .nf, .highlight .nc { color: #8250df; }
.highlight .nd, .highlight .na { color: #953800; }
.highlight .mi, .highlight .mf { color: #0550ae; }

:root[data-theme="dark"] .highlight .k, :root[data-theme="dark"] .highlight .kd,
:root[data-theme="dark"] .highlight .kt, :root[data-theme="dark"] .highlight .kn,
:root[data-theme="dark"] .highlight .kc { color: #ff7b72; }
:root[data-theme="dark"] .highlight .s, :root[data-theme="dark"] .highlight .s1,
:root[data-theme="dark"] .highlight .s2 { color: #a5d6ff; }
:root[data-theme="dark"] .highlight .nf, :root[data-theme="dark"] .highlight .nc { color: #d2a8ff; }
:root[data-theme="dark"] .highlight .nd, :root[data-theme="dark"] .highlight .na { color: #ffa657; }
:root[data-theme="dark"] .highlight .mi, :root[data-theme="dark"] .highlight .mf { color: #79c0ff; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .highlight .k, :root:not([data-theme="light"]) .highlight .kd,
  :root:not([data-theme="light"]) .highlight .kt, :root:not([data-theme="light"]) .highlight .kn,
  :root:not([data-theme="light"]) .highlight .kc { color: #ff7b72; }
  :root:not([data-theme="light"]) .highlight .s, :root:not([data-theme="light"]) .highlight .s1,
  :root:not([data-theme="light"]) .highlight .s2 { color: #a5d6ff; }
  :root:not([data-theme="light"]) .highlight .nf, :root:not([data-theme="light"]) .highlight .nc { color: #d2a8ff; }
  :root:not([data-theme="light"]) .highlight .nd, :root:not([data-theme="light"]) .highlight .na { color: #ffa657; }
  :root:not([data-theme="light"]) .highlight .mi, :root:not([data-theme="light"]) .highlight .mf { color: #79c0ff; }
}

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  body { font-size: 16px; }
  h1 { font-size: 2.1rem; }
  h2 { font-size: 1.4rem; }
  .site-header { padding: 20px 0; }
  .site-nav { gap: 14px; }
}
