@layer components {
  /* Buttons */
  .btn-primary {
    @apply inline-flex items-center justify-center bg-primary text-ivory font-semibold py-2.5 px-6 rounded-md hover:bg-primary-dark transition;
  }

  .btn-inverse {
    @apply inline-flex items-center justify-center bg-ivory text-primary font-semibold py-2.5 px-6 rounded-md hover:bg-secondary hover:text-primary-dark transition;
  }

  /* Links */
  .link {
    @apply text-primary hover:text-primary-dark underline-offset-2 hover:underline;
  }

  .link-inverse {
    @apply text-ivory hover:text-secondary underline-offset-2 hover:underline;
  }

  /* Inputs */
  .input-field {
    @apply w-full rounded-md border border-black/10 bg-white px-3 py-2 text-sm text-body placeholder:text-body/50 focus:outline-none focus:ring-2 focus:ring-primary;
  }
}

/* === Reusable Section Background System === */
.section-bg {
  position: relative;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
}

.section-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: rgba(25, 54, 37, 0.4); /* brand overlay */
  z-index: 0;
}

.section-bg > * {
  position: relative;
  z-index: 1;
}

/* === Section-specific backgrounds === */
.hero-bg { background-image: url("hero-bg.jpg"); }
.features-bg { background-image: url("features-bg.jpg"); }
.pricing-bg { background-image: url("pricing-bg.jpg"); }
.about-bg { background-image: url("about-bg.jpg"); }

:target {
  scroll-margin-top: 6rem; /* adjust based on header height */
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fadeIn {
  animation: fadeIn 0.25s ease-out;
}

/* === Blog Modal (desktop behavior) === */
.blog-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  z-index: 50;
  padding: 2rem;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.25s ease-out;
}

.blog-modal-content {
  background: #F5F5EB; /* ivory */
  color: #374151; /* body text */
  border-radius: 0.75rem;
  max-width: 800px;
  width: 100%;
  padding: 2rem;
  margin-top: 2rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

@media (min-width: 768px) {
  .blog-modal {
    align-items: center;
  }
}

/* === BLOG MODAL (Desktop final verified version) === */
@media (min-width: 768px) {
  body.modal-open {
    overflow: hidden; /* Lock background scroll */
  }

  .blog-modal {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.55);
    z-index: 50;
    backdrop-filter: blur(3px);
    animation: fadeIn 0.25s ease-out;
    padding: 2rem;
  }

  .blog-modal-content {
    background: #F5F5EB; /* ivory */
    color: #374151;      /* body text */
    border-radius: 0.75rem;
    width: 100%;
    max-width: 800px;
    height: 90vh;        /* Fixed viewport height */
    display: flex;
    flex-direction: column;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  }

  .blog-modal-header,
  .blog-modal-footer {
    flex-shrink: 0;
    background: #F5F5EB;
    padding: 1rem 1.5rem;
    position: sticky;
    z-index: 10;
  }

  .blog-modal-header {
    top: 0;
    border-radius: 0.75rem 0.75rem 0 0;
  }

  .blog-modal-footer {
    bottom: 0;
    border-radius: 0 0 0.75rem 0.75rem;
  }

  .blog-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
  }
}

/* Blog content readability tweaks */
.prose p,
.prose ul,
.prose ol,
.prose li,
.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  margin-top: 0.75em;
  margin-bottom: 0.75em;
  line-height: 1.6;
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
  list-style-position: inside;
}

.prose a {
  color: #B17457; /* your accent */
  text-decoration: underline;
}

.prose strong {
  font-weight: 600;
}

/* Center and evenly distribute blog cards */
#blogPosts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;      /* center when 1 item */
  gap: 1.5rem;                  /* space between cards */
}

#blogPosts > article {
  flex: 1 1 300px;              /* responsive: min 300px, grow if space */
  max-width: 360px;             /* optional: consistent width cap */
}
