.gmw-overlay-card {
  position: relative;
  display: block;
  width: 100%; /* fill the column width */
  color: #fff;
  text-decoration: none;
  overflow: hidden;
  border-radius: 2px;
  height: auto; /* natural by default */
}

/* Natural sizing (default): figure height grows with image intrinsic ratio */
.gmw-overlay-card__figure {
  position: relative;
  width: 100%;
  height: auto;
  margin: 0;
}

.gmw-overlay-card__figure img {
  position: static; /* normal flow */
  width: 100%;
  height: auto;
  display: block;
}

/* Ratio (cover) mode */
.gmw-ol-cover {
  aspect-ratio: var(--gmw-ol-aspect-ratio, 16 / 9);
}
.gmw-ol-cover .gmw-overlay-card__figure {
  height: 100%;
}
.gmw-ol-cover .gmw-overlay-card__figure img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: var(--gmw-ol-object-fit, cover);
}

/* Max-height mode: cap total height with CSS variable; accept %, px, vh, etc. */
.gmw-ol-max .gmw-overlay-card__figure img {
  max-height: var(--gmw-ol-max-height, 100%);
  width: 100%;
  height: auto;
  object-fit: var(--gmw-ol-object-fit, contain);
}

/* Back-compat: previously saved "fixed height" mode */
.gmw-ol-fixed-height {
  aspect-ratio: auto;
  height: var(--gmw-ol-height, auto);
}
.gmw-ol-fixed-height .gmw-overlay-card__figure { height: 100%; }
.gmw-ol-fixed-height .gmw-overlay-card__figure img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: var(--gmw-ol-object-fit, cover);
}

.gmw-overlay-card__figure figcaption {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  background: var(--gmw-ol-bg, rgba(0,0,0,0.6));
  opacity: 0;
  transition: opacity 180ms ease-in-out;
}

.gmw-overlay-card:hover .gmw-overlay-card__figure figcaption,
.gmw-overlay-card:focus .gmw-overlay-card__figure figcaption,
.gmw-overlay-card:focus-visible .gmw-overlay-card__figure figcaption {
  opacity: 1;
}

/* Editor aids */
.is-editor .gmw-overlay-card__figure figcaption {
  opacity: 1; /* keep visible while editing */
}

/* Keyboard focus ring */
.gmw-overlay-card:focus-visible {
  outline: 2px solid #6cf;
  outline-offset: 2px;
}

/* Media picker UI in editor */
.gmw-ol-picker {
  margin-bottom: 0.5rem;
}
.gmw-ol-picker__preview {
  position: relative;
}
.gmw-ol-picker__preview img {
  max-width: 100%;
  height: auto;
  display: block;
}
.gmw-ol-picker__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.gmw-ol-ar-1x1  { --gmw-ol-aspect-ratio: 1 / 1; }
.gmw-ol-ar-4x3  { --gmw-ol-aspect-ratio: 4 / 3; }
.gmw-ol-ar-3x2  { --gmw-ol-aspect-ratio: 3 / 2; }
.gmw-ol-ar-16x9 { --gmw-ol-aspect-ratio: 16 / 9; }

/* Optional helper: force image contain behavior */
.gmw-overlay-card--contain .gmw-overlay-card__figure img {
  object-fit: contain;          /* show full image, no crop */
  background: #000;             /* optional: letterbox color */
  object-position: center center;
}

/* Max-height mode: give the figure a definite height and let the image fill it */
.gmw-ol-max .gmw-overlay-card__figure {
    height: var(--gmw-ol-max-height, 100%);  /* was not set */
}
/* previously used max-height + height:auto (object-fit ignored).
   Use height:100% so object-fit can work (fill, contain, cover, etc.). */
.gmw-ol-max .gmw-overlay-card__figure img {
    width: 100%;
    height: 100%;                              /* was height:auto */
    object-fit: var(--gmw-ol-object-fit, contain);
}

