.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
  margin: 1.2rem 0 0;
}

.post-card {
  position: relative;
  border: none;
  border-radius: var(--card-radius);
  background: var(--card-surface);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--card-border);
  transition:
    transform var(--anim-duration) ease,
    box-shadow var(--anim-duration) ease,
    border-color var(--anim-duration) ease;
  isolation: isolate;
  overflow: hidden;
}

.post-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(80, 64, 24, 0.02) 0%,
    rgba(80, 64, 24, 0.08) 100%
  );
  opacity: 0;
  transition: opacity var(--anim-duration) ease;
  z-index: 1;
}

.post-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--card-border-strong);
  transform: translateY(-3px);
}

.post-card:hover::before {
  opacity: 1;
}

.post-card .thumb {
  width: 100%;
  height: 236px;
  overflow: hidden;
  border-top-left-radius: var(--card-radius);
  border-top-right-radius: var(--card-radius);
}
.post-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--anim-duration) ease;
}

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

.post-body {
  padding: 1.25rem 1.25rem 1.45rem;
  position: relative;
  z-index: 2;
}

.post-body h3 {
  margin: 0 0 0.52rem 0;
  color: var(--gray-800);
  font-size: 1.24rem;
  line-height: 1.34;
  transition: color 0.3s ease;
}

.post-body p {
  color: var(--gray-700);
  margin: 0;
  line-height: 1.68;
  transition: color 0.3s ease;
}

/* Project page styles */
.project-hero {
  position: relative;
  min-height: clamp(360px, 56vh, 540px);
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(
      135deg,
      rgba(24, 18, 7, 0.74) 0%,
      rgba(58, 42, 16, 0.58) 44%,
      rgba(74, 55, 23, 0.4) 70%,
      rgba(74, 55, 23, 0.26) 100%
    ),
    var(--primary-dark);
  background-size: cover;
  background-position: center;
  background-attachment: scroll;
  color: var(--white);
  margin-bottom: 2.5rem;
  overflow: hidden;
  padding: clamp(86px, 10vh, 118px) 0 clamp(56px, 8vh, 84px);
}

.project-hero .hero-inner {
  position: relative;
  z-index: 2;
  text-align: center;
  width: min(100%, 920px);
  margin: auto;
  padding: 0 clamp(1rem, 3vw, 2.2rem);
  display: grid;
  gap: 0.85rem;
}

.project-title {
  font-size: clamp(2rem, 4.4vw, 3.35rem);
  line-height: 1.1;
  margin: 0;
  color: var(--white);
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.44);
}

.project-meta {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  justify-content: center;
  color: rgba(255, 248, 236, 0.95);
  font-size: 1.1rem;
  font-weight: 500;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
}

.project-content {
  max-width: 1200px;
  margin: 2.5rem auto;
  padding: 0 2rem;
}

/* Make rich content images responsive but constrained */
.project-content img {
  display: block;
  width: 100%;
  max-width: 640px; /* limit width so images take less space */
  height: auto;
  margin: 1rem auto;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  cursor: zoom-in; /* indicate lightbox availability */
}
/* 3-column wrapping grid for consecutive images */
.project-content .inline-image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 1.25rem 0;
}
.project-content .inline-image-grid figure {
  margin: 0;
}
.project-content .inline-image-grid img {
  width: 100%;
  max-width: 100%;
  height: 250px; /* consistent thumbnail height */
  object-fit: cover;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  margin: 0; /* override generic image margin */
  cursor: zoom-in;
}
/* Align images using Quill's align classes preserved in HTML */
.project-content .ql-align-left img {
  float: left;
  margin: 0.5rem 1rem 1rem 0;
}
.project-content .ql-align-right img {
  float: right;
  margin: 0.5rem 0 1rem 1rem;
}
.project-content .ql-align-center img {
  float: none;
  margin-left: auto;
  margin-right: auto;
}
/* Clear floats after content block to contain wrapping */
.project-content::after {
  content: "";
  display: table;
  clear: both;
}

/* Legacy mini-gallery markup flattening */
.project-content .mini-gallery {
  display: contents;
}
.project-content .mini-gallery figure {
  display: block;
  margin: 1rem auto;
  max-width: 640px;
}
.project-content .mini-gallery img {
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 10px;
}
/* no custom scrollbar needed when not scrolling */

.project-overview {
  margin-bottom: 2.5rem;
  color: var(--gray-800);
  line-height: 1.75;
  font-size: 1.05rem;
}

.project-content h2 {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--primary);
  font-size: 1.5rem;
}

.project-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}
.project-gallery img {
  width: 100%;
  height: 280px;
  object-fit: cover;
  border-radius: 14px;
  transition:
    transform var(--anim-duration) ease,
    box-shadow var(--anim-duration) ease;
}

.project-back {
  display: inline-block;
  margin-top: 1.5rem;
  color: var(--primary);
  text-decoration: underline;
}

/* Lightbox styles */
.lightbox {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(26, 22, 16, 0.84);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  z-index: 2000;
  opacity: 0;
  transition: opacity 220ms ease;
}
.lightbox.open {
  opacity: 1;
}
.lightbox-inner {
  position: relative;
  max-width: 95%;
  max-height: 95%;
  display: grid;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
}
.lightbox-img {
  max-width: calc(100vw - 160px);
  max-height: calc(100vh - 160px);
  border-radius: 16px;
  border: 1px solid rgba(242, 236, 223, 0.28);
  box-shadow: 0 18px 38px rgba(12, 10, 8, 0.42);
}
.lightbox-caption {
  color: #f6efe1;
  text-align: center;
  margin-top: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  background: rgba(17, 13, 10, 0.68);
  border: 1px solid rgba(242, 236, 223, 0.24);
  border-radius: 999px;
  padding: 0.42rem 0.85rem;
  max-width: min(86vw, 760px);
  justify-self: center;
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(20, 16, 12, 0.72);
  border: 1px solid rgba(242, 236, 223, 0.28);
  color: #f9f5ec;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background var(--anim-duration) ease,
    border-color var(--anim-duration) ease,
    transform var(--anim-duration) ease;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(30, 24, 18, 0.88);
  border-color: rgba(242, 236, 223, 0.45);
  transform: translateY(-1px);
}

.lightbox-close {
  right: 14px;
  top: 14px;
}
.lightbox-prev {
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
}
.lightbox-next {
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

@media (max-width: 700px) {
  .lightbox-img {
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 140px);
  }

  .lightbox-caption {
    max-width: calc(100vw - 40px);
    font-size: 0.85rem;
  }

  .lightbox-prev,
  .lightbox-next {
    display: none;
  }
}

@media (max-width: 900px) {
  .project-gallery {
    grid-template-columns: repeat(2, 1fr);
  }

  .project-hero {
    min-height: 340px;
    padding: 80px 0 52px;
  }
}

@media (max-width: 520px) {
  .project-gallery {
    grid-template-columns: 1fr;
  }

  .project-hero .hero-inner {
    padding: 0 1rem;
  }

  .project-title {
    font-size: clamp(1.9rem, 8vw, 2.65rem);
  }
}
