.gallery {
  --gallery-gap: clamp(.8rem, 1.6vw, 1.5rem);
  --gallery-space: clamp(2rem, 4vw, 3rem);
  padding-block: var(--gallery-space);
}
.gallery-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 44px;
  margin: 0 auto var(--gallery-gap);
  padding: .55rem 1.1rem;
  border: 1px solid var(--edge);
  border-radius: var(--rz-control-radius);
  background: var(--shell);
  color: var(--mint);
  font-weight: 650;
  text-align: center;
}
.gallery-back:is(:hover, :focus-visible) { border-color: var(--mint); }
.gallery h1 {
  display: flex;
  justify-content: center;
  margin: 0 0 var(--gallery-space);
  font-size: clamp(2rem, 5vw, 4rem);
}
.gallery h1 .rz-nav-lettering { justify-content: center; flex-wrap: wrap; font-size: inherit; }
.gallery h1 .rz-nav-word { max-width: 100%; }

/* Equal widths throughout the series, including a centered partial row. */
.gallery-grid {
  --columns: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gallery-gap);
  list-style: none;
  padding: 0;
  margin: 0;
}
.gallery-grid > li {
  display: flex;
  flex: 0 0 calc((100% + var(--gallery-gap)) / var(--columns) - var(--gallery-gap));
  min-width: 0;
}
@media (min-width: 22rem) {
  .gallery-grid { --columns: 2; }
}
@media (min-width: 56rem) {
  .gallery-grid { --columns: 3; }
}
@media (min-width: 68rem) {
  .gallery-grid:has(> li:nth-child(4n):last-child) { --columns: 4; }
}
.gallery-photo {
  display: block;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--edge);
  border-radius: var(--corner);
  background: var(--shell);
  color: var(--ink);
  cursor: zoom-in;
}
.gallery-photo:is(:hover, :focus-visible) { border-color: var(--mint); color: var(--mint); }
.gallery-photo figure {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  margin: 0;
}
.gallery-photo img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: var(--crop, center 36%);
}
.gallery-grid :is([data-photo="embrujo"], [data-photo="beats"], [data-photo="vocals"]) { --crop: 50% 30%; }
.gallery-grid [data-photo="production"] { --crop: 50% 50%; }
.gallery-grid [data-photo="coaching"] { --crop: 50% 25%; }
.gallery-grid [data-photo="mixing"] { --crop: 50% 40%; }
.gallery-grid [data-photo="embrujo-perfil"] { --crop: 50% 10%; }
.gallery-grid [data-photo="embrujo-rojo"] { --crop: 77% 50%; }
.gallery-grid [data-photo="embrujo-noche"] { --crop: 50% 52%; }
.gallery-photo figcaption {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 1rem;
  font-weight: 650;
  line-height: 1.45;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.gallery-photo figure::after {
  content: "";
  position: absolute;
  top: .8rem;
  right: .8rem;
  width: 2rem;
  height: 2rem;
  border: 1px solid #ffffff80;
  border-radius: 50%;
  background:
    linear-gradient(white, white) center / 13px 2px no-repeat,
    linear-gradient(white, white) center / 2px 13px no-repeat,
    #080e12cf;
}

html:has(.gallery-viewer[open]) { overflow: hidden; }
.gallery-viewer {
  --inset: clamp(.65rem, 2vw, 1.25rem);
  position: fixed;
  inset: 0;
  margin: auto;
  padding: var(--inset);
  width: min(68rem, 96vw);
  height: 94vh;
  height: 94dvh;
  max-width: none;
  max-height: none;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: var(--corner);
  overscroll-behavior: contain;
}
.gallery-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: .65rem;
}
.gallery-viewer::backdrop { background: rgb(0 0 0 / .85); }
.gallery-viewer figure {
  margin: 0;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: .65rem;
}
.gallery-viewer img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  touch-action: pan-y pinch-zoom;
}
.gallery-viewer figcaption {
  text-align: center;
  line-height: 1.4;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.gallery-viewer [data-count] {
  position: absolute;
  inset: var(--inset) auto auto var(--inset);
  display: grid;
  align-items: center;
  min-height: 44px;
  color: var(--mint);
  font: 500 .9rem/1.4 var(--mono);
}
.gallery-viewer button {
  min-height: 44px;
  padding: .55rem 1rem;
  border: 1px solid var(--edge);
  border-radius: var(--rz-control-radius);
  background: var(--shell);
  color: var(--ink);
  font: 650 1rem/1.25 var(--sans);
  cursor: pointer;
}
.gallery-viewer button:is(:hover, :focus-visible) { border-color: var(--mint); color: var(--mint); }
.gallery-viewer [data-close] { justify-self: end; }
.gallery-controls:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gallery-gap);
  width: min(100%, 25rem);
  margin-inline: auto;
}
@media (max-width: 38rem) {
  .gallery-photo figcaption { padding: .75rem .5rem; font-size: .9rem; }
  .gallery-photo figure::after { top: .5rem; right: .5rem; width: 1.7rem; height: 1.7rem; }
}
@media (max-width: 23rem) {
  .gallery-viewer button { padding-inline: .4rem; }
}
@media (max-height: 30rem) {
  .gallery-viewer { --inset: .5rem; }
  .gallery-viewer[open], .gallery-viewer figure { gap: .25rem; }
}

.gallery-back { gap: .6rem; max-width: 100%; }
.gallery :is(.gallery-back, button) .rz-nav-lettering {
  justify-content: center;
  flex-wrap: wrap;
  font-size: clamp(.9rem, 1.4vw, 1.125rem);
}
