/* ============================================================
   BLOG.CSS
   Extends the existing design system (variables.css / main.css).
   No colors, fonts, radii or spacing are redefined here —
   everything is pulled from the site's CSS custom properties so
   the blog looks like a native part of the website.
   ============================================================ */

/* ---------------------------------------------------------------
   1. Hero — badge, stats
--------------------------------------------------------------- */
.blog-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius-full);
  padding: 0.4rem 0.9rem 0.4rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.blog-hero-badge .dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--cobalt);
  flex-shrink: 0;
}

.blog-hero-stats {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
}
.blog-hero-stat { display: flex; flex-direction: column; }
.blog-hero-stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}
.blog-hero-stat-label { margin-top: 0.35rem; font-size: 0.8125rem; color: var(--muted); }

/* ---------------------------------------------------------------
   2. Search
--------------------------------------------------------------- */
.blog-search {
  position: relative;
  max-width: 34rem;
}
.blog-search-icon {
  position: absolute;
  left: 1.125rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.05rem;
  height: 1.05rem;
  color: var(--muted);
  pointer-events: none;
}
.blog-search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 0.9rem 1.25rem 0.9rem 2.85rem;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--paper);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.blog-search-input::placeholder { color: var(--muted); }
.blog-search-input:focus {
  outline: none;
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px rgba(54, 84, 255, 0.12);
}
.blog-search-clear {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.75rem;
  height: 1.75rem;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.blog-search-clear:hover { background: var(--paper-2); color: var(--ink); }
.blog-search-clear.is-visible { display: inline-flex; }
.blog-search-clear svg { width: 0.9rem; height: 0.9rem; }

/* ---------------------------------------------------------------
   3. Toolbar — filters + sort
--------------------------------------------------------------- */
.blog-toolbar {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius-full);
  padding: 0.5rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
}
.filter-pill:hover { border-color: var(--cobalt-2); color: var(--ink); }
.filter-pill:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.filter-pill[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.filter-pill .count {
  font-size: 0.6875rem;
  color: inherit;
  opacity: 0.65;
}

.blog-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.blog-result-count { font-size: 0.8125rem; color: var(--muted); }
.blog-result-count strong { color: var(--ink); font-weight: 600; }

.blog-sort {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.blog-sort label { font-size: 0.8125rem; color: var(--muted); white-space: nowrap; }
.blog-sort-select {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.5rem 2.1rem 0.5rem 0.875rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--ink);
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2363656b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 0.65rem center / 0.9rem;
  appearance: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
.blog-sort-select:hover { border-color: var(--cobalt-2); }
.blog-sort-select:focus { outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(54, 84, 255, 0.12); }

/* ---------------------------------------------------------------
   4. Featured article
--------------------------------------------------------------- */
.featured-post {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  transition: border-color var(--transition-base);
  background: var(--paper);
}
.featured-post:hover { border-color: var(--cobalt-2); }
.featured-post-media { position: relative; background: var(--paper-2); aspect-ratio: 16 / 9; overflow: hidden; }
.featured-post-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--transition-slow); }
.featured-post:hover .featured-post-media img { transform: scale(1.035); }
.featured-post-flag {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
}
.featured-post-body { padding: 2rem; display: flex; flex-direction: column; }
.featured-post-title {
  margin-top: 0.75rem;
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 2.6vw, 1.875rem);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}
.featured-post-excerpt { margin-top: 0.75rem; font-size: 0.9375rem; color: var(--muted); line-height: 1.65; }

@media (min-width: 768px) {
  .featured-post { grid-template-columns: 1.1fr 1fr; align-items: stretch; }
  .featured-post-media { aspect-ratio: auto; height: 100%; }
  .featured-post-body { padding: 2.5rem; justify-content: center; }
}

