/**
 * @interface
 * var(--content-image-layout: bounded) - limit image height and align it to the start
 * var(--content-image-layout: fill) - fill and crop to the containing area
 * var(--content-image-shadow: none) - hide the blurred image background
 */

@layer components {
  @scope (blog-content-image) to ([data-component]) {
    :scope {
      display: block;
      position: relative;
      isolation: isolate;
      width: max-content;
      max-height: 100%;
      max-width: min(100%, var(--image-width));

      @container style(--content-image-layout: fill) {
        width: 100%;
        max-width: none;
        height: 100%;
      }

      &::before {
        content: var(--content-image-shadow, "");
        position: absolute;
        z-index: -1;
        inset: 0;
        background: var(--image-placeholder) center / cover no-repeat;
        border-radius: 0.375rem;
        filter: blur(8px);
        opacity: 0.2;
        pointer-events: none;

        :root[data-color-scheme="dark"] & {
          background-image: var(--image-placeholder-dark, var(--image-placeholder));
        }
      }

    }

    picture {
      display: block;
      margin: 0;

      :root[data-color-scheme="light"] &[data-image-theme="dark"],
      :root[data-color-scheme="dark"] &[data-image-theme="light"] {
        display: none;
      }

      @container style(--content-image-layout: fill) {
        width: 100%;
        max-width: none;
        height: 100%;
      }
    }

    img {
      position: relative;
      display: block;
      width: auto;
      max-width: 100%;
      height: auto;
      margin: 0 auto;
      border-radius: 0.375rem;

      @container style(--content-image-layout: bounded) {
        max-height: min(65vh, 32rem);
        margin-inline: 0;
        cursor: zoom-in;
      }

      @container style(--content-image-layout: fill) {
        width: 100%;
        height: 100%;
        max-height: none;
        object-fit: cover;
        cursor: zoom-in;
      }
    }
  }
}
