/* Image atom: ratio box, focus-point crop is done server-side (snippet image). Empty placeholder without <img>. */
@layer components {
  .image {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: var(--image-ratio, 4 / 3);
    background-color: var(--color-sand-200);
    color: var(--color-sand-600);
  }

  .image--ratio-4-3 {
    --image-ratio: 4 / 3;
  }

  .image--ratio-16-9 {
    --image-ratio: 16 / 9;
  }

  .image--ratio-1-1 {
    --image-ratio: 1 / 1;
  }

  .image--ratio-7-8 {
    --image-ratio: 7 / 8;
  }

  .image--ratio-3-2 {
    --image-ratio: 3 / 2;
  }

  /* Poster format (DIN A and most film posters are close to 5:7). */
  .image--ratio-5-7 {
    --image-ratio: 5 / 7;
  }

  /* Own ratio of the file: the img carries the file's width and height, so it keeps its ratio and is never upscaled. */
  .image--ratio-auto {
    aspect-ratio: auto;
    inline-size: fit-content;
    max-inline-size: 100%;
  }

  .image--ratio-auto .image__img {
    inline-size: auto;
    block-size: auto;
    max-inline-size: 100%;
    max-block-size: 85vh; /* a tall phone photo stays within the screen; the ratio is kept */
  }

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

  /* Placeholder: calm light tint (the olive hover shadow stays visible), one decorative icon, no text. */
  /* Light tint so the hover shadow stays visible; the hairline keeps it visible on beige sections. */
  .image--empty {
    background-color: var(--color-sand-50);
    border: var(--border-width-thin) solid var(--color-sand-300);
    color: var(--color-sand-600);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .image--empty .icon {
    flex: none;
    inline-size: clamp(1.5rem, 24%, 3rem);
    block-size: auto;
    aspect-ratio: 1;
  }

  a.image:focus-visible {
    outline-offset: 2px;
  }
}
