/* CSS Variables for easier maintenance */
:root {
  --primary-color: #007bff;
  --secondary-color: green;
  --secondary-color-dark: darkgreen;
  --border-color: #ccc;
  --border-color-light: #ddd;
  --background-light: #f4f4f4;
  --text-color-dark: #333;
  --text-color-medium: #444;
  --text-color-light: #777;
  --error-color: red;
  --link-color: blue;
  --shadow-color: rgba(0, 0, 0, 0.1);

  --spacing-extra-small: 3px;
  --spacing-small: 5px;
  --spacing-medium: 10px;
  --spacing-large: 15px;
  --spacing-extra-large: 20px;
  --spacing-jumbo: 30px;

  --section-padding: var(--spacing-jumbo) var(--spacing-extra-large);
  --column-gap: var(--spacing-extra-large);
  --column-padding: var(--spacing-large);
}

/* Body Styles */
body {
  font-family: "Open Sans", sans-serif, Arial, sans-serif;
  margin: 0;
  padding: 0;
  padding-top: 150px;
  display: block;
  min-height: 100vh;
  background-color: transparent;
  position: relative;
}

html {
  scroll-padding-top: 150px;
  scroll-behavior: smooth;
}

.hidden {
  display: none !important;
}

/* Sticky Header Styles */
#sticky-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background-color: white;
  padding: var(--spacing-medium) var(--spacing-extra-large);
  box-shadow: 0 2px 5px var(--shadow-color);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  margin-right: var(--spacing-extra-large);
  display: flex;
  align-items: center;
}

.logo a {
  text-decoration: none;
}

.logo img {
  display: block;
  height: 120px;
  width: auto;
  margin: 0;
  padding: 0;
}

.main-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: var(--spacing-large);
  align-items: center;
}

.main-nav a {
  text-decoration: none;
  color: var(--text-color-dark);
  font-size: 1em;
  padding: var(--spacing-small) var(--spacing-medium);
  transition: color 0.3s ease;
}

.main-nav a:hover {
  color: var(--primary-color);
}

.cta-button {
  display: inline-block;
  padding: var(--spacing-medium) var(--spacing-large);
  background-color: var(--secondary-color);
  color: white;
  font-size: 1em;
  font-weight: bold;
  text-decoration: none;
  border: none;
  border-radius: var(--spacing-small);
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin-left: var(--spacing-extra-large);
}

.cta-button:hover {
  background-color: var(--secondary-color-dark);
}

.hamburger-icon {
  display: none;
  background: none;
  border: none;
  font-size: 1.8em;
  color: var(--text-color-dark);
  cursor: pointer;
  padding: var(--spacing-small);
  z-index: 1001;
  margin-left: var(--spacing-medium);
}

/* Show navigation when toggled */
.main-nav.show {
  display: flex !important;
  transform: translateY(0%);
}

/* Intro Section */
.intro-section {
  padding: var(--section-padding);
  padding-bottom: 0px;
  text-align: center;
  margin-bottom: 0px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.intro-section h1 {
  color: var(--primary-color);
  font-size: 2.5em;
  margin-bottom: var(--spacing-medium);
}

.intro-section p {
  color: var(--text-color-dark);
  font-size: 1.2em;
  line-height: 1.6;
  margin-bottom: 0px;
  text-align: left;
}

/* Form */
form {
  width: 80%;
  max-width: 800px;
  background: white;
  padding: var(--spacing-extra-large);
  border-radius: 8px;
  box-shadow: 0px 4px 6px var(--shadow-color);
  margin-top: 0px;
  margin-left: auto;
  margin-right: auto;
}

.radio-group {
  display: flex;
  align-items: center;
  gap: var(--spacing-medium);
  margin-bottom: var(--spacing-large);
}

.input-group {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--spacing-large);
}

.input-group.text-input-box:not(.hidden) {
  min-height: 150px;
  transition: min-height 0.3s ease;
}

.input-group.file-input-box:not(.hidden) {
  display: flex;
  flex-direction: column;
  min-height: auto;
}

textarea {
  width: 100%;
  height: 120px;
  resize: vertical;
  padding: 8px;
  border-radius: var(--spacing-small);
  border: 1px solid var(--border-color);
  font-size: 1.1em;
}

textarea.is-invalid {
  border-color: var(--error-color);
}

input[type="email"] {
  width: 50%;
  padding: 8px;
  border-radius: var(--spacing-small);
  border: 1px solid var(--border-color);
  font-size: 1.1em;
}

