/* Add breathing room between major homepage sections without changing card-to-card gaps. */
.page-home .home-content > section,
.page-home body > section:not(.home-media-hero) {
  margin-block: 0 !important;
  padding-top: clamp(50px, 5vw, 76px) !important;
  padding-bottom: clamp(44px, 4vw, 64px) !important;
}

@media (max-width: 820px) {
  .page-home .home-content > section,
  .page-home body > section:not(.home-media-hero) {
    padding-top: 42px !important;
    padding-bottom: 48px !important;
  }
}

/* The home-spaces cards animate in from +/-72px while still below the fold.
   Keep that reveal inside its section so it cannot create page-level x-scroll. */
.page-home .home-spaces {
  overflow-x: clip;
}

/* Preserve the existing gap above the category tiles. */
.page-home .home-content > .home-main-categories {
  padding-top: 24px !important;
}

.home-project-stack {
  --project-stack-step: max(260px, calc(var(--project-card-height) - 88px));
}

.home-project-stack__stage {
  display: block;
}

.home-project-stack__card {
  position: sticky;
  top: clamp(104px, 13vh, 148px);
  z-index: calc(10 + var(--stack-index));
  padding-top: calc(var(--stack-index) * var(--project-stack-gap));
  margin: 0 0 calc(var(--project-stack-step) - var(--project-card-height));
  opacity: 1;
  transform: none;
}

.home-project-stack__link {
  min-height: var(--project-card-height);
  transform: scale(calc(1 - (var(--stack-index) * 0.012)));
}

.home-project-stack__link img {
  height: var(--project-card-height);
}

.home-project-stack__spacer {
  display: block;
  height: calc(var(--project-card-height) * 0.72);
}

@media (max-width: 820px) {
  .home-project-stack {
    --project-stack-step: calc(var(--project-card-height) - 56px);
  }

  .home-project-stack__card {
    top: 96px;
  }
}

.home-project-gallery {
  width: 100%;
  max-width: 100%;
  padding: clamp(42px, 6vw, 84px) 0 clamp(52px, 7vw, 92px);
}

.home-project-gallery__heading {
  display: grid;
  justify-items: center;
  gap: clamp(12px, 1.6vw, 22px);
  width: min(100%, 1280px);
  margin: 0 auto clamp(34px, 5vw, 68px);
  text-align: center;
  transition: opacity 520ms ease, transform 620ms cubic-bezier(.16, 1, .3, 1);
}

.home-project-gallery__heading p {
  max-width: 880px;
  margin: 0;
  color: var(--color-muted, #595959);
  font-family: var(--font-body, Georgia, serif);
  font-size: clamp(.98rem, 1.25vw, 1.1rem);
  line-height: 1.35;
}

.home-project-gallery__heading h2 {
  margin: 0;
  color: var(--color-ink);
  font-size: clamp(1.9rem, 2.6vw, 2.75rem);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.05;
}

.home-project-gallery__row {
  display: flex;
  align-items: stretch;
  gap: 0;
  block-size: clamp(240px, 29vw, 390px);
  height: clamp(240px, 29vw, 390px);
  max-height: clamp(240px, 29vw, 390px);
  min-height: 0;
  overflow: hidden;
  contain: layout paint;
  border: 1px solid var(--color-border, rgba(25, 32, 29, .18));
}

.home-project-gallery__item {
  min-width: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  flex: 1 1 0%;
  align-self: stretch;
  transition: flex-grow 480ms cubic-bezier(.2,.75,.25,1), opacity 420ms ease, transform 560ms cubic-bezier(.16,1,.3,1);
}

.home-project-gallery.is-reveal-ready:not(.is-in-view) .home-project-gallery__heading,
.home-project-gallery.is-reveal-ready:not(.is-in-view) .home-project-gallery__item {
  opacity: 0;
  transform: translateY(18px);
}

.home-project-gallery.is-in-view .home-project-gallery__heading,
.home-project-gallery.is-in-view .home-project-gallery__item { opacity: 1; transform: translateY(0); }
.home-project-gallery.is-in-view .home-project-gallery__item { transition-delay: var(--project-gallery-delay, 0ms); }
.home-project-gallery__item:nth-child(2) { --project-gallery-delay: 70ms; }
.home-project-gallery__item:nth-child(3) { --project-gallery-delay: 140ms; }
.home-project-gallery__item:nth-child(4) { --project-gallery-delay: 210ms; }
.home-project-gallery__item:nth-child(5) { --project-gallery-delay: 280ms; }
.home-project-gallery__item:nth-child(6) { --project-gallery-delay: 350ms; }
.home-project-gallery__item:nth-child(7) { --project-gallery-delay: 420ms; }
.home-project-gallery__item:nth-child(8) { --project-gallery-delay: 490ms; }

.home-project-gallery__item + .home-project-gallery__item {
  border-left: 1px solid rgba(255, 255, 255, .7);
}

.home-project-gallery__link {
  display: block;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  color: inherit;
}

.home-project-gallery__image {
  position: relative;
  display: block;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #e9e7e1;
}

.home-project-gallery__image img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 700ms cubic-bezier(.2,.75,.25,1), filter 300ms ease;
}