/* ---------------------------------------------------------------
   5. Popular topics chips
--------------------------------------------------------------- */
.topic-chips { display: flex; flex-wrap: wrap; gap: 0.625rem; }
.topic-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 0.55rem 1.1rem;
  font-size: 0.8125rem;
  color: var(--ink);
  background: var(--paper);
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}
.topic-chip:hover { border-color: var(--cobalt-2); transform: translateY(-2px); }

/* ---------------------------------------------------------------
   6. Layout — main + sidebar
--------------------------------------------------------------- */
.blog-layout {
  margin-top: 3rem;
  display: grid;
  gap: 3rem;
  align-items: start;
}
@media (min-width: 1024px) {
  .blog-layout { grid-template-columns: 1fr 320px; }
}

/* ---------------------------------------------------------------
   7. Post cards (grid)
--------------------------------------------------------------- */
.post-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .post-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .post-grid { grid-template-columns: repeat(2, 1fr); } }

.post-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  background: var(--paper);
  transition: border-color var(--transition-base), transform var(--transition-fast), box-shadow var(--transition-base);
  height: 100%;
}
.post-card:hover {
  border-color: var(--cobalt-2);
  transform: translateY(-3px);
  box-shadow: var(--shadow-panel);
}
.post-card-media { position: relative; aspect-ratio: 16 / 10; background: var(--paper-2); overflow: hidden; }
.post-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--transition-slow); }
.post-card:hover .post-card-media img { transform: scale(1.04); }
.post-card-category {
  position: absolute;
  top: 0.875rem;
  left: 0.875rem;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
}
.post-card-body { padding: 1.5rem; display: flex; flex-direction: column; flex: 1; }
.post-card-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}
.post-card-title a { color: inherit; }
.post-card-title a::after { content: ""; position: absolute; inset: 0; }
.post-card-excerpt { margin-top: 0.625rem; font-size: 0.875rem; color: var(--muted); line-height: 1.6; flex: 1; }

.post-card-tags { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.post-card-tag {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted);
  background: var(--paper-2);
  border-radius: var(--radius-full);
  padding: 0.2rem 0.6rem;
}

.post-card-meta {
  margin-top: 1.25rem;
  padding-top: 1.125rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.post-card-author { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.post-card-author img {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.post-card-author-info { display: flex; flex-direction: column; min-width: 0; }
.post-card-author-name { font-size: 0.75rem; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-card-date { font-size: 0.6875rem; color: var(--muted); }
.post-card-reading { display: flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }
.post-card-reading svg { width: 0.875rem; height: 0.875rem; }

.post-card-link {
  position: relative;
  margin-top: 1.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--cobalt-2);
}
.post-card-link svg { width: 0.9rem; height: 0.9rem; transition: transform var(--transition-fast); }
.post-card:hover .post-card-link svg { transform: translate(2px, -2px); }

/* Card is a positioning context so the stretched title-link works,
   but the "Read more" link itself must stay clickable above it. */
.post-card { position: relative; }
.post-card-title { position: relative; }
.post-card-link { z-index: 1; }

/* ---------------------------------------------------------------
   8. Load more / pagination
--------------------------------------------------------------- */
.blog-load-more { margin-top: 3rem; display: flex; justify-content: center; }
.btn-load-more {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.blog-load-more.is-done .btn-load-more { display: none; }

.blog-empty {
  display: none;
  text-align: center;
  padding: 4rem 1.5rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-2xl);
}
.blog-empty.is-visible { display: block; }
.blog-empty-title { font-family: var(--font-display); font-size: 1.125rem; font-weight: 600; color: var(--ink); }
.blog-empty-text { margin-top: 0.5rem; font-size: 0.875rem; color: var(--muted); }

/* ---------------------------------------------------------------
   9. Sidebar
--------------------------------------------------------------- */
.sidebar-stack { display: flex; flex-direction: column; gap: 1.5rem; }
.sidebar-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  padding: 1.75rem;
  background: var(--paper);
}
.sidebar-card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.sidebar-post-list { margin-top: 1.25rem; display: flex; flex-direction: column; gap: 1.125rem; }
.sidebar-post { display: flex; gap: 0.875rem; align-items: flex-start; }
.sidebar-post-thumb {
  width: 3.75rem;
  height: 3.75rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--paper-2);
}
.sidebar-post-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar-post-info { min-width: 0; }
.sidebar-post-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sidebar-post-title:hover { color: var(--cobalt-2); }
.sidebar-post-meta { margin-top: 0.375rem; font-size: 0.6875rem; color: var(--muted); }

.sidebar-cat-list { margin-top: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
.sidebar-cat-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--ink);
  padding: 0.1rem 0;
}
.sidebar-cat-link:hover { color: var(--cobalt-2); }
.sidebar-cat-link .count { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--muted); }

