:root {
  --bg: #fbfaf7;
  --fg: #1d1d1f;
  --muted: #6b6b70;
  --rule: #e4e2dc;
  --accent: #1f3a5f;
  --code-bg: #f1efe9;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616;
    --fg: #e8e6e1;
    --muted: #9a9894;
    --rule: #2e2d2b;
    --accent: #8fb4e3;
    --code-bg: #222120;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0 auto;
  max-width: 44rem;
  padding: 0 1.25rem;
  background: var(--bg);
  color: var(--fg);
  font: 1.125rem/1.7 var(--serif);
}

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

/* Header / footer */
.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  padding: 2rem 0 1.25rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
}
.site-title { font-weight: 700; font-size: 1.25rem; color: var(--fg); text-decoration: none; letter-spacing: -0.01em; }
.site-subtitle { font-weight: 400; color: var(--muted); }
.site-header nav { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; font-size: 0.9rem; }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--accent); }

.site-footer {
  margin-top: 4rem;
  padding: 1.5rem 0 3rem;
  border-top: 1px solid var(--rule);
  font: 0.85rem var(--sans);
  color: var(--muted);
}
.site-footer a { color: inherit; }
.site-footer p { margin: 0.25rem 0; }

/* Icon links (LinkedIn, GitHub, RSS) */
.icon { display: block; }
.icon-link { display: inline-flex; color: var(--muted); }
.icon-link:hover { color: var(--accent); }
.nav-icons { display: inline-flex; align-items: center; gap: 0.9rem; }
.social { display: flex; gap: 1rem; margin-top: 0.75rem !important; }

/* Shared bits */
.meta, .kicker { font: 0.85rem/1.5 var(--sans); color: var(--muted); margin: 0.25rem 0; }
.kicker { text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; font-size: 0.75rem; }

.intro { padding: 2.5rem 0 0.5rem; }
.intro p { color: var(--muted); margin: 0.25rem 0; }
.intro h1 { font-size: 2rem; line-height: 1.2; margin: 0.25rem 0; }

/* Post list */
.post-list { list-style: none; padding: 0; margin: 0; }
.post-card { padding: 1.75rem 0; border-bottom: 1px solid var(--rule); }
.post-card:last-child { border-bottom: 0; }
.post-card h2 { font-size: 1.4rem; line-height: 1.3; margin: 0.25rem 0 0.5rem; }
.post-card h2 a { color: var(--fg); text-decoration: none; }
.post-card h2 a:hover { color: var(--accent); }
.post-card > p:last-child { margin: 0; color: var(--muted); font-size: 1rem; }

/* Article */
.post > header { padding: 2.5rem 0 1rem; }
.post h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); line-height: 1.2; margin: 0.25rem 0 0.75rem; letter-spacing: -0.01em; }

.prose h2 { font-size: 1.5rem; line-height: 1.3; margin: 2.5rem 0 0.75rem; }
.prose h3 { font-size: 1.2rem; line-height: 1.35; margin: 2rem 0 0.5rem; }
.prose h4 { font-size: 1.05rem; margin: 1.75rem 0 0.5rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: 0.35rem 0; }
.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
.prose img { max-width: 100%; height: auto; }

code { font: 0.85em var(--mono); background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }
pre {
  background: var(--code-bg);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.5;
}
pre code { background: none; padding: 0; font-size: 0.85rem; }

.post-footer { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 0.9rem; }
.source { color: var(--muted); }
.post-nav { display: flex; justify-content: space-between; gap: 1.5rem; margin-top: 1.5rem; }
.post-nav a { text-decoration: none; max-width: 48%; }
.post-nav a[rel="next"] { text-align: right; }

/* Standalone pages */
/* Photo sits to the left of the first paragraph; the text wraps round it. */
.portrait {
  float: left;
  width: 120px; height: 120px;
  object-fit: cover;
  border-radius: 50%;
  margin: 0.35rem 1.5rem 0.75rem 0;
}
.prose h2 { clear: both; }
@media (max-width: 480px) { .portrait { width: 96px; height: 96px; margin-right: 1rem; } }

/* Home page: photo to the left of the intro, text centred beside it */
.intro-photo { display: flex; align-items: center; gap: 1.5rem; }
.intro-photo .portrait { float: none; flex: none; margin: 0; }
@media (max-width: 480px) { .intro-photo { gap: 1rem; } }
.nowrap { white-space: nowrap; }

/* Linked images (e.g. project cards on the Links page) */
.prose a:has(> img) { display: block; margin: 0.75rem 0; }
.prose a > img { display: block; border: 1px solid var(--rule); border-radius: 8px; }
.prose a:hover > img { border-color: var(--accent); }

/* Lighter list: "The Classics I Still Dip Into" on the Links page */
.prose h3#the-classics-i-still-dip-into { font-size: 1.05rem; color: var(--muted); font-family: var(--sans); }
.prose h3#the-classics-i-still-dip-into + ul { list-style: none; padding-left: 0; font-size: 1rem; color: var(--muted); }
.prose h3#the-classics-i-still-dip-into + ul li { margin: 0.2rem 0; }
.prose h3#the-classics-i-still-dip-into + ul strong { color: var(--fg); font-weight: 600; }

/* Closing line at the end of a page */
.prose .closing { margin-top: 3rem; }

@media (max-width: 480px) { .site-header nav { gap: 0.9rem; } }

/* Watermark: rainbow bars hanging from the top right, and the same bars rising from the bottom left. */
html { position: relative; min-height: 100%; }
body::before, body::after {
  content: "";
  position: absolute;
  width: 230px;
  height: 65px;
  background: url("watermark.svg") no-repeat center / contain;
  opacity: 0.3;
  pointer-events: none;
  z-index: -1;
}
body::before { top: 0; right: 0; }
body::after { bottom: 0; left: 0; transform: scale(-1, -1); }
@media (prefers-color-scheme: dark) { body::before, body::after { opacity: 0.35; } }
@media (max-width: 700px) { body::before, body::after { width: 100px; height: 28px; } }

/* Footer: right aligned, away from the bottom-left watermark */
.site-footer { text-align: right; }
.site-footer .social { justify-content: flex-end; }
