/* Diamond gallery — grid of clipped diamonds + lightbox */

.diamond-gallery {
  --dg-size: 120px;
  --dg-gap: 6px;
  /* 1px diamond frame (aligned with clip-path); used by ::after on open/static */
  --dg-frame-side: calc(var(--dg-size) * 1.414);
  --dg-expand-ease: cubic-bezier(0.22, 1, 0.36, 1);
  width: 100%;
  max-width: 100%;
}

.diamond-gallery__primary {
  display: grid;
  grid-template-columns: repeat(6, var(--dg-size));
  grid-auto-rows: var(--dg-size);
  gap: var(--dg-gap);
  place-items: start center;
  margin: 0;
  padding: 0.5rem 0 1rem;
  overflow: visible;
  justify-content: center;
  transition:
    opacity 0.38s var(--dg-expand-ease),
    transform 0.46s var(--dg-expand-ease),
    filter 0.38s ease,
    max-height 0.46s var(--dg-expand-ease),
    padding 0.34s ease;
  transform-origin: top center;
  max-height: 2400px;
  will-change: transform, opacity;
}

.diamond-gallery__expanded {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  padding: 0.35rem;
  margin: -0.35rem;
  transform: translateY(28px) scale(0.965);
  transform-origin: top center;
  transition:
    opacity 0.34s ease,
    transform 0.52s var(--dg-expand-ease),
    filter 0.38s ease,
    max-height 0.48s var(--dg-expand-ease),
    margin-top 0.32s ease;
  filter: blur(10px);
  will-change: transform, opacity;
}

.diamond-gallery--expanded .diamond-gallery__primary {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  transform: translateY(-24px) scale(0.93);
  filter: blur(10px);
  pointer-events: none;
}

.diamond-gallery--expanded .diamond-gallery__expanded {
  opacity: 1;
  max-height: 5000px;
  margin-top: 0.25rem;
  overflow: visible;
  filter: blur(0);
  transform: translateY(0) scale(1);
}

.diamond-gallery__thumb-grid {
  display: grid;
  --dg-thumb-size: var(--dg-frame-side);
  grid-template-columns: repeat(
    auto-fill,
    minmax(var(--dg-thumb-size), var(--dg-thumb-size))
  );
  gap: 0.7rem;
  width: 100%;
  justify-content: center;
}

