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

:root {
  --fg: #111;
  --bg: #f5f5f0;
  --muted: #777;
  --accent: #111;
  --font-sans: 'Space Grotesk', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-serif: 'Space Grotesk', Georgia, 'Times New Roman', serif;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
}

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

/* ── Homepage ── */
.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  padding: 3rem 2.5rem 1rem;
}

.site-title {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.post-list {
  list-style: none;
  padding: 1rem 2.5rem 4rem;
  flex: 1;
}

.post-list li {
  border-top: 1px solid #e0e0e0;
}

.post-list li:last-child {
  border-bottom: 1px solid #e0e0e0;
}

.post-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 0;
  transition: opacity 0.15s ease;
}

.post-link:hover {
  opacity: 0.55;
}

.post-link-title {
  font-size: clamp(2rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--fg);
}

.pin-icon {
  width: 0.5em;
  height: 0.5em;
  vertical-align: baseline;
  margin-right: 0.15em;
  stroke: var(--muted);
  flex-shrink: 0;
}

.post-link-year {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Post ── */
.post {
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
}

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

.back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 2.5rem;
  transition: color 0.15s ease;
}

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

.post-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.post-date {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

.post-body {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.75;
  color: #333;
}

.post-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-body p {
  margin-bottom: 1.5rem;
}

.post-body h2 {
  font-family: var(--font-sans);
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--fg);
}

.post-body h3 {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--fg);
}

.post-body ul, .post-body ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.post-body li {
  margin-bottom: 0.4rem;
}

.post-body blockquote {
  border-left: 3px solid #ddd;
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--muted);
  font-style: italic;
}

.post-body code {
  font-family: 'Space Mono', monospace;
  font-size: 0.85em;
  background: #f0f0f0;
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.post-body pre {
  background: #1a1a1a;
  color: #e0e0e0;
  padding: 1.25rem 1.5rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem -2rem;
  line-height: 1.5;
}

.post-body pre code {
  background: none;
  padding: 0;
  font-size: 0.8rem;
  color: inherit;
}

.post-body table {
  width: calc(100% + 8rem);
  margin-left: -4rem;
  border-collapse: collapse;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.post-body thead {
  border-bottom: 2px solid var(--fg);
}

.post-body th {
  text-align: left;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
}

.post-body td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #e8e8e8;
}

.post-body td a,
.post-body th a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-body tr:last-child td {
  border-bottom: 2px solid var(--fg);
  font-weight: 600;
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 0.5rem 0 1rem;
}

/* ── Figures ── */
.post-body figure {
  margin: 0;
}

.post-body figcaption {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
  margin-top: 0.35rem;
}

.post-body .figure-margin {
  float: right;
  width: 240px;
  margin: 0.25rem -300px 1rem 1.5rem;
  clear: right;
}

.post-body .figure-margin img {
  width: 100%;
  border-radius: 4px;
  margin: 0;
}

.post-body .figure-inline {
  margin: 2rem -4rem;
}

.post-body .figure-inline img {
  width: 100%;
  border-radius: 4px;
  margin: 0;
}

.post-body .figure-inline figcaption {
  padding: 0 4rem;
  margin-top: 0.5rem;
}

.post-body hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 2.5rem 0;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .post-body .figure-margin {
    float: none;
    width: 100%;
    margin: 1.5rem 0;
  }
}

@media (max-width: 600px) {
  .site-header {
    padding: 2rem 1.25rem 0.5rem;
  }

  .post-list {
    padding: 0.5rem 1.25rem 3rem;
  }

  .post-link {
    flex-direction: column;
    gap: 0.15rem;
    padding: 1rem 0;
  }

  .post-link-year {
    order: -1;
    font-size: 0.75rem;
  }

  .post {
    padding: 2rem 1.25rem 4rem;
  }

  .post-body table {
    width: calc(100% + 2.5rem);
    margin-left: -1.25rem;
    font-size: 0.7rem;
    display: block;
    overflow-x: auto;
  }

  .post-body .figure-margin {
    float: none;
    width: 100%;
    margin: 1.5rem 0;
  }

  .post-body .figure-inline {
    margin: 1.5rem -1.25rem;
  }

  .post-body .figure-inline figcaption {
    padding: 0 1.25rem;
  }
}
