:root {
  --bg: #ffffff;
  --fg: #101010;
  --muted: #6b6b6b;
  --rule: #e5e5e5;
  --shade: #f5f5f5;

  --sans:
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Charter", "Georgia", "Times New Roman", serif;
  --mono:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono",
    monospace;

  --measure: 40rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0b;
    --fg: #ededed;
    --muted: #9a9a9a;
    --rule: #262626;
    --shade: #161616;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 19px;
  line-height: 1.7;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: 1.5rem;
}

/* ----------------------------- links ----------------------------- */

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--rule);
  transition: text-decoration-color 0.15s ease;
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ----------------------------- header ---------------------------- */

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 3.5rem 0;
}

.brand {
  text-decoration: none;
  color: var(--fg);
  font-size: 2.35rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.rss {
  display: inline-flex;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.rss:hover {
  color: var(--fg);
}

/* ------------------------------ main ----------------------------- */

main.wrap {
  flex: 1 0 auto;
  padding-block: 3rem 7rem;
}

main.wrap--bare {
  padding-top: 5rem;
}

.backlink {
  padding-block: 3.5rem 0;
  font-size: 0.95rem;
}

.backlink a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.backlink a:hover {
  color: var(--fg);
}

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

.prose h1,
.prose h2,
.prose h3,
.page-title,
.post-title {
  font-family: var(--sans);
  letter-spacing: -0.03em;
  line-height: 1.15;
  font-weight: 600;
  text-wrap: balance;
}

.prose h1,
.page-title {
  margin: 0 0 1.25rem;
}

.prose h2 {
  font-size: 1.35rem;
  margin: 2.75rem 0 0.85rem;
}

.prose h3 {
  font-size: 1.1rem;
  margin: 2rem 0 0.6rem;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.35rem;
}

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

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

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

.prose img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--rule);
}

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

.prose blockquote {
  margin: 2rem 0;
  padding: 0.15rem 0 0.15rem 1.25rem;
  border-left: 2px solid var(--fg);
  font-family: var(--serif);
  font-size: 1.12rem;
  font-style: italic;
  color: var(--fg);
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose strong {
  font-weight: 600;
}

/* code */

.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--shade);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.prose pre {
  background: var(--shade);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 0 0 1.6rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.6rem;
  font-size: 0.95rem;
}

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

/* ---------------------------- page lede -------------------------- */

.page-lede {
  color: var(--muted);
  margin: -0.4rem 0 2.5rem;
  font-size: 1rem;
}

/* --------------------------- post list --------------------------- */

ul.post-list {
  list-style: none;
  margin: 2.5rem 0 0;
  padding: 0;
}

.page-lede + ul.post-list {
  margin-top: 0;
}

.post-list__item + .post-list__item {
  margin-top: 0.5rem;
}

.post-list__link {
  text-decoration: none;
}

.post-list__title {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.post-list__link:hover .post-list__title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.post-list__date {
  margin-left: 0.6rem;
  font-size: 0.92rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ----------------------------- post ------------------------------ */

.post-header {
  margin-bottom: 2.5rem;
}

.post-title {
  margin: 0;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.9rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.post-meta a[rel="author"] {
  color: var(--fg);
  font-weight: 600;
}

a.tag {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

a.tag:hover {
  color: var(--fg);
  border-bottom-color: currentColor;
}

.tag::before {
  content: "#";
  opacity: 0.6;
}

/* --------------------------- tag archive ------------------------- */

.archive-kicker {
  margin: 0 0 0.6rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.archive-kicker + .page-title {
  margin-bottom: 0.75rem;
}

/* ---------------------------- post nav --------------------------- */

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 4rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
}

.post-nav__link {
  display: grid;
  gap: 0.2rem;
  max-width: 15rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.post-nav__link:hover span:last-child {
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.post-nav__link--next {
  margin-left: auto;
  text-align: right;
}

.post-nav__label {
  font-size: 0.88rem;
  color: var(--muted);
}

/* ----------------------------- footer ---------------------------- */

.site-footer {
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer__inner {
  padding-block: 0 3rem;
}

.site-footer a {
  text-decoration-color: var(--rule);
}

/* --------------------------- responsive -------------------------- */

@media (max-width: 34rem) {
  body {
    font-size: 17px;
  }

  .site-header__inner {
    padding-block: 2.5rem 0;
  }

  .brand {
    font-size: 1.9rem;
  }

  main.wrap {
    padding-block: 2.5rem 5rem;
  }

  main.wrap--bare {
    padding-top: 3.5rem;
  }

  .backlink {
    padding-block: 2.5rem 0;
  }

  .site-footer__inner {
    padding-block: 0 2.5rem;
  }

  .post-list__title {
    font-size: 1.25rem;
  }

  .post-nav {
    flex-direction: column;
  }

  .post-nav__link--next {
    margin-left: 0;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ------------------------ syntax highlighting -------------------- */

.highlight .c,
.highlight .c1,
.highlight .cm,
.highlight .cs {
  color: var(--muted);
  font-style: italic;
}

.highlight .k,
.highlight .kd,
.highlight .kn,
.highlight .kr,
.highlight .kt,
.highlight .kc {
  font-weight: 600;
}

.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .sb,
.highlight .sd,
.highlight .se,
.highlight .si,
.highlight .sx,
.highlight .sr {
  opacity: 0.78;
}

.highlight .nf,
.highlight .nc,
.highlight .nb {
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 0.2em;
}

.highlight .m,
.highlight .mi,
.highlight .mf {
  opacity: 0.78;
}