.diamond-gallery__thumb-cell {
  min-width: 0;
  position: relative;
  z-index: 1;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.diamond-gallery__thumb-cell:hover,
.diamond-gallery__thumb-cell:has(:focus-visible) {
  z-index: 10;
}

.diamond-gallery__thumb-open {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  margin: 0;
  border: 1px solid #000;
  border-radius: 2px;
  overflow: visible;
  background: #ffffff;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.96),
    0 2px 10px rgba(20, 48, 58, 0.12);
  cursor: zoom-in;
  line-height: 0;
  position: relative;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    filter 0.18s ease;
}

.diamond-gallery__thumb-open:focus {
  outline: none;
}

.diamond-gallery__thumb-open:focus-visible {
  outline: 2px solid rgba(38, 166, 154, 0.95);
  outline-offset: 3px;
}

.diamond-gallery__thumb-img {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  border-radius: 2px;
  transition: transform 0.22s ease, filter 0.18s ease;
}

.diamond-gallery__thumb-open::before,
.diamond-gallery__thumb-open::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.diamond-gallery__thumb-open::before {
  z-index: 0;
  border-radius: 2px;
  background: #ffffff;
  opacity: 0;
  transform: scale(1);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.95),
    0 0 0 5px rgba(38, 166, 154, 0.72),
    0 0 24px 3px rgba(38, 166, 154, 0.35),
    0 16px 40px rgba(20, 48, 58, 0.32),
    0 6px 16px rgba(20, 48, 58, 0.2);
  transition:
    opacity 0.22s ease,
    transform 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.diamond-gallery__thumb-open::after {
  z-index: 0;
  border: 1px solid #000;
  border-radius: 2px;
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.diamond-gallery__thumb-cell:hover .diamond-gallery__thumb-open::before,
.diamond-gallery__thumb-open:hover::before,
.diamond-gallery__thumb-cell:has(:focus-visible) .diamond-gallery__thumb-open::before {
  opacity: 1;
  transform: scale(1.08);
}

.diamond-gallery__thumb-cell:hover .diamond-gallery__thumb-open::after,
.diamond-gallery__thumb-open:hover::after,
.diamond-gallery__thumb-cell:has(:focus-visible) .diamond-gallery__thumb-open::after {
  transform: scale(1.04);
}

.diamond-gallery__thumb-open:hover .diamond-gallery__thumb-img,
.diamond-gallery__thumb-open:focus-visible .diamond-gallery__thumb-img,
.diamond-gallery__thumb-cell:hover .diamond-gallery__thumb-img,
.diamond-gallery__thumb-cell:has(:focus-visible) .diamond-gallery__thumb-img {
  transform: scale(1.1);
  filter: brightness(1.08);
}

.diamond-gallery--expanding .diamond-gallery__primary .diamond-gallery__cell {
  animation: dg-diamond-exit 0.48s var(--dg-expand-ease) both;
  animation-delay: calc(var(--dg-item-index, 0) * 18ms);
}

.diamond-gallery--expanding .diamond-gallery__cell--more {
  animation-delay: calc(var(--dg-item-index, 0) * 18ms + 40ms);
}

.diamond-gallery--expanding .diamond-gallery__expanded .diamond-gallery__thumb-cell {
  opacity: 0;
  transform: translateY(26px) scale(0.92);
  animation: dg-square-enter 0.54s var(--dg-expand-ease) both;
  animation-delay: calc(120ms + (var(--dg-item-index, 0) * 22ms));
}

@keyframes dg-diamond-exit {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
    filter: blur(0);
  }

  100% {
    opacity: 0;
    transform: translateY(-22px) scale(0.9) rotate(-8deg);
    filter: blur(8px);
  }
}

@keyframes dg-square-enter {
  0% {
    opacity: 0;
    transform: translateY(26px) scale(0.92);
    filter: blur(10px);
  }

  60% {
    opacity: 1;
    transform: translateY(-4px) scale(1.02);
    filter: blur(0);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .diamond-gallery__primary,
  .diamond-gallery__expanded,
  .diamond-gallery__thumb-open,
  .diamond-gallery__thumb-img,
  .diamond-gallery__thumb-open::before,
  .diamond-gallery__thumb-open::after,
  .diamond-gallery__open::before,
  .diamond-gallery__open::after,
  .diamond-gallery__img {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
  }
}

.diamond-gallery__cell {
  grid-column: auto / span 2;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  /* Instant stacking — no delayed z-index transition (delay was leaving the
     previous tile on top and blocking hover on neighbors for ~0.45s). */
  z-index: 1;
}

.diamond-gallery__cell:hover,
.diamond-gallery__cell:has(:focus-visible) {
  z-index: 10;
}

.diamond-gallery__primary .diamond-gallery__cell:nth-child(5n + 2) {
  grid-column: 2 / span 2;
}

.diamond-gallery__open,
.diamond-gallery__static {
  display: block;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: default;
  line-height: 0;
  border-radius: 0;
  font: inherit;
  color: inherit;
  position: relative;
  overflow: visible;
}

.diamond-gallery__open {
  cursor: zoom-in;
}

.diamond-gallery__open:focus {
  outline: none;
}

/*
 * Highlight active tile: clip-path on <img> often hides filter drop-shadows in browsers.
 * This ::before is a rotated square (reads as a diamond) with unclipped box-shadow
 * so the teal ring + depth stay visible behind the photo.
 */
.diamond-gallery__open::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  /* Square whose diagonal ≈ tile width, matches the diamond footprint after rotate(45deg) */
  width: var(--dg-frame-side);
  height: var(--dg-frame-side);
  transform: translate(-50%, -50%) rotate(45deg) scale(1);
  transform-origin: center center;
  border-radius: 3px;
  background: #ffffff;
  pointer-events: none;
  opacity: 0;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.95),
    0 0 0 5px rgba(38, 166, 154, 0.72),
    0 0 24px 3px rgba(38, 166, 154, 0.35),
    0 16px 40px rgba(20, 48, 58, 0.32),
    0 6px 16px rgba(20, 48, 58, 0.2);
  transition:
    opacity 0.22s ease,
    transform 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/*
 * Thin black diamond edge — clip-path on <img> hides border/filter on the image itself
 * (see MDN / WebKit issues). This frame sits under the media (z-index 0 vs img 1).
 */
.diamond-gallery__open::after,
.diamond-gallery__static::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: var(--dg-frame-side);
  height: var(--dg-frame-side);
  box-sizing: border-box;
  transform: translate(-50%, -50%) rotate(45deg) scale(1);
  transform-origin: center center;
  border: 1px solid #000;
  border-radius: 2px;
  background: transparent;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.diamond-gallery__cell:hover .diamond-gallery__open:not(.diamond-gallery__open--more)::after,
.diamond-gallery__open:not(.diamond-gallery__open--more):hover::after,
.diamond-gallery__cell:has(:focus-visible)
  .diamond-gallery__open:not(.diamond-gallery__open--more)::after {
  transform: translate(-50%, -50%) rotate(45deg) scale(1.1);
}

.diamond-gallery__cell:hover .diamond-gallery__static::after,
.diamond-gallery__static:has(:focus-visible)::after {
  transform: translate(-50%, -50%) rotate(45deg) scale(1.1);
}

.diamond-gallery__cell:hover .diamond-gallery__open--more::after,
.diamond-gallery__open--more:hover::after,
.diamond-gallery__cell:has(:focus-visible) .diamond-gallery__open--more::after {
  transform: translate(-50%, -50%) rotate(45deg) scale(1.1);
}

.diamond-gallery__cell:hover .diamond-gallery__open::before,
.diamond-gallery__open:hover::before,
.diamond-gallery__cell:has(:focus-visible) .diamond-gallery__open::before {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(45deg) scale(1.14);
}

.diamond-gallery__img {
  display: block;
  position: relative;
  z-index: 1;
  width: calc(var(--dg-size) * 2);
  height: calc(var(--dg-size) * 2);
  max-width: none;
  object-fit: cover;
  object-position: center center;
  transform: scale(1);
  transform-origin: center center;
  /* Diamond mask kept on hover — smooth zoom-in of the photo inside the mask */
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  filter: drop-shadow(0 0 0.5px rgba(255, 255, 255, 0.55))
    drop-shadow(0 2px 8px rgba(20, 48, 58, 0.14));
  transition:
    transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    filter 0.28s ease;
  vertical-align: middle;
}

.diamond-gallery__cell:hover .diamond-gallery__img,
.diamond-gallery__open:hover .diamond-gallery__img {
  transform: scale(1.1);
  filter: brightness(1.08);
}

.diamond-gallery__open:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.95);
  outline-offset: 4px;
  border-radius: 4px;
}

