/* Gallery page only. Colours and type come from the shared site stylesheet. */
.work-gallery {
  --gutter: clamp(12px, 1.5vw, 24px);
  padding-bottom: clamp(56px, 7vw, 100px);
  background: var(--paper);
  color: var(--ink);
  text-align: center;
}
.gallery-banner {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: clamp(210px, 24vw, 350px);
  padding: 32px 20px;
  overflow: hidden;
  background: #193429;
  color: #fff;
}
.gallery-banner img, .gallery-banner::after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.gallery-banner img { object-fit: cover; object-position: center 55%; z-index: -2; }
.gallery-banner::after {
  content: "";
  background: linear-gradient(180deg, rgba(14, 29, 21, .36), rgba(14, 29, 21, .65));
  z-index: -1;
}
.work-gallery .gallery-banner h1 {
  margin: 0 0 12px;
  color: inherit;
  font: 500 clamp(2.4rem, 4vw, 3.85rem)/1 var(--serif);
  letter-spacing: -.025em;
}
.gallery-breadcrumb {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  font: 400 .875rem/1.4 var(--sans);
}
.gallery-breadcrumb a { color: #fff; font: inherit; letter-spacing: normal; text-transform: none; padding: .5em 0; }
/* Use the shared navigation underline and make it visible over the banner. */
.gallery-breadcrumb a::after {
  bottom: .32em;
  background: currentColor;
}
.gallery-breadcrumb a:focus-visible::after { transform: scaleX(1); }
.work-gallery .work-filters a::after { display: none; }
@media (prefers-reduced-motion: reduce) {
  .gallery-breadcrumb a::after { transition: none; }
}
.gallery-breadcrumb [aria-current] { color: #edf1eb; }

.work-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  margin: clamp(24px, 4vw, 52px) auto clamp(16px, 2vw, 26px);
  gap: 2px clamp(8px, 1.5vw, 24px);
}
.work-gallery .work-filters a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 10px;
  border: 0;
  color: var(--muted);
  opacity: .84;
  font: 700 .94rem/1.25 var(--sans);
  text-decoration: none;
  text-transform: none;
  letter-spacing: normal;
  background: transparent;
  box-shadow: none;
}
.work-gallery .work-filters a:hover,
.work-gallery .work-filters a:focus-visible {
  color: var(--ink);
  opacity: .92;
}
.work-gallery .work-filters a[aria-current] {
  color: var(--ink);
  opacity: 1;
}

