:root {
  color-scheme: light;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #f7f1e7;
  color: #17130f;
  --orange: #f3a73f;
  --paper: #f7f1e7;
}

* { box-sizing: border-box; }

body {
  min-width: 18rem;
  margin: 0;
  background: var(--paper);
}

button, a { -webkit-tap-highlight-color: transparent; }

main { width: 100%; }

.gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.2rem, 0.45vw, 0.5rem);
}

.photo {
  aspect-ratio: 1;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 0.28rem;
  background: #ded5c8;
  cursor: zoom-in;
  content-visibility: auto;
  contain-intrinsic-size: auto 20rem;
}

.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 350ms cubic-bezier(0.2, 0.7, 0.2, 1), filter 200ms ease;
}

.photo:hover img {
  transform: scale(1.025);
  filter: saturate(1.06);
}

.photo:focus-visible {
  outline: 0.25rem solid var(--orange);
  outline-offset: 0.18rem;
}

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(16, 14, 12, 0.97);
  color: white;
  overscroll-behavior: contain;
  touch-action: none;
  user-select: none;
}

.lightbox[open] {
  display: block;
}

.lightbox::backdrop { background: #100e0c; }

.lightbox figure {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
}

.lightbox__image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
}

.lightbox__close, .lightbox__arrow {
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.lightbox__close {
  position: fixed;
  z-index: 1;
  top: 1rem;
  right: 1rem;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: 50%;
  font: 300 2rem/1 sans-serif;
}

.lightbox__arrow {
  position: fixed;
  z-index: 1;
  top: 50%;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.6rem;
  transition: background 150ms ease;
  transform: translateY(-50%);
}

.lightbox__arrow--previous { left: 0.75rem; }
.lightbox__arrow--next { right: 0.75rem; }

.lightbox__arrow:hover,
.lightbox__arrow:focus-visible,
.lightbox__close:hover,
.lightbox__close:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

@media (max-width: 70rem) {
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 44rem) {
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lightbox__arrow--previous { left: 0.25rem; }
  .lightbox__arrow--next { right: 0.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .photo img { transition: none; }
}