.file-input-box {
  display: block;
}

.file-input-box input[type="file"] {
  display: none;
}

.file-input-box label {
  display: inline-block;
  padding: var(--spacing-medium);
  background-color: var(--background-light);
  border: 1px solid var(--border-color);
  border-radius: var(--spacing-small);
  cursor: pointer;
}

.file-input-box input[type="file"]:focus + label {
  border-color: var(--secondary-color);
}

.terms-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-medium);
  margin-top: var(--spacing-medium);
}

.terms-container input[type="checkbox"] {
  margin: 0;
  width: 18px;
  height: 18px;
}

.terms-container label {
  font-size: 14px;
}

.terms-container a {
  color: var(--link-color);
  text-decoration: underline;
  cursor: pointer;
}

.submit-button {
  width: 100%;
  padding: var(--spacing-medium);
  background-color: var(--secondary-color);
  color: white;
  font-size: 16px;
  border: none;
  border-radius: var(--spacing-small);
  cursor: pointer;
  margin-top: var(--spacing-large);
}

.submit-button:hover:not(:disabled) {
  background-color: var(--secondary-color-dark);
}

/* Style for disabled button */
.submit-button:disabled {
  background-color: #cccccc; /* Lighter grey */
  cursor: not-allowed;
}

.error-message {
  font-size: 0.8em;
  margin-top: var(--spacing-small);
  color: var(--error-color);
}

/* NEW: Ensure #error-message is always red */
#error-message {
  color: var(--error-color) !important;
}

.input-info {
  font-size: 0.9em;
  color: var(--text-color-light);
  margin-top: var(--spacing-extra-small);
}

#submission-message {
  margin-top: var(--spacing-extra-large);
}

#submission-message .success-title {
  font-size: 1.2em;
  font-weight: bold;
}

.required-info {
  font-size: 0.9em;
  color: var(--text-color-medium);
  margin-bottom: var(--spacing-medium);
}

/* Section Styles */
.how-it-works-columns,
.support-all-subjects,
.testimonials-columns,
.about-us {
  padding: 10px var(--spacing-extra-large);
  text-align: center;
  border-bottom: 1px solid var(--border-color-light);
  margin-bottom: 0;
  margin-top: 0;
}

.how-it-works-columns h2,
.support-all-subjects h2,
.testimonials-columns h2,
.about-us h2 {
  color: var(--primary-color);
  margin-bottom: var(--spacing-large);
  font-size: 36px;
}

.how-it-works-columns .columns,
.support-all-subjects .columns,
.testimonials-columns .columns {
  display: flex;
  flex-direction: row;
  gap: var(--column-gap);
  justify-content: space-around;
  margin-top: var(--spacing-extra-large);
}

.how-it-works-columns .column,
.support-all-subjects .column,
.testimonials-columns .column {
  flex: 1;
  padding: var(--column-padding);
  border: 1px solid var(--border-color-light);
  border-radius: var(--spacing-small);
}

.how-it-works-columns .column img,
.support-all-subjects .column img,
.testimonials-columns .column img {
  display: block;
  object-fit: contain;
}

.how-it-works-columns .column img {
  margin: 0 auto var(--spacing-large) auto;
}

.support-all-subjects .column img {
  margin: 0 auto var(--spacing-small) auto;
}

.testimonials-columns .column img {
  margin: 0 auto var(--spacing-small) auto;
}

.how-it-works-columns .column {
  text-align: center;
}

.how-it-works-columns .column h3 {
  margin-top: 0;
  color: var(--text-color-dark);
  font-size: 1.5em;
}

.how-it-works-columns .column p {
  text-align: left;
}

.support-all-subjects .column {
  text-align: left;
}

.support-all-subjects .column h3 {
  color: var(--text-color-dark);
  margin-top: 0;
  font-size: 1.5em;
  line-height: 1.2;
  text-align: center;
}

.support-all-subjects p {
  line-height: 1.6;
  margin-bottom: var(--spacing-medium);
}

.support-all-subjects ul {
  list-style: none;
  padding: 0;
  margin-top: var(--spacing-large);
  display: inline-block;
  text-align: left;
}

.support-all-subjects ul li {
  margin-bottom: 8px;
}

.testimonials-columns .column {
  text-align: left;
}

.testimonials-columns .column p:first-child {
  font-weight: bold;
  color: var(--text-color-medium);
  margin-bottom: var(--spacing-small);
}

.about-us p {
  line-height: 1.6;
}

