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

:root {
  --bg: #1a1b26;
  --bg-light: #24283b;
  --text: #c0caf5;
  --text-muted: #565f89;
  --accent: #7aa2f7;
  --accent-hover: #89b4fa;
  --border: #3b4261;
}

html {
  font-size: 18px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
  width: 100%;
  max-width: 65ch;
  margin: 0 auto;
  padding: 2rem 1rem;
}

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

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Header */
header {
  border-bottom: 1px solid var(--border);
}

header nav {
  max-width: 65ch;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  align-items: center;
}

.site-name {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 1.2rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.site-name:hover {
  text-decoration: none;
}

/* Inherits the link colour, including on hover */
.snowman {
  width: 2rem;
  height: 2rem;
  flex: none;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

footer a {
  color: var(--text-muted);
}

footer a:hover {
  color: var(--accent);
}

/* Post listing */
.post-list {
  list-style: none;
  padding-left: 0;
}

.post-list > li::before {
  content: none;
}

.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.post-list time {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Article */
article time {
  display: block;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

article h1 {
  font-size: 1.8rem;
  line-height: 1.3;
  margin-bottom: 0.25rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: #e0e4ff;
}

h2 {
  font-size: 1.4rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

h3 {
  font-size: 1.15rem;
  color: var(--text);
}

p {
  margin-bottom: 1rem;
  text-align: justify;
  text-justify: inter-character;
  text-wrap: pretty;
  hyphens: auto;
}

ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

ul {
  list-style: none;
}

ul > li::before {
  content: "–";
  color: var(--text-muted);
  display: inline-block;
  width: 1.2em;
  margin-left: -1.2em;
}

li + li {
  margin-top: 0.25rem;
}

ul > li {
  text-align: justify;
  text-justify: inter-character;
  text-wrap: pretty;
  hyphens: auto;
}

ol > li {
  text-wrap: pretty;
}

/* Code */
code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.9em;
  background: var(--bg-light);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}

pre {
  margin-bottom: 1rem;
  padding: 1rem;
  overflow-x: auto;
  border-radius: 6px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  scrollbar-color: var(--border) transparent;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.85rem;
}

/* Tables */
table {
  width: 100%;
  margin-bottom: 1rem;
  border-collapse: collapse;
}

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

th {
  background: var(--bg-light);
  font-weight: 700;
}

tr:nth-child(even) {
  background: rgba(36, 40, 59, 0.5);
}

/* Blockquotes */
blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* Centre images narrower than the column, which justified text would left-align */
p:has(> img),
p:has(> a > img) {
  text-align: center;
}

/* Downscaled images link to the original */
a:has(> img) {
  display: inline-block;
  cursor: zoom-in;
}

a:has(> img):hover {
  text-decoration: none;
}

/* Image captions: a paragraph of only italic text following an image */
img + em,
a:has(> img) + em,
p:has(> img) + p > em:only-child,
p:has(> a > img) + p > em:only-child {
  display: block;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

/* Emphasis */
em {
  font-style: italic;
}

strong {
  font-weight: 700;
}