.work-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: var(--gutter);
}
.collection-tile {
  position: relative;
  display: block;
  overflow: hidden;
  isolation: isolate;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: var(--cream);
  cursor: pointer;
}
.collection-tile {
  flex: 0 0 calc((100% - var(--gutter) - var(--gutter)) / 3);
  aspect-ratio: 16 / 10;
}
.collection-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.collection-tile[data-service="restoration-clearance"] {
  background: var(--cream);
}
.collection-tile[data-service="restoration-clearance"] img { object-fit: contain; }
@media (min-width: 521px) {
  .work-gallery:has([data-filter="restoration-clearance"][aria-current]) .collection-tile {
    flex-basis: calc((100% - var(--gutter)) / 2);
    aspect-ratio: 2 / 1;
  }
}
.work-gallery [hidden] { display: none !important; }
.work-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.work-gallery :focus-visible { outline: 3px solid currentColor; outline-offset: -4px; }
.collection-tile:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* The enlarged image keeps its full proportions, including before-and-after pairs. */
.work-viewer {
  --viewer-rail: clamp(56px, 7vw, 104px);
  --viewer-width: calc(100vw - var(--viewer-rail) - var(--viewer-rail));
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  margin: auto; padding: 0; border: 0;
  background: transparent;
  color: #eee;
}
.work-viewer[open] {
  display: grid;
  grid-template-columns: var(--viewer-rail) minmax(0, 1fr) var(--viewer-rail);
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
}
.work-viewer::backdrop { background: rgba(0, 0, 0, .88); }
.work-viewer figure {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  margin: 0;
  max-height: calc(100vh - 128px);
  max-height: calc(100dvh - 128px);
}
.work-viewer .viewer-zoom {
  display: block;
  width: max-content;
  height: auto;
  max-width: none;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: default;
}
.work-viewer .viewer-zoom img {
  display: block;
  width: auto;
  height: auto;
  max-width: var(--viewer-width);
  max-height: calc(100vh - 128px);
  max-height: calc(100dvh - 128px);
  touch-action: pan-y pinch-zoom;
}
.work-viewer figure.is-zoomed { overflow: auto; }
.work-viewer figure.is-zoomed .viewer-zoom img {
  max-width: none;
  width: 100%;
  max-height: none;
  touch-action: auto;
}
.work-viewer button:not(.viewer-zoom) {
  display: grid;
  place-items: center;
  justify-self: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #eee;
  cursor: pointer;
  z-index: 1;
}
.work-viewer button:hover { color: #fff; }
.work-viewer button:not(.viewer-zoom)::before {
  content: "";
  box-sizing: border-box;
}
.viewer-prev::before, .viewer-next::before {
  width: 12px;
  height: 12px;
  border: solid currentColor;
  border-width: 2px 2px 0 0;
}
.viewer-prev::before { transform: translateX(2px) rotate(-135deg); }
.viewer-next::before { transform: translateX(-2px) rotate(45deg); }
.viewer-close::before, .viewer-close::after {
  content: "";
  grid-area: 1 / 1;
  width: 22px;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
}
.viewer-close::after { transform: rotate(-45deg); }
.viewer-close { position: absolute; top: 12px; right: 16px; }
.viewer-prev { grid-column: 1; grid-row: 1; }
.viewer-next { grid-column: 3; grid-row: 1; }
html:has(.work-viewer[open]) { overflow: hidden; }

@media (max-width: 780px) {
  .collection-tile { flex-basis: calc((100% - var(--gutter)) / 2); }
  .work-viewer[open] {
    --viewer-width: calc(100vw - 24px);
    grid-template-columns: minmax(0, 1fr);
  }
  .work-viewer figure { grid-column: 1; }
  .work-viewer .viewer-prev, .work-viewer .viewer-next { position: absolute; bottom: max(8px, env(safe-area-inset-bottom)); }
  .viewer-prev { left: 12px; }
  .viewer-next { right: 12px; }
}
@media (max-width: 520px) {
  .work-grid > .collection-tile { flex-basis: 100%; }
  .work-grid > .collection-tile[data-service="restoration-clearance"] { flex: 1 0 100%; aspect-ratio: 2 / 1; }
}
/* The overlay tints the photo without shifting the grid. */
.collection-tile::after {
  position: absolute;
  inset: 0;
  background: #101310;
  opacity: 0;
  content: "";
  pointer-events: none;
}
.collection-tile:focus-visible::after { opacity: .4; }
@media (hover: hover) {
  .collection-tile:hover::after { opacity: .48; }
}
@media (prefers-reduced-motion: no-preference) {
  .work-gallery .work-filters a { transition: color .18s ease, opacity .18s ease, transform .18s ease; }
  .work-gallery .work-filters a:hover { transform: translateY(-2px); }
  .collection-tile::after { transition: opacity .22s ease; }
  .collection-tile:not([hidden]) { animation: gallery-reveal .5s cubic-bezier(.22, 1, .36, 1) both; }
  .collection-tile:nth-child(3n + 2) { animation-delay: 45ms; }
  .collection-tile:nth-child(3n) { animation-delay: 90ms; }
  @keyframes gallery-reveal {
    from { opacity: .35; transform: scale(.94); }
    to { opacity: 1; transform: scale(1); }
  }
}

.collection-tile[data-service="log-store"] img { object-position: center 60%; }

/* Keep these two gallery navigation rows in the page on small screens.
   The shared header has a separate collapsible navigation. */
@media (max-width: 900px) {
  .work-gallery :is(.work-filters, .gallery-breadcrumb) {
    display: flex;
    position: static;
    flex-flow: row wrap;
    align-items: center;
    justify-content: center;
    width: auto;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .work-gallery .work-filters {
    gap: 0 clamp(6px, 1.5vw, 16px);
    margin: 20px auto 12px;
  }
  .work-gallery .work-filters a {
    padding: 6px 8px;
    min-height: 44px;
    justify-content: center;
    text-align: center;
  }
  .work-gallery .gallery-breadcrumb { gap: .65rem; }
  .work-gallery .gallery-breadcrumb a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 .25rem;
  }
}
/* End of gallery.css */