/* Media Queries */
@media (min-width: 769px) and (max-width: 1024px) {
  #sticky-header {
    padding: var(--spacing-medium) var(--spacing-large);
    overflow: visible;
  }

  .header-container {
    display: flex;
    gap: var(--spacing-large);
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    overflow: visible;
  }

  .main-nav ul {
    gap: var(--spacing-small);
  }

  .main-nav a {
    padding: var(--spacing-small) 8px;
    display: block;
  }

  .cta-button {
    padding: var(--spacing-small) 22px;
    font-size: 1em;
    margin-left: 16px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: visible;
    max-width: none;
  }

  .logo img {
    height: 110px;
    width: auto;
  }

  body {
    padding-top: 140px;
  }

  html {
    scroll-padding-top: 140px;
  }
}

@media (max-width: 768px) {
  #sticky-header {
    padding: var(--spacing-small) var(--spacing-medium);
  }

  .header-container {
    flex-direction: row;
    justify-content: space-between;
  }

  .logo {
    margin-right: 0;
    flex-shrink: 0;
  }

  .logo img {
    height: 100px;
    width: auto;
  }

  body {
    padding-top: 130px;
  }

  html {
    scroll-padding-top: 130px;
  }

  .hamburger-icon {
    display: block;
  }

  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: white;
    box-shadow: 0 2px 5px var(--shadow-color);
    flex-direction: column;
    align-items: flex-start;
    padding: var(--spacing-medium) var(--spacing-extra-large);
    transition: transform 0.3s ease-in-out;
    transform: translateY(-100%);
    z-index: 1000;
  }

  .main-nav ul {
    flex-direction: column;
    width: 100%;
    gap: var(--spacing-small);
  }

  .main-nav li {
    width: 100%;
    border-bottom: 1px solid var(--border-color-light);
    padding: var(--spacing-medium) 0;
  }

  .main-nav a {
    width: 100%;
  }

  /* --- ADDED STYLE FOR MOBILE COLUMN STACKING --- */
  .how-it-works-columns .columns,
  .support-all-subjects .columns,
  .testimonials-columns .columns {
    flex-direction: column;
    /* The gap variable will now apply vertically between columns */
  }
  /* -------------------------------------------- */

  /* NEW: Improved visibility for the terms checkbox on mobile */
  .terms-container input[type="checkbox"] {
    -webkit-appearance: checkbox; /* Ensure it's rendered as a standard checkbox for Webkit browsers */
    -moz-appearance: checkbox;    /* For Firefox */
    appearance: checkbox;         /* Standard property */
    width: 24px; /* Slightly larger for better tap target */
    height: 24px; /* Slightly larger */
    border: 2px solid var(--text-color-dark); /* Explicit dark border */
    background-color: white; /* Explicit white background */
    cursor: pointer;
    vertical-align: middle; /* Helps align with text */
    margin-right: 8px; /* Add some space between checkbox and label */
    flex-shrink: 0; /* Prevent it from shrinking */
  }

  /* NEW: Style for the checked state of the checkbox */
  .terms-container input[type="checkbox"]:checked {
    background-color: var(--secondary-color); /* Green background when checked */
    border-color: var(--secondary-color-dark); /* Darker green border when checked */
  }
}

/* === Final Mobile Adjustments Only === */
@media (max-width: 768px) {
  #sticky-header .cta-button {
    display: none !important;
  }

  .cta-button-mobile {
    display: block !important;
    margin: 5px auto 5px auto !important;
    padding: 10px 20px !important;
    max-width: 260px;
    text-align: center;
  }

  .intro-section {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  form {
    margin-top: 0 !important;
  }

  .logo img {
    height: 140px !important;
    width: auto;
  }

  body {
    padding-top: 160px !important;
  }

  html {
    scroll-padding-top: 160px !important;
  }
}

/* Desktop hides mobile CTA */
@media (min-width: 1025px) {
  .cta-button-mobile {
    display: none !important;
  }
}


@media (min-width: 769px) {
  .cta-button-mobile {
    display: none !important;
  }
}


/* === Prevent Header Cutoff in 1025px–1150px Range === */
@media (min-width: 1025px) and (max-width: 1150px) {
  .header-container {
    flex-wrap: wrap;
    gap: var(--spacing-small);
    justify-content: space-between;
    row-gap: 10px;
  }

  .main-nav ul {
    flex-wrap: wrap;
    gap: var(--spacing-small);
  }

  .logo img {
    height: 100px;
    width: auto;
  }

  .cta-button {
    padding: 8px 18px;
    font-size: 0.95em;
    white-space: nowrap;
    flex-shrink: 0;
  }
}