.diamond-gallery__open:focus-visible .diamond-gallery__img {
  transform: scale(1.1);
  filter: brightness(1.1);
}

/* “Mais fotos” tile — same diamond footprint as thumbnails */
.diamond-gallery__open--more {
  cursor: pointer;
  /* Parent .diamond-gallery__open uses line-height: 0 for photos; that hides text here without flex + min-height */
  line-height: normal;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: calc(var(--dg-size) * 2);
  min-height: calc(var(--dg-size) * 2);
}

.diamond-gallery__more-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  width: calc(var(--dg-size) * 2);
  height: calc(var(--dg-size) * 2);
  flex-shrink: 0;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  background:
    radial-gradient(
      ellipse at 34% 28%,
      rgba(255, 255, 255, 0.85) 0%,
      rgba(255, 255, 255, 0.32) 18%,
      transparent 44%
    ),
    linear-gradient(155deg, #fbfcfe 0%, #dce5ec 34%, #adc0cc 68%, #88a3b1 100%);
  color: #10252d;
  -webkit-font-smoothing: antialiased;
  text-align: center;
  font-family: inherit;
  font-size: clamp(0.58rem, 2.4vw, 0.78rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: scale(1);
  transform-origin: center center;
  transition:
    transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    filter 0.28s ease;
  box-sizing: border-box;
  padding: 0.3rem 0.65rem;
  filter: drop-shadow(0 0 0.5px rgba(255, 255, 255, 0.45))
    drop-shadow(0 6px 18px rgba(10, 24, 32, 0.34));
}

.diamond-gallery__more-visual::before {
  content: "";
  position: absolute;
  inset: 8%;
  border: 1px solid rgba(255, 255, 255, 0.48);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  pointer-events: none;
  opacity: 0.9;
}

.diamond-gallery__more-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(38, 166, 154, 0.22) 0%, transparent 42%),
    linear-gradient(315deg, rgba(245, 208, 140, 0.22) 0%, transparent 38%);
  pointer-events: none;
}

.diamond-gallery__more-label {
  display: block;
  max-width: 8.5em;
  position: relative;
  z-index: 2;
}

.diamond-gallery__cell:hover .diamond-gallery__open--more .diamond-gallery__more-visual,
.diamond-gallery__open--more:hover .diamond-gallery__more-visual {
  transform: scale(1.1);
  filter: brightness(1.06)
    saturate(1.06)
    drop-shadow(0 0 1px rgba(255, 255, 255, 0.36))
    drop-shadow(0 14px 30px rgba(10, 24, 32, 0.38))
    drop-shadow(0 4px 14px rgba(10, 24, 32, 0.28));
}

.diamond-gallery__open--more:focus-visible .diamond-gallery__more-visual {
  transform: scale(1.1);
  filter: brightness(1.08)
    saturate(1.08)
    drop-shadow(0 0 1px rgba(255, 255, 255, 0.4))
    drop-shadow(0 16px 34px rgba(10, 24, 32, 0.42));
}

