/* General Blog Styles */
:root {
  --blog-primary-color: #0b3954; /* Deep blue */
  --blog-secondary-color: #087e8b; /* Teal */
  --blog-accent-color: #ff6f61; /* Coral */
  --blog-text-color: #333333;
  --blog-light-text-color: #666666;
  --blog-bg-color: #ffffff;
  --blog-card-bg: #ffffff;
  --blog-border-color: #e0e0e0;
  --blog-font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --blog-max-width: 1100px;
  --transition-speed: 0.3s;
}

/* Base Layout & Container */
.blog-container {
  max-width: var(--blog-max-width);
  margin: 2rem auto;
  padding: 0 1rem;
}

/* Hero Section */
.blog-hero {
  background: linear-gradient(to right, var(--blog-primary-color), var(--blog-secondary-color));
  color: white;
  padding: 4rem 1rem;
  margin-bottom: 3rem;
  text-align: center;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

.hero-heading {
  font-size: 2.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero-description {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* Category Filters */
.category-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2rem;
}

.category-button {
  padding: 0.5rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 20px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color var(--transition-speed), border-color var(--transition-speed);
  text-decoration: none;
}

.category-button:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.category-button.active-category {
  background-color: white;
  color: var(--blog-secondary-color);
  border-color: white;
  font-weight: 500;
}

/* Search Bar */
.blog-search {
  position: relative;
  max-width: 600px;
  margin: 0 auto 2.5rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  padding-right: 3rem; /* Space for icon */
  border: 1px solid var(--blog-border-color);
  border-radius: 8px;
  font-size: 1rem;
  box-sizing: border-box; /* Include padding and border in element's total width and height */
}

.search-input:focus {
  outline: none;
  border-color: var(--blog-secondary-color);
  box-shadow: 0 0 0 2px rgba(8, 126, 139, 0.2);
}

.search-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--blog-light-text-color);
}

/* Posts Grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

/* Post Card */
.post-card {
  background: var(--blog-card-bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--blog-border-color);
  transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
  display: flex;
  flex-direction: column;
}

.post-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.post-card-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.post-image {
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.post-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-speed) ease;
}

.post-card:hover .post-image img {
  transform: scale(1.05);
}

.post-content {
  padding: 1.25rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.post-category {
  color: var(--blog-secondary-color);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.post-title {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.75rem;
  color: var(--blog-primary-color);
}

.post-excerpt {
  color: var(--blog-light-text-color);
  margin-bottom: 1.5rem;
  line-height: 1.6;
  font-size: 0.9rem;
  flex-grow: 1; /* Pushes meta to bottom */
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--blog-light-text-color);
  margin-top: auto; /* Pushes to bottom */
}

.meta-icon {
  margin-right: 0.3rem;
}

/* Loading & Messages */
.loading-spinner,
.no-posts-message,
.error-message {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  grid-column: 1 / -1; /* Span full grid width */
  text-align: center;
  padding: 2rem;
}

.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--blog-secondary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.no-posts-message h2,
.error-message h2 {
  font-size: 1.1rem;
  color: var(--blog-light-text-color);
}

.error-message h2 {
    color: #d9534f; /* Error color */
}

/* Infinite Scroll Sentinel */
.infinite-scroll-sentinel {
    height: 10px; /* Small invisible element to trigger intersection */
    grid-column: 1 / -1;
}

/* Newsletter Section */
.newsletter {
  background: #f8f9fa; /* Light gray background */
  border: 1px solid var(--blog-border-color);
  border-radius: 12px;
  padding: 2.5rem;
  text-align: center;
  margin-top: 3rem;
}

.newsletter-heading {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--blog-primary-color);
  margin-bottom: 0.75rem;
}

.newsletter-text {
  color: var(--blog-light-text-color);
  margin-bottom: 1.5rem;
}

.newsletter-form {
  max-width: 450px;
  margin: 0 auto;
  display: flex;
  gap: 0.75rem;
}

