/* --bg, --fg, --muted, --border, --code-bg and --pre-bg are also read by CSS inside posts. */
:root {
  --bg: #ffffff;
  --fg: #222222;
  --muted: #666b73;
  --border: #dcdfe3;
  --code-bg: #eff1f3;
  --pre-bg: #f5f6f7;
  --accent: #17437d;
  --hl-comment: #6b7480;
  --hl-keyword: #a3243b;
  --hl-string: #1f6f43;
  --hl-number: #17437d;
  --hl-title: #6a3fa0;
  --hl-attr: #8a5a00;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: Menlo, Consolas, "Liberation Mono", monospace;
  --rail: 11rem;
  --gap: 3rem;
  --measure: 40rem;
}

html.dark {
  --bg: #14171a;
  --fg: #e6e8ea;
  --muted: #9aa1a9;
  --border: #2c3136;
  --code-bg: #23282d;
  --pre-bg: #1b1f23;
  --accent: #9bbcf2;
  --hl-comment: #8691a0;
  --hl-keyword: #f08a9b;
  --hl-string: #8fd3aa;
  --hl-number: #9bbcf2;
  --hl-title: #c4a8f5;
  --hl-attr: #e6bd6e;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
}

@media (min-width: 48rem) {
  body {
    font-size: 1.0625rem;
  }
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 50;
  padding: 0.5rem 1rem;
  background: var(--bg);
}

/* One container for header, main and footer: a meta rail plus the reading column. */

.site-header,
main,
.site-footer {
  width: 100%;
  max-width: calc(var(--rail) + var(--gap) + var(--measure) + 3rem);
  margin: 0 auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

main {
  flex: 1;
  outline: none;
}

/* Header */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 2rem;
  padding-bottom: 2.5rem;
}

.site-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.9375rem;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
}

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

.site-header nav a[aria-current="page"] {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.45em;
}

#theme-toggle {
  display: inline-flex;
  padding: 0.25rem;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

#theme-toggle:hover {
  color: var(--fg);
}

.icon {
  width: 1.125rem;
  height: 1.125rem;
}

.icon-sun,
html.dark .icon-moon {
  display: none;
}

html.dark .icon-sun {
  display: block;
}

@media (min-width: 48rem) {
  .site-header {
    padding-top: 3rem;
    padding-bottom: 3.5rem;
  }
}

/* Footer */

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 1.25rem;
  padding-bottom: 2.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.site-footer-end {
  display: flex;
  gap: 1.25rem;
}

#visits:empty {
  display: none;
}

.site-footer a {
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--fg);
  text-decoration: underline;
}

