/* ==========================================================================
   ApiCrate Blog Styles
   Uses existing CSS variables from main.css
   ========================================================================== */

/* ── Hero ── */
.blog-hero {
  position: relative;
  z-index: 1;
  padding: calc(var(--nav-h) + 4rem) 0 3rem;
  text-align: center;
}

.blog-hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  margin: 0.5rem 0;
}

.hero-subtitle {
  color: var(--text-dim);
  font-size: 1.15rem;
  max-width: 600px;
  margin: 0 auto;
}

/* ── Container ── */
.blog-list .container,
.blog-post .container,
.blog-related .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ── Grid ── */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.blog-grid-sm {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ── Post Card ── */
.blog-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.blog-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.blog-card-image img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.blog-card-body {
  padding: 1.5rem;
}

.blog-card-category {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-decoration: none;
}

.blog-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0.5rem 0;
  line-height: 1.3;
}

.blog-card-title a {
  color: var(--text);
  text-decoration: none;
}

.blog-card-title a:hover {
  color: var(--accent);
}

.blog-card-excerpt {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.blog-card-author {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

/* ── Stacked Post List ── */
.blog-stack {
  max-width: 720px;
  margin: 0 auto 3rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.blog-card-row {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.blog-card-row:first-child {
  padding-top: 0;
}

.blog-card-row-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.blog-card-row-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

.blog-card-row-title a {
  color: var(--text);
  text-decoration: none;
}

.blog-card-row-title a:hover {
  color: var(--accent);
}

.blog-card-row-excerpt {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

/* ── Post Detail ── */
.blog-post {
  position: relative;
  z-index: 1;
}

.blog-post-header {
  padding: calc(var(--nav-h) + 4rem) 0 2rem;
  text-align: center;
}

.blog-post-header .container {
  max-width: 800px;
}

.blog-post-header h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  margin: 0.75rem 0;
  line-height: 1.2;
}

.blog-post-category {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-decoration: none;
}

.blog-post-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-top: 1rem;
}

.blog-post-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.blog-author-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.blog-post-tags {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.blog-tag {
  font-size: 0.8rem;
  color: var(--accent);
  background: rgba(139, 92, 246, 0.08);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  text-decoration: none;
  border: 1px solid rgba(139, 92, 246, 0.15);
}

.blog-tag:hover {
  background: rgba(139, 92, 246, 0.15);
}

/* ── Hero Image ── */
.blog-post-hero-image {
  max-width: 900px;
  margin: 0 auto 2rem;
}

.blog-featured-img {
  width: 100%;
  border-radius: 12px;
  display: block;
}

/* ── Post Layout (body + TOC) ── */
.blog-post-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  max-width: 900px;
  padding-bottom: 3rem;
}

@media (min-width: 1024px) {
  .blog-post-layout:has(.blog-toc) {
    grid-template-columns: 200px 1fr;
    max-width: 1000px;
  }
}

/* ── Table of Contents ── */
.blog-toc {
  order: -1;
}

@media (min-width: 1024px) {
  .blog-toc {
    position: sticky;
    top: calc(var(--nav-h) + 2rem);
    align-self: start;
  }
}

.blog-toc-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.blog-toc ul {
  list-style: none;
  padding: 0;
}

.blog-toc li {
  margin-bottom: 0.3rem;
}

.blog-toc a {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}

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

/* ── Post Body Typography ── */
.blog-post-body {
  max-width: 720px;
  font-size: 1.05rem;
  line-height: 1.8;
}

.blog-post-body h1,
.blog-post-body h2,
.blog-post-body h3,
.blog-post-body h4 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
  scroll-margin-top: calc(var(--nav-h) + 1.5rem);
}

.blog-post-body h2 { font-size: 1.6rem; }
.blog-post-body h3 { font-size: 1.3rem; }
.blog-post-body h4 { font-size: 1.1rem; }

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

.blog-post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(139, 92, 246, 0.3);
  text-underline-offset: 2px;
}

.blog-post-body a:hover {
  text-decoration-color: var(--accent);
}

.blog-post-body img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1.5rem 0;
}

.blog-post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1.5rem;
  margin: 1.5rem 0;
  color: var(--text-dim);
  background: rgba(139, 92, 246, 0.04);
  border-radius: 0 8px 8px 0;
}

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

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

.blog-post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.blog-post-body th,
.blog-post-body td {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  text-align: left;
}

.blog-post-body th {
  background: var(--surface);
  font-weight: 600;
}

.blog-post-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.blog-post-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.blog-post-body pre code {
  background: none;
  padding: 0;
  font-size: 0.88rem;
  line-height: 1.6;
}

