/* Gallery, after the client's reference: the title, one large photo in the
   middle and the photo names underneath, on a blurred, enlarged copy of the
   active photo that fills the whole section. The photos form a row that
   slides left and right. A light veil of the page
   background over the blur keeps the text readable and the page light.
   main.js switches the slides, the backdrop crossfades with them. */

.gallery {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 100svh;
  overflow: clip;
}

.gallery__backdrops {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.gallery__backdrop {
  position: absolute;
  inset: -6%;
  width: 112%;
  height: 112%;
  object-fit: cover;
  filter: blur(56px) saturate(1.6) contrast(1.15);
  opacity: 0;
  transition: opacity 1.1s var(--theme-ease-signature);
}

.gallery__backdrop.is-active {
  opacity: 1;
}

.gallery__backdrop--mono {
  filter: blur(56px) grayscale(1) contrast(1.15);
}

/* The veil over the blur: mostly the page background, so the photo's
   colors only tint the section, a little stronger in the middle. */
.gallery__backdrops::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--theme-color-background) 86%, transparent),
    color-mix(in srgb, var(--theme-color-background) 72%, transparent) 45%,
    color-mix(in srgb, var(--theme-color-background) 72%, transparent) 60%,
    color-mix(in srgb, var(--theme-color-background) 88%, transparent)
  );
}

.gallery__inner {
  display: grid;
  align-content: center;
  gap: var(--theme-space-md);
  padding: var(--theme-section-space) var(--theme-bleed);
}

/* Title on the left, the step buttons on the right. */
.gallery__head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
}

.gallery__title {
  margin: 0;
}

.gallery__controls {
  display: flex;
  gap: 8px;
}

/* The stage spans the section; the track holds all photos in a row and is
   moved by main.js (--theme-gallery-x) so the active photo starts at the
   content edge, the next ones following on the right. */
.gallery__stage {
  width: calc(100% + 2 * var(--theme-bleed));
  margin-inline: calc(-1 * var(--theme-bleed));
  overflow: hidden;
  user-select: none;
}

.gallery__stage:focus-visible {
  outline: 2px solid var(--theme-color-heading);
  outline-offset: -6px;
}

.gallery__track {
  --theme-gallery-slide: min(60rem, 72vw);

  display: flex;
  gap: clamp(16px, 2.5vw, 40px);
  width: max-content;
  translate: var(--theme-gallery-x, 0) 0;
  transition: translate 0.9s var(--theme-ease-signature);
}

.gallery__track.is-jumping,
.gallery__track.is-jumping .gallery__slide {
  transition: none;
}

.gallery__slide {
  flex: none;
  width: var(--theme-gallery-slide);
  aspect-ratio: 16 / 10;
  margin: 0;
  overflow: hidden;
}

.gallery__slide.is-active {
  box-shadow: 0 40px 80px -40px color-mix(in srgb, var(--theme-color-primary) 55%, transparent);
}

.gallery__slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.gallery__slide--mono img {
  filter: grayscale(1);
}

/* The names under the row. */
.gallery__names {
  display: flex;
  flex-wrap: wrap;
  gap: 4px clamp(12px, 2.4vw, 32px);
  list-style: none;
}

.gallery__name {
  position: relative;
  padding: 8px 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--theme-text-sm);
  font-weight: var(--theme-font-weight-medium);
  color: color-mix(in srgb, var(--theme-color-heading) 55%, transparent);
  cursor: pointer;
  transition: color 0.3s var(--theme-ease-signature);
}

.gallery__index {
  margin-right: 4px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.gallery__name:hover,
.gallery__name[aria-selected='true'] {
  color: var(--theme-color-heading);
}

/* Under the active name a line fills up while the photo is shown
   (--theme-gallery-time, set by main.js; stops while paused). */
.gallery__name::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--theme-color-heading);
  transform: scaleX(0);
  transform-origin: left;
}

.gallery__name[aria-selected='true']::after {
  transform: scaleX(var(--theme-gallery-time, 1));
}

.gallery__name:focus-visible,
.gallery__step:focus-visible {
  outline: 2px solid var(--theme-color-heading);
  outline-offset: 3px;
}

.gallery__step {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid color-mix(in srgb, var(--theme-color-heading) 25%, transparent);
  border-radius: var(--theme-radius-sm);
  background: color-mix(in srgb, var(--theme-color-surface) 60%, transparent);
  color: var(--theme-color-heading);
  cursor: pointer;
}

.gallery__step--dark {
  border-color: var(--theme-color-primary);
  background: var(--theme-color-primary);
  color: var(--theme-color-inverse-text);
}

.gallery__step svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2;
}

@media (width <= 800px) {
  .gallery__track {
    --theme-gallery-slide: 80vw;
  }

  .gallery__slide {
    aspect-ratio: 4 / 5;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery__track,
  .gallery__backdrop,
  .gallery__name {
    transition: none;
  }
}
