:root {
  --home-divider: #ddddda;
  --home-section-space-before: clamp(46px, 4.8vw, 72px);
  --home-section-space-after: clamp(28px, 2.8vw, 42px);
}

/* Bring the homepage carousel closer to the logo and navigation. */
body[data-page="home"] .site-header {
  min-height: 154px;
  padding-top: 24px;
  padding-bottom: 16px;
  gap: 24px;
}

/* Homepage carousel: reserve the final stage before any image is decoded. */
body[data-page="home"] .carousel {
  --home-carousel-target-height: clamp(330px, 52vh, 580px);
  --home-carousel-stage-height: clamp(400px, 60vh, 650px);
  --home-carousel-max-width: calc(100vw - 220px);
}

body[data-page="home"] .carousel,
body[data-page="home"] .carousel-images {
  overflow: visible;
}

body[data-page="home"] .carousel-images {
  height: var(--home-carousel-stage-height);
  min-height: 0;
  background: var(--paper);
}

body[data-page="home"] .carousel-slide {
  display: grid;
  place-items: center;
  padding: 18px clamp(82px, 8vw, 132px) 32px;
  overflow: visible;
  transform: none !important;
  transition: opacity 900ms ease !important;
}

body[data-page="home"] .carousel-slide.is-active {
  transform: none !important;
}

body[data-page="home"] .carousel-slide img {
  display: block;
  width: auto;
  height: var(--home-carousel-target-height);
  max-width: var(--home-carousel-max-width);
  max-height: var(--home-carousel-target-height);
  aspect-ratio: auto !important;
  object-fit: contain !important;
  object-position: center !important;
  transform: none !important;
  opacity: 0;
  transition: opacity 320ms ease;
  box-shadow:
    -8px 9px 14px rgba(18, 18, 18, .21),
    -2px 3px 5px rgba(18, 18, 18, .12);
}

body[data-page="home"] .carousel-slide img[data-home-carousel-ready="true"] {
  opacity: 1;
}

/* Plain arrows in the side gutters, without circles or backgrounds. */
body[data-page="home"] .carousel-arrow {
  width: 48px;
  height: 56px;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: rgba(18, 18, 18, .72);
  text-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body[data-page="home"] .carousel-arrow--previous { left: 24px; }
body[data-page="home"] .carousel-arrow--next { right: 24px; }

body[data-page="home"] .carousel-controls button {
  border-color: rgba(18, 18, 18, .5);
}

body[data-page="home"] .carousel-controls button.is-active {
  background: rgba(18, 18, 18, .76);
}

/* Divider: more room above the line, less room between line and next title. */
body[data-page="home"] .home-hero + .work-section {
  margin-top: var(--home-section-space-before);
  padding-top: var(--home-section-space-after);
  padding-bottom: var(--home-section-space-before);
  border-top: 1px solid var(--home-divider);
}

body[data-page="home"] .work-section + .work-section {
  padding-top: var(--home-section-space-after);
  border-top: 1px solid var(--home-divider);
}

/* JS-positioned wall: four columns desktop, exact equal gaps, original ratios. */
#photography-preview[data-dynamic-photography="true"] {
  --home-wall-gap: clamp(12px, 1.2vw, 18px);
  position: relative;
  display: block !important;
  width: 100%;
  height: 0;
  margin-top: 18px;
  padding: 0 !important;
}

#photography-preview[data-dynamic-photography="true"] .home-dynamic-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  min-width: 0;
  margin: 0;
  display: block;
  grid-column: auto !important;
  grid-row-end: auto !important;
  align-self: start;
  opacity: 1;
  filter: blur(0);
  transition:
    opacity 1.2s cubic-bezier(.22, .61, .36, 1),
    filter 1.2s cubic-bezier(.22, .61, .36, 1);
  will-change: opacity, filter;
}

#photography-preview[data-dynamic-photography="true"] .home-dynamic-card .work-image {
  width: 100%;
  height: 100%;
  margin: 0;
  display: block;
  overflow: hidden;
  background: transparent;
}

#photography-preview[data-dynamic-photography="true"] .home-dynamic-card img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  object-fit: contain !important;
  object-position: top center;
  transform: none !important;
}

#photography-preview[data-dynamic-photography="true"] .home-dynamic-card.is-leaving,
#photography-preview[data-dynamic-photography="true"] .home-dynamic-card.is-entering {
  opacity: 0;
  filter: blur(2px);
}

@media (max-width: 820px) {
  :root {
    --home-section-space-before: 38px;
    --home-section-space-after: 24px;
  }

  body[data-page="home"] .site-header {
    min-height: 132px;
    padding-top: 20px;
    padding-bottom: 10px;
    gap: 20px;
  }

  body[data-page="home"] .carousel {
    --home-carousel-target-height: clamp(240px, 38vh, 360px);
    --home-carousel-stage-height: clamp(294px, 46vh, 414px);
    --home-carousel-max-width: calc(100vw - 76px);
  }

  body[data-page="home"] .carousel-slide {
    padding: 14px 44px 28px;
  }

  body[data-page="home"] .carousel-slide img {
    box-shadow:
      -6px 7px 11px rgba(18, 18, 18, .20),
      -2px 2px 4px rgba(18, 18, 18, .11);
  }

  body[data-page="home"] .carousel-arrow {
    width: 32px;
    height: 46px;
  }

  body[data-page="home"] .carousel-arrow--previous { left: 6px; }
  body[data-page="home"] .carousel-arrow--next { right: 6px; }

  #photography-preview[data-dynamic-photography="true"] {
    --home-wall-gap: 10px;
    margin-top: 14px;
  }
}

@media (max-width: 460px) {
  body[data-page="home"] .carousel-slide {
    padding: 12px 38px 26px;
  }

  #photography-preview[data-dynamic-photography="true"] {
    --home-wall-gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-page="home"] .carousel-slide img {
    transition-duration: 0ms;
  }

  #photography-preview[data-dynamic-photography="true"] .home-dynamic-card {
    transition-duration: .25s;
  }
}