.muted {
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Front page statement */

.intro {
  max-width: 34rem;
  margin: 0 0 3rem;
  font-size: 1em;
  font-weight: 400;
  line-height: 1.6;
}

/* Section and listing headings */

.page-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.blurb {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.blurb a {
  color: var(--accent);
}

.page-head {
  margin-bottom: 2.5rem;
}

/* Sign-up form for new-post emails */

.subscribe label {
  display: block;
  color: var(--muted);
  font-size: 0.9375rem;
}

.subscribe-row {
  display: flex;
  gap: 0.5rem;
  max-width: 26rem;
  margin-top: 0.625rem;
}

.subscribe input[type="email"],
.subscribe button {
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.subscribe input[type="email"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
}

.subscribe input[type="email"]::placeholder {
  color: var(--muted);
}

.subscribe button {
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  font-weight: 700;
  cursor: pointer;
}

.subscribe button:hover {
  opacity: 0.85;
}

.subscribe-trap {
  position: absolute;
  left: -100rem;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.post-subscribe {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

#newsletter-body {
  margin-top: 1rem;
}

/* The index of writing: one row per piece, grouped by year */

.index-year {
  margin: 2.5rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1;
}

.index-year:first-of-type {
  margin-top: 0;
}

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

.index-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "date kind"
    "title title";
  gap: 0.125rem 1rem;
  padding: 0.5rem 0;
}

.index-date,
.index-kind,
.index-status {
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.index-date {
  grid-area: date;
}

.index-kind {
  grid-area: kind;
  justify-self: end;
}

.index-title {
  grid-area: title;
  font-size: 1.0625rem;
  line-height: 1.35;
}

.index-title a {
  text-decoration: none;
}

.index-title a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.index-status {
  margin-left: 0.5rem;
  font-style: italic;
}

@media (min-width: 40rem) {
  .index-row {
    grid-template-columns: 4.25rem minmax(0, 1fr) auto;
    grid-template-areas: "date title kind";
    align-items: baseline;
    column-gap: 1.5rem;
  }

  .index-date,
  .index-kind {
    font-size: 0.875rem;
  }

  .index-title {
    font-size: 1.125rem;
  }
}

/* A post or page: meta in the rail, text in the reading column */

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.post-kind {
  margin: 0;
  color: var(--fg);
  font-weight: 700;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.875rem;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-tags a {
  text-decoration: none;
}

.post-tags a:hover {
  color: var(--fg);
  text-decoration: underline;
}

.post-title {
  margin: 0 0 2rem;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

@media (min-width: 60rem) {
  .post {
    display: grid;
    grid-template-columns: var(--rail) minmax(0, var(--measure));
    column-gap: var(--gap);
  }

  .post-meta {
    display: block;
    margin: 0;
    padding-top: 0.625rem;
  }

  .post-tags {
    display: block;
    margin-top: 1.25rem;
  }

  .post-main {
    grid-column: 2;
  }

  .post-title {
    margin-bottom: 2.5rem;
    font-size: 2.25rem;
  }
}

/* Post body */

.prose > * {
  margin-top: 0;
  margin-bottom: 0;
}

.prose > * + * {
  margin-top: 1.25rem;
}

.prose > .post-credit {
  color: var(--muted);
  font-size: 0.875rem;
}

.prose h2,
.prose h3,
.prose h4 {
  font-weight: 700;
  line-height: 1.25;
  scroll-margin-top: 1rem;
}

.prose > h2 {
  margin-top: 3rem;
  font-size: 1.375em;
  letter-spacing: -0.015em;
}

.prose > h3 {
  margin-top: 2.25rem;
  font-size: 1.125em;
  letter-spacing: -0.01em;
}

.prose > h4 {
  margin-top: 2rem;
  font-size: 1em;
}

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

.prose a:hover {
  text-decoration-thickness: 2px;
}

.prose ul,
.prose ol {
  padding-left: 1.4rem;
}

.prose li + li,
.prose li > ul,
.prose li > ol {
  margin-top: 0.4rem;
}

.prose li::marker {
  color: var(--muted);
}

.prose img {
  max-width: 100%;
  height: auto;
}

.prose hr {
  margin: 3rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--fg);
  color: var(--muted);
}

.prose code {
  font-family: var(--mono);
  font-size: 0.875em;
}

.prose :not(pre) > code {
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: var(--code-bg);
}

.prose pre {
  padding: 1rem 1.125rem;
  overflow-x: auto;
  border-radius: 3px;
  background: var(--pre-bg);
  font-size: 0.8125rem;
  line-height: 1.65;
}

.prose pre code {
  font-size: inherit;
}

.prose figure {
  margin-left: 0;
  margin-right: 0;
}

/* Tables written as HTML inside a post or figure */

.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.875em;
}

.prose th,
.prose td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.prose th {
  font-weight: 700;
}

/* Markdown tables: rules above and below, one under the header, none between columns */

.table-wrap {
  overflow-x: auto;
}

.prose > .table-wrap {
  margin-top: 1.75rem;
  margin-bottom: 1.75rem;
}

.table-wrap > table {
  display: table;
  width: 100%;
  border-top: 2px solid var(--fg);
  border-bottom: 2px solid var(--fg);
  font-size: 0.9375rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.table-wrap th,
.table-wrap td {
  padding: 0.5rem 1.25rem 0.5rem 0;
  border-bottom: 0;
  vertical-align: top;
}

.table-wrap th {
  border-bottom: 1px solid var(--fg);
  vertical-align: bottom;
}

.table-wrap tbody tr + tr > td {
  border-top: 1px solid var(--border);
}

.table-wrap th:last-child,
.table-wrap td:last-child {
  padding-right: 0;
}

/* Code highlighting (highlight.js class names) */

.hljs-comment,
.hljs-quote {
  color: var(--hl-comment);
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-doctag,
.hljs-deletion {
  color: var(--hl-keyword);
}

.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-symbol {
  color: var(--hl-string);
}

.hljs-number,
.hljs-built_in,
.hljs-type {
  color: var(--hl-number);
}

.hljs-title,
.hljs-section,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
  color: var(--hl-title);
}

.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-template-variable,
.hljs-meta {
  color: var(--hl-attr);
}