/* === FINAL TWEAKS === */

/* Restore mobile CTA visibility (only show below 769px) */
@media (max-width: 768px) {
  .cta-button-mobile {
    display: block !important;
    margin: 5px auto !important;
    padding: 10px 20px !important;
    max-width: 260px;
    text-align: center;
  }

  .hamburger-icon {
    margin-left: 0 !important;
  }
}

/* Enlarge logo slightly for tablet view */
@media (min-width: 769px) and (max-width: 1024px) {
  .logo img {
    height: 120px !important;
  }
}

/* NEW: Loading Spinner and Processing Message Styles */
#loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 15px;
}

#loading-spinner.hidden {
  display: none !important; /* Ensure it's hidden when the class is present */
}

.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: var(--primary-color); /* Using your primary color from variables */
  border-radius: 50%;
  width: 28px;
  height: 28px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#processing-message {
  text-align: center;
  margin-top: 10px;
  font-size: 1em;
  color: var(--primary-color); /* Using your primary color from variables */
  font-weight: bold;
}

#processing-message.hidden {
  display: none !important; /* Ensure it's hidden when the class is present */
}
.blog-list-main {
  padding: var(--spacing-jumbo) var(--spacing-extra-large);
  max-width: 1200px;
  margin: 0 auto;
}

.blog-list-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-jumbo);
}

/* Blog header styles */
.blog-list-header {
  text-align: center;
  margin-bottom: 0; /* AGGRESSIVELY REMOVED ALL MARGIN BELOW HEADER */
  padding-bottom: 0; /* Also remove padding */
}

.blog-list-title {
  color: var(--primary-color);
  font-size: 3em;
  margin-bottom: var(--spacing-medium);
}

.blog-list-description {
  color: var(--text-color-dark);
  font-size: 1.2em;
  line-height: 1.6;
  max-width: 800px;
  margin: 0 auto 0 auto; /* Removed bottom margin */
}

/* New styles for the separate Categories section */
.categories-section {
  padding-top: 0; /* AGGRESSIVELY REMOVED PADDING-TOP */
  padding-bottom: var(--spacing-large); /* Keep some padding at the bottom of the section */
  padding-left: var(--spacing-extra-large);
  padding-right: var(--spacing-extra-large);
  text-align: center;
  border-bottom: 1px solid var(--border-color-light);
  margin-bottom: var(--spacing-medium); /* Reduced space below categories */
  margin-top: 0; /* AGGRESSIVELY REMOVED ALL MARGIN ABOVE CATEGORIES */
}

.categories-section .categories-title {
  color: var(--primary-color);
  margin-top: 0; /* AGGRESSIVELY REMOVED MARGIN-TOP */
  margin-bottom: var(--spacing-large);
  font-size: 36px;
}

.categories-list-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--spacing-medium);
  list-style: none;
  padding: 0;
  margin: 0;
}

.categories-list-container .category-pill {
  display: inline-block;
  background-color: var(--secondary-color); /* Full green background */
  color: white; /* White text */
  border: none; /* Removed border to make it solid green */
  padding: var(--spacing-small) var(--spacing-large);
  border-radius: var(--spacing-large);
  text-decoration: none;
  font-size: 1.1em;
  transition: background-color 0.3s ease, color 0.3s ease;
  white-space: nowrap;
}

.categories-list-container .category-pill:hover {
  background-color: var(--secondary-color-dark); /* Darker green on hover */
  color: white;
}


/* Wrapper for the latest articles and sidebar */
.latest-articles-content-sidebar-wrapper {
  display: flex;
  flex-direction: column; /* ALWAYS STACK: Articles then Tags, both on desktop and mobile */
  gap: var(--column-gap); /* Gap between sections when stacked */
  align-items: flex-start; /* Align items to the start when stacked */
}

/* Specific styles for the "Ultimi Articoli" section on the blog page */
.latest-articles-section {
  flex-grow: 1; /* Allow it to grow if in a flex container */
  width: 100%; /* Ensure it takes full width */
  padding: var(--spacing-jumbo) var(--spacing-extra-large);
  border-bottom: none;
  margin-bottom: 0;
  margin-top: var(--spacing-medium); /* Reduced margin-top to bring it closer */
}