.sidebar-tag-cloud { margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sidebar-tag {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.75rem;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.sidebar-tag:hover { border-color: var(--cobalt-2); color: var(--cobalt-2); }

.sidebar-newsletter p { margin-top: 0.5rem; font-size: 0.8125rem; color: var(--muted); line-height: 1.6; }
.sidebar-newsletter form { margin-top: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }

.sidebar-cta { background: var(--ink); border-color: var(--ink); }
.sidebar-cta .sidebar-card-title { color: var(--paper); }
.sidebar-cta p { margin-top: 0.5rem; font-size: 0.8125rem; color: rgba(255,255,255,0.7); line-height: 1.6; }
.sidebar-cta .btn-primary { margin-top: 1.25rem; width: 100%; justify-content: center; }

/* ---------------------------------------------------------------
   10. Newsletter section (full-width)
--------------------------------------------------------------- */
.newsletter-banner {
  background: var(--ink);
  border-radius: var(--radius-3xl);
  padding: 3.5rem 2rem;
  text-align: center;
  color: var(--paper);
}
.newsletter-banner .eyebrow { color: rgba(255,255,255,0.55); display: block; text-align: center; margin-bottom: 1rem; }
.newsletter-banner .heading-lg { color: var(--paper); max-width: 34rem; margin-inline: auto; }
.newsletter-banner p { max-width: 28rem; margin-inline: auto; margin-top: 1rem; font-size: 0.875rem; color: rgba(255,255,255,0.65); }

.newsletter-form {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 26rem;
  margin-inline: auto;
}
.newsletter-input {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-full);
  padding: 0.9rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--paper);
}
.newsletter-input::placeholder { color: rgba(255,255,255,0.45); }
.newsletter-input:focus { outline: none; border-color: var(--paper); }
.newsletter-form .btn-primary { justify-content: center; }
.newsletter-note { margin-top: 1rem; font-size: 0.75rem; color: rgba(255,255,255,0.45); }
.newsletter-success {
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: #8fe3c1;
  display: none;
}
.newsletter-success.is-visible { display: block; }

@media (min-width: 480px) {
  .newsletter-form { flex-direction: row; }
  .newsletter-input { flex: 1; }
  .newsletter-form .btn-primary { flex-shrink: 0; }
}
@media (min-width: 768px) {
  .newsletter-banner { padding: 4.5rem 4rem; }
}

/* ---------------------------------------------------------------
   11. Article page — cover, meta, prose, tags, author, related
--------------------------------------------------------------- */
.article-cover {
  margin-top: 2rem;
  border-radius: var(--radius-2xl);
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 16 / 8;
  background: var(--paper-2);
}
.article-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.article-meta-row {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
}
.article-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.article-author img { width: 2.75rem; height: 2.75rem; border-radius: 50%; object-fit: cover; }
.article-author-name { font-size: 0.875rem; font-weight: 600; color: var(--ink); }
.article-author-role { font-size: 0.75rem; color: var(--muted); }
.article-meta-sep { width: 1px; height: 1.75rem; background: var(--line); }
.article-meta-items { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.8125rem; color: var(--muted); }
.article-meta-items span { display: inline-flex; align-items: center; gap: 0.375rem; }
.article-meta-items svg { width: 0.9rem; height: 0.9rem; }

