.image-with-text .grid {
  margin-bottom: 0;
}

.image-with-text .grid__item {
  position: relative;
}

/* Mobile: text card first, then image (default - image_second) */
@media screen and (max-width: 749px) {
  .image-with-text .grid {
    display: flex;
    flex-direction: column-reverse;
  }
  
  /* Mobile: image first, then text card (when mobile_layout is image_first) */
  .image-with-text .image-with-text__grid--mobile-image-first {
    flex-direction: column;
  }
  
  /* Mobile: text first, then image card (when mobile_layout is image_second - default behavior) */
  .image-with-text .image-with-text__grid--mobile-image-second {
    flex-direction: column-reverse;
  }
  
  .image-with-text__content,
  .image-with-text__content--radius {
    display: flex !important;
    flex-direction: column !important;
    border-radius: var(--border-radius-content) !important;
  }

  .image-with-text__text-item {
    border-radius: var(--border-radius-content) !important;
    overflow: hidden;
  }
  
  /* When image is first on mobile, text card keeps all rounded corners */
  .image-with-text .image-with-text__grid--mobile-image-first .image-with-text__content,
  .image-with-text .image-with-text__grid--mobile-image-first .image-with-text__content--radius {
    border-radius: var(--border-radius-content) !important;
  }

  .image-with-text .image-with-text__grid--mobile-image-first .image-with-text__text-item {
    border-radius: var(--border-radius-content) !important;
    overflow: hidden;
  }
  
  /* Mobile: Disable the overlay gradient (::before) - we only want vertical shine */
  .image-with-text__content::before {
    opacity: 0 !important;
    display: none !important;
  }
  
  /* Mobile: Change inset shadow from top to bottom, remove white border */
  .image-with-text__content {
    box-shadow: 3px 0px 6px -20px rgba(0, 0, 0, 0.06),
                2px 0px 3px -1px rgba(0, 0, 0, 0.04),
                inset 0 -8px 22px rgba(255, 255, 255, 0.18) !important;
  }
  
  /* Mobile: Enable shine effect on mobile as well - vertical gradient from bottom */
  .image-with-text__content::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 60%;
    background: 
      linear-gradient(to top,
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(255, 255, 255, 0.90) 8%,
        rgba(255, 255, 255, 0.84) 15%,
        rgba(255, 255, 255, 0.76) 22%,
        rgba(255, 255, 255, 0.67) 28%,
        rgba(255, 255, 255, 0.57) 34%,
        rgba(255, 255, 255, 0.47) 40%,
        rgba(255, 255, 255, 0.37) 46%,
        rgba(255, 255, 255, 0.29) 52%,
        rgba(255, 255, 255, 0.21) 58%,
        rgba(255, 255, 255, 0.15) 64%,
        rgba(255, 255, 255, 0.10) 70%,
        rgba(255, 255, 255, 0.06) 76%,
        rgba(255, 255, 255, 0.04) 82%,
        rgba(255, 255, 255, 0.02) 88%,
        rgba(255, 255, 255, 0.01) 94%,
        transparent 100%
      );
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
    opacity: 1;
  }
  
  /* When text is on the left (image first on mobile), gradient stays the same - bottom to top */
  .image-with-text .image-with-text__grid--mobile-image-first .image-with-text__content::after {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 60%;
    background: 
      linear-gradient(to top,
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(255, 255, 255, 0.90) 8%,
        rgba(255, 255, 255, 0.84) 15%,
        rgba(255, 255, 255, 0.76) 22%,
        rgba(255, 255, 255, 0.67) 28%,
        rgba(255, 255, 255, 0.57) 34%,
        rgba(255, 255, 255, 0.47) 40%,
        rgba(255, 255, 255, 0.37) 46%,
        rgba(255, 255, 255, 0.29) 52%,
        rgba(255, 255, 255, 0.21) 58%,
        rgba(255, 255, 255, 0.15) 64%,
        rgba(255, 255, 255, 0.10) 70%,
        rgba(255, 255, 255, 0.06) 76%,
        rgba(255, 255, 255, 0.04) 82%,
        rgba(255, 255, 255, 0.02) 88%,
        rgba(255, 255, 255, 0.01) 94%,
        transparent 100%
      );
  }
  
  /* Heading first, text second */
  .image-with-text__content > .image-with-text__heading,
  .image-with-text__content > h2,
  .image-with-text__content > [class*="heading"] {
    order: 1 !important;
  }
  
  .image-with-text__content > .image-with-text__text,
  .image-with-text__content > .rte,
  .image-with-text__content > p,
  .image-with-text__content > [class*="text"] {
    order: 2 !important;
  }
  
  .image-with-text__content > .button,
  .image-with-text__content > .button-wrapper,
  .image-with-text__content > a {
    order: 3 !important;
  }
}

