:root {
  --theme-color: rgba(53, 152, 219, 1);
  --theme-color-dark: rgba(33, 110, 165, 1);
  --bg-color: rgba(248, 248, 246, 1);
  --text-dark: #1a1a24;
  --text-muted: #5a5a66;
}

body {
  background-color: var(--bg-color);
  color: var(--text-dark);
  padding: 24px 40px;
  /* Override the row-flex centering inherited from styles.css. A column layout
     keeps the content width fixed (capped at 1200px, centered) no matter how
     many posts the filter shows — otherwise the row-flex sizes the column to its
     content, so years with shorter titles shift the whole block sideways. */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  overflow: visible;
  font-family: 'Inter', sans-serif;
  line-height: 1.6;
}

/* Back Link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 1.1rem;
  margin-bottom: 0;
  transition: color 0.2s;
}

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

/* Sticky Top Bar (home button stays pinned) */
.page-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-color);
  padding: 14px 0;
  margin-bottom: 12px;
}

/* ===========================
   Index: post list
   =========================== */
.blog-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- Filter bar (search + year chips) ---- */
.blog-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 4px;
}

.blog-search {
  flex: 1 1 240px;
  max-width: 340px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-dark);
  padding: 9px 16px;
  border: 1px solid #d7d7d7;
  border-radius: 50px;
  background: white;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.blog-search::placeholder {
  color: #9a9aa3;
}

.blog-search:focus {
  border-color: var(--theme-color);
  box-shadow: 0 0 0 3px rgba(53, 152, 219, 0.15);
}

.year-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.year-chip {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: white;
  border: 1px solid #d7d7d7;
  border-radius: 50px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.year-chip:hover {
  border-color: var(--theme-color);
  color: var(--theme-color-dark);
}

.year-chip.is-active {
  background: var(--theme-color);
  border-color: var(--theme-color);
  color: white;
}

.year-chip .year-count {
  opacity: 0.7;
  font-weight: 500;
  font-size: 0.78rem;
}

.blog-noresults {
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 32px 0;
}

.post-card {
  background: white;
  border-radius: 24px;
  padding: 18px 22px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
  display: flex;
  gap: 20px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  border-left: 4px solid transparent;
  transition: transform 0.3s ease, border-left-color 0.3s ease, box-shadow 0.3s ease;
}

.post-card:hover {
  transform: translateY(-3px);
  border-left-color: var(--theme-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.post-thumb-col {
  flex-shrink: 0;
  width: 120px;
  height: 80px;
}

.post-thumb {
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 12px;
  filter: grayscale(60%);
  transition: filter 0.3s ease;
  background: #eee;
}

.post-card:hover .post-thumb {
  filter: grayscale(0%);
}

.post-thumb--empty {
  background: linear-gradient(135deg, #e8eef3, #d6e2ec);
}

.post-card-body {
  flex-grow: 1;
  min-width: 0;
}

.post-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.35;
  margin-bottom: 6px;
}

.post-card:hover .post-card-title {
  color: var(--theme-color-dark);
}

.post-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.post-labels,
.post-article-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.post-label {
  background-color: var(--theme-color);
  color: white;
  padding: 3px 12px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ===========================
   Post page (article)
   =========================== */
.post-article {
  max-width: 760px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.post-allposts {
  display: inline-block;
  text-decoration: none;
  color: var(--theme-color-dark);
  font-weight: 600;
  font-size: 0.95rem;
  margin: 4px 0 18px;
  transition: opacity 0.2s;
}

.post-allposts:hover {
  opacity: 0.7;
}

.post-article-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-dark);
  margin-bottom: 10px;
}

.post-article-meta {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 12px;
}

.post-article-labels {
  margin-bottom: 8px;
}

.post-divider {
  border: none;
  border-top: 1px solid #e2e2e2;
  margin: 20px 0;
}

/* Long-form content typography */
.post-content {
  font-size: 1.02rem;
  color: #2a2a33;
  line-height: 1.75;
}

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

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  margin: 28px 0 12px;
  line-height: 1.3;
  color: var(--text-dark);
}

.post-content a {
  color: var(--theme-color-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 20px auto;
  border-radius: 12px;
}

.post-content ul,
.post-content ol {
  margin: 0 0 16px 1.4em;
}

.post-content li {
  margin-bottom: 6px;
}

.post-content blockquote {
  border-left: 4px solid var(--theme-color);
  margin: 16px 0;
  padding: 4px 0 4px 16px;
  color: var(--text-muted);
  font-style: italic;
}

.post-content pre {
  background: #1e1e28;
  color: #f4f4f4;
  padding: 16px;
  border-radius: 12px;
  overflow-x: auto;
  font-size: 0.88rem;
  margin: 16px 0;
}

.post-content code {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9em;
  background: rgba(53, 152, 219, 0.1);
  padding: 1px 5px;
  border-radius: 5px;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
  font-size: 0.92rem;
}

.post-content th,
.post-content td {
  border: 1px solid #ddd;
  padding: 8px 10px;
  text-align: left;
}

.post-content iframe {
  max-width: 100%;
}

/* ===========================
   Scroll Animations
   =========================== */
.hidden-section {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.show-section {
  opacity: 1;
  transform: translateY(0);
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
  body {
    padding: 16px;
  }

  .post-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .post-thumb-col,
  .post-thumb {
    width: 100%;
    height: 160px;
  }
}
