/*
 * Gallery mosaic (snippet gallery-mosaic): 1–4 photos form one speech-bubble silhouette. The container carries the
 * bubble radii (classes bubble bubble--m|l bubble--tip-left) and clips; the gaps between the photos are cut out
 * (transparent, the ground shows through). Every photo has small inner radii and the bubble radii at the outer corners it
 * touches, plus a thin inner outline so bright photos keep the silhouette. No hover surface, no shadow, no zoom: mosaic cards never get the hover shadow
 * (it would show behind a split silhouette). Hover and focus live on the text button of the card.
 */
@layer components {
  .gallery-mosaic {
    --mosaic-gap: var(--space-8);
    --mosaic-inner: var(--space-8);
    position: relative;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr));
    gap: var(--mosaic-gap);
    aspect-ratio: var(--mosaic-ratio, 4 / 3);
    overflow: hidden;
    min-inline-size: 0;
  }

  .gallery-mosaic__tile {
    position: relative;
    min-inline-size: 0;
    min-block-size: 0;
    overflow: hidden;
    border-radius: var(--mosaic-inner);
  }

  /* Thin inner outline on every photo (bright photos keep their shape): overlay inside the tile, follows the tile's
     own radii, does not change any size. Same tone as the map frame and the image placeholders, section-aware. */
  .gallery-mosaic__tile::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: var(--z-content);
    border-radius: inherit;
    box-shadow: inset 0 0 0 var(--border-width-thin) var(--surface-raised-outline, var(--color-border-default));
    pointer-events: none;
  }

  /* Outer corners of the silhouette belong to the photos that touch them: they take the bubble radii (incl. the 4 px
     tip bottom-left and the smaller corner opposite), all other corners keep the small inner radius. */
  .gallery-mosaic--n0 .gallery-mosaic__tile,
  .gallery-mosaic--n1 .gallery-mosaic__tile {
    border-radius: var(--bubble-tl) var(--bubble-tr) var(--bubble-tip-br) var(--bubble-tip-bl);
  }
  .gallery-mosaic--n2 .gallery-mosaic__tile:nth-child(1),
  .gallery-mosaic--n3 .gallery-mosaic__tile:nth-child(1),
  .gallery-mosaic--n4 .gallery-mosaic__tile:nth-child(1) {
    border-top-left-radius: var(--bubble-tl);
    border-bottom-left-radius: var(--bubble-tip-bl);
  }
  .gallery-mosaic--n2 .gallery-mosaic__tile:nth-child(2),
  .gallery-mosaic--n3 .gallery-mosaic__tile:nth-child(2),
  .gallery-mosaic--n4 .gallery-mosaic__tile:nth-child(2) {
    border-top-right-radius: var(--bubble-tr);
  }
  .gallery-mosaic--n2 .gallery-mosaic__tile:nth-child(2) {
    border-bottom-right-radius: var(--bubble-tip-br);
  }
  .gallery-mosaic--n3 .gallery-mosaic__tile:nth-child(3),
  .gallery-mosaic--n4 .gallery-mosaic__tile:nth-child(4) {
    border-bottom-right-radius: var(--bubble-tip-br);
  }

  /* The placeholder tile (no photos, press only) has no border of its own: the inner outline does that job. */
  .gallery-mosaic__tile .image--empty {
    border: 0;
  }

  /* Photos fill their grid cell, the image crops itself. */
  .gallery-mosaic__tile .image {
    position: absolute;
    inset: 0;
    aspect-ratio: auto;
    inline-size: 100%;
    block-size: 100%;
    transition: none;
    box-shadow: none;
    transform: none;
  }

  /* 6 × 6 cells: one large photo (4 columns) with a column of 2 or 3 small photos beside it (2 columns). */
  .gallery-mosaic--n0 .gallery-mosaic__tile,
  .gallery-mosaic--n1 .gallery-mosaic__tile { grid-column: 1 / -1; grid-row: 1 / -1; }

  .gallery-mosaic--n2 .gallery-mosaic__tile:nth-child(1) { grid-column: 1 / 4; grid-row: 1 / -1; }
  .gallery-mosaic--n2 .gallery-mosaic__tile:nth-child(2) { grid-column: 4 / -1; grid-row: 1 / -1; }

  .gallery-mosaic--n3 .gallery-mosaic__tile:nth-child(1),
  .gallery-mosaic--n4 .gallery-mosaic__tile:nth-child(1) { grid-column: 1 / 5; grid-row: 1 / -1; }
  .gallery-mosaic--n3 .gallery-mosaic__tile:nth-child(2) { grid-column: 5 / -1; grid-row: 1 / 4; }
  .gallery-mosaic--n3 .gallery-mosaic__tile:nth-child(3) { grid-column: 5 / -1; grid-row: 4 / -1; }
  .gallery-mosaic--n4 .gallery-mosaic__tile:nth-child(2) { grid-column: 5 / -1; grid-row: 1 / 3; }
  .gallery-mosaic--n4 .gallery-mosaic__tile:nth-child(3) { grid-column: 5 / -1; grid-row: 3 / 5; }
  .gallery-mosaic--n4 .gallery-mosaic__tile:nth-child(4) { grid-column: 5 / -1; grid-row: 5 / -1; }
}