@media screen and (min-width: 750px) {
  .image-with-text__grid--reverse {
    flex-direction: row-reverse;
  }

  /* Mirror shadow whenever text card is rendered second (grid reversed) */
  .image-with-text__grid--reverse .image-with-text__text-item .image-with-text__content,
  .image-with-text__grid--reverse .image-with-text__text-item .image-with-text__content--radius {
    box-shadow: -3px 0px 6px -20px rgba(0, 0, 0, 0.06),
                -2px 0px 3px -1px rgba(0, 0, 0, 0.04),
                inset 1px 0 0 1px rgba(255, 255, 255, 0.35),
                inset 0 8px 22px rgba(255, 255, 255, 0.18);
  }
}

.image-with-text__media {
  overflow: visible;
}


.image-with-text__media--small {
  height: 19.4rem;
}

.image-with-text__media--medium {
  height: 32rem;
}

.image-with-text__media--large {
  height: 43.5rem;
}

@media screen and (min-width: 750px) {
  .image-with-text__media--small {
    height: 31.4rem;
  }

  .image-with-text__media--medium {
    height: 50rem;
  }

  .image-with-text__media--large {
    height: 69.5rem;
  }
}

.image-with-text__media--placeholder {
  position: relative;
  overflow: hidden;
}

.image-with-text__media--placeholder:after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(var(--color-foreground), 0.04);
}

.image-with-text__media--placeholder.image-with-text__media--adapt {
  height: 20rem;
}

@media screen and (min-width: 750px) {
  .image-with-text__media--placeholder.image-with-text__media--adapt {
    height: 30rem;
  }
}

.image-with-text__media--placeholder > svg {
  position: absolute;
  inset-inline-start: 50%;
  max-width: 80rem;
  top: 50%;
  transform: translate(calc(var(--transform-direction) * 50%), -50%);
  fill: currentColor;
}

.image-with-text__content {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: center;
  align-self: center;
  padding: 4rem calc(3.5rem / var(--font-body-scale)) 5rem;
  position: relative;
  z-index: 1;
  overflow: hidden;
  
  /* Liquid Glass Effect - Same as text-icons */
  border: none;
  box-shadow: 3px 0px 6px -20px rgba(0, 0, 0, 0.06),
              2px 0px 3px -1px rgba(0, 0, 0, 0.04),
              inset -1px 0 0 1px rgba(255, 255, 255, 0.35),
              inset 0 8px 22px rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(calc(var(--button-glass-blur) * 1.5));
  -webkit-backdrop-filter: blur(calc(var(--button-glass-blur) * 1.5));
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, calc(var(--button-glass-opacity) * 1.8)), 
    rgba(255, 255, 255, calc(var(--button-glass-opacity) * 1.2))
  ) !important;
  transition: background 180ms ease;
}
/* Hover overlay gradient that doesn’t reach the edge */
.image-with-text__content::before {
  content: "";
  position: absolute;
  inset: 0;
  inset-inline-start: 12%;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(225deg,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(255, 255, 255, 0.86) 30%,
    rgba(255, 255, 255, 0.72) 58%,
    rgba(255, 255, 255, 0.48) 75%,
    rgba(255, 255, 255, 0.28) 88%,
    rgba(255, 255, 255, 0.14) 96%,
    rgba(255, 255, 255, 0) 100%
  );
  mask-image: linear-gradient(to left,
    rgba(0, 0, 0, 0.95) 0%,
    rgba(0, 0, 0, 0.9) 45%,
    rgba(0, 0, 0, 0.65) 65%,
    rgba(0, 0, 0, 0.35) 80%,
    rgba(0, 0, 0, 0.1) 92%,
    rgba(0, 0, 0, 0) 100%
  );
  -webkit-mask-image: linear-gradient(to left,
    rgba(0, 0, 0, 0.95) 0%,
    rgba(0, 0, 0, 0.9) 45%,
    rgba(0, 0, 0, 0.65) 65%,
    rgba(0, 0, 0, 0.35) 80%,
    rgba(0, 0, 0, 0.1) 92%,
    rgba(0, 0, 0, 0) 100%
  );
  transition: opacity 220ms ease, transform 260ms ease;
  transform: scale(0.96);
  transform-origin: right center;
}

