.gallery-page { background: #eeece4; color: #1c211e; }
.gallery-header { color: var(--cream); }
.gallery-header .header-inner { display: flex; justify-content: space-between; gap: 1rem; }
.gallery-back {
  display: inline-flex; align-items: center; gap: .65rem; min-height: 44px;
  color: var(--cream); font: 600 .9rem/1.4 var(--display); text-decoration: none;
}
.gallery-back [aria-hidden] { color: var(--orange); }
.gallery-back:hover { text-decoration: underline; text-underline-offset: .3em; }
.gallery-heading { color: var(--cream); background: var(--carbon); }
.gallery-heading > .wrap {
  display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,.7fr); align-items: end;
  gap: 1rem clamp(2rem,6vw,7rem); padding-block: clamp(2.6rem,6.5vw,6.75rem);
}
.gallery-heading h1 {
  max-width: 16ch; font-size: clamp(3.1rem,6.4vw,7rem); font-weight: 720;
  line-height: .99; letter-spacing: -.045em; text-wrap: balance; overflow-wrap: anywhere;
}
.gallery-heading p { max-width: 37ch; color: #c7ccc4; font-size: clamp(1rem,1.4vw,1.2rem); }
.gallery-grid {
  --altura-linha: clamp(12.5rem, 18vw, 18rem);
  display: flex; flex-wrap: wrap; align-items: flex-start;
  gap: clamp(1.45rem,2.9vw,3rem) clamp(.8rem,1.5vw,1.6rem);
  padding-block: clamp(2rem,4.25vw,4.5rem) clamp(3.5rem,7vw,7.5rem);
}
.gallery-card {
  --proporcao: clamp(.77, calc(var(--foto-largura, 4) / var(--foto-altura, 3)), 2);
  flex: var(--proporcao) 1 calc(var(--altura-linha) * var(--proporcao));
  max-width: min(100%,calc(var(--altura-linha) * var(--proporcao) * 1.45)); min-width: 0;
}
.gallery-thumb {
  position: relative; display: block; width: 100%; aspect-ratio: var(--proporcao);
  contain: paint; background: #cbcfc5; color: #fff; cursor: zoom-in;
}
.gallery-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb::after {
  content: "↗"; display: grid; place-items: center; position: absolute; right: .65rem; bottom: .65rem;
  width: 2.2rem; height: 2.2rem; color: #fff; background: #161916e8;
  opacity: 0; transform: translateY(.2rem); transition: opacity 150ms,transform 150ms;
}
.gallery-thumb:is(:hover,:focus-visible)::after { opacity: 1; transform: none; }
.gallery-card figcaption {
  margin-top: .65rem; color: #343b33; font: 600 clamp(.9rem,1.35vw,1.08rem)/1.4 var(--display);
  overflow-wrap: anywhere;
}
.gallery-empty { color: #50584e; border-top: 1px solid #b7bcb1; padding-block: 2rem; width: 100%; }
.gallery-page .rodape { color: var(--cream); }
.photo-viewer:not([open]) { display: none; }
.photo-viewer[open] {
  position: fixed; inset: 0; display: grid; grid-template-rows: auto minmax(0,1fr);
  width: min(calc(100% - 2rem), 98rem); height: calc(100% - 2rem); height: calc(100dvh - 2rem);
  max-width: none; max-height: none; margin: auto; padding: 0; overflow: hidden;
  border: 1px solid #4d524b; background: #191c19; color: #f9f7ef;
}
.photo-viewer::backdrop { background: rgb(9 12 10 / 86%); }
html:has(.photo-viewer[open]) { overflow: hidden; }
.viewer-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .4rem clamp(.65rem,2vw,1.7rem); border-bottom: 1px solid #40453e;
}
.viewer-count { font: 600 .9rem/1.45 var(--display); }
.viewer-controls { display: flex; align-items: center; gap: .2rem; }
.viewer-controls button {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-width: 44px; min-height: 44px; padding: .3rem .55rem; color: #f8f7ec;
  border: 1px solid transparent; border-radius: 0; background: transparent;
  font: 600 .9rem/1.4 var(--display); cursor: pointer;
}
.viewer-controls button [aria-hidden] { font: 400 1.5rem/1 var(--body); }
.viewer-controls .viewer-close { margin-left: .3rem; border-color: #92988b; }
.viewer-controls button:hover { color: var(--orange); background: #30352f; }
.viewer-controls button:focus-visible { outline-offset: -3px; }
.viewer-figure { display: grid; grid-template-rows: minmax(0,1fr) auto; gap: .5rem; min-height: 0; padding: clamp(.6rem,1.5vw,1.5rem); }
.viewer-stage { min-width: 0; min-height: 0; display: grid; place-items: center; }
.viewer-stage img { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
.viewer-caption { text-align: center; max-height: 25vh; overflow: auto; font-size: .94rem; overflow-wrap: anywhere; }
@media (max-width: 48rem) {
  .gallery-heading > .wrap { grid-template-columns: 1fr; }
  .gallery-heading h1 { max-width: 18ch; }
  .gallery-grid { --altura-linha: clamp(10.75rem, 29vw, 15rem); }
}
@media (max-width: 36rem) {
  .gallery-grid { display: grid; grid-template-columns: minmax(0, 1fr); }
  .gallery-card { max-width: none; }
  .gallery-thumb { aspect-ratio: clamp(.95,var(--proporcao),1.85); }
  .photo-viewer[open] { width: 100%; height: 100%; height: 100dvh; border: 0; }
  .viewer-toolbar { padding-top: max(.4rem,env(safe-area-inset-top)); }
  .viewer-figure { padding-bottom: max(.6rem,env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .gallery-thumb::after { transition: none; } }
