/* Light theme (default) */
:root {
  --bg: #fbfaf7;
  --text: #1f1d1a;
  --muted: #6f6a62;
  --rule: #e6e2da;
  --accent: #b4441f;
  --code-bg: #f1eee8;
  --font: Roboto, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Dark theme: chosen with the toggle, or the system setting when JS is off */
:root[data-theme="dark"] {
  --bg: #161514;
  --text: #e8e4dc;
  --muted: #9b958b;
  --rule: #2e2b28;
  --accent: #ec8a5f;
  --code-bg: #24221f;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #161514;
    --text: #e8e4dc;
    --muted: #9b958b;
    --rule: #2e2b28;
    --accent: #ec8a5f;
    --code-bg: #24221f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0 auto;
  max-width: 40rem;
  padding: 3rem 1.25rem 4rem;
  background: var(--bg);
  color: var(--text);
  font: 300 1.0625rem/1.7 var(--font);
}

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3, h4 { font-weight: 400; line-height: 1.25; }
strong, b { font-weight: 500; }

/* Header & footer */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.25rem;
  margin-bottom: 2.5rem;
}
.site-name { color: var(--text); font-weight: 500; text-decoration: none; }

.theme-toggle {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: currentColor; }
.theme-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Show the theme you'd switch to */
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font: 0.9rem var(--font);
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* Home */
.intro h1 { font-size: 2.5rem; font-weight: 300; margin: 0 0 1rem; }
section + section { margin-top: 3rem; }
section h2 {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 1rem;
}
.section-note { color: var(--muted); margin: -0.5rem 0 1rem; font-size: 1rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 1.25rem; padding: 0.35rem 0; }
.list time {
  flex: 0 0 5.5rem;
  color: var(--muted);
  font: 0.9rem/1.9 var(--font);
  font-variant-numeric: tabular-nums;
}
.list a { color: var(--text); text-decoration-color: var(--rule); }
.list a:hover { color: var(--accent); text-decoration-color: currentColor; }
.draft { color: var(--accent); font: 0.8rem var(--font); }
.list.lab li { flex-direction: column; gap: 0; }
.list.lab span { color: var(--muted); font-size: 1rem; }

@media (max-width: 30rem) {
  .list li { flex-direction: column; gap: 0; }
  .list time { flex: none; line-height: 1.4; }
}

/* Article */
.post header { margin-bottom: 2rem; }
.post h1 { font-size: 2.5rem; font-weight: 300; margin: 0 0 0.5rem; }
.post header time { color: var(--muted); font: 0.95rem var(--font); }

.prose h2 { font-size: 1.5rem; margin: 2.5rem 0 0.75rem; }
.prose h3 { font-size: 1.2rem; margin: 2rem 0 0.5rem; }
.prose img, .prose video { max-width: 100%; height: auto; }
.prose li + li { margin-top: 0.35rem; }
.prose blockquote {
  margin: 1.5rem 0;
  padding-left: 1.25rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

code, pre { font-family: var(--mono); font-size: 0.85em; }
:not(pre) > code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }
pre {
  background: var(--code-bg);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.5;
}

.back { margin-top: 3rem; font: 0.95rem var(--font); }
.back a { text-decoration: none; }
