/* ------------------------------------------------------------------
   Pebble gallery (home page)

   Soft irregular "pebble" shapes, each one different (six shapes in a
   cycle), framed by the double gold ring of a medallion: the inner and
   outer rings are pseudo-elements with the same border-radius as the
   photo, so they follow its outline. Rows wrap and centre themselves,
   so any number of photos works (the home page shows 8: 4x2).

   Sizing: 4 per row by width. Where the home page fits one screen
   (.home-gallery is then a size container, see "Home layout" in
   style.sass) the pebbles also shrink so that two rows fit the height
   left. On phones the row does not wrap: it scrolls sideways.
   ------------------------------------------------------------------ */

.pebbles {
  --gap: clamp(22px, 3vw, 40px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
  max-width: 1040px;
  margin-inline: auto;
  padding: 14px;
}

.pebble {
  --shape: 62% 38% 55% 45% / 48% 58% 42% 52%;
  position: relative;
  /* 4 per row on desktop */
  flex: 0 0 calc((100% - 3 * var(--gap)) / 4);
  aspect-ratio: 1;
  filter: drop-shadow(0 8px 10px rgba(48, 52, 49, .2));
}

.pebble:nth-child(6n+2) { --shape: 45% 55% 40% 60% / 55% 42% 58% 45%; }
.pebble:nth-child(6n+3) { --shape: 55% 45% 62% 38% / 42% 55% 45% 58%; }
.pebble:nth-child(6n+4) { --shape: 40% 60% 48% 52% / 60% 45% 55% 40%; }
.pebble:nth-child(6n+5) { --shape: 58% 42% 45% 55% / 45% 60% 40% 55%; }
.pebble:nth-child(6n)   { --shape: 48% 52% 60% 40% / 58% 40% 60% 42%; }

.pebble-photo,
.pebble::before,
.pebble::after {
  position: absolute;
  border-radius: var(--shape);
}

.pebble-photo {
  inset: 0;
  overflow: hidden;
  background-color: #c9a35f;
  background-size: cover;
  background-position: center;
}

/* double gold ring, as on the medallions */
.pebble::before,
.pebble::after {
  content: "";
  pointer-events: none;
}

.pebble::before {
  inset: -6px;
  border: 2px solid #c9a35f;
}

.pebble::after {
  inset: -12px;
  border: 1px solid rgba(201, 163, 95, .6);
}

/* hover: the same glossy light sweep used across the site (no zoom) */
.pebble-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg,
    rgba(255, 255, 255, 0) 35%,
    rgba(255, 255, 255, .55) 48%,
    rgba(255, 255, 255, .15) 54%,
    rgba(255, 255, 255, 0) 62%);
  background-size: 250% 250%;
  background-position: 120% 0;
  opacity: 0;
  transition: background-position .8s ease, opacity .3s ease;
}

.pebble:hover .pebble-photo::after {
  background-position: -20% 0;
  opacity: 1;
}

/* one screen: 2 rows must fit the gallery's height too (28px = .pebbles padding, 8px = room for the rings) */
@container home-gallery (min-width: 0) {
  .pebbles {
    --w: min(calc((min(100cqw, 1040px) - 28px - 3 * var(--gap)) / 4),
             calc((100cqh - 28px - 8px - var(--gap)) / 2));
    /* exactly 4 per row, also when the height made them smaller */
    max-width: calc(4 * var(--w) + 3 * var(--gap) + 28px);
  }

  .pebble {
    flex-basis: var(--w);
  }
}

/* phones: one row swiped sideways instead of a long column */
@media (max-width: 767.98px) {
  .pebbles {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 14px;
    padding-block: 18px 22px;
    scrollbar-width: thin;
  }

  .pebble {
    flex-basis: 42%;
    scroll-snap-align: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pebble-photo::after { transition: none; }
  .pebble:hover .pebble-photo::after { background-position: 50% 0; }
}