.image-with-text__grid--reverse .image-with-text__text-item .image-with-text__content::before {
  inset-inline-start: 0;
  inset-inline-end: 12%;
  transform-origin: left center;
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(255, 255, 255, 0.86) 30%,
    rgba(255, 255, 255, 0.72) 58%,
    rgba(255, 255, 255, 0.48) 75%,
    rgba(255, 255, 255, 0.28) 88%,
    rgba(255, 255, 255, 0.14) 96%,
    rgba(255, 255, 255, 0) 100%
  );
  mask-image: linear-gradient(to right,
    rgba(0, 0, 0, 0.95) 0%,
    rgba(0, 0, 0, 0.9) 45%,
    rgba(0, 0, 0, 0.65) 65%,
    rgba(0, 0, 0, 0.35) 80%,
    rgba(0, 0, 0, 0.1) 92%,
    rgba(0, 0, 0, 0) 100%
  );
  -webkit-mask-image: linear-gradient(to right,
    rgba(0, 0, 0, 0.95) 0%,
    rgba(0, 0, 0, 0.9) 45%,
    rgba(0, 0, 0, 0.65) 65%,
    rgba(0, 0, 0, 0.35) 80%,
    rgba(0, 0, 0, 0.1) 92%,
    rgba(0, 0, 0, 0) 100%
  );
}

.image-with-text__text-item:hover .image-with-text__content::before,
.image-with-text__text-item:focus-within .image-with-text__content::before,
.image-with-text__content:hover::before,
.image-with-text__content:focus-within::before {
  opacity: 1;
  transform: scale(1);
}

/* Glass shine effect - enabled on all devices */

@media screen and (min-width: 750px) {
  /* Desktop: show shine effect */
  .image-with-text__content::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: auto;
    width: 40%;
    height: 100%;
    background: 
      radial-gradient(ellipse at top right,
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(255, 255, 255, 0.90) 8%,
        rgba(255, 255, 255, 0.84) 15%,
        rgba(255, 255, 255, 0.76) 22%,
        rgba(255, 255, 255, 0.67) 28%,
        rgba(255, 255, 255, 0.57) 34%,
        rgba(255, 255, 255, 0.47) 40%,
        rgba(255, 255, 255, 0.37) 46%,
        rgba(255, 255, 255, 0.29) 52%,
        rgba(255, 255, 255, 0.21) 58%,
        rgba(255, 255, 255, 0.15) 64%,
        rgba(255, 255, 255, 0.10) 70%,
        rgba(255, 255, 255, 0.06) 76%,
        rgba(255, 255, 255, 0.04) 82%,
        rgba(255, 255, 255, 0.02) 88%,
        rgba(255, 255, 255, 0.01) 94%,
        transparent 100%
      );
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
    opacity: 1;
    mask-image: linear-gradient(to left, 
      rgba(0,0,0,1) 0%, 
      rgba(0,0,0,1) 60%,
      rgba(0,0,0,0.8) 75%,
      rgba(0,0,0,0.5) 85%,
      rgba(0,0,0,0.2) 92%,
      rgba(0,0,0,0) 100%
    );
    -webkit-mask-image: linear-gradient(to left, 
      rgba(0,0,0,1) 0%, 
      rgba(0,0,0,1) 60%,
      rgba(0,0,0,0.8) 75%,
      rgba(0,0,0,0.5) 85%,
      rgba(0,0,0,0.2) 92%,
      rgba(0,0,0,0) 100%
    );
  }

  /* When text is on the right (grid reversed), restore original orientation */
  .image-with-text__grid--reverse .image-with-text__content::after {
    left: 0;
    right: auto;
    background: 
      radial-gradient(ellipse at top left,
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(255, 255, 255, 0.90) 8%,
        rgba(255, 255, 255, 0.84) 15%,
        rgba(255, 255, 255, 0.76) 22%,
        rgba(255, 255, 255, 0.67) 28%,
        rgba(255, 255, 255, 0.57) 34%,
        rgba(255, 255, 255, 0.47) 40%,
        rgba(255, 255, 255, 0.37) 46%,
        rgba(255, 255, 255, 0.29) 52%,
        rgba(255, 255, 255, 0.21) 58%,
        rgba(255, 255, 255, 0.15) 64%,
        rgba(255, 255, 255, 0.10) 70%,
        rgba(255, 255, 255, 0.06) 76%,
        rgba(255, 255, 255, 0.04) 82%,
        rgba(255, 255, 255, 0.02) 88%,
        rgba(255, 255, 255, 0.01) 94%,
        transparent 100%
      );
    mask-image: linear-gradient(to right, 
      rgba(0,0,0,1) 0%, 
      rgba(0,0,0,1) 60%,
      rgba(0,0,0,0.8) 75%,
      rgba(0,0,0,0.5) 85%,
      rgba(0,0,0,0.2) 92%,
      rgba(0,0,0,0) 100%
    );
    -webkit-mask-image: linear-gradient(to right, 
      rgba(0,0,0,1) 0%, 
      rgba(0,0,0,1) 60%,
      rgba(0,0,0,0.8) 75%,
      rgba(0,0,0,0.5) 85%,
      rgba(0,0,0,0.2) 92%,
      rgba(0,0,0,0) 100%
    );
  }
}