.home-project-gallery__image::after {
  position: absolute;
  inset: 35% 0 0;
  background: linear-gradient(transparent, rgba(12, 16, 14, .66));
  content: "";
  pointer-events: none;
}

.home-project-gallery__arrow {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.72);
  color: #fff;
  opacity: 0;
  transform: translate(-3px, 3px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.home-project-gallery__caption {
  position: absolute;
  right: 18px;
  bottom: 17px;
  left: 18px;
  z-index: 1;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 5px;
  color: #fff;
}

.home-project-gallery__caption strong {
  display: -webkit-box;
  overflow: hidden;
  color: #fff;
  font-size: clamp(.9rem, 1.15vw, 1.12rem);
  font-weight: 600;
  line-height: 1.18;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.home-project-gallery__caption small {
  overflow: hidden;
  color: rgba(255,255,255,.78);
  font-size: .68rem;
  letter-spacing: .04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (hover: hover) and (min-width: 821px) {
  .home-project-gallery__row:hover .home-project-gallery__item { flex-grow: .82; }
  .home-project-gallery__row:hover .home-project-gallery__item:hover,
  .home-project-gallery__item:focus-within { flex-grow: 1.8; }
}

.home-project-gallery__item:hover .home-project-gallery__image img,
.home-project-gallery__item:focus-within .home-project-gallery__image img { transform: scale(1.045); }
.home-project-gallery__item:hover .home-project-gallery__arrow,
.home-project-gallery__item:focus-within .home-project-gallery__arrow { opacity: 1; transform: translateY(0); }

@media (max-width: 820px) {
  .home-project-gallery { padding-top: 34px; overflow: clip; }
  .home-project-gallery__heading {
    gap: 10px;
    margin-bottom: 24px;
  }
  .home-project-gallery__heading h2 { font-size: clamp(1.9rem, 8vw, 3rem); }
  .home-project-gallery__row {
    block-size: 280px;
    height: 280px;
    max-height: 280px;
    overflow-x: auto;
    overflow-y: hidden;
    contain: layout paint;
    border-right: 0;
    border-left: 0;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .home-project-gallery__row::-webkit-scrollbar { display: none; }
  .home-project-gallery__item { flex: 0 0 min(72vw, 320px); scroll-snap-align: start; }
  .home-project-gallery__item + .home-project-gallery__item { border-left: 1px solid rgba(255,255,255,.7); }
  .home-project-gallery__item,
  .home-project-gallery__link,
  .home-project-gallery__image { height: 100%; }
  .home-project-gallery__caption { right: 14px; bottom: 14px; left: 14px; }
  .home-project-gallery__arrow { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .home-project-gallery__heading,
  .home-project-gallery__item,
  .home-project-gallery__image img,
  .home-project-gallery__arrow { transition: none; }
}
