/* Base reset and box-sizing */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Root variables for easy theming */
:root {
  --font-body: Georgia, "Times New Roman", serif;
  --font-heading: system-ui, -apple-system, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --color-bg: #fefefe;
  --color-text: #222;
  --color-text-muted: #666;
  --color-link: #1a5f7a;
  --color-link-visited: #5c3d6e;
  --color-border: #ddd;
  --color-code-bg: #f5f5f5;

  --measure: 65ch;
  --spacing: 1.5rem;
}

/* Body and typography */
body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.6;
  margin: 0;
  padding: var(--spacing);
  max-width: var(--measure);
  margin-inline: auto;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.25;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

/* Links */
a {
  color: var(--color-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

a:hover, a:focus {
  text-decoration-thickness: 2px;
}

/* Header */
header {
  margin-bottom: 2rem;
}

header h1 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

header h1 a {
  text-decoration: none;
  color: inherit;
}

header h1 a:hover {
  text-decoration: underline;
}

nav {
  margin-bottom: 1rem;
}

nav a {
  margin-right: 1rem;
}

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

/* Article and main content */
main {
  margin-bottom: 3rem;
}

article h2 {
  margin-top: 0;
}

/* Post metadata (dates) */
article > p:first-of-type small {
  color: var(--color-text-muted);
  font-style: italic;
}

/* Paragraphs */
p {
  margin-top: 0;
  margin-bottom: 1rem;
}

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

li {
  margin-bottom: 0.25rem;
}

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

/* Code */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--color-code-bg);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

pre {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background-color: var(--color-code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 4px;
  line-height: 1.5;
}

pre code {
  padding: 0;
  background: none;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
}

/* Backlinks section */
section h3 {
  font-size: 1rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

/* Post list on homepage */
main ul a {
  font-size: 1.1rem;
}

/* Small text utility */
small {
  font-size: 0.875rem;
}

/* Focus styles for accessibility */
a:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  body {
    font-size: 1rem;
    padding: 1rem;
  }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.35rem; }
  h3 { font-size: 1.15rem; }
}