/* Ensure content stays above the shine */
.image-with-text__content > * {
  position: relative;
  z-index: 1;
}


.image-with-text .grid__item::after {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

.image-with-text__media-item--two-images {
  --image-width: 55%;
  --image-delta: 3rem;
  padding-top: var(--image-delta);
}

.image-with-text__media-item__one-in-two {
  width: var(--image-width);
}

.image-with-text__media-item__one-in-two:first-child {
  z-index: 1;
}

.image-with-text__media-item__one-in-two:last-child {
  position: absolute;
  top: calc(50% - var(--image-delta) / 2);
  inset-inline-end: 0;
  transform: translateY(-50%);
  z-index: -1;
}

.image-with-text__content--radius {
  border-radius: var(--border-radius-content);
}

.image-with-text__media--radius, .image-with-text__media--radius > * {
  border-radius: var(--border-radius-media);
}

.image-with-text .image-with-text__media-item > * {
  overflow: hidden;
}

.image-with-text__content--mobile-right > * {
  align-self: flex-end;
  text-align: end;
}

.image-with-text__content--mobile-center > * {
  align-self: center;
  text-align: center;
}

.image-with-text--overlap .image-with-text__content {
  width: calc(100% - 3rem);
  margin: -3rem auto 0;
}

.image-with-text__heading--bold {
  font-weight: var(--font-heading-weight-rte-bold);
}

.image-with-text__heading--gradient {
  background: var(--gradient-heading);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.image-with-text__badge {
  padding: 1.2rem 2.4rem;
  font-weight: var(--font-body-weight-medium);
  border: 0.1rem solid rgb(var(--color-foreground));
  border-radius: 10rem;
  line-height: 1;
}

.image-with-text__badge--small {
  font-size: calc(1.4rem * var(--font-body-scale));
}

.image-with-text__badge--medium {
  font-size: calc(1.6rem * var(--font-body-scale));
}

.image-with-text__badge--large {
  font-size: calc(1.8rem * var(--font-body-scale));
}

.image-with-text_icon {
  width: 4.5rem;
}

@media screen and (min-width: 750px) {
  .image-with-text__grid--reverse .image-with-text__content {
    margin-inline-start: auto;
  }

  .image-with-text__content--bottom {
    justify-content: flex-end;
    align-self: flex-end;
  }

  .image-with-text__content--top {
    justify-content: flex-start;
    align-self: flex-start;
  }

  .image-with-text__content--desktop-right > * {
    align-self: flex-end;
    text-align: end;
  }

  .image-with-text__content--desktop-left > * {
    align-self: flex-start;
    text-align: start;
  }

  .image-with-text__content--desktop-center > * {
    align-self: center;
    text-align: center;
  }

  .image-with-text--overlap {
    --overlap-value: 4rem;
    --overlap-media-margin: calc(var(--overlap-value) * (-1));
    --overlap-text-margin: calc(var(--overlap-value) * (-1));
    --number-of-images: 1;
  }

  .image-with-text--overlap:has(.image-with-text__media-item__one-in-two) {
    --number-of-images: 2;
  }

  .image-with-text--overlap .image-with-text__text-item {
    display: flex;
    padding: 3rem 0;
  }

  .image-with-text--overlap .image-with-text__media-item > * {
    width: calc((100% / var(--number-of-images)) + var(--overlap-value));
    margin-inline-end: var(--overlap-media-margin);
  }

  .image-with-text--overlap .image-with-text__content {
    --padding-page-width: 1.5rem;
    height: auto;
    width: calc(100% + var(--overlap-value));
    margin-top: 0;
    margin-inline-start: var(--overlap-text-margin);
  }

  .image-with-text--overlap > div:not(.page-width):not(.page-width--full) .image-with-text__content {
    margin-inline-end: max(var(--padding-page-width), calc(50vw - (var(--page-width) / 2) + var(--padding-page-width)));
  } 

  .image-with-text--overlap > .page-width--full .image-with-text__content {
    margin-inline-end: max(0rem, calc(50vw - (var(--page-width) / 2)));
  }

  .image-with-text--overlap .image-with-text__grid--reverse .image-with-text__media-item > * {
    margin-inline-start: var(--overlap-text-margin);
    margin-inline-end: 0;
  }

  .image-with-text--overlap .image-with-text__grid--reverse .image-with-text__content {
    margin-inline-end: var(--overlap-text-margin);
  }

  .image-with-text--overlap > div:not(.page-width):not(.page-width--full) .image-with-text__grid--reverse .image-with-text__content {
    margin-inline-start: max(var(--padding-page-width), calc(50vw - (var(--page-width) / 2) + var(--padding-page-width)));
    margin-inline-end: var(--overlap-text-margin);
  } 

  .image-with-text--overlap > .page-width--full .image-with-text__grid--reverse .image-with-text__content {
    margin-inline-start: max(0rem, calc(50vw - (var(--page-width) / 2)));
  }

  .image-with-text--overlap .image-with-text__grid--reverse .image-with-text__text-item {
    justify-content: flex-end;
  }

  .image-with-text--overlap .image-with-text__media-item--top {
    align-self: flex-start;
  }

  .image-with-text--overlap .image-with-text__media-item--middle {
    align-self: center;
  }

  .image-with-text--overlap .image-with-text__media-item--bottom {
    align-self: flex-end;
  }

  .image-with-text.collapse-borders:not(.image-with-text--overlap) .grid:not(.image-with-text__grid--reverse) .image-with-text__content {
    border-inline-start: 0;
  }

  .image-with-text.collapse-borders:not(.image-with-text--overlap) .image-with-text__grid--reverse .image-with-text__content {
    border-inline-end: 0;
  }
}

.image-with-text:not(.collapse-corners, .image-with-text--overlap) .image-with-text__media-item {
  z-index: 2;
}

@media screen and (min-width: 990px) {
  .image-with-text__content {
    padding: 6rem 7rem 6rem;
  }

  .image-with-text--overlap {
    --overlap-value: 7rem;
  }

  .image-with-text--overlap .image-with-text__content {
    --padding-page-width: 5rem;
  }
}

@media screen and (min-width: 1700px) {
  .image-with-text--overlap.image-with-text--media-large {
    --overlap-text-margin: calc(var(--overlap-value) * (-1) - 5rem);
  }
}

@media screen and (min-width: 2300px) {
  .image-with-text--overlap.image-with-text--media-large {
    --overlap-text-margin: calc(var(--overlap-value) * (-1) - 10rem);
  }
}

.image-with-text__content > * + * {
  margin-top: 2rem;
}

.image-with-text__content > .image-with-text__text:empty ~ a {
  margin-top: 2rem;
}

.image-with-text__content > :first-child:is(.image-with-text__heading),
.image-with-text__text--caption:first-child {
  margin-top: 0;
}
.image-with-text__text--caption + .image-with-text__heading {
  margin-top: 1rem;
}

.image-with-text__content :last-child:is(.image-with-text__heading),
.image-with-text__text--caption {
  margin-bottom: 0;
}

.image-with-text__content .button + .image-with-text__text {
  margin-top: 2rem;
}

.image-with-text__content .image-with-text__text + .button {
  margin-top: 3rem;
}

.image-with-text__heading {
  margin-bottom: 0;
}

.image-with-text__text p {
  word-break: break-word;
  margin-top: 0;
  margin-bottom: 1rem;
}

.image-with-text__text.rte {
  --color-link: var(--color-foreground);
}

/* check for flexbox gap in older Safari versions */
@supports not (inset: 10px) {
  .image-with-text .grid {
    margin-inline-start: 0;
  }
}