/* Pygments highlight overrides for dark theme */
.blog-post-body .highlight {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.blog-post-body .highlight pre {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
}

/* TOC anchor links */
.toc-anchor {
  color: var(--text-dim);
  text-decoration: none;
  margin-left: 0.3rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.blog-post-body h2:hover .toc-anchor,
.blog-post-body h3:hover .toc-anchor,
.blog-post-body h4:hover .toc-anchor {
  opacity: 1;
}

/* ── Series Navigation ── */
/* Reset generic nav styles (main.css targets all <nav> elements) */
.blog-series-nav {
  position: static;
  display: block;
  backdrop-filter: none;
  border-bottom: none;
  max-width: 720px;
  margin: 2rem auto;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.blog-series-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.blog-series-list {
  padding-left: 1.5rem;
}

.blog-series-list li {
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.blog-series-list a {
  color: var(--accent);
  text-decoration: none;
}

.blog-series-list a:hover {
  text-decoration: underline;
}

.blog-series-current span {
  color: var(--text);
  font-weight: 600;
}

/* ── Related Posts ── */
.blog-related {
  padding: 3rem 0;
  border-top: 1px solid var(--border);
}

.blog-related-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

/* ── Author Header ── */
.blog-author-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  justify-content: center;
  text-align: left;
}

.blog-author-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.blog-author-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

/* ── Pagination ── */
.blog-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 0 4rem;
  font-size: 0.95rem;
}

.blog-pagination a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.blog-pagination a:hover {
  text-decoration: underline;
}

.blog-pagination-current {
  color: var(--text-dim);
}

/* ── Empty State ── */
.blog-empty {
  color: var(--text-dim);
  text-align: center;
  padding: 3rem 0;
  grid-column: 1 / -1;
}

/* ── Pygments Syntax Highlighting (monokai) ── */
.blog-post-body .highlight .c,
.blog-post-body .highlight .ch,
.blog-post-body .highlight .cm,
.blog-post-body .highlight .cp,
.blog-post-body .highlight .cpf,
.blog-post-body .highlight .c1,
.blog-post-body .highlight .cs { color: #959077; }
.blog-post-body .highlight .k,
.blog-post-body .highlight .kc,
.blog-post-body .highlight .kd,
.blog-post-body .highlight .kp,
.blog-post-body .highlight .kr,
.blog-post-body .highlight .kt,
.blog-post-body .highlight .no { color: #66D9EF; }
.blog-post-body .highlight .kn,
.blog-post-body .highlight .o,
.blog-post-body .highlight .ow,
.blog-post-body .highlight .nt,
.blog-post-body .highlight .gd { color: #FF4689; }
.blog-post-body .highlight .l,
.blog-post-body .highlight .m,
.blog-post-body .highlight .mb,
.blog-post-body .highlight .mf,
.blog-post-body .highlight .mh,
.blog-post-body .highlight .mi,
.blog-post-body .highlight .mo,
.blog-post-body .highlight .il,
.blog-post-body .highlight .se { color: #AE81FF; }
.blog-post-body .highlight .s,
.blog-post-body .highlight .sa,
.blog-post-body .highlight .sb,
.blog-post-body .highlight .sc,
.blog-post-body .highlight .dl,
.blog-post-body .highlight .sd,
.blog-post-body .highlight .s2,
.blog-post-body .highlight .sh,
.blog-post-body .highlight .si,
.blog-post-body .highlight .sx,
.blog-post-body .highlight .sr,
.blog-post-body .highlight .s1,
.blog-post-body .highlight .ss,
.blog-post-body .highlight .ld { color: #E6DB74; }
.blog-post-body .highlight .na,
.blog-post-body .highlight .nc,
.blog-post-body .highlight .nd,
.blog-post-body .highlight .ne,
.blog-post-body .highlight .nf,
.blog-post-body .highlight .nx,
.blog-post-body .highlight .fm,
.blog-post-body .highlight .gi { color: #A6E22E; }
.blog-post-body .highlight .gp { color: #FF4689; font-weight: bold; }
.blog-post-body .highlight .ge { font-style: italic; }
.blog-post-body .highlight .gs { font-weight: bold; }
.blog-post-body .highlight .gu { color: #959077; }
.blog-post-body .highlight .go { color: #66D9EF; }
.blog-post-body .highlight .err { color: #ED007E; background-color: #1E0010; }
.blog-post-body .highlight .hll { background-color: #49483e; }

/* ── Preview Banner ── */
.blog-preview-banner {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  z-index: 99;
  padding: 0.5rem 2rem;
  background: rgba(245, 158, 11, 0.9);
  color: #1a1d27;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  backdrop-filter: blur(8px);
}

.blog-preview-banner a {
  color: #1a1d27;
  margin-left: 1rem;
  text-decoration: underline;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .blog-grid {
    grid-template-columns: 1fr;
  }

  .blog-post-layout {
    padding: 0 1rem 3rem;
  }

  .blog-author-header {
    flex-direction: column;
    text-align: center;
  }
}
