/* Reading Progress Bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.reading-progress.visible {
  opacity: 1;
}

.reading-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #667eea, #764ba2, #6c63ff);
  border-radius: 0 2px 2px 0;
  transition: width 0.1s linear;
}

.blog-hero {
  padding: 8rem 0 4rem;
  text-align: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  position: relative;
  overflow: hidden;
}

.blog-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.04) 0%, transparent 50%);
  pointer-events: none;
}

.blog-hero-title {
  font-size: 3.5rem;
  font-weight: 900;
  margin-bottom: 1rem;
  position: relative;
  animation: fadeInUp 0.8s ease both;
}

.blog-hero-subtitle {
  font-size: 1.3rem;
  opacity: 0.85;
  position: relative;
  animation: fadeInUp 0.8s ease 0.15s both;
}

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

.blog-section {
  padding: 4rem 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.blog-filters {
  margin-bottom: 3rem;
}

.blog-search {
  width: 100%;
  max-width: 500px;
  padding: 0.85rem 1.25rem 0.85rem 2.75rem;
  border: 2px solid var(--gray-light);
  border-radius: 12px;
  font-size: 1rem;
  margin-bottom: 2rem;
  font-family: inherit;
  transition: all 0.2s ease;
  background: var(--white);
}

.blog-search-wrapper {
  position: relative;
  max-width: 500px;
  margin-bottom: 2rem;
}

.blog-search-wrapper .blog-search {
  margin-bottom: 0;
}

.blog-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray);
  pointer-events: none;
}

.blog-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

.blog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.blog-tag {
  padding: 0.5rem 1.2rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  background: var(--white);
  border: 2px solid var(--gray-light);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  color: inherit;
}

.blog-tag:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.blog-tag.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.blog-posts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 2rem;
}

.blog-post-view {
  display: none;
  padding: 4rem 0;
}

.blog-post-view.active {
  display: block;
}

.blog-post-content {
  max-width: 760px;
  margin: 0 auto;
  background: var(--white);
  padding: 3rem;
  border-radius: 16px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.blog-post-content h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: var(--dark);
  line-height: 1.2;
}

.blog-post-content h2 {
  font-size: 1.8rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--dark);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid rgba(108, 99, 255, 0.1);
}

.blog-post-content h3 {
  font-size: 1.4rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--dark);
}

.blog-post-content p {
  margin-bottom: 1.5rem;
  line-height: 1.85;
  color: var(--dark-light);
  font-size: 1.05rem;
}

.blog-post-content img {
  max-width: 100%;
  border-radius: 12px;
  margin: 2rem 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.blog-post-content code {
  background: rgba(108, 99, 255, 0.06);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9em;
  color: var(--primary);
}

.blog-post-content pre {
  background: var(--dark);
  color: var(--white);
  padding: 1.5rem;
  border-radius: 12px;
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.blog-post-content blockquote {
  border-left: 4px solid var(--primary);
  padding: 1rem 1.5rem;
  margin: 2rem 0;
  font-style: italic;
  color: var(--gray);
  background: rgba(108, 99, 255, 0.03);
  border-radius: 0 12px 12px 0;
}

.blog-post-content ul,
.blog-post-content ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
}

.blog-post-content li {
  margin-bottom: 0.5rem;
  line-height: 1.8;
}

.blog-post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  overflow-x: auto;
  display: block;
}

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

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

.blog-post-content tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

/* Table of Contents */
.post-toc {
  background: var(--light);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  margin: 2rem 0;
  border-left: 4px solid var(--primary);
}

.post-toc h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.75rem;
}

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

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

.post-toc a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.post-toc a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.post-toc li.toc-h3 {
  padding-left: 1rem;
}

/* Share Buttons */
.post-share {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2rem 0;
  padding: 1.5rem 0;
  border-top: 1px solid var(--gray-light);
}

.post-share span {
  font-weight: 600;
  color: var(--dark);
  font-size: 0.95rem;
}

.share-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  transition: all 0.3s ease;
}

.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.share-btn.twitter { background: #1DA1F2; }
.share-btn.linkedin { background: #0077B5; }
.share-btn.facebook { background: #4267B2; }
.share-btn.copy-link { background: var(--primary); }

/* Reading time & post meta */
.post-reading-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--gray);
  margin-bottom: 1rem;
}

.post-reading-info svg {
  width: 16px;
  height: 16px;
}

/* Syntax highlighting overrides */
.blog-post-content pre[class*=\"language-\"] {
  border-radius: 12px;
  margin: 2rem 0;
}

.blog-post-content code[class*=\"language-\"] {
  font-size: 0.9rem;
}

/* Blog empty state */
.blog-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--gray);
}
.blog-empty-state svg {
  margin-bottom: 1rem;
  opacity: 0.4;
}
.blog-empty-state p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

.blog-error-detail {
  color: #888;
  font-size: 0.9rem;
}

.blog-error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
}

/* Code block copy button */
.code-block-wrapper {
  position: relative;
}
.code-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.3rem 0.7rem;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 1;
}
.code-copy-btn:hover {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.back-to-posts-bottom {
  display: block;
  margin: 3rem auto 0;
}

.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.post-card-tag {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: rgba(108, 99, 255, 0.12);
  color: var(--primary);
}

.post-header-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 1rem;
}

.post-header-tag {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  background: rgba(108, 99, 255, 0.14);
  color: var(--primary);
}

.blog-post-content .post-hero-image {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 16px;
  margin-bottom: 1.5rem;
}

.related-posts {
  margin: 3rem 0 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--gray-light);
}

.related-posts-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 1.25rem;
}

.related-posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

.related-post-card {
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  background: var(--white);
}

.related-post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 28px rgba(108, 99, 255, 0.12);
}

.related-post-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  background: var(--gradient-2);
}

.related-post-img--placeholder {
  min-height: 120px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.35), rgba(118, 75, 162, 0.35));
}

.related-post-body {
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.related-post-meta {
  font-size: 0.8rem;
  color: var(--gray);
}

.related-post-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.35;
}

.blog-newsletter-strip {
  margin: 0;
  padding: 2.5rem 0 3rem;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.blog-newsletter-inner {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  padding: 0 1rem;
}

.blog-newsletter-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.blog-newsletter-desc {
  color: var(--dark-light);
  margin-bottom: 1.25rem;
  line-height: 1.65;
}

.blog-newsletter-cta {
  display: inline-flex;
}

/* ── Dark Mode ── */
@media (prefers-color-scheme: dark) {
  .blog-search {
    background: var(--white);
    color: var(--dark);
    border-color: var(--gray-light);
  }
  .blog-tag {
    background: var(--white);
    border-color: var(--gray-light);
    color: var(--dark);
  }
  .blog-tag.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }
  .blog-post-content {
    background: var(--white);
    border-color: var(--gray-light);
  }
  .blog-post-content code {
    background: rgba(108, 99, 255, 0.15);
  }
  .blog-post-content blockquote {
    background: rgba(108, 99, 255, 0.08);
  }
  .post-toc {
    background: #161825;
  }
  .blog-post-content th {
    background: rgba(255, 255, 255, 0.05);
  }
  .blog-post-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
  }
}
