/* Colors: light by default, dark when the reader's system is dark,
   and whatever they pick with the toggle wins over both. */

:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --line: #d6d6d6;
  --code-bg: #f4f4f4;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --text: #e8e8e8;
    --muted: #9e9e9e;
    --line: #3d3d3d;
    --code-bg: #1e1e1e;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121212;
  --text: #e8e8e8;
  --muted: #9e9e9e;
  --line: #3d3d3d;
  --code-bg: #1e1e1e;
  color-scheme: dark;
}

/* Base */

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans",
    "Helvetica Neue", Arial, sans-serif;
  font-size: 1.125rem;
  line-height: 1.7;
}

@media (min-width: 40rem) {
  body {
    font-size: 1.1875rem;
  }
}

.site,
main {
  max-width: 40rem;
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--line);
}

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

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

/* Header: name on the left, theme toggle on the far right */

.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 2rem;
  padding-bottom: 3.5rem;
}

.site h1 {
  margin: 0;
  font-size: inherit;
  line-height: inherit;
}

.name {
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

/* The silent "te" in Bytenary */
.silent {
  font-weight: 400;
  color: var(--muted);
}

.theme {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: -0.625rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.js .theme {
  display: inline-flex;
}

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

/* Post list */

.posts {
  list-style: none;
  margin: 0;
  padding: 0 0 6rem;
}

.posts li {
  margin-bottom: 1.75rem;
}

.posts a {
  font-weight: 600;
  font-size: 1.1em;
  line-height: 1.4;
  text-decoration: none;
}

.posts a:hover {
  text-decoration: underline;
  text-decoration-color: var(--line);
}

.posts time {
  display: block;
  margin-top: 0.2rem;
}

time {
  color: var(--muted);
  font-size: 0.9em;
}

/* Post */

article {
  padding-bottom: 6rem;
}

article h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.85rem, 1.4rem + 1.8vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

article > time {
  display: block;
  margin-bottom: 2.75rem;
}

.content h2,
.content h3 {
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.content h2 {
  margin: 2.75rem 0 0.75rem;
  font-size: 1.35em;
}

.content h3 {
  margin: 2.25rem 0 0.5rem;
  font-size: 1.1em;
}

.content p {
  margin: 0 0 1.25em;
  text-wrap: pretty;
}

.content ul,
.content ol {
  margin: 0 0 1.25em;
  padding-left: 1.4em;
}

.content li {
  margin-bottom: 0.5em;
}

.content blockquote {
  margin: 2rem 0;
  padding: 0.1rem 0 0.1rem 1.25rem;
  border-left: 3px solid var(--text);
}

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

dfn {
  font-style: normal;
  font-weight: 600;
}

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

.content hr {
  margin: 2.75rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: var(--code-bg);
}

pre {
  overflow-x: auto;
  margin: 0 0 1.25em;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  background: var(--code-bg);
  font-size: 0.85em;
  line-height: 1.55;
}

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