.gallery-cover {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--panel);
  color: var(--white);
}
.gallery-cover[hidden] { display: none; }
.gallery-cover--added {
  width: min(100%, 45rem);
  margin-top: 16px;
  border-radius: 7px;
}
.gallery-cover img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.gallery-cover img.case-image { aspect-ratio: 1.68; }
.gallery-cover:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
  z-index: 1;
}
.gallery-cover-label {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 9px;
  border-radius: 5px;
  background: rgb(23 22 21 / 92%);
  color: var(--white);
  font-size: .77rem;
  font-weight: 650;
  line-height: 1.35;
}
.gallery-cover-label::after {
  content: "";
  display: inline-block;
  width: .48em;
  height: .48em;
  margin-inline: .55em .12em;
  border-top: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
  vertical-align: .16em;
}
.gallery-open { overflow: hidden; }
.gallery-dialog {
  position: fixed;
  box-sizing: border-box;
  inset: 0;
  width: min(920px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100% - 24px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--dark-rule);
  border-radius: 12px;
  background: var(--panel);
  color: var(--white);
}
.gallery-dialog::backdrop { background: rgb(12 11 10 / 86%); }
.gallery-viewer { padding: clamp(10px, 2.3vw, 20px); }
.gallery-header,
.gallery-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.gallery-header { margin-bottom: 10px; }
.gallery-header h2 {
  font: 800 clamp(1.45rem, 4.2vw, 2.05rem)/1.05 var(--display);
  overflow-wrap: anywhere;
}
.gallery-header form { margin: 0; }
.gallery-stage {
  display: grid;
  place-items: center;
  height: min(64vh, 620px);
  height: min(64dvh, 620px);
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
  border-radius: 5px;
  background: var(--night);
}
.gallery-stage img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}
.gallery-dialog [hidden] { display: none; }
.gallery-error { margin: 15px; font-size: .9rem; text-align: center; }
.gallery-navigation { margin-top: 10px; }
.gallery-control {
  display: grid;
  place-items: center;
  width: 46px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--dark-rule);
  border-radius: 6px;
  background: var(--night);
  color: var(--white);
  font: 1.4rem/1 var(--body);
  cursor: pointer;
}
.gallery-control:hover,
.gallery-control:focus-visible { border-color: var(--accent); color: var(--accent); }
.gallery-counter { color: var(--light-muted); font-size: .85rem; }

@media (min-width: 761px) {
  .project-reference .gallery-cover--added { max-width: 36rem; }
}
@media (max-width: 560px) {
  .gallery-stage { height: min(64vh, 85vw); height: min(64dvh, 85vw); }
}
@media (max-height: 480px) {
  .gallery-stage { height: min(52vh, 350px); height: min(52dvh, 350px); }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .gallery-cover img { transition: transform .27s ease; }
  .gallery-cover:hover img { transform: scale(1.035); }
}
@media (prefers-reduced-motion: no-preference) {
  .gallery-dialog[open] { animation: gallery-appear .2s ease-out both; }
  @keyframes gallery-appear {
    from { opacity: 0; transform: translateY(7px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
