.project-gallery-link {
  display: block;
  cursor: zoom-in;
}

.project-gallery {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #111;
  color: #f3f0e9;
  font: inherit;
  touch-action: auto;
}

.project-gallery:not([open]) {
  display: none;
}

.project-gallery::backdrop {
  background: #111;
}

.project-gallery__frame {
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.project-gallery__heading {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.project-gallery__toolbar,
.project-gallery__actions {
  display: flex;
  align-items: center;
}

.project-gallery__toolbar {
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.project-gallery__counter {
  margin: 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.project-gallery__actions {
  gap: 8px;
  flex: 0 0 auto;
}

.project-gallery__zoom,
.project-gallery__close,
.project-gallery__previous,
.project-gallery__next {
  box-sizing: border-box;
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid rgb(243 240 233 / 30%);
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  touch-action: auto;
}

.project-gallery__zoom {
  font-size: 14px;
  white-space: nowrap;
}

.project-gallery__close,
.project-gallery__previous,
.project-gallery__next {
  width: 44px;
  padding: 0;
  font-size: 24px;
}

.project-gallery button:focus-visible,
.project-gallery__viewport:focus-visible {
  outline: 2px solid #f3f0e9;
  outline-offset: -3px;
}

.project-gallery button:disabled {
  opacity: .35;
  cursor: default;
}

.project-gallery__viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: auto;
}

.project-gallery__track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 100%);
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  will-change: transform;
}

.project-gallery__slide {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.project-gallery.is-zoomed .project-gallery__track {
  display: block;
  width: max-content;
  height: max-content;
  will-change: auto;
}

.project-gallery.is-zoomed .project-gallery__slide[data-gallery-position="current"] {
  width: max-content;
  height: max-content;
  min-width: 100%;
  min-height: 100%;
  overflow: visible;
}

.project-gallery.is-zoomed .project-gallery__slide[aria-hidden="true"] {
  display: none;
}

.project-gallery__canvas {
  display: grid;
  place-items: center;
  width: max-content;
  min-width: 100%;
  height: max-content;
  min-height: 100%;
}

.project-gallery .project-gallery__image {
  display: block;
  width: auto;
  max-width: none;
  height: auto;
  max-height: none;
  margin: 0;
  object-fit: contain;
  touch-action: auto;
}

.project-gallery .project-gallery__image[hidden] {
  display: none;
}

.project-gallery__footer {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.project-gallery__caption {
  min-width: 0;
  max-height: 4.2em;
  margin: 0;
  overflow: auto;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  text-align: center;
}

.project-gallery.is-single .project-gallery__counter,
.project-gallery.is-single .project-gallery__previous,
.project-gallery.is-single .project-gallery__next { display:none; }
.project-gallery.is-single .project-gallery__toolbar { justify-content:flex-end; }
.project-gallery.is-single .project-gallery__footer { grid-template-columns:minmax(0,1fr); }

@media (hover: none) and (pointer: coarse) {
  .project-gallery.has-drag-swipe .project-gallery__footer {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Swipe is the visible touch control. Keep button actions available to
     assistive technology and reveal them when keyboard-focused. */
  .project-gallery.has-drag-swipe .project-gallery__previous,
  .project-gallery.has-drag-swipe .project-gallery__next {
    position: absolute;
    width: 1px;
    min-width: 1px;
    height: 1px;
    min-height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    border: 0;
  }

  .project-gallery.has-drag-swipe .project-gallery__previous:focus-visible,
  .project-gallery.has-drag-swipe .project-gallery__next:focus-visible {
    position: fixed;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
    clip-path: none;
    border: 1px solid rgb(243 240 233 / 30%);
  }

  .project-gallery.has-drag-swipe .project-gallery__previous:focus-visible {
    left: max(12px, env(safe-area-inset-left));
  }

  .project-gallery.has-drag-swipe .project-gallery__next:focus-visible {
    right: max(12px, env(safe-area-inset-right));
  }
}
