:root {
  --bg: #fcfcfa;
  --heading: #181818;
  --text: #343434;
  --muted: #6e6e6e;
  --border: #e2e2dd;
  --accent: #1f3a5f;
  --accent-hover: #12263f;
  --track-bg: #ececea;

  --page-width: 720px;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-serif: "Lora", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Space Mono", "SF Mono", "Fira Code", "JetBrains Mono", Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #17181a;
  --heading: #f2f2f0;
  --text: #d3d3d0;
  --muted: #93938e;
  --border: #34363a;
  --accent: #7fa8d9;
  --accent-hover: #a3c2e8;
  --track-bg: #26282c;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.66;
  letter-spacing: 0.003em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  transition: background 0.15s ease, color 0.15s ease;
}

main {
  width: min(var(--page-width), calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.45rem;
  color: var(--heading);
  line-height: 1.22;
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
}

h1 {
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 440;
  font-variation-settings: "opsz" 40;
  letter-spacing: -0.015em;
  line-height: 1.08;
}

p {
  margin: 0 0 0.9rem;
  font-family: var(--font-serif);
}

a {
  color: var(--accent);
  text-underline-offset: 0.14em;
}

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

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

/* Header / nav */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.9rem 1.25rem 0.8rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(var(--page-width), calc(100% - 2.5rem));
  margin: 0 auto;
}

.site-name {
  margin: 0;
  font-size: 0.92rem;
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0;
}

.site-name a {
  padding: 0.1rem 0;
  text-decoration: none;
  color: var(--muted);
}

.site-name a:hover {
  color: var(--heading);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1.3rem;
}

.internal-links {
  display: flex;
  gap: 0.9rem;
}

.internal-links a {
  padding: 0.1rem 0;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 500;
}

.internal-links a:hover {
  color: var(--heading);
}

/* Theme toggle */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: var(--muted);
}

.theme-toggle .icon {
  width: 0.95rem;
  height: 0.95rem;
  flex: none;
  fill: currentColor;
}

.theme-toggle .track {
  position: relative;
  width: 2.15rem;
  height: 1.15rem;
  border-radius: 999px;
  background: var(--track-bg);
  border: 1px solid var(--border);
  transition: background 0.15s ease;
}

.theme-toggle .thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transform: translateX(0);
  transition: transform 0.18s ease;
}

[data-theme="dark"] .theme-toggle .thumb {
  transform: translateX(1rem);
}

/* Bio (home page) */

.bio {
  margin-bottom: 1.9rem;
}

.tagline {
  margin: 0 0 1.35rem;
  padding-bottom: 1.35rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.tagline::before {
  content: "> ";
  color: var(--accent);
}

.portrait {
  float: right;
  width: clamp(220px, 24vw, 280px);
  margin: 0 0 1rem 1.6rem;
}

.portrait img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 7px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .portrait img {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.45);
}

.bio-copy::after {
  content: "";
  display: block;
  clear: both;
}

/* Writing list / empty state */

.empty-state {
  color: var(--muted);
  font-family: var(--font-sans);
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.35rem;
}

.post-list h3 {
  margin: 0 0 0.3rem;
  font-size: 1.42rem;
  font-weight: 500;
}

.post-list a {
  color: inherit;
  text-decoration: none;
}

.post-list a:hover h3 {
  color: var(--heading);
  text-decoration: underline;
  text-decoration-color: var(--muted);
}

.post-list .description {
  margin: 0 0 0.36rem;
  font-family: var(--font-serif);
}

.post-list .meta {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.91rem;
}

/* Footer / contact links */

footer {
  width: min(var(--page-width), calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 1.4rem 1.25rem 2.5rem;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.88rem;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.9rem;
  margin: 0 0 0.8rem;
  padding: 0;
  list-style: none;
}

.contact-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
}

.contact-links a:hover {
  color: var(--accent);
}

.contact-links svg {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

.footer-meta {
  margin: 0;
  font-size: 0.8rem;
  text-align: center;
}

.sr-only {
  border: 0;
  padding: 0;
  margin: 0;
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 720px) {
  body {
    font-size: 1rem;
  }

  main {
    width: auto;
    padding: 1.5rem 1rem 2.5rem;
  }

  h1 {
    font-size: 2.3rem;
  }

  nav {
    width: auto;
  }

  .portrait {
    float: none;
    width: min(100%, 340px);
    max-width: 340px;
    margin: 0 0 1.25rem;
  }
}