@media (max-width: 640px) {
  .diamond-gallery__primary {
    --dg-size: 80px;
    grid-template-columns: repeat(4, var(--dg-size));
    padding-bottom: 0.65rem;
  }

  .diamond-gallery__primary .diamond-gallery__cell:nth-child(5n + 2) {
    grid-column: auto / span 2;
  }

  .diamond-gallery__primary .diamond-gallery__cell:nth-child(3n + 2) {
    grid-column: 2 / span 2;
  }

  .diamond-gallery__thumb-grid {
    --dg-thumb-size: min(9rem, calc((100% - 0.5rem) / 2));
    grid-template-columns: repeat(2, minmax(0, var(--dg-thumb-size)));
    gap: 0.5rem;
  }
}

@media (max-width: 400px) {
  .diamond-gallery__primary {
    --dg-size: 66px;
    grid-template-columns: repeat(4, var(--dg-size));
  }

  .diamond-gallery__thumb-grid {
    --dg-thumb-size: min(8rem, calc((100% - 0.45rem) / 2));
    gap: 0.45rem;
  }
}

/* Modal (elements created by diamond-gallery.js) */
body.dg-modal-open {
  overflow: hidden;
}

.dg-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(20, 48, 58, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: dg-fade-in 0.22s ease;
}

@keyframes dg-fade-in {
  from {
    opacity: 0;
  }
}

.dg-dialog {
  position: relative;
  width: min(94vw, 84rem);
  max-width: min(94vw, 84rem);
  max-height: min(94vh, 60rem);
  margin: 0;
  padding: 0.75rem;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.dg-stage {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
}

.dg-stage-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
}

.dg-viewport {
  width: 100%;
  height: min(78vh, 50rem);
  min-height: min(60vh, 24rem);
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  place-items: center;
  padding: 0.75rem;
  border-radius: 20px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03)),
    rgba(8, 19, 24, 0.42);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 18px 48px rgba(0, 0, 0, 0.24);
}

.dg-viewport[data-zoomed="true"] {
  place-items: start;
}

.dg-media {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: auto;
}

.dg-toolbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.8rem 0.95rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  color: #14303a;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

.dg-toolbar__group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dg-nav {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 999px;
  background: #f3f5f7;
  color: #14303a;
  font-size: 1.65rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: none;
  transition: background 0.15s ease, transform 0.15s ease;
}

.dg-nav:hover:not(:disabled) {
  background: #fff;
  transform: translateY(-1px);
}

.dg-nav:focus-visible {
  outline: 2px solid #26a69a;
  outline-offset: 2px;
}

.dg-nav:disabled {
  opacity: 0;
  pointer-events: none;
}

.dg-counter {
  margin: 0;
  min-width: 4rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: #14303a;
}

.dg-zoom-btn {
  min-height: 2.5rem;
  padding: 0.55rem 0.9rem;
  border: none;
  border-radius: 999px;
  background: #f3f5f7;
  color: #14303a;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.dg-zoom-btn:hover:not(:disabled) {
  background: #fff;
  transform: translateY(-1px);
}

.dg-zoom-btn:focus-visible {
  outline: 2px solid #26a69a;
  outline-offset: 2px;
}

.dg-zoom-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.dg-zoom-label {
  margin: 0 0 0 0.25rem;
  min-width: 3.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.dg-close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #14303a;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}

.dg-close:hover {
  background: #fff;
}

.dg-close:focus-visible {
  outline: 2px solid #26a69a;
  outline-offset: 2px;
}

.dg-dialog .dg-lightbox-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
}

.dg-caption {
  margin: 0;
  max-width: min(100%, 54rem);
  text-align: center;
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.45;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

@media (max-width: 720px) {
  .dg-overlay {
    padding: 0.5rem;
  }

  .dg-dialog {
    width: min(100vw - 1rem, 84rem);
    max-height: calc(100vh - 1rem);
    max-height: calc(100dvh - 1rem);
    padding: 0.35rem;
    gap: 0.5rem;
  }

  .dg-viewport {
    height: clamp(20rem, calc(100vh - 9.75rem), 44rem);
    height: clamp(20rem, calc(100dvh - 9.75rem), 44rem);
    min-height: min(62vh, 22rem);
    min-height: min(62dvh, 22rem);
    padding: 0.35rem;
    border-radius: 16px;
    -webkit-overflow-scrolling: touch;
  }

  .dg-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
  }

  .dg-toolbar__group {
    justify-content: center;
  }

  .dg-nav {
    width: 2.5rem;
    height: 2.5rem;
  }

  .dg-zoom-btn {
    min-height: 2.35rem;
    padding: 0.5rem 0.8rem;
  }

  .dg-caption {
    font-size: 0.9rem;
  }

  .dg-zoom-label {
    margin-left: 0;
    text-align: center;
  }
}