.latest-articles-section .latest-articles-title {
  color: var(--primary-color);
  margin-bottom: var(--spacing-large);
  font-size: 36px;
  text-align: center; /* Confirmed already centered */
}

/* Main articles grid and individual card adjustments for blog page */
.latest-articles-section .article-grid {
  display: flex;
  flex-direction: row; /* Articles will try to go horizontal */
  flex-wrap: wrap; /* Allow articles to wrap to the next line */
  justify-content: center; /* Center articles horizontally within the grid */
  gap: var(--spacing-large); /* Space between article cards */
  margin-top: var(--spacing-extra-large);
  padding-left: var(--spacing-extra-large);
  padding-right: var(--spacing-extra-large);
}

.latest-articles-section .view-all-button {
  margin-top: var(--spacing-large);
  padding-left: var(--spacing-extra-large);
}


.latest-articles-section .article-grid .article-card-container {
  min-width: 280px; /* Ensure a minimum width for cards */
  width: 100%; /* Default to full width for small screens/initial flex calculation */
  flex: 1 1 calc(33.333% - var(--spacing-large) * 2 / 3); /* Try for three columns, accounting for gap */
  max-width: calc(33.333% - var(--spacing-large) * 2 / 3); /* Max width for three columns */
  margin: 0; /* Reset margin from previous auto */
  box-sizing: border-box;
}


/* Sidebar Styles */
.blog-sidebar {
  width: 100%; /* Take full width when stacked */
  background-color: var(--background-light);
  padding: var(--spacing-large);
  border-radius: var(--spacing-small);
  box-shadow: 0 2px 5px var(--shadow-color);
  box-sizing: border-box;
  margin-top: var(--spacing-jumbo); /* Add space above Tags section */
  display: none; /* HIDE BY DEFAULT FOR MOBILE */
}

.blog-sidebar .sidebar-title {
  color: var(--primary-color);
  font-size: 1.8em;
  margin-top: 0;
  margin-bottom: var(--spacing-large);
  text-align: center; /* Centered for consistency */
}

.blog-sidebar .sidebar-title-mt {
   margin-top: var(--spacing-extra-large);
}

.sidebar-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-small);
  justify-content: center; /* Center tags within the sidebar */
}

.sidebar-tag-pill {
  background-color: var(--secondary-color); /* Tags color changed to green */
  color: white;
  padding: var(--spacing-small) var(--spacing-medium);
  border-radius: var(--spacing-large);
  text-decoration: none;
  font-size: 0.9em;
  transition: background-color 0.3s ease;
}

.sidebar-tag-pill:hover {
  background-color: var(--secondary-color-dark); /* Darker green on hover */
}

/* Styles for "Tutti gli Articoli" section */
.all-articles-wrapper {
  width: 100%;
}

.all-articles-section {
  padding: 0;
  text-align: center;
  border-bottom: none;
  margin-top: var(--spacing-jumbo);
  margin-bottom: var(--spacing-jumbo);
}

.all-articles-section .all-articles-title {
  color: var(--primary-color);
  margin-bottom: var(--spacing-large);
  font-size: 36px;
}

.all-articles-section .article-grid {
  display: flex;
  flex-direction: row; /* Try to put articles in a row */
  flex-wrap: wrap;
  justify-content: center; /* Center them */
  gap: var(--spacing-large); /* Consistent gap */
  margin-top: var(--spacing-extra-large);
}

.all-articles-section .article-grid .article-card-container {
  min-width: 280px;
  width: 100%;
  flex: 1 1 calc(33.333% - var(--spacing-large) * 2 / 3); /* Try for three columns */
  max-width: calc(33.333% - var(--spacing-large) * 2 / 3);
  margin: 0;
  box-sizing: border-box;
}

/* Pagination Styles */
.pagination {
  margin-top: var(--spacing-jumbo);
  text-align: center;
}

.pagination-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  gap: var(--spacing-medium);
  flex-wrap: wrap;
}

