.wn-gallery {
  --gallery-wall: #301d19;
  --gallery-label: #ead4bc;
  --gallery-line: #ead4bc44;
  background: var(--gallery-wall);
  color: var(--ivory);
  padding-block: clamp(42px, 6vw, 88px);
  scroll-margin-top: 12px;
}

.wn-gallery__header {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 10px 32px;
  padding-bottom: clamp(19px, 3vw, 36px);
}

.wn-gallery .wn-gallery__header h2 {
  color: inherit;
  font-size: clamp(37px, 5.5vw, 85px);
}

.wn-gallery .wn-gallery__header p {
  color: var(--gallery-label);
  margin: 0 0 3px;
  font-size: 12px;
}

.wn-gallery__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: repeat(3, clamp(138px, 16vw, 245px));
  gap: clamp(6px, 1vw, 14px);
}

.wn-gallery__photo {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: #583b2e;
  color: var(--ivory);
  text-decoration: none;
  transition: opacity .35s ease;
}

.wn-gallery__photo--dune { grid-area: 1 / 1 / 3 / 8; --photo-position: 56% 37%; }
.wn-gallery__photo--ksar { grid-area: 1 / 8 / 2 / 13; --photo-position: 50% 38%; }
.wn-gallery__photo--horizon { grid-area: 2 / 8 / 4 / 13; --photo-position: 50% 50%; }
.wn-gallery__photo--table { grid-area: 3 / 1 / 4 / 4; --photo-position: 50% 56%; }
.wn-gallery__photo--ahellil { grid-area: 3 / 4 / 4 / 8; --photo-position: 50% 35%; }

.wn-gallery__photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--photo-position);
  transition: transform .8s cubic-bezier(.22, .61, .36, 1);
}

.wn-gallery__photo::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 50%;
  min-height: 70px;
  background: linear-gradient(0deg, #20120de8, transparent);
  pointer-events: none;
}

.wn-gallery__caption {
  position: absolute;
  z-index: 1;
  inset: auto clamp(8px, 1.45vw, 22px) clamp(9px, 1.35vw, 20px);
  font: 400 clamp(21px, 2.5vw, 38px)/1 var(--serif);
  letter-spacing: -.02em;
  transition: transform .4s ease;
}

.wn-gallery__expand {
  position: absolute;
  z-index: 1;
  inset: clamp(7px, 1vw, 15px) clamp(7px, 1vw, 15px) auto auto;
  display: grid;
  place-items: center;
  width: clamp(25px, 3.2vw, 39px);
  aspect-ratio: 1;
  border: 1px solid #f8f0e299;
  border-radius: 50%;
  background: #301d1999;
  font: 400 22px/1 var(--sans);
  transition: background .25s ease, color .25s ease, transform .35s ease;
}

.wn-gallery__photo:focus-visible {
  outline: 2px solid var(--ivory);
  outline-offset: -4px;
}

.wn-gallery__photo:focus-visible img { transform: scale(1.055); }
.wn-gallery__photo:focus-visible .wn-gallery__expand { background: var(--ivory); color: var(--gallery-wall); }

@media (hover: hover) and (pointer: fine) {
  .wn-gallery__grid:has(.wn-gallery__photo:hover) .wn-gallery__photo:not(:hover, :focus-visible) { opacity: .7; }
  .wn-gallery__photo:hover img { transform: scale(1.075); }
  .wn-gallery__photo:hover .wn-gallery__caption { transform: translateY(-4px); }
  .wn-gallery__photo:hover .wn-gallery__expand {
    background: var(--ivory);
    color: var(--gallery-wall);
    transform: scale(1.1);
  }
}

.wn-gallery__credits {
  color: var(--gallery-label);
  font-size: 12px;
}

.wn-gallery__credits summary {
  width: fit-content;
  padding-block: 16px;
  cursor: pointer;
}

.wn-gallery__credits ul {
  margin: 0;
  padding-inline-start: 17px;
  line-height: 1.75;
}

.wn-gallery__credits a,
.wn-gallery__viewer-credit { text-underline-offset: 3px; }

.wn-gallery__viewer {
  width: min(calc(100% - 24px), 1130px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--gallery-line);
  background: var(--gallery-wall);
  color: var(--ivory);
  overflow: auto;
  overscroll-behavior: contain;
}

.wn-gallery__viewer[open] { animation: wn-gallery-open .28s ease both; }
.wn-gallery__viewer::backdrop { background: #170e0be8; }

@keyframes wn-gallery-open {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

.wn-gallery__figure { margin: 0; }

.wn-gallery__full-image {
  display: block;
  width: 100%;
  height: min(70dvh, 750px);
  object-fit: contain;
  background: #231511;
}

.wn-gallery__viewer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: clamp(12px, 2vw, 24px);
}

.wn-gallery__viewer-caption {
  margin: 0;
  font: 400 clamp(26px, 4vw, 42px)/1.05 var(--serif);
}

.wn-gallery__viewer-credit {
  color: var(--gallery-label);
  font-size: 12px;
}

.wn-gallery__controls { display: flex; align-items: center; gap: 10px; }
.wn-gallery__viewer-count { font-size: 12px; font-variant-numeric: tabular-nums; }

.wn-gallery__control {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--gallery-line);
  border-radius: 50%;
  background: var(--gallery-wall);
  color: inherit;
  font-size: 22px;
  line-height: 1;
}

.wn-gallery__control:hover { color: var(--gallery-wall); background: var(--ivory); }
.wn-gallery__control:focus-visible { outline-offset: 3px; }
.wn-gallery__close { position: absolute; inset: 10px 10px auto auto; }

@media (max-width: 760px) {
  .wn-gallery__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
  }

  .wn-gallery__photo { grid-area: auto; aspect-ratio: 1.16; }
  .wn-gallery__photo--dune { grid-column: 1 / -1; aspect-ratio: 1.45; }
  .wn-gallery__full-image { height: min(61dvh, 600px); }
}

@media (prefers-reduced-motion: reduce) {
  .wn-gallery__viewer[open] { animation: none; }
  .wn-gallery__photo,
  .wn-gallery__photo img,
  .wn-gallery__caption,
  .wn-gallery__expand { transition: none; }

  .wn-gallery .wn-gallery__photo img,
  .wn-gallery .wn-gallery__photo .wn-gallery__caption,
  .wn-gallery .wn-gallery__photo .wn-gallery__expand { transform: none; }
}
