/* ==========================================================================
   Gallery page
   Requires theme.css first (banner, breadcrumbs, eyebrow, links).
   ========================================================================== */

.gl-page {
  padding: var(--ims-section) 0;
  background: var(--ims-surface);
}

.gl-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--ims-gap-md);
  margin-bottom: 34px;
}

/* ---- Filters ------------------------------------------------------------ */

.gl-filters ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gl-filters a {
  display: inline-block;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ims-ink-soft);
  background: var(--ims-paper);
  border: 1px solid var(--ims-rule);
}

.gl-filters a:hover,
.gl-filters a:focus {
  color: var(--ims-ink);
  border-color: var(--ims-ink);
  text-decoration: none;
}

.gl-filters a.active {
  color: var(--ims-ink-invert);
  background: var(--ims-ink);
  border-color: var(--ims-ink);
}

.gl-filters__count {
  margin-left: 6px;
  font-weight: 400;
  opacity: 0.7;
}

/* ---- Grid ---------------------------------------------------------------
   Isotope positions children absolutely and reads their width from CSS, so
   this is a float layout with percentage widths, not CSS grid.

   Four across rather than the projects page's three: these are photographs
   rather than portfolio entries, so more per row reads as a contact sheet.
   ------------------------------------------------------------------------ */

.gl-grid {
  margin: 0 -8px;
}

.gl-grid::after {
  content: '';
  display: block;
  clear: both;
}

.gl-grid__cell {
  float: left;
  width: 25%;
  padding: 0 8px 16px;
}

/* ---- Tile --------------------------------------------------------------- */

.gl-tile {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--ims-surface-2);
  border: 1px solid var(--ims-rule);
}

.gl-tile__img {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 400ms ease;
}

.gl-tile:hover .gl-tile__img {
  transform: scale(1.06);
}

.gl-tile__zoom {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  font-size: 15px;
  color: var(--ims-ink-invert);
  background: var(--ims-brand);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
  transition: opacity 220ms ease, transform 220ms ease;
}

.gl-tile:hover .gl-tile__zoom,
.gl-tile:focus-visible .gl-tile__zoom {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Caption sits on the image, revealed with the zoom. It repeats the alt
   text, which is fine: sighted users get it on hover, screen readers get it
   from the alt, and neither hears it twice. */
.gl-tile__caption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 26px 12px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ims-ink-invert);
  background: linear-gradient(to top, rgba(15, 28, 38, 0.9), rgba(15, 28, 38, 0));
  opacity: 0;
  transition: opacity 220ms ease;
}

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

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

/* ---- Foot --------------------------------------------------------------- */

.gl-page__note {
  margin: 24px 0 0;
  font-size: 14px;
  color: var(--ims-ink-soft);
}

/* ---- Breakpoints -------------------------------------------------------- */

@media (max-width: 1199px) {
  .gl-grid__cell { width: 33.3333%; }
}

@media (max-width: 767px) {
  .gl-page { padding: var(--ims-section-sm) 0; }

  .gl-grid__cell { width: 50%; }
  .gl-tile__img { height: 150px; }

  /* No hover on touch, so keep the affordance and drop the caption overlay */
  .gl-tile__zoom { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  .gl-tile__caption { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gl-tile__img,
  .gl-tile__zoom,
  .gl-tile__caption {
    transition: none;
  }

  .gl-tile:hover .gl-tile__img { transform: none; }
}