.newsletter-input {
  flex-grow: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--blog-border-color);
  border-radius: 8px;
  font-size: 0.9rem;
}

.newsletter-input:focus {
  outline: none;
  border-color: var(--blog-secondary-color);
  box-shadow: 0 0 0 2px rgba(8, 126, 139, 0.2);
}

.newsletter-button {
  padding: 0.75rem 1.5rem;
  background-color: var(--blog-secondary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-speed);
}

.newsletter-button:hover {
  background-color: #065f68; /* Darker teal */
}

/* Post Details Page */
.post-detail-container {
    max-width: 800px; /* More focused reading width */
}

.post-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.post-nav {
    text-align: left;
    margin-bottom: 1.5rem;
}

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

.back-link:hover {
    text-decoration: underline;
}

.icon-left {
    margin-right: 0.4rem;
}

.post-meta-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem 1rem; /* Row and column gap */
    font-size: 0.85rem;
    color: var(--blog-light-text-color);
    margin-bottom: 1rem;
}

.category-badge {
    background-color: rgba(8, 126, 139, 0.1); /* Light teal background */
    color: var(--blog-secondary-color);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-weight: 500;
}

.meta-item {
    display: flex;
    align-items: center;
}

.post-title-main {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--blog-primary-color);
    line-height: 1.3;
    margin-bottom: 1rem;
}

.post-description {
    font-size: 1.1rem;
    color: var(--blog-light-text-color);
    margin-bottom: 2rem;
    line-height: 1.7;
}

.post-cover-image-container {
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 3rem;
    aspect-ratio: 16 / 9;
}

.post-cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Post Body Content */
.post-body {
  line-height: 1.8;
  font-size: 1rem; /* Base font size for content */
  color: var(--blog-text-color);
}

.post-body h1, .post-body h2, .post-body h3, .post-body h4, .post-body h5, .post-body h6 {
  color: var(--blog-primary-color);
  margin-top: 2em;
  margin-bottom: 1em;
  line-height: 1.4;
}

.post-body h1 { font-size: 1.8em; }
.post-body h2 { font-size: 1.5em; }
.post-body h3 { font-size: 1.3em; }
.post-body h4 { font-size: 1.1em; }

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

.post-body a {
  color: var(--blog-secondary-color);
  text-decoration: none;
  border-bottom: 1px solid rgba(8, 126, 139, 0.3);
  transition: border-bottom-color var(--transition-speed);
}

.post-body a:hover {
  border-bottom-color: var(--blog-secondary-color);
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 2rem 0;
  display: block; /* Center images if they have margins */
  margin-left: auto;
  margin-right: auto;
}

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

.post-body li {
  margin-bottom: 0.5em;
}

.post-body blockquote {
  border-left: 4px solid var(--blog-secondary-color);
  padding-left: 1em;
  margin: 1.5em 0;
  color: var(--blog-light-text-color);
  font-style: italic;
}

.post-body code {
  background-color: #f1f1f1;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

.post-body pre {
  background-color: #f1f1f1;
  padding: 1em;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.5em 0;
}

.post-body pre code {
  background-color: transparent;
  padding: 0;
  font-size: 0.85em;
}

/* Tags */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 2.5rem 0;
}

.tag-link {
    background-color: #eef2f5; /* Light gray */
    color: var(--blog-light-text-color);
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

.tag-link:hover {
    background-color: #dde4e9;
    color: var(--blog-text-color);
}

/* Author Section */
.author-section {
    background-color: #f8f9fa; /* Light background */
    border-radius: 12px;
    padding: 1.5rem;
    margin: 2.5rem 0;
    border: 1px solid var(--blog-border-color);
}

.author-content {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

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

.author-info {
    flex-grow: 1;
}

.author-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--blog-primary-color);
}