.pagination-link {
  display: inline-block;
  padding: var(--spacing-small) var(--spacing-medium);
  background-color: var(--background-light);
  border: 1px solid var(--border-color);
  border-radius: var(--spacing-small);
  color: var(--text-color-dark);
  text-decoration: none;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.pagination-link:hover {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Article Card Date/Meta Info */
.article-card-meta {
  font-size: 0.9em;
  color: var(--text-color-light);
  margin-bottom: var(--spacing-small);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modal Styles */
.article-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: var(--spacing-medium);
  box-sizing: border-box;
}

.article-modal-content {
  background-color: white;
  padding: var(--spacing-extra-large);
  border-radius: 8px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal-close-button {
  position: absolute;
  top: var(--spacing-medium);
  right: var(--spacing-medium);
  background: none;
  border: none;
  font-size: 2em;
  cursor: pointer;
  color: var(--text-color-dark);
}

.modal-close-button:hover {
  color: black;
}

.modal-article-content h2 {
  color: var(--primary-color);
  font-size: 2.2em;
  margin-bottom: var(--spacing-medium);
}

.modal-article-content .article-meta {
  color: var(--text-color-light);
  font-size: 0.9em;
  margin-bottom: var(--spacing-large);
}

.modal-article-content .article-body {
  line-height: 1.7;
  color: var(--text-color-dark);
}

/* Media Queries for Blog Page */

/* Desktop layout: Articles and Tags are now stacked vertically. */
@media (min-width: 769px) {
  /* Remove flex direction from wrapper, allowing children to stack naturally */
  .latest-articles-content-sidebar-wrapper {
    flex-direction: column; /* Ensure stacking on desktop as well */
    align-items: center; /* Center the stacked sections */
  }

  .latest-articles-section {
    width: 100%; /* Take full available width */
    margin-right: 0; /* Remove side margin */
  }

  .blog-sidebar {
    width: 100%; /* Take full available width */
    max-width: 100%; /* Remove max-width restriction for full width stacking */
    position: static; /* No longer sticky, stacks below articles */
    margin-top: var(--spacing-jumbo); /* Add space between articles and tags */
    display: block; /* SHOW ON DESKTOP */
  }

  .blog-sidebar .sidebar-title {
    text-align: center; /* Center tags title when full width */
  }

  .sidebar-tags-container {
    justify-content: center; /* Center tags within the full-width sidebar */
  }

  .latest-articles-section .article-grid {
    /* Articles are already set to flex-direction: row; and justify-content: center; */
    /* This will now attempt to lay them out horizontally in the full available width. */
  }

  /* Adjust article card width to try and fit 3 on a line in the new full width */
  .latest-articles-section .article-grid .article-card-container {
    flex: 1 1 calc(33.333% - var(--spacing-large) * 2 / 3); /* Try for three columns, accounting for gap */
    max-width: calc(33.333% - var(--spacing-large) * 2 / 3);
  }

  .all-articles-section .article-grid {
    justify-content: center; /* Center articles */
  }

  .all-articles-section .article-grid .article-card-container {
    flex: 1 1 calc(33.333% - var(--column-gap) * 2 / 3);
    max-width: calc(33.333% - var(--column-gap) * 2 / 3);
  }
}

/* Tablet adjustments for article grid (still two columns) */
@media (min-width: 769px) and (max-width: 1024px) {
  .latest-articles-section .article-grid .article-card-container,
  .all-articles-section .article-grid .article-card-container {
    flex: 1 1 calc(50% - var(--column-gap) / 2); /* Two columns with gap */
    max-width: calc(50% - var(--column-gap) / 2);
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .categories-section .categories-title {
    font-size: 2em;
  }

  .categories-list-container {
    justify-content: center;
  }

  .categories-list-container .category-pill {
    font-size: 1em;
    padding: var(--spacing-small) var(--spacing-medium);
  }

  /* Tags sidebar behavior on mobile: hidden */
  .blog-sidebar {
    order: 2; /* Ensures it stays below the articles if it were visible */
    margin-top: var(--spacing-jumbo); /* Add space above sidebar when stacked */
    display: none; /* HIDE ON MOBILE */
  }

    .latest-articles-section {
    order: 1;
  }

  .latest-articles-section .article-grid {
    flex-direction: column; /* Ensure articles stack vertically on mobile */
    justify-content: center;
  }

  .latest-articles-section .article-grid .article-card-container {
      min-width: unset;
      width: 100%;
      max-width: 100%; /* Ensure it takes full width */
  }
}

/* Styles for Single Article Page (post.njk) */

/* Main container for the article content, ensuring it's not full page width */
.blog-post-main {
  padding: var(--spacing-jumbo) var(--spacing-extra-large); /* Consistent padding around the main content area */
  max-width: 1200px; /* Max width for the overall main section, similar to blog list */
  margin: 0 auto; /* Center the main blog post area */
}

/* Message Container Alignment (outside form card) */
.message-container {
  width: 80%;
  max-width: 800px;
  margin: 20px auto;
  box-sizing: border-box;
  text-align: left;
}