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

/* === Custom Properties === */
:root {
  --bg: #0e0e0e;
  --text: #e0e0e0;
  --heading: #f5f5f5;
  --muted: #666;
  --rule: #1a1a1a;
  --code-bg: #141414;
  --code-border: #1e1e1e;
  --accent: #e07020;

  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
  --mono: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', 'Source Code Pro', monospace;
}

/* === Base === */
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.8;
  max-width: 38em;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* === Links === */
a {
  color: var(--text);
  text-decoration: none;
}

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

/* === Index Page === */
.site-title {
  font-size: 2.4rem;
  font-weight: 300;
  color: var(--heading);
  letter-spacing: 0.02em;
}

.site-tagline {
  color: var(--muted);
  font-size: 1rem;
  margin-top: 0.25rem;
}

.site-rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 1.5rem 0;
}

.post-list {
  list-style: none;
}

.post-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.post-date {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

/* === Post Page === */
.back-link {
  display: inline-block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

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

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

.post-title {
  font-size: 2rem;
  font-weight: 400;
  color: var(--heading);
  line-height: 1.3;
}

.post-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* === Prose === */
article {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

article p + p {
  text-indent: 2em;
}

article p {
  margin: 0;
}

/* === Headings === */
article h2 {
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--heading);
  margin-top: 3rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
}

article h3 {
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--heading);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

/* Reset indent after non-paragraph elements */
article h2 + p,
article h3 + p,
article pre + p,
article blockquote + p,
article figure + p,
article .math-display + p {
  text-indent: 0;
}

/* === Blockquotes === */
blockquote {
  border-left: 2px solid var(--accent);
  margin: 1.5rem 0;
  padding: 0.25rem 1.5rem;
  color: var(--text);
  font-style: italic;
}

blockquote p:last-child {
  font-style: normal;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

blockquote + p {
  text-indent: 0;
}

/* === Code === */
code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 3px;
  padding: 1rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* === Figures === */
figure {
  margin: 2rem 0;
  text-align: center;
}

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

figcaption {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* === Footnotes === */
.footnotes {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
  color: var(--muted);
}

/* === KaTeX Overrides === */
.math-display {
  margin: 1.5rem 0;
  text-align: center;
}

.katex { font-size: 1.1em; }

/* === highlight.js Overrides === */
.hljs {
  background: var(--code-bg) !important;
}

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

  article {
    text-align: left;
    hyphens: none;
  }

  .site-title {
    font-size: 1.8rem;
  }

  .post-title {
    font-size: 1.5rem;
  }
}
