.teaser {
  --teaser-padding: 0;
  container-type: inline-size;
  min-width: 0;
  height: 100%;
}

.teaser--has-background {
  --teaser-padding: 2.25rem;
}

.teaser__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.teaser__media {
  flex: none;
  overflow: hidden;
  aspect-ratio: 3 / 2;
}

.teaser__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Uncropped: the whole image at its own shape (an upright cover). */
.teaser--shape-original > .teaser__inner > .teaser__media {
  aspect-ratio: auto;
}

.teaser--shape-original > .teaser__inner > .teaser__media > .teaser__image,
.teaser--shape-original > .teaser__inner > .teaser__media img {
  height: auto;
  object-fit: contain;
}

.teaser__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--space-m);
  min-width: 0;
  padding: var(--teaser-padding);
}

/* Without a background the image keeps its own spacing from the text. */
.teaser:not(.teaser--has-background) .teaser__media + .teaser__body {
  padding-block-start: var(--space-m);
}

.teaser__pretitle {
  font-size: var(--font-size-xsmall);
  font-weight: var(--font-weight-bold);
  line-height: 1.1;
}

.teaser__title-link {
  color: inherit;
  text-decoration: none;
}

.teaser__title-link:hover,
.teaser__title-link:focus-visible {
  text-decoration: underline;
}

/* Linked cards: the title link stretches over the whole card. */
.teaser--linked {
  position: relative;
}

/* dal.ca's linked card titles: a 2px underline, 0.2rem below the text. */
.teaser--linked .teaser__title-link {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2rem;
}

.teaser--linked .teaser__title-link::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
}

.teaser--linked:hover .teaser__title-link {
  text-decoration-thickness: 3px;
}

/* Extra buttons and links in the description stay clickable above the
 * stretched link. */
.teaser--linked .teaser__actions,
.teaser--linked .teaser__description a {
  position: relative;
  z-index: 2;
}

.teaser__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s);
}

/* Hide the actions row when there is no call to action and no extra buttons. */
.teaser__actions:not(:has(*)) {
  display: none;
}

.teaser--centered .teaser__body {
  align-items: center;
  text-align: center;
}

.teaser--centered .teaser__actions {
  justify-content: center;
}

/* Stacked or gridded buttons fill their group, and a centred body shrinks
   its children to their content, so the two would collapse each other: give
   the actions a width of their own. */
.teaser--centered .teaser__actions:has(> .button-group--stack, > .button-group--grid) {
  width: min(100%, 30rem);
}

.teaser--centered .teaser__actions > :is(.button-group--stack, .button-group--grid) {
  flex: 1 1 100%;
}

@media (max-width: 37.5rem) {
  .teaser--has-background {
    --teaser-padding: var(--space-m);
  }
}

/* Horizontal layouts once the teaser itself is wide enough. */
@container (min-width: 36rem) {
  .teaser--image-left.teaser--has-image > .teaser__inner {
    flex-direction: row;
  }

  .teaser--image-right.teaser--has-image > .teaser__inner {
    flex-direction: row-reverse;
  }

  :is(.teaser--image-left, .teaser--image-right) .teaser__media {
    width: 33.333%;
    min-height: 12rem;
    aspect-ratio: auto;
  }

  :is(.teaser--image-left, .teaser--image-right).teaser--image-half .teaser__media {
    width: 50%;
  }

  :is(.teaser--image-left, .teaser--image-right).teaser--image-large .teaser__media {
    width: 58.333%;
    min-height: 20rem;
  }

  /* Text beside the image is centred on it vertically. */
  :is(.teaser--image-left, .teaser--image-right).teaser--has-image .teaser__body {
    justify-content: center;
  }

  .teaser--image-left:not(.teaser--has-background) .teaser__media + .teaser__body {
    padding-block-start: 0;
    padding-inline-start: var(--space-l);
  }

  .teaser--image-right:not(.teaser--has-background) .teaser__media + .teaser__body {
    padding-block-start: 0;
    padding-inline-end: var(--space-l);
  }
}
