:root {
  color-scheme: dark;
  --bg: #000;
  --tile-w: 180px;
  --gap: 32px;
  --cols: 6;
  --edge-gray: #444;
  --edge-mid: #444;
  --edge-white: rgba(255, 255, 255, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: #fff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.rain-glass {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 36%),
    #000;
  pointer-events: none;
  z-index: 0;
}

.rain-glass::after {
  content: "";
  position: absolute;
  inset: -18%;
  background:
    linear-gradient(105deg, transparent 0 42%, rgba(255, 255, 255, 0.052) 43%, transparent 45% 100%),
    linear-gradient(76deg, transparent 0 55%, rgba(255, 255, 255, 0.04) 56%, transparent 58% 100%);
  filter: blur(12px) saturate(1.15);
  opacity: 0.48;
  animation: glassDrift 16s linear infinite alternate;
}

.rain-glass__glint {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  border-radius: 999px;
  background: hsl(var(--glint-hue) var(--glint-saturation) var(--glint-lightness));
  opacity: 0;
  filter: blur(var(--blur));
  mix-blend-mode: screen;
  transform: translate3d(-50%, -50%, 0);
  will-change: opacity;
}

.gallery-shell {
  position: relative;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  padding: clamp(34px, 6vw, 92px);
  background: transparent;
  overflow: hidden;
  z-index: 1;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--tile-w));
  gap: var(--gap);
  justify-content: center;
  align-content: center;
  max-width: 100%;
  max-height: 100%;
  perspective: 760px;
  transform-style: preserve-3d;
}

.tile {
  position: relative;
  display: block;
  width: var(--tile-w);
  aspect-ratio: 3 / 2;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.tile__card {
  position: absolute;
  inset: 0;
  display: block;
  overflow: visible;
  border: 1px solid transparent;
  border-radius: inherit;
  background:
    linear-gradient(#090909, #090909) padding-box,
    radial-gradient(140% 140% at var(--shine-x, 50%) var(--shine-y, 50%),
      rgba(255, 255, 255, var(--shine, 0)) 0%,
      rgba(255, 255, 255, calc(var(--shine, 0) * 1.8)) 18%,
      rgba(255, 255, 255, calc(var(--shine, 0) * 1.1)) 34%,
      var(--edge-mid) 58%,
      var(--edge-gray) 100%) border-box;
  box-shadow: none;
  pointer-events: none;
  transform:
    perspective(760px)
    rotateX(var(--rx, 0deg))
    rotateY(var(--ry, 0deg))
    scale(var(--tile-scale, 1));
  transform-style: preserve-3d;
  transition:
    transform 180ms cubic-bezier(.2, .8, .2, 1),
    background 120ms ease-out,
    opacity 120ms ease;
  will-change: transform;
}

.tile:hover,
.tile:focus-visible,
.tile * {
  cursor: pointer;
}

.tile.is-preview-source {
  pointer-events: none;
}

.tile.is-preview-source .tile__card {
  opacity: 0;
}

.tile__card::after {
  content: none;
}

.tile:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.72);
  outline-offset: 5px;
}

.tile__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
  transform: translateZ(1px);
  cursor: pointer;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.tile__label {
  position: absolute;
  left: 0;
  top: calc(100% + 7px);
  max-width: 20ch;
  overflow: hidden;
  color: rgb(
    calc(54 + var(--shine, 0) * 201)
    calc(54 + var(--shine, 0) * 201)
    calc(54 + var(--shine, 0) * 201)
  );
  font-family: "Google Sans", "Product Sans", Arial, sans-serif;
  font-size: 10px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  text-align: left;
  text-overflow: clip;
  text-shadow: none;
  white-space: nowrap;
  pointer-events: none;
  transform: translateZ(3px);
}

.lightbox {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 52px);
  opacity: 0;
  pointer-events: none;
  perspective: 900px;
  transition: opacity 180ms ease;
  z-index: 20;
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox__scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
}

