:root {
  --background: 0 0% 100%;
  --foreground: 0 0% 10%;
  --muted-foreground: 0 0% 40%;
  --border: 0 0% 87%;
  --link: 240 100% 47%;
  --link-visited: 277 60% 32%;
  --code-bg: 210 25% 97%;
  --code-border: 0 0% 87%;
}

html.dark {
  --background: 0 0% 7%;
  --foreground: 0 0% 88%;
  --muted-foreground: 0 0% 53%;
  --border: 0 0% 20%;
  --link: 217 90% 76%;
  --link-visited: 271 80% 72%;
  --code-bg: 0 0% 12%;
  --code-border: 0 0% 20%;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

body {
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.25rem;
}

a {
  color: hsl(var(--link));
  text-decoration: none;
}

a:visited {
  color: hsl(var(--link-visited));
}

a:hover {
  text-decoration: underline;
}

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

/* Theme toggle */

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: none;
  border: 1px solid hsl(var(--border));
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.75rem;
  transition: color 150ms ease, border-color 150ms ease;
}

.theme-toggle:hover {
  color: hsl(var(--foreground));
  border-color: hsl(var(--foreground) / 0.4);
}

.theme-toggle:focus-visible {
  outline: 2px solid hsl(var(--link));
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .theme-toggle {
    position: static;
    float: right;
    margin-bottom: 1rem;
  }
}

/* Homepage */

.home-header h1 {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.home-header h1 .prompt {
  color: hsl(var(--link));
}

.home-header p {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9rem;
  color: hsl(var(--muted-foreground));
}

section h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

section ul {
  list-style: none;
  padding: 0;
}

section ul li {
  margin-bottom: 0.25rem;
}

.post-list li {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.post-list .date {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  flex-shrink: 0;
}

/* Post page */

nav.back {
  margin-bottom: 2rem;
}

nav.back a {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

nav.back a:hover {
  color: hsl(var(--foreground));
  text-decoration: none;
}

article header {
  margin-top: 2rem;
  margin-bottom: 2rem;
}

article header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

article header .meta {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

/* Prose content */

.prose h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  line-height: 1.3;
  color: hsl(var(--foreground));
}

.prose h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  color: hsl(var(--foreground));
}

.prose h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: hsl(var(--foreground));
}

.prose p {
  margin-bottom: 1.25rem;
}

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

.prose ul, .prose ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

.prose img {
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
}

.prose figcaption {
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  margin-top: -1rem;
  margin-bottom: 1.5rem;
}

.prose code:not(pre code) {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
  background: hsl(var(--code-bg));
  border: 1px solid hsl(var(--code-border));
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.prose pre {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875rem;
  background: hsl(var(--code-bg));
  border: 1px solid hsl(var(--code-border));
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.5;
}

.prose video {
  max-width: 100%;
  margin: 1.5rem 0;
}

.prose iframe {
  max-width: 100%;
}

/* Code block copy button */

.code-block-wrapper {
  position: relative;
}

.code-block-wrapper .copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease;
}

.code-block-wrapper:hover .copy-btn {
  opacity: 1;
}

.code-block-wrapper .copy-btn:hover {
  color: hsl(var(--foreground));
}

.code-block-wrapper .copy-btn:focus-visible {
  opacity: 1;
  outline: 2px solid hsl(var(--link));
  outline-offset: 2px;
  border-radius: 2px;
}

/* 404 */

.not-found {
  display: flex;
  min-height: 60vh;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.not-found h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.not-found p {
  font-size: 1.25rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 1rem;
}

/* Syntax highlighting - light */

.chroma .c, .chroma .ch, .chroma .cm, .chroma .c1, .chroma .cs,
.chroma .cp, .chroma .cpf {
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn, .chroma .kp,
.chroma .kr, .chroma .kt {
  color: hsl(240 80% 52%);
}

.chroma .s, .chroma .sa, .chroma .sb, .chroma .sc, .chroma .dl,
.chroma .sd, .chroma .s2, .chroma .se, .chroma .sh, .chroma .si,
.chroma .sx, .chroma .sr, .chroma .s1, .chroma .ss {
  color: hsl(120 40% 36%);
}

.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh, .chroma .mi,
.chroma .il, .chroma .mo {
  color: hsl(0 70% 55%);
}

.chroma .n, .chroma .na, .chroma .nb, .chroma .nc, .chroma .no,
.chroma .nd, .chroma .ni, .chroma .ne, .chroma .nf, .chroma .nl,
.chroma .nn, .chroma .nx, .chroma .nt, .chroma .nv, .chroma .bp,
.chroma .vc, .chroma .vg, .chroma .vi, .chroma .vm {
  color: hsl(var(--foreground));
}

.chroma .o, .chroma .p {
  color: hsl(var(--foreground) / 0.7);
}

.chroma .nf, .chroma .nc {
  color: hsl(280 50% 45%);
}

html.dark .chroma .k, html.dark .chroma .kc, html.dark .chroma .kd,
html.dark .chroma .kn, html.dark .chroma .kp, html.dark .chroma .kr,
html.dark .chroma .kt {
  color: hsl(217 90% 76%);
}

html.dark .chroma .s, html.dark .chroma .sa, html.dark .chroma .sb,
html.dark .chroma .sc, html.dark .chroma .dl, html.dark .chroma .sd,
html.dark .chroma .s2, html.dark .chroma .se, html.dark .chroma .sh,
html.dark .chroma .si, html.dark .chroma .sx, html.dark .chroma .sr,
html.dark .chroma .s1, html.dark .chroma .ss {
  color: hsl(120 40% 62%);
}

html.dark .chroma .m, html.dark .chroma .mb, html.dark .chroma .mf,
html.dark .chroma .mh, html.dark .chroma .mi, html.dark .chroma .il,
html.dark .chroma .mo {
  color: hsl(0 70% 70%);
}

html.dark .chroma .nf, html.dark .chroma .nc {
  color: hsl(280 50% 72%);
}
