/**
 * @file
 * Split feature component. Mobile first: image stacked above the text, then
 * side by side from 992px. The image is landscape at 16:9 throughout.
 */

.xp-split {
  display: flex;
  flex-direction: column;
}

/* The picture is landscape at 16:9. Beside the text the band is at least
   that tall, and the picture fills its height: when the text is taller the
   picture grows with it, cropped, so there is never a gap above or below. */
.xp-split__media {
  position: relative;
  aspect-ratio: 16 / 9;
  background-color: var(--xp-media-bg);
}

.xp-split__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.xp-split__text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem 1.25rem;
}

.xp-split--none .xp-split__text {
  padding-inline: 0;
}

.xp-split__heading {
  margin-bottom: 1.125rem;
  font-size: var(--xp-font-size-h2);
}

.xp-split__body > * + * {
  margin-top: 1.5rem;
}

/* Text panel colours, as the Section backgrounds. Dark ones also get
   xp-text-light; light ones put the site's own text colours back (xp-on-light
   rules), in case the Split feature sits in a dark Section. */
.xp-split--white {
  background-color: var(--xp-bg-white);
}

.xp-split--light {
  background-color: var(--xp-bg-light);
}

.xp-split--tint {
  background-color: var(--xp-bg-tint);
}

.xp-split--primary {
  background-color: var(--xp-bg-primary);
}

.xp-split--secondary {
  background-color: var(--xp-bg-secondary);
}

.xp-split--dark {
  background-color: var(--xp-bg-dark);
}

.xp-split--white,
.xp-split--light,
.xp-split--tint {
  --bs-body-color: var(--xp-body-color);
  --bs-heading-color: var(--xp-heading-color);
  --bs-secondary-color: var(--xp-secondary-color);
  --bs-link-color-rgb: var(--xp-link-color-rgb);
  --bs-link-hover-color-rgb: var(--xp-link-hover-color-rgb);

  color: var(--xp-body-color);
}

/* A video keeps its own 16:9 shape, centred in its half, instead of being
   cropped to the height. */
.xp-split--video .xp-split__media {
  aspect-ratio: auto;
  background-color: transparent;
}

@media (max-width: 991.98px) {
  .xp-split--none .xp-split__text {
    padding-bottom: 0;
  }
}

@media (min-width: 992px) {
  .xp-split {
    flex-direction: row;
    align-items: stretch;
  }

  .xp-split--image-right {
    flex-direction: row-reverse;
  }

  .xp-split__media {
    flex: 1 1 50%;
  }

  .xp-split__text {
    flex: 1 1 50%;
    max-width: 42.5rem;
    padding: 3rem clamp(1.5rem, 3vw, 3rem);
  }

  .xp-split--video .xp-split__media {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
  }
}
