@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&display=swap');

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

:root {
  --bg:      #F0EAD6;
  --text:    #0C0B08;
  --muted:   #635D52;
  --faint:   #A09A8E;
  --border:  #D5CEBC;
  --base:    17px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:      #1B1814;
  --text:    #ECE6D5;
  --muted:   #8E8778;
  --faint:   #504940;
  --border:  #2E2920;
  color-scheme: dark;
}

html {
  font-size: var(--base);
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  font-weight: 400;
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

/* ─── Layout ─────────────────────────────────────────── */

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ─── Animations ──────────────────────────────────────── */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

header { animation: rise 0.4s ease both; }
main   { animation: rise 0.4s ease both; animation-delay: 0.08s; }
footer { animation: rise 0.4s ease both; animation-delay: 0.14s; }

/* ─── Header ──────────────────────────────────────────── */

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
  margin-bottom: 68px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 32px;
}

.site-name {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  transition: color 0.15s;
}

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

nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

nav a {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.01em;
  transition: color 0.15s;
}

nav a:hover,
nav a.current {
  color: var(--text);
}

/* ─── Theme toggle ────────────────────────────────────── */

.theme-toggle {
  display: grid;
  place-items: center;
  overflow: visible;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--muted);
}

.theme-toggle svg {
  grid-area: 1 / 1;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.theme-toggle .icon-sun  { opacity: 0; }
.theme-toggle .icon-moon { opacity: 1; }

[data-theme="dark"] .theme-toggle .icon-sun  { opacity: 1; }
[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; }

/* ─── Main ────────────────────────────────────────────── */

main {
  padding-bottom: 100px;
}

/* ─── Intro (home) ────────────────────────────────────── */

.intro {
  margin-bottom: 64px;
}

.intro p {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 400;
  font-style: italic;
  line-height: 1.6;
  color: var(--text);
}

/* ─── Section header ──────────────────────────────────── */

.section-label {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 28px;
}

/* ─── Essay list ──────────────────────────────────────── */

.essays {
  list-style: none;
}

.essay {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0 28px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  transition: border-color 0.3s ease;
}

.essays .essay:last-child {
  border-bottom: 1px solid var(--border);
}

.essay-date {
  font-size: 0.75rem;
  color: var(--muted);
  padding-top: 3px;
  white-space: nowrap;
}

.essay-title {
  display: inline;
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  background-image: linear-gradient(var(--text), var(--text));
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0% 1px;
  transition: background-size 0.25s ease;
}

.essay-title:hover {
  background-size: 100% 1px;
}

.essay-excerpt {
  display: block;
  margin-top: 6px;
  font-size: 0.84rem;
  line-height: 1.65;
  color: var(--muted);
}

/* ─── "All posts" link ────────────────────────────────── */

.all-link {
  display: inline-block;
  margin-top: 36px;
  font-size: 0.82rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}

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

/* ─── Year divider (posts archive) ───────────────────── */

.year-group {
  margin-bottom: 8px;
}

.year-group + .year-group {
  margin-top: 52px;
}

.year-heading {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  margin-bottom: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  transition: border-color 0.3s ease;
}

/* ─── About page ──────────────────────────────────────── */

.about-text p {
  font-size: 1rem;
  line-height: 1.82;
  margin-bottom: 28px;
  color: var(--text);
}

.about-text p:last-child {
  margin-bottom: 0;
}

.about-text a {
  border-bottom: 1px solid var(--border);
  transition: border-color 0.15s;
}

.about-text a:hover {
  border-color: var(--text);
}

.contact-section {
  margin-top: 60px;
  padding-top: 36px;
  border-top: 1px solid var(--border);
  transition: border-color 0.3s ease;
}

.contact-section .section-label {
  margin-bottom: 20px;
}

.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contact-list li {
  font-size: 0.88rem;
  color: var(--muted);
}

.contact-list a {
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
  transition: border-color 0.15s;
}

.contact-list a:hover {
  border-color: var(--text);
}

/* ─── Footer ──────────────────────────────────────────── */

footer {
  padding: 32px 0 48px;
  border-top: 1px solid var(--border);
  transition: border-color 0.3s ease;
}

footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-copy {
  font-size: 0.75rem;
  color: var(--faint);
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  font-size: 0.75rem;
  color: var(--muted);
  transition: color 0.15s;
}

.footer-links a:hover {
  color: var(--text);
}

/* ─── Post page ───────────────────────────────────────── */

.post-back {
  display: inline-block;
  margin-bottom: 52px;
  font-size: 0.8rem;
  color: var(--muted);
  transition: color 0.15s;
}

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

.post-header {
  margin-bottom: 48px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
  transition: border-color 0.3s ease;
}

.post-title {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 14px;
}

.post-date {
  font-size: 0.8rem;
  color: var(--muted);
  display: block;
}

.posts-loading {
  color: var(--muted);
  font-size: 0.84rem;
}

/* ─── Rendered markdown ───────────────────────────────── */

.post-content {
  font-size: 1rem;
  line-height: 1.85;
}

.post-content h2 {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 52px 0 16px;
  color: var(--text);
}

.post-content h3 {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: 1rem;
  font-weight: 700;
  margin: 40px 0 12px;
  color: var(--text);
}

.post-content p {
  margin-bottom: 24px;
}

.post-content p:last-child {
  margin-bottom: 0;
}

.post-content blockquote {
  border-left: 2px solid var(--border);
  padding-left: 22px;
  margin: 32px 0;
  color: var(--muted);
  font-style: italic;
}

.post-content blockquote p {
  margin-bottom: 0;
}

.post-content a {
  border-bottom: 1px solid var(--border);
  transition: border-color 0.15s;
}

.post-content a:hover {
  border-color: var(--text);
}

.post-content ul,
.post-content ol {
  padding-left: 22px;
  margin-bottom: 24px;
}

.post-content li {
  margin-bottom: 8px;
  line-height: 1.72;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 52px 0;
}

.post-content strong {
  font-weight: 700;
}

.post-content code {
  font-family: 'SFMono-Regular', 'Fira Code', Menlo, monospace;
  font-size: 0.875em;
  background: var(--border);
  padding: 2px 6px;
  border-radius: 3px;
}

.post-content pre {
  background: var(--border);
  padding: 18px 22px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 28px 0;
  line-height: 1.6;
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
}

/* ─── Responsive ──────────────────────────────────────── */

@media (max-width: 600px) {
  :root {
    --base: 16px;
  }

  header {
    padding: 14px 0;
    margin-bottom: 48px;
  }

  .intro p {
    font-size: 1.15rem;
  }

  .essay {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 20px 0;
  }

  .essay-date {
    padding-top: 0;
  }

  nav {
    gap: 18px;
  }

  .year-group + .year-group {
    margin-top: 40px;
  }

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

@media (max-width: 400px) {
  .container {
    padding: 0 20px;
  }

  header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}
