@use "../base/var";
@use "../base/color";

[part~="wy-image"] {
  padding: 0;
  width: 50%;
  position: relative;
  flex: auto;
  background-color: inherit;
  background-clip: content-box;
  max-height: var.default(--wy-image-max-size);
}

[part~="wy-image-filled"] {
  position: relative;
  background-size: 100%, 100% 100%;
  background-position: center;
  background-clip: content-box;
  clip-path: content-box;
  align-items: center;
  justify-content: center;

  &::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    backdrop-filter: blur(32px);
    background-color: color.token(--wy-shade);
  }
}

[part~="wy-image-full-width"] {
  flex-basis: 100% !important;
}

// images in posts, messages and comments
[part~="wy-image-grid"] {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  position: relative;
  border-radius: var.default(--wy-border-radius-sm);
  overflow: hidden;
  gap: var.default(--wy-gap-sm);
}

[part~="wy-image-grid-outer"] {
  border-radius: 0;
}

[part~="wy-image-area"] {
  display: flex;
  height: 100%;
  cursor: pointer;
  align-items: center;
}

[part~="wy-image-content"] {
  position: absolute;
  height: auto;
  max-height: 100%;
  width: 100%;
  object-fit: contain;
  z-index: 2;

  // image loading classes
  &[part~="wy-loading"] {
    transition: opacity 0.15s ease-out;
    opacity: 0;

    &[part~="wy-loaded"] {
      opacity: 1;
      transition: opacity 0.15s ease-out;

      ~ [part~="wy-image-preview"] {
        // hide any previous images/thumbs, wait for loaded image transition
        transition-delay: 0.15s;
        opacity: 0;
      }
    }
  }
}

[part~="wy-image-icon"] {
  object-fit: scale-down;
  object-position: center center;
}

[part~="wy-image-grid-more"] {
  position: absolute;
  z-index: 3;
  line-height: 100%;
  color: color.default(--wy-white);
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var.wy-rem(1.5);
  background: rgba(0, 0, 0, var.default(--wy-opacity-disabled));
}
