/* CSS Variables for consistent spacing and typography */
:root {
  --blog-spacing-sm: 12px;
  --blog-spacing-md: 20px;
  --blog-spacing-lg: 30px;

  --blog-font-xs: 13px;
  --blog-font-sm: 14px;
  --blog-font-base: 16px;
  --blog-font-lg: 18px;
  --blog-font-xl: 24px;

  --blog-line-height-tight: 1.4;
  --blog-line-height-normal: 1.6;

  /* Theme colors */
  --blog-green-primary: #0ea5e9;
}

/* Container */
.blog-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--blog-spacing-lg) var(--blog-spacing-md);
}

/* Header (desktop-only, mirrors .category-header pattern) */
.blog-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

@media (min-width: 48em) {
  .blog-container {
    padding-top: 0;
  }

  .blog-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 100;
  }
}

.blog-header-text {
  min-width: 0;
}

.blog-header-title {
  margin: 0;
  color: #111827;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.blog-header-desc {
  margin: 0.25rem 0 0;
  color: #6b7280;
  font-size: 0.875rem;
  line-height: var(--blog-line-height-normal);
}

.blog-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: #0284c7;
  color: #fff;
  border: none;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.blog-header-btn:hover {
  background: #0369a1;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  color: #fff;
}

.blog-header-btn svg {
  width: 1.125rem;
  height: 1.125rem;
}


/* Masonry Layout — Pinterest-style, cards flow top-to-bottom per column with natural heights */
.posts-list {
  column-count: 3;
  column-gap: var(--blog-spacing-lg);
  margin-top: var(--blog-spacing-lg);
}

/* Card Styling — matches .product-card border/shadow/hover */
.blog-post {
  background: #fff;
  border-radius: 1rem;
  border: 1px solid #f3f4f6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  break-inside: avoid;
  margin-bottom: var(--blog-spacing-lg);
}

.blog-post:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Cover Image */
.post-cover {
  width: 100%;
  height: 200px;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
  margin: 0;
}

.post-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.3s ease;
}

.blog-post:hover .post-cover img {
  transform: scale(1.05);
}


/* Content wrapper for posts with images */
.post-content-wrapper {
  padding: var(--blog-spacing-lg);
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

/* Typography */
.post-title {
  margin: 0 0 var(--blog-spacing-sm) 0;
  font-size: var(--blog-font-xl);
  line-height: var(--blog-line-height-tight);
  font-weight: 700;
  flex-shrink: 0;
}

.post-title a {
  color: #333;
  text-decoration: none;
  transition: color 0.3s ease;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-title a:hover {
  color: #111827;
}

/* Stretch the title link over the whole card so the entire card is clickable */
.post-title a::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Metadata with icons */
.post-meta {
  display: flex;
  align-items: center;
  gap: var(--blog-spacing-sm);
  color: #777;
  font-size: var(--blog-font-sm);
  margin-bottom: var(--blog-spacing-md);
  padding-bottom: var(--blog-spacing-sm);
  border-bottom: 1px solid #e0f2fe;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.post-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-icon-small {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: #9ca3af;
}

/* Star Rating */
.post-rating {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.post-rating .rating-stars {
  display: flex;
  gap: 1px;
}

.post-rating .star-wrap {
  position: relative;
  display: inline-block;
  color: #ddd;
  font-size: 14px;
  line-height: 1;
}

.post-rating .star-wrap::before {
  content: '★';
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  width: var(--fill, 0%);
  color: #ffc107;
}

.post-rating .rating-count {
  font-size: var(--blog-font-xs);
  color: #999;
  white-space: nowrap;
}

.post-rating .no-rating {
  font-size: var(--blog-font-xs);
  color: #9ca3af;
}

/* Excerpt with line clamping */
.post-excerpt {
  line-height: var(--blog-line-height-normal);
  color: #555;
  font-size: var(--blog-font-base);
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Empty state */
.no-posts {
  text-align: center;
  color: #999;
  font-size: 18px;
  padding: 40px;
  column-span: all;
}

/* Tablet: 2 columns */
@media (max-width: 1024px) {
  .posts-list {
    column-count: 2;
    column-gap: var(--blog-spacing-md);
  }

  .blog-post {
    margin-bottom: var(--blog-spacing-md);
  }
}

/* Mobile: 1 column */
@media (max-width: 768px) {
  .posts-list {
    column-count: 1;
    column-gap: var(--blog-spacing-md);
  }

  .blog-container {
    padding: var(--blog-spacing-sm);
  }

  .post-title {
    font-size: var(--blog-font-lg);
  }

  .post-meta {
    font-size: var(--blog-font-xs);
  }

  .post-excerpt {
    -webkit-line-clamp: 3;
  }

  .post-content-wrapper {
    padding: var(--blog-spacing-md);
  }
}

/* Extra small mobile */
@media (max-width: 480px) {
  .post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}