.lightbox__image {
  position: relative;
  display: block;
  width: var(--lightbox-w, auto);
  height: var(--lightbox-h, auto);
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border: 1px solid transparent;
  border-radius: 8px;
  background:
    linear-gradient(#050505, #050505) padding-box,
    radial-gradient(140% 140% at var(--modal-shine-x, 50%) var(--modal-shine-y, 50%),
      rgba(255, 255, 255, calc(var(--modal-shine, 0) * 1.85)) 0%,
      rgba(255, 255, 255, calc(var(--modal-shine, 0) * 1.55)) 13%,
      rgba(244, 244, 244, calc(0.56 + var(--modal-shine, 0) * 0.44)) 30%,
      var(--edge-mid) 56%,
      var(--edge-gray) 100%) border-box;
  box-shadow:
    0 36px 110px rgba(0, 0, 0, 0.82),
    0 0 calc(10px + var(--modal-shine, 0) * 28px) rgba(255, 255, 255, calc(var(--modal-shine, 0) * 0.28));
  transform:
    translate3d(var(--from-x, 0px), var(--from-y, 0px), 0)
    translate3d(var(--zoom-x, 0px), var(--zoom-y, 0px), 0)
    scale(var(--from-scale-x, 1), var(--from-scale-y, 1))
    scale(var(--zoom-scale, 1))
    translateZ(var(--from-z, 0px))
    perspective(900px)
    rotateX(var(--modal-rx, 0deg))
    rotateY(var(--modal-ry, 0deg));
  transform-style: preserve-3d;
  transform-origin: center;
  transition:
    transform 420ms cubic-bezier(.2, .8, .2, 1),
    width 420ms cubic-bezier(.2, .8, .2, 1),
    height 420ms cubic-bezier(.2, .8, .2, 1),
    opacity 180ms ease;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  z-index: 2;
}

.lightbox__label {
  position: fixed;
  left: calc(50% - var(--lightbox-w, 900px) / 2);
  top: calc(50% + var(--lightbox-h, 0px) / 2 + 10px);
  max-width: min(90vw, var(--lightbox-w, 900px));
  overflow: hidden;
  color: rgb(
    calc(54 + var(--modal-shine, 0) * 201)
    calc(54 + var(--modal-shine, 0) * 201)
    calc(54 + var(--modal-shine, 0) * 201)
  );
  font-family: "Google Sans", "Product Sans", Arial, sans-serif;
  font-size: 10px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  text-align: left;
  text-shadow: none;
  transform: none;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

.lightbox__image--ghost {
  position: fixed;
  left: 50%;
  top: 50%;
  width: var(--ghost-w, auto);
  height: var(--ghost-h, auto);
  max-width: none;
  max-height: none;
  pointer-events: none;
  z-index: 1;
  transform:
    translate(-50%, -50%)
    translate3d(var(--ghost-x, 0px), var(--ghost-y, 0px), 0)
    scale(var(--ghost-scale-x, 1), var(--ghost-scale-y, 1))
    translateZ(var(--ghost-z, 0px))
    perspective(900px)
    rotateX(var(--modal-rx, 0deg))
    rotateY(var(--modal-ry, 0deg));
  transition:
    transform 320ms cubic-bezier(.2, .8, .2, 1),
    opacity 260ms ease;
}

.lightbox__control {
  position: fixed;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 1;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.88);
  transform: none;
  transform-style: flat;
  transition: opacity 160ms ease;
  z-index: 2;
}

.lightbox__control,
.lightbox__control * {
  cursor: pointer;
}

.lightbox__control:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.72);
  outline-offset: 4px;
}

.lightbox__control span {
  display: block;
  font-family: "Google Sans", "Product Sans", Arial, sans-serif;
  font-size: 46px;
  font-weight: 300;
  line-height: 1;
  pointer-events: none;
}

.lightbox__control--close {
  top: clamp(12px, 2vw, 28px);
  right: clamp(12px, 2vw, 28px);
}

.lightbox__control--close span {
  font-size: 42px;
  transform: translateY(-2px);
}

.lightbox__control--prev,
.lightbox__control--next {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__control--prev {
  left: clamp(12px, 3vw, 42px);
}

.lightbox__control--next {
  right: clamp(12px, 3vw, 42px);
}

.lightbox__control--prev span,
.lightbox__control--next span {
  font-size: 64px;
  font-weight: 400;
  letter-spacing: 0;
  transform: scaleX(0.7);
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .gallery-shell {
    min-height: 100vh;
    height: auto;
    padding: 24px;
    overflow: visible;
  }

  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 22px;
  }

  .tile {
    width: auto;
  }

  .lightbox__control {
    width: 48px;
    height: 48px;
  }

  .lightbox__control--prev,
  .lightbox__control--next {
    width: 42px;
  }
}

@media (max-width: 430px) {
  .gallery {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile {
    transition-duration: 80ms;
  }

  .rain-glass__glint,
  .rain-glass::after {
    animation: none;
  }

  .rain-glass__glint {
    transition: none;
  }
}

@keyframes glassDrift {
  from {
    transform: translate3d(-4%, -3%, 0);
  }

  to {
    transform: translate3d(4%, 3%, 0);
  }
}