.author-bio {
    font-size: 0.9rem;
    color: var(--blog-light-text-color);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.author-socials {
    display: flex;
    gap: 1rem;
}

.author-social-link {
    color: var(--blog-light-text-color);
    font-size: 1.2rem;
    text-decoration: none;
    transition: color var(--transition-speed);
}

.author-social-link:hover {
    color: var(--blog-secondary-color);
}

/* Related Articles Section */
.related-articles-section {
    margin: 3rem 0;
}

.related-articles-heading {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--blog-primary-color);
    margin-bottom: 1.5rem;
}

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

.related-article-card {
    background-color: var(--blog-card-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--blog-border-color);
    text-decoration: none;
    color: inherit;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.related-article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.related-article-image-container {
    aspect-ratio: 16 / 10;
    background-color: #eee; /* Placeholder background */
    overflow: hidden;
}

.related-article-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-speed);
}

.related-article-card:hover .related-article-image {
    transform: scale(1.05);
}

.related-article-placeholder {
    width: 100%;
    height: 100%;
    background-color: #e0e0e0;
}

.related-article-content {
    padding: 1rem;
}

.related-article-category {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--blog-secondary-color);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
}

.related-article-title {
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--blog-primary-color);
    transition: color var(--transition-speed);
}

.related-article-card:hover .related-article-title {
    color: var(--blog-secondary-color);
}

.no-related-articles,
.error-message {
    grid-column: 1 / -1; /* Span full width */
    text-align: center;
    color: var(--blog-light-text-color);
    padding: 1rem;
}

/* Newsletter Section (Shared Styles) */
.newsletter-section {
    background-color: #f8f9fa;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    margin-top: 3rem;
    border: 1px solid var(--blog-border-color);
}

/* Styles for the new Listmonk form */
.listmonk-form {
    max-width: 450px;
    margin: 1.5rem auto 0; /* Add margin top */
    text-align: left; /* Align form elements left */
}

.listmonk-form h3 {
    font-size: 1.3rem; /* Slightly smaller heading */
    font-weight: 600;
    color: var(--blog-primary-color);
    margin-bottom: 1rem;
    text-align: center; /* Center the heading */
}

.listmonk-form p {
    margin-bottom: 1rem; /* Space between form elements */
}

.listmonk-form input[type="email"],
.listmonk-form input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--blog-border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    box-sizing: border-box; /* Include padding and border */
}

.listmonk-form input[type="email"]:focus,
.listmonk-form input[type="text"]:focus {
    outline: none;
    border-color: var(--blog-secondary-color);
    box-shadow: 0 0 0 2px rgba(8, 126, 139, 0.2);
}

.listmonk-form input[type="checkbox"] {
    margin-right: 0.5rem;
    accent-color: var(--blog-secondary-color); /* Style checkbox color */
    vertical-align: middle;
}

.listmonk-form label {
    font-size: 0.9rem;
    color: var(--blog-text-color);
    vertical-align: middle;
}

.listmonk-form input[type="submit"] {
    display: block; /* Make button full width */
    width: 100%;
    padding: 0.75rem 1.5rem;
    background-color: var(--blog-secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-speed);
    margin-top: 1.5rem; /* Add space above button */
}

.listmonk-form input[type="submit"]:hover {
    background-color: #065f68; /* Darker teal */
}

/* Animations */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
  .hero-heading {
    font-size: 2rem;
  }
  .hero-description {
    font-size: 1rem;
  }
  .post-title-main {
      font-size: 1.8rem;
  }
  .post-description {
      font-size: 1rem;
  }
  .author-content {
      flex-direction: column;
      align-items: center;
      text-align: center;
  }
  .author-socials {
      justify-content: center;
  }
  .newsletter-form {
      flex-direction: column;
  }
}

@media (max-width: 480px) {
    .posts-grid {
        grid-template-columns: 1fr; /* Single column on small screens */
    }
    .related-articles-grid {
        grid-template-columns: 1fr;
    }
    .post-meta-info {
        font-size: 0.8rem;
        gap: 0.3rem 0.8rem;
    }
    .post-title-main {
        font-size: 1.6rem;
    }
}