:root {
  --brand: #39ff14;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: #ffffff;
  color: #171717;
}

button {
  font-family: inherit;
}

.gallery {
  padding: 4rem 1rem;
}

.gallery__inner {
  max-width: 72rem;
  margin: 0 auto;
}

.gallery__header {
  max-width: 42rem;
  margin: 0 auto;
  text-align: center;
}

.gallery__heading {
  margin: 0;
  font-size: clamp(1.75rem, 1.4rem + 1.8vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #171717;
}

.gallery__subheading {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: #737373;
}

.gallery__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 2.5rem;
}

.tile {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  border-radius: 1rem;
  border: none;
  padding: 0;
  background: #f5f5f5;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  text-align: left;
  transition: box-shadow 300ms ease;
}

.tile--active {
  aspect-ratio: 4 / 3;
}

.tile:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.tile__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (prefers-reduced-motion: no-preference) {
  .tile__image {
    transition: transform 300ms ease;
  }

  .tile:hover .tile__image {
    transform: scale(1.05);
  }
}

.tile__caption {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 0.75rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}

.tile--active .tile__caption {
  opacity: 1;
}

.tile:hover .tile__caption,
.tile:focus-visible .tile__caption {
  opacity: 1;
}

.tile__title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: #ffffff;
}

.tile__category {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.tile--just-featured {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--brand);
}

@media (min-width: 640px) {
  .gallery__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .tile--active {
    grid-column: span 2;
  }
}

@media (min-width: 1024px) {
  .gallery {
    padding: 6rem 2rem;
  }

  .gallery__grid {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 170px;
    grid-auto-flow: dense;
    margin-top: 3.5rem;
  }

  .tile {
    aspect-ratio: auto;
  }

  .tile--active {
    grid-column: span 2;
    grid-row: span 2;
  }

  .tile--tall {
    grid-row: span 2;
  }

  .tile--wide {
    grid-column: span 2;
  }
}

/*
 * Gallery 03 — "masonry reveal + selected-item expand" animation identity.
 * Same canonical transitions as `Gallery03.tailwind.css`. Scoped so this
 * never collides with another Resource's own animation layer. Entirely
 * disabled under reduced motion: outside the media query below, every tile
 * already renders in its final, fully visible state.
 */
@media (prefers-reduced-motion: no-preference) {
  .tile {
    clip-path: inset(0 0 100% 0);
    opacity: 0;
    transition:
      clip-path 650ms cubic-bezier(0.16, 1, 0.3, 1),
      opacity 500ms ease,
      box-shadow 300ms ease;
  }

  .tile.is-visible {
    clip-path: inset(0 0 0% 0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile {
    clip-path: none;
    opacity: 1;
  }
}