.article-prose {
  margin-top: 3rem;
  max-width: 42rem;
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--ink);
}
.article-prose > * + * { margin-top: 1.5rem; }
.article-prose h2 {
  margin-top: 2.75rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--ink);
}
.article-prose h3 {
  margin-top: 2rem;
  font-family: var(--font-display);
  font-size: 1.1875rem;
  font-weight: 600;
  color: var(--ink);
}
.article-prose p { color: var(--ink); }
.article-prose p.text-lead { font-size: 1.15rem; }
.article-prose ul, .article-prose ol { padding-left: 1.375rem; display: flex; flex-direction: column; gap: 0.625rem; }
.article-prose li { color: var(--ink); }
.article-prose li::marker { color: var(--cobalt-2); }
.article-prose a { color: var(--cobalt-2); text-decoration: underline; text-underline-offset: 2px; }
.article-prose strong { font-weight: 600; }
.article-prose blockquote {
  border-left: 3px solid var(--cobalt);
  padding-left: 1.5rem;
  font-style: italic;
  color: var(--muted);
}
.article-prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--paper-2);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
}
.article-prose pre {
  background: var(--ink);
  color: var(--paper);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
}
.article-prose pre code { background: none; padding: 0; color: inherit; }
.article-prose table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.article-prose th, .article-prose td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
.article-prose th { font-family: var(--font-display); font-weight: 600; color: var(--ink); }
.article-prose hr { border: none; border-top: 1px solid var(--line); }

.article-callout {
  border: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: var(--radius-xl);
  padding: 1.5rem 1.75rem;
}
.article-callout p { margin: 0; font-size: 0.9375rem; }
.article-callout p + p { margin-top: 0.75rem; }

.article-tags { margin-top: 2.5rem; max-width: 42rem; display: flex; flex-wrap: wrap; gap: 0.625rem; }

.article-share {
  margin-top: 2rem;
  max-width: 42rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.article-share-label { font-size: 0.8125rem; color: var(--muted); }
.article-share-links { display: flex; gap: 0.625rem; }
.article-share-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.article-share-links a:hover { border-color: var(--cobalt-2); color: var(--cobalt-2); }
.article-share-links svg { width: 1rem; height: 1rem; }

.article-author-box {
  margin-top: 3rem;
  max-width: 42rem;
  display: flex;
  gap: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  padding: 1.75rem;
}
.article-author-box img { width: 3.5rem; height: 3.5rem; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.article-author-box-name { font-family: var(--font-display); font-size: 1rem; font-weight: 600; color: var(--ink); }
.article-author-box-role { margin-top: 0.15rem; font-size: 0.8125rem; color: var(--muted); }
.article-author-box-bio { margin-top: 0.75rem; font-size: 0.875rem; color: var(--muted); line-height: 1.6; }

.related-heading { margin-top: 4.5rem; }
.related-grid { margin-top: 2rem; display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 768px) { .related-grid { grid-template-columns: repeat(3, 1fr); } }

.toc-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 1.5rem 1.75rem;
  max-width: 42rem;
  margin-top: 2rem;
}
.toc-card-title { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--copper); }
.toc-card ol { margin-top: 0.875rem; padding-left: 1.125rem; display: flex; flex-direction: column; gap: 0.5rem; }
.toc-card a { font-size: 0.875rem; color: var(--ink); }
.toc-card a:hover { color: var(--cobalt-2); }

/* ---------------------------------------------------------------
   12. Misc / responsive safety
--------------------------------------------------------------- */
img { max-width: 100%; }
.lazy-img { background: var(--paper-2); }

@media (max-width: 374px) {
  .blog-hero-stats { gap: 1.25rem 1.5rem; }
}
